Jump to content

[1.10.2] Anyone got a good tutorial on sub blocks?


SanaRinomi

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.