Java Code Examples for net.minecraft.world.World.isAreaLoaded()

The following are Jave code examples for showing how to use isAreaLoaded() of the net.minecraft.world.World class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: Got-Wood   File: BlockPalmLeaves.java   Source Code and License Vote up 6 votes
@Override
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) {
	if (!worldIn.isRemote && state.getValue(CHECK_DECAY) && state.getValue(DECAYABLE)) {
		int i = pos.getX();
		int j = pos.getY();
		int k = pos.getZ();
		int r = 10;
		if (worldIn.isAreaLoaded(new BlockPos(i - r, j - r, k - r), new BlockPos(i + r, j + r, k + r))) {
			for (BlockPos blockpos : BlockPos.getAllInBox(new BlockPos(i - r, j - r, k - r), new BlockPos(i + r, j + r, k + r))) {
				if (worldIn.getBlockState(blockpos).getBlock() == BlockRegistry.palm_log) {
					return;
				}
			}
			this.destroyBlock(worldIn, pos);
		}
	}
}
 
Example 2
Project: DecompiledMinecraft   File: BlockLog.java   Source Code and License Vote up 6 votes
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
{
    int i = 4;
    int j = i + 1;

    if (worldIn.isAreaLoaded(pos.add(-j, -j, -j), pos.add(j, j, j)))
    {
        for (BlockPos blockpos : BlockPos.getAllInBox(pos.add(-i, -i, -i), pos.add(i, i, i)))
        {
            IBlockState iblockstate = worldIn.getBlockState(blockpos);

            if (iblockstate.getBlock().getMaterial() == Material.leaves && !((Boolean)iblockstate.getValue(BlockLeaves.CHECK_DECAY)).booleanValue())
            {
                worldIn.setBlockState(blockpos, iblockstate.withProperty(BlockLeaves.CHECK_DECAY, Boolean.valueOf(true)), 4);
            }
        }
    }
}
 
Example 3
Project: Backmemed   File: BlockLog.java   Source Code and License Vote up 6 votes
/**
 * Called serverside after this block is replaced with another in Chunk, but before the Tile Entity is updated
 */
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
{
    int i = 4;
    int j = 5;

    if (worldIn.isAreaLoaded(pos.add(-5, -5, -5), pos.add(5, 5, 5)))
    {
        for (BlockPos blockpos : BlockPos.getAllInBox(pos.add(-4, -4, -4), pos.add(4, 4, 4)))
        {
            IBlockState iblockstate = worldIn.getBlockState(blockpos);

            if (iblockstate.getMaterial() == Material.LEAVES && !((Boolean)iblockstate.getValue(BlockLeaves.CHECK_DECAY)).booleanValue())
            {
                worldIn.setBlockState(blockpos, iblockstate.withProperty(BlockLeaves.CHECK_DECAY, Boolean.valueOf(true)), 4);
            }
        }
    }
}
 
Example 4
Project: Got-Wood   File: BlockBambooLog.java   Source Code and License Vote up 5 votes
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
{
    int i = 1;
    int j = 2;
    int k = pos.getX();
    int l = pos.getY();
    int i1 = pos.getZ();

    if (worldIn.isAreaLoaded(new BlockPos(k - 2, l - 2, i1 - 2), new BlockPos(k + 2, l + 2, i1 + 2)))
    {
        for (int j1 = -1; j1 <= 1; ++j1)
        {
            for (int k1 = -1; k1 <= 1; ++k1)
            {
                for (int l1 = -1; l1 <= 1; ++l1)
                {
                    BlockPos blockpos = pos.add(j1, k1, l1);
                    IBlockState iblockstate = worldIn.getBlockState(blockpos);

                    if (iblockstate.getBlock().isLeaves(iblockstate, worldIn, blockpos))
                    {
                        iblockstate.getBlock().beginLeavesDecay(iblockstate, worldIn, blockpos);
                    }
                }
            }
        }
    }
}
 
Example 5
Project: CustomWorldGen   File: BlockDragonEgg.java   Source Code and License Vote up 5 votes
private void checkFall(World worldIn, BlockPos pos)
{
    if (worldIn.isAirBlock(pos.down()) && BlockFalling.canFallThrough(worldIn.getBlockState(pos.down())) && pos.getY() >= 0)
    {
        int i = 32;

        if (!BlockFalling.fallInstantly && worldIn.isAreaLoaded(pos.add(-32, -32, -32), pos.add(32, 32, 32)))
        {
            worldIn.spawnEntityInWorld(new EntityFallingBlock(worldIn, (double)((float)pos.getX() + 0.5F), (double)pos.getY(), (double)((float)pos.getZ() + 0.5F), this.getDefaultState()));
        }
        else
        {
            worldIn.setBlockToAir(pos);
            BlockPos blockpos;

            for (blockpos = pos; worldIn.isAirBlock(blockpos) && BlockFalling.canFallThrough(worldIn.getBlockState(blockpos)) && blockpos.getY() > 0; blockpos = blockpos.down())
            {
                ;
            }

            if (blockpos.getY() > 0)
            {
                worldIn.setBlockState(blockpos, this.getDefaultState(), 2);
            }
        }
    }
}
 
Example 6
Project: Backmemed   File: BlockLeaves.java   Source Code and License Vote up 5 votes
/**
 * Called serverside after this block is replaced with another in Chunk, but before the Tile Entity is updated
 */
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
{
    int i = 1;
    int j = 2;
    int k = pos.getX();
    int l = pos.getY();
    int i1 = pos.getZ();

    if (worldIn.isAreaLoaded(new BlockPos(k - 2, l - 2, i1 - 2), new BlockPos(k + 2, l + 2, i1 + 2)))
    {
        for (int j1 = -1; j1 <= 1; ++j1)
        {
            for (int k1 = -1; k1 <= 1; ++k1)
            {
                for (int l1 = -1; l1 <= 1; ++l1)
                {
                    BlockPos blockpos = pos.add(j1, k1, l1);
                    IBlockState iblockstate = worldIn.getBlockState(blockpos);

                    if (iblockstate.getMaterial() == Material.LEAVES && !((Boolean)iblockstate.getValue(CHECK_DECAY)).booleanValue())
                    {
                        worldIn.setBlockState(blockpos, iblockstate.withProperty(CHECK_DECAY, Boolean.valueOf(true)), 4);
                    }
                }
            }
        }
    }
}
 
Example 7
Project: DecompiledMinecraft   File: EntityLightningBolt.java   Source Code and License Vote up 5 votes
public EntityLightningBolt(World worldIn, double posX, double posY, double posZ)
{
    super(worldIn);
    this.setLocationAndAngles(posX, posY, posZ, 0.0F, 0.0F);
    this.lightningState = 2;
    this.boltVertex = this.rand.nextLong();
    this.boltLivingTime = this.rand.nextInt(3) + 1;
    BlockPos blockpos = new BlockPos(this);

    if (!worldIn.isRemote && worldIn.getGameRules().getBoolean("doFireTick") && (worldIn.getDifficulty() == EnumDifficulty.NORMAL || worldIn.getDifficulty() == EnumDifficulty.HARD) && worldIn.isAreaLoaded(blockpos, 10))
    {
        if (worldIn.getBlockState(blockpos).getBlock().getMaterial() == Material.air && Blocks.fire.canPlaceBlockAt(worldIn, blockpos))
        {
            worldIn.setBlockState(blockpos, Blocks.fire.getDefaultState());
        }

        for (int i = 0; i < 4; ++i)
        {
            BlockPos blockpos1 = blockpos.add(this.rand.nextInt(3) - 1, this.rand.nextInt(3) - 1, this.rand.nextInt(3) - 1);

            if (worldIn.getBlockState(blockpos1).getBlock().getMaterial() == Material.air && Blocks.fire.canPlaceBlockAt(worldIn, blockpos1))
            {
                worldIn.setBlockState(blockpos1, Blocks.fire.getDefaultState());
            }
        }
    }
}
 
Example 8
Project: BaseClient   File: BlockLeaves.java   Source Code and License Vote up 5 votes
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
{
    int i = 1;
    int j = i + 1;
    int k = pos.getX();
    int l = pos.getY();
    int i1 = pos.getZ();

    if (worldIn.isAreaLoaded(new BlockPos(k - j, l - j, i1 - j), new BlockPos(k + j, l + j, i1 + j)))
    {
        for (int j1 = -i; j1 <= i; ++j1)
        {
            for (int k1 = -i; k1 <= i; ++k1)
            {
                for (int l1 = -i; l1 <= i; ++l1)
                {
                    BlockPos blockpos = pos.add(j1, k1, l1);
                    IBlockState iblockstate = worldIn.getBlockState(blockpos);

                    if (iblockstate.getBlock().getMaterial() == Material.leaves && !((Boolean)iblockstate.getValue(CHECK_DECAY)).booleanValue())
                    {
                        worldIn.setBlockState(blockpos, iblockstate.withProperty(CHECK_DECAY, Boolean.valueOf(true)), 4);
                    }
                }
            }
        }
    }
}
 
Example 9
Project: DecompiledMinecraft   File: BlockLeaves.java   Source Code and License Vote up 5 votes
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
{
    int i = 1;
    int j = i + 1;
    int k = pos.getX();
    int l = pos.getY();
    int i1 = pos.getZ();

    if (worldIn.isAreaLoaded(new BlockPos(k - j, l - j, i1 - j), new BlockPos(k + j, l + j, i1 + j)))
    {
        for (int j1 = -i; j1 <= i; ++j1)
        {
            for (int k1 = -i; k1 <= i; ++k1)
            {
                for (int l1 = -i; l1 <= i; ++l1)
                {
                    BlockPos blockpos = pos.add(j1, k1, l1);
                    IBlockState iblockstate = worldIn.getBlockState(blockpos);

                    if (iblockstate.getBlock().getMaterial() == Material.leaves && !((Boolean)iblockstate.getValue(CHECK_DECAY)).booleanValue())
                    {
                        worldIn.setBlockState(blockpos, iblockstate.withProperty(CHECK_DECAY, Boolean.valueOf(true)), 4);
                    }
                }
            }
        }
    }
}
 
Example 10
Project: Backmemed   File: EntityLightningBolt.java   Source Code and License Vote up 5 votes
public EntityLightningBolt(World worldIn, double x, double y, double z, boolean effectOnlyIn)
{
    super(worldIn);
    this.setLocationAndAngles(x, y, z, 0.0F, 0.0F);
    this.lightningState = 2;
    this.boltVertex = this.rand.nextLong();
    this.boltLivingTime = this.rand.nextInt(3) + 1;
    this.effectOnly = effectOnlyIn;
    BlockPos blockpos = new BlockPos(this);

    if (!effectOnlyIn && !worldIn.isRemote && worldIn.getGameRules().getBoolean("doFireTick") && (worldIn.getDifficulty() == EnumDifficulty.NORMAL || worldIn.getDifficulty() == EnumDifficulty.HARD) && worldIn.isAreaLoaded(blockpos, 10))
    {
        if (worldIn.getBlockState(blockpos).getMaterial() == Material.AIR && Blocks.FIRE.canPlaceBlockAt(worldIn, blockpos))
        {
            worldIn.setBlockState(blockpos, Blocks.FIRE.getDefaultState());
        }

        for (int i = 0; i < 4; ++i)
        {
            BlockPos blockpos1 = blockpos.add(this.rand.nextInt(3) - 1, this.rand.nextInt(3) - 1, this.rand.nextInt(3) - 1);

            if (worldIn.getBlockState(blockpos1).getMaterial() == Material.AIR && Blocks.FIRE.canPlaceBlockAt(worldIn, blockpos1))
            {
                worldIn.setBlockState(blockpos1, Blocks.FIRE.getDefaultState());
            }
        }
    }
}
 
Example 11
Project: DecompiledMinecraft   File: BlockFalling.java   Source Code and License Vote up 5 votes
private void checkFallable(World worldIn, BlockPos pos)
{
    if (canFallInto(worldIn, pos.down()) && pos.getY() >= 0)
    {
        int i = 32;

        if (!fallInstantly && worldIn.isAreaLoaded(pos.add(-i, -i, -i), pos.add(i, i, i)))
        {
            if (!worldIn.isRemote)
            {
                EntityFallingBlock entityfallingblock = new EntityFallingBlock(worldIn, (double)pos.getX() + 0.5D, (double)pos.getY(), (double)pos.getZ() + 0.5D, worldIn.getBlockState(pos));
                this.onStartFalling(entityfallingblock);
                worldIn.spawnEntityInWorld(entityfallingblock);
            }
        }
        else
        {
            worldIn.setBlockToAir(pos);
            BlockPos blockpos;

            for (blockpos = pos.down(); canFallInto(worldIn, blockpos) && blockpos.getY() > 0; blockpos = blockpos.down())
            {
                ;
            }

            if (blockpos.getY() > 0)
            {
                worldIn.setBlockState(blockpos.up(), this.getDefaultState());
            }
        }
    }
}
 
Example 12
Project: BaseClient   File: EntityLightningBolt.java   Source Code and License Vote up 5 votes
public EntityLightningBolt(World worldIn, double posX, double posY, double posZ)
{
    super(worldIn);
    this.setLocationAndAngles(posX, posY, posZ, 0.0F, 0.0F);
    this.lightningState = 2;
    this.boltVertex = this.rand.nextLong();
    this.boltLivingTime = this.rand.nextInt(3) + 1;
    BlockPos blockpos = new BlockPos(this);

    if (!worldIn.isRemote && worldIn.getGameRules().getBoolean("doFireTick") && (worldIn.getDifficulty() == EnumDifficulty.NORMAL || worldIn.getDifficulty() == EnumDifficulty.HARD) && worldIn.isAreaLoaded(blockpos, 10))
    {
        if (worldIn.getBlockState(blockpos).getBlock().getMaterial() == Material.air && Blocks.fire.canPlaceBlockAt(worldIn, blockpos))
        {
            worldIn.setBlockState(blockpos, Blocks.fire.getDefaultState());
        }

        for (int i = 0; i < 4; ++i)
        {
            BlockPos blockpos1 = blockpos.add(this.rand.nextInt(3) - 1, this.rand.nextInt(3) - 1, this.rand.nextInt(3) - 1);

            if (worldIn.getBlockState(blockpos1).getBlock().getMaterial() == Material.air && Blocks.fire.canPlaceBlockAt(worldIn, blockpos1))
            {
                worldIn.setBlockState(blockpos1, Blocks.fire.getDefaultState());
            }
        }
    }
}
 
Example 13
Project: DecompiledMinecraft   File: BlockDragonEgg.java   Source Code and License Vote up 5 votes
private void checkFall(World worldIn, BlockPos pos)
{
    if (BlockFalling.canFallInto(worldIn, pos.down()) && pos.getY() >= 0)
    {
        int i = 32;

        if (!BlockFalling.fallInstantly && worldIn.isAreaLoaded(pos.add(-i, -i, -i), pos.add(i, i, i)))
        {
            worldIn.spawnEntityInWorld(new EntityFallingBlock(worldIn, (double)((float)pos.getX() + 0.5F), (double)pos.getY(), (double)((float)pos.getZ() + 0.5F), this.getDefaultState()));
        }
        else
        {
            worldIn.setBlockToAir(pos);
            BlockPos blockpos;

            for (blockpos = pos; BlockFalling.canFallInto(worldIn, blockpos) && blockpos.getY() > 0; blockpos = blockpos.down())
            {
                ;
            }

            if (blockpos.getY() > 0)
            {
                worldIn.setBlockState(blockpos, this.getDefaultState(), 2);
            }
        }
    }
}
 
Example 14
Project: Backmemed   File: BlockDragonEgg.java   Source Code and License Vote up 5 votes
private void checkFall(World worldIn, BlockPos pos)
{
    if (BlockFalling.canFallThrough(worldIn.getBlockState(pos.down())) && pos.getY() >= 0)
    {
        int i = 32;

        if (!BlockFalling.fallInstantly && worldIn.isAreaLoaded(pos.add(-32, -32, -32), pos.add(32, 32, 32)))
        {
            worldIn.spawnEntityInWorld(new EntityFallingBlock(worldIn, (double)((float)pos.getX() + 0.5F), (double)pos.getY(), (double)((float)pos.getZ() + 0.5F), this.getDefaultState()));
        }
        else
        {
            worldIn.setBlockToAir(pos);
            BlockPos blockpos;

            for (blockpos = pos; BlockFalling.canFallThrough(worldIn.getBlockState(blockpos)) && blockpos.getY() > 0; blockpos = blockpos.down())
            {
                ;
            }

            if (blockpos.getY() > 0)
            {
                worldIn.setBlockState(blockpos, this.getDefaultState(), 2);
            }
        }
    }
}
 
Example 15
Project: BaseClient   File: EntityLightningBolt.java   Source Code and License Vote up 5 votes
public EntityLightningBolt(World worldIn, double posX, double posY, double posZ)
{
    super(worldIn);
    this.setLocationAndAngles(posX, posY, posZ, 0.0F, 0.0F);
    this.lightningState = 2;
    this.boltVertex = this.rand.nextLong();
    this.boltLivingTime = this.rand.nextInt(3) + 1;
    BlockPos blockpos = new BlockPos(this);

    if (!worldIn.isRemote && worldIn.getGameRules().getBoolean("doFireTick") && (worldIn.getDifficulty() == EnumDifficulty.NORMAL || worldIn.getDifficulty() == EnumDifficulty.HARD) && worldIn.isAreaLoaded(blockpos, 10))
    {
        if (worldIn.getBlockState(blockpos).getBlock().getMaterial() == Material.air && Blocks.fire.canPlaceBlockAt(worldIn, blockpos))
        {
            worldIn.setBlockState(blockpos, Blocks.fire.getDefaultState());
        }

        for (int i = 0; i < 4; ++i)
        {
            BlockPos blockpos1 = blockpos.add(this.rand.nextInt(3) - 1, this.rand.nextInt(3) - 1, this.rand.nextInt(3) - 1);

            if (worldIn.getBlockState(blockpos1).getBlock().getMaterial() == Material.air && Blocks.fire.canPlaceBlockAt(worldIn, blockpos1))
            {
                worldIn.setBlockState(blockpos1, Blocks.fire.getDefaultState());
            }
        }
    }
}
 
Example 16
Project: CustomWorldGen   File: EntityLightningBolt.java   Source Code and License Vote up 5 votes
public EntityLightningBolt(World worldIn, double x, double y, double z, boolean effectOnlyIn)
{
    super(worldIn);
    this.setLocationAndAngles(x, y, z, 0.0F, 0.0F);
    this.lightningState = 2;
    this.boltVertex = this.rand.nextLong();
    this.boltLivingTime = this.rand.nextInt(3) + 1;
    this.effectOnly = effectOnlyIn;
    BlockPos blockpos = new BlockPos(this);

    if (!effectOnlyIn && !worldIn.isRemote && worldIn.getGameRules().getBoolean("doFireTick") && (worldIn.getDifficulty() == EnumDifficulty.NORMAL || worldIn.getDifficulty() == EnumDifficulty.HARD) && worldIn.isAreaLoaded(blockpos, 10))
    {
        if (worldIn.getBlockState(blockpos).getMaterial() == Material.AIR && Blocks.FIRE.canPlaceBlockAt(worldIn, blockpos))
        {
            worldIn.setBlockState(blockpos, Blocks.FIRE.getDefaultState());
        }

        for (int i = 0; i < 4; ++i)
        {
            BlockPos blockpos1 = blockpos.add(this.rand.nextInt(3) - 1, this.rand.nextInt(3) - 1, this.rand.nextInt(3) - 1);

            if (worldIn.getBlockState(blockpos1).getMaterial() == Material.AIR && Blocks.FIRE.canPlaceBlockAt(worldIn, blockpos1))
            {
                worldIn.setBlockState(blockpos1, Blocks.FIRE.getDefaultState());
            }
        }
    }
}
 
Example 17
Project: CustomWorldGen   File: BlockFalling.java   Source Code and License Vote up 5 votes
private void checkFallable(World worldIn, BlockPos pos)
{
    if ((worldIn.isAirBlock(pos.down()) || canFallThrough(worldIn.getBlockState(pos.down()))) && pos.getY() >= 0)
    {
        int i = 32;

        if (!fallInstantly && worldIn.isAreaLoaded(pos.add(-32, -32, -32), pos.add(32, 32, 32)))
        {
            if (!worldIn.isRemote)
            {
                EntityFallingBlock entityfallingblock = new EntityFallingBlock(worldIn, (double)pos.getX() + 0.5D, (double)pos.getY(), (double)pos.getZ() + 0.5D, worldIn.getBlockState(pos));
                this.onStartFalling(entityfallingblock);
                worldIn.spawnEntityInWorld(entityfallingblock);
            }
        }
        else
        {
            IBlockState state = worldIn.getBlockState(pos);
            worldIn.setBlockToAir(pos);
            BlockPos blockpos;

            for (blockpos = pos.down(); (worldIn.isAirBlock(blockpos) || canFallThrough(worldIn.getBlockState(blockpos))) && blockpos.getY() > 0; blockpos = blockpos.down())
            {
                ;
            }

            if (blockpos.getY() > 0)
            {
                worldIn.setBlockState(blockpos.up(), state); //Forge: Fix loss of state information during world gen.
            }
        }
    }
}
 
Example 18
Project: BaseClient   File: BlockFalling.java   Source Code and License Vote up 5 votes
private void checkFallable(World worldIn, BlockPos pos)
{
    if (canFallInto(worldIn, pos.down()) && pos.getY() >= 0)
    {
        int i = 32;

        if (!fallInstantly && worldIn.isAreaLoaded(pos.add(-i, -i, -i), pos.add(i, i, i)))
        {
            if (!worldIn.isRemote)
            {
                EntityFallingBlock entityfallingblock = new EntityFallingBlock(worldIn, (double)pos.getX() + 0.5D, (double)pos.getY(), (double)pos.getZ() + 0.5D, worldIn.getBlockState(pos));
                this.onStartFalling(entityfallingblock);
                worldIn.spawnEntityInWorld(entityfallingblock);
            }
        }
        else
        {
            worldIn.setBlockToAir(pos);
            BlockPos blockpos;

            for (blockpos = pos.down(); canFallInto(worldIn, blockpos) && blockpos.getY() > 0; blockpos = blockpos.down())
            {
                ;
            }

            if (blockpos.getY() > 0)
            {
                worldIn.setBlockState(blockpos.up(), this.getDefaultState());
            }
        }
    }
}
 
Example 19
Project: Backmemed   File: BlockFalling.java   Source Code and License Vote up 5 votes
private void checkFallable(World worldIn, BlockPos pos)
{
    if (canFallThrough(worldIn.getBlockState(pos.down())) && pos.getY() >= 0)
    {
        int i = 32;

        if (!fallInstantly && worldIn.isAreaLoaded(pos.add(-32, -32, -32), pos.add(32, 32, 32)))
        {
            if (!worldIn.isRemote)
            {
                EntityFallingBlock entityfallingblock = new EntityFallingBlock(worldIn, (double)pos.getX() + 0.5D, (double)pos.getY(), (double)pos.getZ() + 0.5D, worldIn.getBlockState(pos));
                this.onStartFalling(entityfallingblock);
                worldIn.spawnEntityInWorld(entityfallingblock);
            }
        }
        else
        {
            worldIn.setBlockToAir(pos);
            BlockPos blockpos;

            for (blockpos = pos.down(); canFallThrough(worldIn.getBlockState(blockpos)) && blockpos.getY() > 0; blockpos = blockpos.down())
            {
                ;
            }

            if (blockpos.getY() > 0)
            {
                worldIn.setBlockState(blockpos.up(), this.getDefaultState());
            }
        }
    }
}
 
Example 20
Project: ThermionicsWorld   File: BlockFluidSimple.java   Source Code and License Vote up 4 votes
@Override
   public void updateTick(@Nonnull World world, @Nonnull BlockPos pos, @Nonnull IBlockState state, @Nonnull Random rand) {
	if (!world.isAreaLoaded(pos, 2)) return;
	//if (!world.doChunksNearChunkExist(x, y, z, 2)) return;
	super.updateTick(world, pos, state, rand);
}