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

Hello,

 

I'm having a bit of trouble with my custom bean block. Whenever I load it in minecraft, it's displayed as tile.null.name instead of tile.BlockBean.name. What do I need to do to fix this?

Code for BlockBean class:

public class BlockBean extends BlockBush implements IGrowable {

protected int maxGrowthStage = 7;

    @SideOnly(Side.CLIENT)
    protected IIcon[] iIcon;

    public BlockBean() {
    	// Basic block setup
        setTickRandomly(true);
        float f = 0.5F;
        setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.25F, 0.5F + f);
        setCreativeTab(CreativeTabs.tabMisc);
        setHardness(0.0F);
        setStepSound(soundTypeGrass);
        disableStats();
    }

    @Override
    protected boolean canPlaceBlockOn(Block parBlock) {
        return parBlock == Blocks.farmland;
    }

    public void incrementGrowStage(World parWorld, Random parRand, int parX, int parY, int parZ) {
        int growStage = parWorld.getBlockMetadata(parX, parY, parZ) + MathHelper.getRandomIntegerInRange(parRand, 2, 5);
        if (growStage > maxGrowthStage)
        	growStage = maxGrowthStage;
        parWorld.setBlockMetadataWithNotify(parX, parY, parZ, growStage, 2);
    }
    
    @Override
    public Item getItemDropped(int p_149650_1_, Random parRand, int parFortune) {
        return CommonProxy.itemBean;
    }

    @Override
    public int getRenderType() {
        return 1; // Cross like flowers
    }

    @Override
    @SideOnly(Side.CLIENT)
    public IIcon getIcon(int parSide, int parGrowthStage) {
    	return iIcon[parGrowthStage];
    }
    
    @Override
    public void updateTick(World parWorld, int parX, int parY, int parZ, Random parRand) {
        super.updateTick(parWorld, parX, parY, parZ, parRand);
        int growStage = parWorld.getBlockMetadata(parX, parY, parZ) + 1;
        if (growStage > 7)
            growStage = 7;
        parWorld.setBlockMetadataWithNotify(parX, parY, parZ, growStage, 2);
    }
    
    @Override
    public int quantityDropped(Random rand) {
        return 1;
    }
    
    @Override
    @SideOnly(Side.CLIENT)
    public void registerBlockIcons(IIconRegister parIIconRegister) {
          iIcon = new IIcon[maxGrowthStage + 1];
          // seems that crops like to have 8 growth icons, but okay to repeat actual texture if you want
          // to make generic should loop to maxGrowthStage
          iIcon[0] = parIIconRegister.registerIcon("nw:BlockBean_stage_0");
          iIcon[1] = parIIconRegister.registerIcon("nw:BlockBean_stage_1");
          iIcon[2] = parIIconRegister.registerIcon("nw:BlockBean_stage_2");
          iIcon[3] = parIIconRegister.registerIcon("nw:BlockBean_stage_3");
          iIcon[4] = parIIconRegister.registerIcon("nw:BlockBean_stage_4");
          iIcon[5] = parIIconRegister.registerIcon("nw:BlockBean_stage_5");
          iIcon[6] = parIIconRegister.registerIcon("nw:BlockBean_stage_6");
          iIcon[7] = parIIconRegister.registerIcon("nw:BlockBean_stage_7");
    }
   
    /*
     * Need to implement the IGrowable interface methods
     */
    @Override
    // checks if finished growing (a grow stage of 7 is final stage)
    public boolean func_149851_a(World parWorld, int parX, int parY, int parZ, boolean p_149851_5_) {
        return parWorld.getBlockMetadata(parX, parY, parZ) != 7;
    }

    @Override
    public boolean func_149852_a(World p_149852_1_, Random parRand, int p_149852_3_, int p_149852_4_, int p_149852_5_) {
        return true;
    }

    @Override
    public void func_149853_b(World parWorld, Random parRand, int parX, int parY, int parZ) {
        incrementGrowStage(parWorld, parRand, parX, parY, parZ);
    }
}

You should set the block's name.. (by setBlockName or setUnlocalizedName)

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

  • Author

Thanks! setUnlocalizedName was unavailable (which was what I was trying to do), but setBlockName did the trick!

setUnlocalizedName() is for naming items

setBlockName() is for naming blocks

I'm beginner in java and in minecraft modding.

Please be specific.

Any code examples are appreciated.

Sorry for my english i'm from Czech republic.

Please hit that thank you button if i helped :)

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.