package erebus.blocks; import java.util.ArrayList; import java.util.List; import com.google.common.base.Predicate; import erebus.ModBlocks.IHasCustomItem; import erebus.ModBlocks.ISubBlocksBlock; import erebus.ModTabs; import erebus.items.block.ItemBlockEnum; import net.minecraft.block.Block; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; 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.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class BlockPlanksErebus extends Block implements IHasCustomItem, ISubBlocksBlock { public static final PropertyEnum<EnumWood> TYPE = PropertyEnum.create("type", EnumWood.class, new Predicate<EnumWood>() { @Override public boolean apply(EnumWood input) { return input.hasPlanks(); } }); public BlockPlanksErebus() { super(Material.WOOD); setHardness(2.0F); setHarvestLevel("axe", 0); setSoundType(SoundType.WOOD); setCreativeTab(ModTabs.BLOCKS); setDefaultState(blockState.getBaseState().withProperty(TYPE, EnumWood.ASPER)); } @Override @SideOnly(Side.CLIENT) public void getSubBlocks(Item item, CreativeTabs tab, List<ItemStack> list) { EnumWood[] values = EnumWood.values(); for (int i = 0; i < values.length; i++) if (values[i].hasPlanks()) list.add(new ItemStack(item, 1, i)); } @Override public IBlockState getStateFromMeta(int meta) { return getDefaultState().withProperty(TYPE, EnumWood.values()[meta]); } @Override public int getMetaFromState(IBlockState state) { return state.getValue(TYPE).getID(); } @Override public int damageDropped(IBlockState state) { return getMetaFromState(state); } @Override protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, new IProperty[] { TYPE }); } @Override public List<String> getModels() { List<String> models = new ArrayList<String>(); for (EnumWood wood : EnumWood.values()) if (wood.hasPlanks()) models.add("planks_" + wood.getName()); return models; } @Override public ItemBlock getItemBlock() { return ItemBlockEnum.create(this, EnumWood.class, '_'); } }