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

I'm making a cherry leaf block and i want it so it has a small chance to change into a leaf that has cherries on it and i would be able to do it but i don't know how to use setBlockState[move]*Fail*[/move] but i need help

if(this.hasCharry == false && rand.nextInt(500) < 1){
        	
        	int i = pos.getX();
        	int j = pos.getY();
        	int k = pos.getZ();
        	BlockPos bpos = new BlockPos(i, j, k);
        	
        	worldIn.setBlockState(bpos, state);
        	
        }

oh and yes i googled it. -_-

 

  • Author

Will It Work Now:

public void updateTick(World world, BlockPos pos, IBlockState state, Random rand)
    {
        super.updateTick(world, pos, state, rand);

        if(this.hasCharry == false && rand.nextInt(500) < 1){
        	
        	int i = pos.getX();
        	int j = pos.getY();
        	int k = pos.getZ();
        	BlockPos bpos = new BlockPos(i, j, k);
        	
        	world.setBlockState(bpos, MoreOresModBlocks.charry_leaves_full.getDefaultState(), 0);
        	
        }
        
    }

Will It Work Now:

Why ask when you can simply try it in your development environment? Then you can find out immediately whether it works or not.

 

Btw, that last argument to setBlockState is a bit flag that tells Minecraft whether or not to update the client side / notify neighboring blocks / other things, and you almost always want it set to either 2 (notify client) or 3 (notify client AND notify neighbors, IIRC).

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.