Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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 by WildHeart

  • 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.

  • 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?

  • 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 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.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.