Posted May 22, 201510 yr 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.
May 22, 201510 yr 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); } }
May 23, 201510 yr 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). http://i.imgur.com/NdrFdld.png[/img]
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.