Posted August 17, 201411 yr This is the updateTick method of my block: public void updateTick(World world, int x, int y, int z, Random prng) { if (!world.blockExists(x, y + 1, z)) return; Block b1 = world.getBlock(x, y + 1, z); // If the block above it is farm land (AKA tilled dirt) if (b1 instanceof BlockFarmland) { if (!world.blockExists(x, y + 2, z)) return; // Get the block above that one Block plant_block = world.getBlock(x, y + 2, z); if (plant_block instanceof IPlantable || plant_block instanceof IGrowable) { plant_block.updateTick(world, x, y + 2, z, this.prng); } } else if (b1 instanceof BlockDirt || b1 instanceof BlockGrass || b1 instanceof BlockSand || b1 instanceof BlockSoulSand) { if (!world.blockExists(x, y + 2, z)) return; // Get the block above that one Block b2 = world.getBlock(x, y + 2, z); if (b2 instanceof BlockSapling || b2 instanceof BlockNetherWart) { b2.updateTick(world, x, y + 2, z, this.prng); } // Reeds and saplings are a bit different else if (b2 instanceof BlockReed || b2 instanceof BlockCactus) { System.out.println("Cactus tick a"); for (int l = 1; world.blockExists(x, y + 1 + l, z) && l < 3; l++) { System.out.println("Cactus tick b"); world.getBlock(x, y + 1 + l, z) .updateTick(world, x, y + 1 + l, z, this.prng); } } } else b1.updateTick(world, x, y + 1, z, prng); } It works fine for seeds, potatoes, carrots, nether wart, melon and pumpkin stems great. However my block doesn't seem to work with cactus or sugar cane and I'm not sure why. According to BlockReed's updateTick method it checks if the block above it is air and if it is, calculates the height of the plant. Then if it's less than 3, it then checks if its metadata is 15 (not sure of the circumstances for this check). If it is 15, it places a reed above it. The only reason I think this is failing is because the metadata isn't 15. I like trains.
August 17, 201411 yr That shouldn't be it. If it isn't 15, then it sets the metadata to be one more than itself. BEFORE ASKING FOR HELP READ THE EAQ! I'll help if I can. Apologies if I do something obviously stupid. If you don't know basic Java yet, go and follow these tutorials.
August 17, 201411 yr Author I just took a second look at the BlockCactus/BlockReed's updateTick method and the metadata thing was the "'issue'". Apparently the cactus/reed block only grows a new block every 16th random tick. So my block was operating as intended, I just didn't understand the code. I like trains.
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.