Java Code Examples for net.minecraft.world.World#neighborChanged()
The following examples show how to use
net.minecraft.world.World#neighborChanged() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BlockTofuYuba.java From TofuCraftReload with MIT License | 6 votes |
private void growByBonemeal(World worldIn, Random rand, BlockPos blockpos) { if (worldIn.isAirBlock(blockpos.down()) && rand.nextFloat() < 0.8F) { worldIn.setBlockState(blockpos.down(), this.getDefaultState(), 2); if (worldIn.isAirBlock(blockpos.down(2)) && rand.nextFloat() < 0.6F) { worldIn.setBlockState(blockpos.down(2), this.getDefaultState(), 2); if (worldIn.isAirBlock(blockpos.down(3)) && rand.nextFloat() < 0.45F) { worldIn.setBlockState(blockpos.down(3), this.getDefaultState(), 2); if (worldIn.isAirBlock(blockpos.down(4)) && rand.nextFloat() < 0.25F) { worldIn.setBlockState(blockpos.down(4), this.getDefaultState(), 2); worldIn.neighborChanged(blockpos.down(4), this, blockpos); } worldIn.neighborChanged(blockpos.down(3), this, blockpos); } worldIn.neighborChanged(blockpos.down(2), this, blockpos); } worldIn.neighborChanged(blockpos.down(), this, blockpos); } worldIn.neighborChanged(blockpos, this, blockpos); }
Example 2
Source File: WorldGenUnderVine.java From TofuCraftReload with MIT License | 5 votes |
public boolean generate(World worldIn, Random rand, BlockPos position) { for (int i = 0; i < 64; ++i) { BlockPos blockpos = position.add(rand.nextInt(8) - rand.nextInt(8), rand.nextInt(4) - rand.nextInt(4), rand.nextInt(8) - rand.nextInt(8)); if (worldIn.isAirBlock(blockpos) && (!worldIn.provider.isNether() || blockpos.getY() < worldIn.getHeight() - 1) && this.block.canBlockStay(worldIn, blockpos)) { worldIn.setBlockState(blockpos, this.block.getDefaultState(), 2); if(worldIn.isAirBlock(blockpos.down()) && rand.nextFloat()< 0.8F) { worldIn.setBlockState(blockpos.down(), this.block.getDefaultState(), 2); if(worldIn.isAirBlock(blockpos.down(2)) && rand.nextFloat()< 0.6F) { worldIn.setBlockState(blockpos.down(2), this.block.getDefaultState(), 2); if(worldIn.isAirBlock(blockpos.down(3)) && rand.nextFloat()< 0.45F) { worldIn.setBlockState(blockpos.down(3), this.block.getDefaultState(), 2); if(worldIn.isAirBlock(blockpos.down(4)) && rand.nextFloat()< 0.25F) { worldIn.setBlockState(blockpos.down(4), this.block.getDefaultState(), 2); worldIn.neighborChanged(blockpos.down(4),this.block,position); } worldIn.neighborChanged(blockpos.down(3),this.block,position); } worldIn.neighborChanged(blockpos.down(2),this.block,position); } worldIn.neighborChanged(blockpos.down(),this.block,position); } worldIn.neighborChanged(blockpos,this.block,position); } } return true; }
Example 3
Source File: GTUtility.java From GT-Classic with GNU Lesser General Public License v3.0 | 5 votes |
/** * A way to update surrounding blocks. this does not update the original block! * * @param world - The world to update in * @param pos - the block pos the update should originate * @param blockType - block type which can be null * @param sides - the list of sides to iterate an update */ public static void updateNeighbors(World world, BlockPos pos, @Nullable Block blockType, RotationList sides) { if (blockType == null) { blockType = Blocks.AIR; } for (EnumFacing side : sides) { BlockPos newPos = pos.offset(side); if (world.isBlockLoaded(newPos)) { world.neighborChanged(newPos, blockType, pos); } } }
Example 4
Source File: TaskUpdateBlocks.java From litematica with GNU Lesser General Public License v3.0 | 5 votes |
protected void updateBlocks(IntBoundingBox box, World world) { for (int y = box.minY; y <= box.maxY; ++y) { for (int z = box.minZ; z <= box.maxZ; ++z) { for (int x = box.minX; x <= box.maxX; ++x) { BlockPos pos = new BlockPos(x, y, z); Block block = world.getBlockState(pos).getBlock(); world.neighborChanged(pos, block, pos); } } } }
Example 5
Source File: BlockMinecoprocessor.java From Minecoprocessors with GNU General Public License v3.0 | 5 votes |
protected void notifyNeighborsOnSide(World worldIn, BlockPos pos, EnumFacing side) { BlockPos neighborPos = pos.offset(side); if (net.minecraftforge.event.ForgeEventFactory.onNeighborNotify(worldIn, pos, worldIn.getBlockState(pos), java.util.EnumSet.of(side), false) .isCanceled()) { return; } worldIn.neighborChanged(neighborPos, this, pos); worldIn.notifyNeighborsOfStateExcept(neighborPos, this, side.getOpposite()); }