Java Code Examples for net.minecraft.world.World#neighborChanged()

The following examples show how to use net.minecraft.world.World#neighborChanged() . These examples are extracted from open source projects. 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 Project: TofuCraftReload   File: BlockTofuYuba.java    License: MIT License 6 votes vote down vote up
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 Project: TofuCraftReload   File: WorldGenUnderVine.java    License: MIT License 5 votes vote down vote up
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
/**
 * 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
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
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());
}