Posted May 19, 201510 yr hey all in 1.7 i had a block that horizontally spread on a random tick but ive tried to update it with this but it wont work for some reason. public void updateTick(World world, BlockPos pos, Random random) { if (!world.isRemote) { int x = pos.getX(); int y = pos.getY(); int z = pos.getZ(); BlockPos blockpos1 = pos.add(x - 1, y, z); BlockPos blockpos2 = pos.add(x + 1, y, z); BlockPos blockpos3 = pos.add(x, y, z - 1); BlockPos blockpos4 = pos.add(x, y, z + 1); if (world.getBlockState(blockpos1).getBlock() == Blocks.air && world.getBlockState(blockpos1.add(x, y-1, z)).getBlock() == Blocks.air) { world.setBlockState(blockpos1, this.getDefaultState(), 3); } if (world.getBlockState(blockpos2).getBlock() == Blocks.air && world.getBlockState(blockpos2.add(x, y-1, z)).getBlock() == Blocks.air) { world.setBlockState(blockpos2, this.getDefaultState(), 3); } if (world.getBlockState(blockpos3).getBlock() == Blocks.air && world.getBlockState(blockpos3.add(x, y-1, z)).getBlock() == Blocks.air) { world.setBlockState(blockpos3, this.getDefaultState(), 3); } if (world.getBlockState(blockpos4).getBlock() == Blocks.air && world.getBlockState(blockpos4.add(x, y-1, z)).getBlock() == Blocks.air) { world.setBlockState(blockpos4, this.getDefaultState(), 3); } } } BioWarfare Mod: http://goo.gl/BYWQty
May 19, 201510 yr Pretty sure that if you take a blockpos at (x,y,z) and add (x,y+1,z) to it you'll have (2x,2y+1,2z) not (x,y+1,z). Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
May 19, 201510 yr Author wait so it should be like this? public void updateTick(World world, BlockPos pos, Random random) { if (!world.isRemote) { int x = pos.getX(); int y = pos.getY(); int z = pos.getZ(); BlockPos blockpos1 = pos.add(- 1, 0, 0); BlockPos blockpos2 = pos.add(+ 1, 0, 0); BlockPos blockpos3 = pos.add(0, 0, - 1); BlockPos blockpos4 = pos.add(0, 0, + 1); if (world.getBlockState(blockpos1).getBlock() == Blocks.air && world.getBlockState(blockpos1.add(0, -1, 0)).getBlock() == Blocks.air) { world.setBlockState(blockpos1, this.getDefaultState(), 3); } if (world.getBlockState(blockpos2).getBlock() == Blocks.air && world.getBlockState(blockpos2.add(0, -1, 0)).getBlock() == Blocks.air) { world.setBlockState(blockpos2, this.getDefaultState(), 3); } if (world.getBlockState(blockpos3).getBlock() == Blocks.air && world.getBlockState(blockpos3.add(0, -1, 0)).getBlock() == Blocks.air) { world.setBlockState(blockpos3, this.getDefaultState(), 3); } if (world.getBlockState(blockpos4).getBlock() == Blocks.air && world.getBlockState(blockpos4.add(0, -1, 0)).getBlock() == Blocks.air) { world.setBlockState(blockpos4, this.getDefaultState(), 3); } } } BioWarfare Mod: http://goo.gl/BYWQty
May 19, 201510 yr wait so it should be like this? public void updateTick(World world, BlockPos pos, Random random) { if (!world.isRemote) { int x = pos.getX(); int y = pos.getY(); int z = pos.getZ(); BlockPos blockpos1 = pos.add(- 1, 0, 0); BlockPos blockpos2 = pos.add(+ 1, 0, 0); BlockPos blockpos3 = pos.add(0, 0, - 1); BlockPos blockpos4 = pos.add(0, 0, + 1); if (world.getBlockState(blockpos1).getBlock() == Blocks.air && world.getBlockState(blockpos1.add(0, -1, 0)).getBlock() == Blocks.air) { world.setBlockState(blockpos1, this.getDefaultState(), 3); } if (world.getBlockState(blockpos2).getBlock() == Blocks.air && world.getBlockState(blockpos2.add(0, -1, 0)).getBlock() == Blocks.air) { world.setBlockState(blockpos2, this.getDefaultState(), 3); } if (world.getBlockState(blockpos3).getBlock() == Blocks.air && world.getBlockState(blockpos3.add(0, -1, 0)).getBlock() == Blocks.air) { world.setBlockState(blockpos3, this.getDefaultState(), 3); } if (world.getBlockState(blockpos4).getBlock() == Blocks.air && world.getBlockState(blockpos4.add(0, -1, 0)).getBlock() == Blocks.air) { world.setBlockState(blockpos4, this.getDefaultState(), 3); } } } No, you add to the original BlockPos twice. You can just use the BlockPos parameter, and use the up(),down(),north(),etc. methods to add/subtract one. Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support. 1.12 -> 1.13 primer by williewillus. 1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support. http://www.howoldisminecraft1710.today/
May 19, 201510 yr Author Still not working public void updateTick(World world, BlockPos pos, Random random) { if (!world.isRemote) { int x = pos.getX(); int y = pos.getY(); int z = pos.getZ(); BlockPos blockpos1 = pos.north(+1); BlockPos blockpos2 = pos.east(+1); BlockPos blockpos3 = pos.south(+1); BlockPos blockpos4 = pos.west(+1); if (world.getBlockState(blockpos1).getBlock() == Blocks.air && world.getBlockState(blockpos1.down()).getBlock() != Blocks.air) { world.setBlockState(blockpos1, this.getDefaultState(), 3); } if (world.getBlockState(blockpos2).getBlock() == Blocks.air && world.getBlockState(blockpos2.down()).getBlock() != Blocks.air) { world.setBlockState(blockpos2, this.getDefaultState(), 3); } if (world.getBlockState(blockpos3).getBlock() == Blocks.air && world.getBlockState(blockpos3.down()).getBlock() != Blocks.air) { world.setBlockState(blockpos3, this.getDefaultState(), 3); } if (world.getBlockState(blockpos4).getBlock() == Blocks.air && world.getBlockState(blockpos4.down()).getBlock() != Blocks.air) { world.setBlockState(blockpos4, this.getDefaultState(), 3); } } } BioWarfare Mod: http://goo.gl/BYWQty
May 19, 201510 yr Define 'still not working'. Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support. 1.12 -> 1.13 primer by williewillus. 1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support. http://www.howoldisminecraft1710.today/
May 19, 201510 yr I dont really get what you Are triing to do. You say you want the block to spread horizontally. Why are you using the north /south etc blockpositions then? If you want it to spread horizontally just check the Block above, if its air replace it
May 19, 201510 yr Btw did you ever checked if tick randomly gets Called? In 1.8 u need to use the setTickRandomly function to allow random ticks not sure about oder versions
May 20, 201510 yr Author I dont really get what you Are triing to do. You say you want the block to spread horizontally. Why are you using the north /south etc blockpositions then? If you want it to spread horizontally just check the Block above, if its air replace it https://rumercooper.files.wordpress.com/2012/09/horizontal_vertical.png Btw did you ever checked if tick randomly gets Called? In 1.8 u need to use the setTickRandomly function to allow random ticks not sure about oder versions public BacteriaTest(Material material) { super(material); this.setHardness(5.0F); this.setResistance(18000000000.0F); this.setBlockBounds(0F, 0F, 0F, 1F, 0.0001F, 1F); this.setCreativeTab(BioWarfare.BioWarfareTab); this.setTickRandomly(true); } BioWarfare Mod: http://goo.gl/BYWQty
May 20, 201510 yr Hey ! First, when you paste your code, use the # symbole just under the "Font Size" scrolling menu. Then, I suggest that you use a tileentity. I'm not sure, but I think that would work.
May 20, 201510 yr Then, I suggest that you use a tileentity. I'm not sure, but I think that would work. A TileEntity is not needed here. This block doesn't need to store any information and isn't even using metadata. It's simply trying to replace a neighboring block with itself. I don't know why it's not working, but I also haven't messed with 1.8 Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
May 20, 201510 yr Author The update method wasn't being called i was using an outdated one or somthing. 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.