Posted August 16, 20169 yr I'm looking for an easy to understand tutorial on sub blocks for 1.10.2. Thanks in advanced.
August 16, 20169 yr By sub blocks do you mean metadata? *Edit Allow me to rephrase do you mean wool blocks? VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
August 16, 20169 yr Author By sub blocks do you mean metadata? *Edit Allow me to rephrase do you mean wool blocks? Yes, I mean metadata
August 16, 20169 yr To use metadata in 1.8+ you need to use blockstates. While blockstates are not limited by amount, metadata is, metadata can only be 0-15(4bits). If you look at wool or even the furnace in vanilla you will see some similarities. These three methods from BlockColored need to be overrided. /** * Convert the given metadata into a BlockState for this Block */ public IBlockState getStateFromMeta(int meta) { return this.getDefaultState().withProperty(COLOR, EnumDyeColor.byMetadata(meta)); } /** * Convert the BlockState into the correct metadata value */ public int getMetaFromState(IBlockState state) { return ((EnumDyeColor)state.getValue(COLOR)).getMetadata(); } protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, new IProperty[] {COLOR}); } As you see all of those loop into the field COLOR which is a Property. Blockstates use properties to define what is looks like from the blockstate JSON. You should use vanilla metadata blocks as a reference. VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
August 16, 20169 yr Author To use metadata in 1.8+ you need to use blockstates. While blockstates are not limited by amount, metadata is, metadata can only be 0-15(4bits). If you look at wool or even the furnace in vanilla you will see some similarities. These three methods from BlockColored need to be overrided. /** * Convert the given metadata into a BlockState for this Block */ public IBlockState getStateFromMeta(int meta) { return this.getDefaultState().withProperty(COLOR, EnumDyeColor.byMetadata(meta)); } /** * Convert the BlockState into the correct metadata value */ public int getMetaFromState(IBlockState state) { return ((EnumDyeColor)state.getValue(COLOR)).getMetadata(); } protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, new IProperty[] {COLOR}); } As you see all of those loop into the field COLOR which is a Property. Blockstates use properties to define what is looks like from the blockstate JSON. You should use vanilla metadata blocks as a reference. Thx!
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.