Posted May 9, 20178 yr Hi, there is one block with a meta tag from 1-15, is to take in hand this block it shows as it should, but if you put it in the variable variants shows the registered name of the block. How to fix? Spoiler public class BlockCulture extends Block { public static final PropertyEnum<HarvestType> VARIANT = PropertyEnum.create("variant", HarvestType.class); public BlockCulture(String name) { super(Material.WOOD); this.setRegistryName(name); this.setUnlocalizedName(name); this.setCreativeTab(Farmland.FMCT); this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT, HarvestType.BEAN)); } @Override @SideOnly(Side.CLIENT) public void getSubBlocks(Item itemIn, CreativeTabs tab, NonNullList<ItemStack> list) { for(HarvestType seedsDoubleType : HarvestType.values()) { list.add(new ItemStack(itemIn, 1, seedsDoubleType.getMeta())); } } @Override public int damageDropped(IBlockState state) { return state.getValue(VARIANT).getMeta(); } @Override public IBlockState getStateFromMeta(int meta) { return this.getDefaultState().withProperty(VARIANT, HarvestType.byMetadata(meta)); } @Override public int getMetaFromState(IBlockState state) { return state.getValue(VARIANT).getMeta(); } @Override protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, new IProperty[] {VARIANT}); } } Edited May 9, 20178 yr by WildHeart
May 9, 20178 yr Author 5 minutes ago, diesieben07 said: Blocks that need their metadata in the inventory need to use ItemMultiTexture or a custom ItemBlock class instead of ItemBlock. With the blocks in the inventory no problem, the problem is that when I put the block of its variants remains the same as the first block.
May 9, 20178 yr Author 6 minutes ago, diesieben07 said: Yes, because the default ItemBlock class always places metadata 0. So it turns out I need to write my ItemBlock nbt storage, and to store the meta for each block there?
May 9, 20178 yr Author 7 minutes ago, diesieben07 said: What on earth do you need an example for? You literally replace new ItemBlock with new ItemMultiTexture. Solved Edited May 9, 20178 yr by WildHeart
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.