-
-
Save killerjdog51/831d6eeef74e3b6a0887cd691453dd69 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Killerjdog51.biomeEnhancementsMod.block; | |
import javax.annotation.Nullable; | |
import com.google.common.base.Predicate; | |
import Killerjdog51.biomeEnhancementsMod.Main; | |
import Killerjdog51.biomeEnhancementsMod.init.ModBlocks; | |
import Killerjdog51.biomeEnhancementsMod.init.ModItems; | |
import Killerjdog51.biomeEnhancementsMod.util.IHasModel; | |
import net.minecraft.block.BlockLog; | |
import net.minecraft.block.SoundType; | |
import net.minecraft.block.material.MapColor; | |
import net.minecraft.block.properties.IProperty; | |
import net.minecraft.block.properties.PropertyEnum; | |
import net.minecraft.block.state.BlockStateContainer; | |
import net.minecraft.block.state.IBlockState; | |
import net.minecraft.creativetab.CreativeTabs; | |
import net.minecraft.item.Item; | |
import net.minecraft.item.ItemStack; | |
import net.minecraft.util.NonNullList; | |
import net.minecraft.util.math.BlockPos; | |
import net.minecraft.world.IBlockAccess; | |
public class BlockModLog extends BlockLog implements IHasModel | |
{ | |
public static final PropertyEnum<BlockModPlanks.EnumType> VARIANT = PropertyEnum.<BlockModPlanks.EnumType>create("variant", BlockModPlanks.EnumType.class, new Predicate<BlockModPlanks.EnumType>() | |
{ | |
public boolean apply(@Nullable BlockModPlanks.EnumType block) | |
{ | |
return block.getMetadata() < 3; | |
} | |
}); | |
public BlockModLog(String name) | |
{ | |
this.setUnlocalizedName(name); | |
this.setRegistryName(name); | |
this.setSoundType(SoundType.WOOD); | |
this.setCreativeTab(CreativeTabs.BUILDING_BLOCKS); | |
this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT, BlockModPlanks.EnumType.PALM).withProperty(LOG_AXIS, BlockLog.EnumAxis.Y)); | |
ModBlocks.BLOCKS.add(this); | |
ModItems.ITEMS.add(new ItemBlockMeta(this).setRegistryName(this.getRegistryName())); | |
} | |
@Override | |
public boolean isFullCube(IBlockState state) { | |
return false; | |
} | |
@Override | |
public boolean isOpaqueCube(IBlockState state) | |
{ | |
return false; | |
} | |
public MapColor getMapColor(IBlockState state, IBlockAccess worldIn, BlockPos pos) | |
{ | |
BlockModPlanks.EnumType blockplanks$enumtype = (BlockModPlanks.EnumType)state.getValue(VARIANT); | |
switch ((BlockLog.EnumAxis)state.getValue(LOG_AXIS)) | |
{ | |
case X: | |
case Z: | |
case NONE: | |
default: | |
switch (blockplanks$enumtype) | |
{ | |
case PALM: | |
default: | |
return BlockModPlanks.EnumType.PALM.getMapColor(); | |
case MANGROVE: | |
return BlockModPlanks.EnumType.MANGROVE.getMapColor(); | |
case BEOBAB: | |
return BlockModPlanks.EnumType.BEOBAB.getMapColor(); | |
} | |
case Y: | |
return blockplanks$enumtype.getMapColor(); | |
} | |
} | |
public void getSubBlocks(CreativeTabs itemIn, NonNullList<ItemStack> items) | |
{ | |
for (BlockModPlanks.EnumType blockplanks$enumtype : BlockModPlanks.EnumType.values()) | |
{ | |
items.add(new ItemStack(this, 1, blockplanks$enumtype.getMetadata())); | |
} | |
} | |
public IBlockState getStateFromMeta(int meta) | |
{ | |
IBlockState iblockstate = this.getDefaultState().withProperty(VARIANT, BlockModPlanks.EnumType.byMetadata((meta & 3) % 4)); | |
switch (meta & 12) | |
{ | |
case 0: | |
iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.Y); | |
break; | |
case 4: | |
iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.X); | |
break; | |
case 8: | |
iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.Z); | |
break; | |
default: | |
iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.NONE); | |
} | |
return iblockstate; | |
} | |
@SuppressWarnings("incomplete-switch") | |
public int getMetaFromState(IBlockState state) | |
{ | |
int i = 0; | |
i = i | ((BlockModPlanks.EnumType)state.getValue(VARIANT)).getMetadata(); | |
switch ((BlockLog.EnumAxis)state.getValue(LOG_AXIS)) | |
{ | |
case X: | |
i |= 4; | |
break; | |
case Z: | |
i |= 8; | |
break; | |
case NONE: | |
i |= 12; | |
} | |
return i; | |
} | |
protected BlockStateContainer createBlockState() | |
{ | |
return new BlockStateContainer(this, new IProperty[] {VARIANT, LOG_AXIS}); | |
} | |
protected ItemStack getSilkTouchDrop(IBlockState state) | |
{ | |
return new ItemStack(Item.getItemFromBlock(this), 1, ((BlockModPlanks.EnumType)state.getValue(VARIANT)).getMetadata()); | |
} | |
public int damageDropped(IBlockState state) | |
{ | |
return ((BlockModPlanks.EnumType)state.getValue(VARIANT)).getMetadata(); | |
} | |
@Override | |
public void registerModel() | |
{ | |
for(BlockModPlanks.EnumType blockplanks$enumtype : BlockModPlanks.EnumType.values()) | |
{ | |
Main.proxy.registerItemMetaRenderer(Item.getItemFromBlock(this), blockplanks$enumtype.getMetadata(), blockplanks$enumtype.getUnlocalizedName(), "inventory"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment