Posted July 16, 201411 yr Hi everyone i have made a block that can spread over the top of grass next to it and i tried to do this with all blocks by using block not Blocks.grass but of course this uses air so it spreads in the air i only want it to spread over the surface is there anyway i can make it spread over every block but air? update tick public void updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_) { if (!p_149674_1_.isRemote) if (p_149674_1_.getBlockLightValue(p_149674_2_, p_149674_3_ + 1, p_149674_4_) >= 9) { for (int l = 0; l < 45000; ++l) { int i1 = p_149674_2_ + p_149674_5_.nextInt(3) - 1; int j1 = p_149674_3_ + p_149674_5_.nextInt(5) - 3; int k1 = p_149674_4_ + p_149674_5_.nextInt(3) - 1; Block block = p_149674_1_.getBlock(i1, j1 + 1, k1); if (p_149674_1_.getBlock(i1, j1, k1) == block && p_149674_1_.getBlockMetadata(i1, j1, k1) == 0 && p_149674_1_.getBlockLightValue(i1, j1 + 1, k1) >= 4 && p_149674_1_.getBlockLightOpacity(i1, j1 + 1, k1) <= 2) p_149674_1_.setBlock(i1, j1 + 1, k1, this); } } } BioWarfare Mod: http://goo.gl/BYWQty
July 16, 201411 yr Wah? what is this? Always, always use good and simple to understand names Here could be your advertisement!
July 16, 201411 yr Author ok thats not very usefull but il be honest i did take some of it from the mycelium class so yea the names arnt very easy to understand BioWarfare Mod: http://goo.gl/BYWQty
July 16, 201411 yr Author better? public void updateTick(World world, int x, int y, int z, Random random) { if (!world.isRemote) if (world.getBlockLightValue(x, y + 1, z) >= 9) { for (int l = 0; l < 45000; ++l) { int i1 = x + random.nextInt(3) - 1; int j1 = y + random.nextInt(5) - 3; int k1 = z + random.nextInt(3) - 1; Block block = world.getBlock(i1, j1 + 1, k1); if (world.getBlock(i1, j1, k1) == block && world.getBlockMetadata(i1, j1, k1) == 0 && world.getBlockLightValue(i1, j1 + 1, k1) >= 4 && world.getBlockLightOpacity(i1, j1 + 1, k1) <= 2) world.setBlock(i1, j1 + 1, k1, this); } } } BioWarfare Mod: http://goo.gl/BYWQty
July 16, 201411 yr yeah, way better. public void updateTick(World world, int x, int y, int z, Random random) { if (!world.isRemote) for (int i = 0; l < 45000; ++l) { int i1 = x + random.nextInt(3) - 1; int j1 = y + random.nextInt(3) - 1; int k1 = z + random.nextInt(3) - 1; Block block = world.getBlock(i1, j1 + 1, k1); if (world.getBlock(i1, j1, k1) != Blocks.air){ world.setBlock(i1, j1 + 1, k1, this); } } try something like thisthis Here could be your advertisement!
July 16, 201411 yr Author no this hasn't worked its still doing the same thing BioWarfare Mod: http://goo.gl/BYWQty
July 16, 201411 yr Author ive done this and its fixed the problem but now it is spreading down if (world.getBlock(i1, j1, k1) ==block && (world.getBlock(i1, j1, k1) != Blocks.air)){ world.setBlock(i1, j1 + 1, k1, this); } BioWarfare Mod: http://goo.gl/BYWQty
July 16, 201411 yr yeah, i know. int i1 = x + random.nextInt(3) - 1; int j1 = y + random.nextInt(3) - 1; int k1 = z + random.nextInt(3) - 1; Block block = world.getBlock(i1, j1 + 1, k1); if (world.getBlock(i1, j1, k1) != Blocks.air){ world.setBlock(i1, j1 + 1, k1, this); } j1 is the y coordinate (height) from the block it spreads to, right?. it basically is the blocks current location plus a random number. ok, what is this random number? int j1 = y + random.nextInt(3) - 1; it is either: 0 1 or 2 minus 1. his means that it can spread -1(down) 0(same y) +1(up) sry accidentaly had a 2 there, my fault, fixed it secs before your post Here could be your advertisement!
July 16, 201411 yr Author wait i dont understand what do i need to change to 0? BioWarfare Mod: http://goo.gl/BYWQty
July 16, 201411 yr By crikey dude, where did that 45000 come from? You will be running that setBlock loop 45000 times for every block you add. for (int l = 0; l < 45000; ++l) { Another question - what's the point of having a random value for y? And in fact, why are you using random values for x and z as well? Why not just try the four adjacent blocks? This link might help you a bit, perhaps? http://greyminecraftcoder.blogspot.com.au/2013/07/blocks.html -TGG[/code]
July 16, 201411 yr guess he wants that his block spreads as fast as possible:D if you want that your block spreads only upwards you have to remove the -1 from the new y(j1) coordinate and change the 3 to a 2 Here could be your advertisement!
July 16, 201411 yr by Crikey dude I might have to add that to my signature. +3 reddit gold! Long time Bukkit & Forge Programmer Happy to try and help
July 16, 201411 yr Author I wont have it spreading that fast but i want it to spread quickly for testing thats all BioWarfare Mod: http://goo.gl/BYWQty
July 16, 201411 yr Author "if you want that your block spreads only upwards you have to remove the -1 from the new y(j1) coordinate and change the 3 to a 2" No i want it so that it dosen't spread upwards BioWarfare Mod: http://goo.gl/BYWQty
July 16, 201411 yr "if you want that your block spreads only upwards you have to remove the -1 from the new y(j1) coordinate and change the 3 to a 2" No i want it so that it dosen't spread upwards it shouldn't spread up/down? than you can us your block y coordinate 1:1 for your new blocks y(=j1) coordinate. Here could be your advertisement!
July 16, 201411 yr Author i dont know if i have done the right thing but this dosen't work. public void updateTick(World world, int x, int y, int z, Random random) { if (!world.isRemote) if (world.getBlockLightValue(x, y + 1, z) >= 9) { for (int l = 0; l < 45000; ++l) { int i1 = x + random.nextInt(3) - 1; int j1 = y + random.nextInt(3) - 1; int k1 = z + random.nextInt(3) - 1; Block block = world.getBlock(i1, j1 + 1, k1); if (world.getBlock(i1, j1, k1) != Blocks.air){ world.setBlock(x, j1 + 1, z, this); } } } } BioWarfare Mod: http://goo.gl/BYWQty
July 16, 201411 yr Author now this is just spreading up public void updateTick(World world, int x, int y, int z, Random random) { if (!world.isRemote) if (world.getBlockLightValue(x, y + 1, z) >= 9) { for (int l = 0; l < 45000; ++l) { int i1 = x + random.nextInt(3) - 1; int j1=y; int k1 = z + random.nextInt(3) - 1; Block block = world.getBlock(i1, j1 + 1, k1); if (world.getBlock(i1, j1, k1) != Blocks.air){ world.setBlock(i1, j1 + 1, k1, this); } } } } BioWarfare Mod: http://goo.gl/BYWQty
July 16, 201411 yr Please use [ code ] tags. It's just spreading up because you're setting the block above with your j1 + 1 . Change that to just j1 . In fact, remove j1 altogether and just use y . Also, as has been pointed out, running 45000 iterations is a bit overkill.
July 16, 201411 yr Author I dont think you understand i want it to spread over the top of blocks next to it if i remove the +1 it will just delete that block and replace it with itself BioWarfare Mod: http://goo.gl/BYWQty
July 16, 201411 yr Author anyone else think they might have a solution? BioWarfare Mod: http://goo.gl/BYWQty
July 16, 201411 yr I dunno, it works public void updateTick(World world, int x, int y, int z, Random random) { if (!world.isRemote && world.getBlockLightValue(x, y + 1, z) >= 9) for (int i = 0; i < 4; ++i) { int randX = x + random.nextInt(3) - 1; int randY = y + random.nextInt(3) - 1; int randZ = z + random.nextInt(3) - 1; if (world.getBlock(randX, randY, randZ) != Blocks.air) world.setBlock(randX, randY, randZ, Yormod.yourblock); } }
July 16, 201411 yr Author no i want it to spread on top of adjacent blocks not to be abble to grow ontop of itself BioWarfare Mod: http://goo.gl/BYWQty
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.