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

The following are Jave code examples for showing how to use containsAnyLiquid() 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: Zombe-Modpack   File: Safe.java   Source Code and License Vote up 5 votes
private static boolean emptySpaceHere(int pX, int pY, int pZ) {
    double x = pX + 0.5, y = (double)pY, z = pZ + 0.5;
    //double r = 0.3, h = 1.8; // skeleton size
    //double r = 0.35, h = 0.5; // cave spider size
    double r = 0.3, h = 0.5; // hybrid size
    AxisAlignedBB aabb = new AxisAlignedBB(x - r, y, z - r, x + r, y + h, z + r);
    World world = getWorld();
    return getCollidingBlockAABBs(world,aabb).isEmpty() && !world.containsAnyLiquid(aabb);
}
 
Example 2
Project: Backmemed   File: EntityLivingBase.java   Source Code and License Vote up 4 votes
/**
 * Teleports the entity to the specified location. Used for Enderman and Chorus Fruit teleportation
 */
public boolean attemptTeleport(double x, double y, double z)
{
    double d0 = this.posX;
    double d1 = this.posY;
    double d2 = this.posZ;
    this.posX = x;
    this.posY = y;
    this.posZ = z;
    boolean flag = false;
    BlockPos blockpos = new BlockPos(this);
    World world = this.world;
    Random random = this.getRNG();

    if (world.isBlockLoaded(blockpos))
    {
        boolean flag1 = false;

        while (!flag1 && blockpos.getY() > 0)
        {
            BlockPos blockpos1 = blockpos.down();
            IBlockState iblockstate = world.getBlockState(blockpos1);

            if (iblockstate.getMaterial().blocksMovement())
            {
                flag1 = true;
            }
            else
            {
                --this.posY;
                blockpos = blockpos1;
            }
        }

        if (flag1)
        {
            this.setPositionAndUpdate(this.posX, this.posY, this.posZ);

            if (world.getCollisionBoxes(this, this.getEntityBoundingBox()).isEmpty() && !world.containsAnyLiquid(this.getEntityBoundingBox()))
            {
                flag = true;
            }
        }
    }

    if (!flag)
    {
        this.setPositionAndUpdate(d0, d1, d2);
        return false;
    }
    else
    {
        int i = 128;

        for (int j = 0; j < 128; ++j)
        {
            double d6 = (double)j / 127.0D;
            float f = (random.nextFloat() - 0.5F) * 0.2F;
            float f1 = (random.nextFloat() - 0.5F) * 0.2F;
            float f2 = (random.nextFloat() - 0.5F) * 0.2F;
            double d3 = d0 + (this.posX - d0) * d6 + (random.nextDouble() - 0.5D) * (double)this.width * 2.0D;
            double d4 = d1 + (this.posY - d1) * d6 + random.nextDouble() * (double)this.height;
            double d5 = d2 + (this.posZ - d2) * d6 + (random.nextDouble() - 0.5D) * (double)this.width * 2.0D;
            world.spawnParticle(EnumParticleTypes.PORTAL, d3, d4, d5, (double)f, (double)f1, (double)f2, new int[0]);
        }

        if (this instanceof EntityCreature)
        {
            ((EntityCreature)this).getNavigator().clearPathEntity();
        }

        return true;
    }
}
 
Example 3
Project: CustomWorldGen   File: EntityLivingBase.java   Source Code and License Vote up 4 votes
/**
 * Teleports the entity to the specified location. Used for Enderman and Chorus Fruit teleportation
 */
public boolean attemptTeleport(double x, double y, double z)
{
    double d0 = this.posX;
    double d1 = this.posY;
    double d2 = this.posZ;
    this.posX = x;
    this.posY = y;
    this.posZ = z;
    boolean flag = false;
    BlockPos blockpos = new BlockPos(this);
    World world = this.worldObj;
    Random random = this.getRNG();

    if (world.isBlockLoaded(blockpos))
    {
        boolean flag1 = false;

        while (!flag1 && blockpos.getY() > 0)
        {
            BlockPos blockpos1 = blockpos.down();
            IBlockState iblockstate = world.getBlockState(blockpos1);

            if (iblockstate.getMaterial().blocksMovement())
            {
                flag1 = true;
            }
            else
            {
                --this.posY;
                blockpos = blockpos1;
            }
        }

        if (flag1)
        {
            this.setPositionAndUpdate(this.posX, this.posY, this.posZ);

            if (world.getCollisionBoxes(this, this.getEntityBoundingBox()).isEmpty() && !world.containsAnyLiquid(this.getEntityBoundingBox()))
            {
                flag = true;
            }
        }
    }

    if (!flag)
    {
        this.setPositionAndUpdate(d0, d1, d2);
        return false;
    }
    else
    {
        int i = 128;

        for (int j = 0; j < 128; ++j)
        {
            double d6 = (double)j / 127.0D;
            float f = (random.nextFloat() - 0.5F) * 0.2F;
            float f1 = (random.nextFloat() - 0.5F) * 0.2F;
            float f2 = (random.nextFloat() - 0.5F) * 0.2F;
            double d3 = d0 + (this.posX - d0) * d6 + (random.nextDouble() - 0.5D) * (double)this.width * 2.0D;
            double d4 = d1 + (this.posY - d1) * d6 + random.nextDouble() * (double)this.height;
            double d5 = d2 + (this.posZ - d2) * d6 + (random.nextDouble() - 0.5D) * (double)this.width * 2.0D;
            world.spawnParticle(EnumParticleTypes.PORTAL, d3, d4, d5, (double)f, (double)f1, (double)f2, new int[0]);
        }

        if (this instanceof EntityCreature)
        {
            ((EntityCreature)this).getNavigator().clearPathEntity();
        }

        return true;
    }
}