Java Code Examples for net.minecraft.util.MathHelper.floor_double()

The following are Jave code examples for showing how to use floor_double() of the net.minecraft.util.MathHelper class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: BaseClient   File: WalkNodeProcessor.java   View Source Code Vote up 6 votes
/**
 * Returns given entity's position as PathPoint
 */
public PathPoint getPathPointTo(Entity entityIn)
{
    int i;

    if (this.canSwim && entityIn.isInWater())
    {
        i = (int)entityIn.getEntityBoundingBox().minY;
        BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(MathHelper.floor_double(entityIn.posX), i, MathHelper.floor_double(entityIn.posZ));

        for (Block block = this.blockaccess.getBlockState(blockpos$mutableblockpos).getBlock(); block == Blocks.flowing_water || block == Blocks.water; block = this.blockaccess.getBlockState(blockpos$mutableblockpos).getBlock())
        {
            ++i;
            blockpos$mutableblockpos.func_181079_c(MathHelper.floor_double(entityIn.posX), i, MathHelper.floor_double(entityIn.posZ));
        }

        this.avoidsWater = false;
    }
    else
    {
        i = MathHelper.floor_double(entityIn.getEntityBoundingBox().minY + 0.5D);
    }

    return this.openPoint(MathHelper.floor_double(entityIn.getEntityBoundingBox().minX), i, MathHelper.floor_double(entityIn.getEntityBoundingBox().minZ));
}
 
Example 2
Project: DecompiledMinecraft   File: Chunk.java   View Source Code Vote up 6 votes
public <T extends Entity> void getEntitiesOfTypeWithinAAAB(Class <? extends T > entityClass, AxisAlignedBB aabb, List<T> listToFill, Predicate <? super T > p_177430_4_)
{
    int i = MathHelper.floor_double((aabb.minY - 2.0D) / 16.0D);
    int j = MathHelper.floor_double((aabb.maxY + 2.0D) / 16.0D);
    i = MathHelper.clamp_int(i, 0, this.entityLists.length - 1);
    j = MathHelper.clamp_int(j, 0, this.entityLists.length - 1);

    for (int k = i; k <= j; ++k)
    {
        for (T t : this.entityLists[k].getByClass(entityClass))
        {
            if (t.getEntityBoundingBox().intersectsWith(aabb) && (p_177430_4_ == null || p_177430_4_.apply(t)))
            {
                listToFill.add(t);
            }
        }
    }
}
 
Example 3
Project: DecompiledMinecraft   File: Entity.java   View Source Code Vote up 5 votes
/**
 * sets the players height back to normal after doing things like sleeping and dieing
 */
protected void resetHeight()
{
    float f = MathHelper.sqrt_double(this.motionX * this.motionX * 0.20000000298023224D + this.motionY * this.motionY + this.motionZ * this.motionZ * 0.20000000298023224D) * 0.2F;

    if (f > 1.0F)
    {
        f = 1.0F;
    }

    this.playSound(this.getSplashSound(), f, 1.0F + (this.rand.nextFloat() - this.rand.nextFloat()) * 0.4F);
    float f1 = (float)MathHelper.floor_double(this.getEntityBoundingBox().minY);

    for (int i = 0; (float)i < 1.0F + this.width * 20.0F; ++i)
    {
        float f2 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width;
        float f3 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width;
        this.worldObj.spawnParticle(EnumParticleTypes.WATER_BUBBLE, this.posX + (double)f2, (double)(f1 + 1.0F), this.posZ + (double)f3, this.motionX, this.motionY - (double)(this.rand.nextFloat() * 0.2F), this.motionZ, new int[0]);
    }

    for (int j = 0; (float)j < 1.0F + this.width * 20.0F; ++j)
    {
        float f4 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width;
        float f5 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width;
        this.worldObj.spawnParticle(EnumParticleTypes.WATER_SPLASH, this.posX + (double)f4, (double)(f1 + 1.0F), this.posZ + (double)f5, this.motionX, this.motionY, this.motionZ, new int[0]);
    }
}
 
Example 4
Project: Uranium   File: CauldronHooks.java   View Source Code Vote up 5 votes
public static boolean checkBoundingBoxSize(Entity entity, AxisAlignedBB aabb)
{
    if (entity instanceof EntityLivingBase && (!(entity instanceof IBossDisplayData) || !(entity instanceof IEntityMultiPart))
            && !(entity instanceof EntityPlayer))
    {
        int logSize = MinecraftServer.cauldronConfig.largeBoundingBoxLogSize.getValue();
        if (logSize <= 0 || !MinecraftServer.cauldronConfig.checkEntityBoundingBoxes.getValue()) return false;
        int x = MathHelper.floor_double(aabb.minX);
        int x1 = MathHelper.floor_double(aabb.maxX + 1.0D);
        int y = MathHelper.floor_double(aabb.minY);
        int y1 = MathHelper.floor_double(aabb.maxY + 1.0D);
        int z = MathHelper.floor_double(aabb.minZ);
        int z1 = MathHelper.floor_double(aabb.maxZ + 1.0D);

        int size = Math.abs(x1 - x) * Math.abs(y1 - y) * Math.abs(z1 - z);
        if (size > MinecraftServer.cauldronConfig.largeBoundingBoxLogSize.getValue())
        {
            logWarning("Entity being removed for bounding box restrictions");
            logWarning("BB Size: {0} > {1} avg edge: {2}", size, logSize, aabb.getAverageEdgeLength());
            logWarning("Motion: ({0}, {1}, {2})", entity.motionX, entity.motionY, entity.motionZ);
            logWarning("Calculated bounding box: {0}", aabb);
            logWarning("Entity bounding box: {0}", entity.getBoundingBox());
            logWarning("Entity: {0}", entity);
            NBTTagCompound tag = new NBTTagCompound();
            entity.writeToNBT(tag);
            logWarning("Entity NBT: {0}", tag);
            logStack();
            entity.setDead();
            return true;
        }
    }

    return false;
}
 
Example 5
Project: BaseClient   File: S18PacketEntityTeleport.java   View Source Code Vote up 5 votes
public S18PacketEntityTeleport(Entity entityIn)
{
    this.entityId = entityIn.getEntityId();
    this.posX = MathHelper.floor_double(entityIn.posX * 32.0D);
    this.posY = MathHelper.floor_double(entityIn.posY * 32.0D);
    this.posZ = MathHelper.floor_double(entityIn.posZ * 32.0D);
    this.yaw = (byte)((int)(entityIn.rotationYaw * 256.0F / 360.0F));
    this.pitch = (byte)((int)(entityIn.rotationPitch * 256.0F / 360.0F));
    this.onGround = entityIn.onGround;
}
 
Example 6
Project: BaseClient   File: EntityHorse.java   View Source Code Vote up 5 votes
public boolean prepareChunkForSpawn()
{
    int i = MathHelper.floor_double(this.posX);
    int j = MathHelper.floor_double(this.posZ);
    this.worldObj.getBiomeGenForCoords(new BlockPos(i, 0, j));
    return true;
}
 
Example 7
Project: BaseClient   File: S2CPacketSpawnGlobalEntity.java   View Source Code Vote up 5 votes
public S2CPacketSpawnGlobalEntity(Entity entityIn)
{
    this.entityId = entityIn.getEntityId();
    this.x = MathHelper.floor_double(entityIn.posX * 32.0D);
    this.y = MathHelper.floor_double(entityIn.posY * 32.0D);
    this.z = MathHelper.floor_double(entityIn.posZ * 32.0D);

    if (entityIn instanceof EntityLightningBolt)
    {
        this.type = 1;
    }
}
 
Example 8
Project: BaseClient   File: S11PacketSpawnExperienceOrb.java   View Source Code Vote up 5 votes
public S11PacketSpawnExperienceOrb(EntityXPOrb xpOrb)
{
    this.entityID = xpOrb.getEntityId();
    this.posX = MathHelper.floor_double(xpOrb.posX * 32.0D);
    this.posY = MathHelper.floor_double(xpOrb.posY * 32.0D);
    this.posZ = MathHelper.floor_double(xpOrb.posZ * 32.0D);
    this.xpValue = xpOrb.getXpValue();
}
 
Example 9
Project: BaseClient   File: S0CPacketSpawnPlayer.java   View Source Code Vote up 5 votes
public S0CPacketSpawnPlayer(EntityPlayer player)
{
    this.entityId = player.getEntityId();
    this.playerId = player.getGameProfile().getId();
    this.x = MathHelper.floor_double(player.posX * 32.0D);
    this.y = MathHelper.floor_double(player.posY * 32.0D);
    this.z = MathHelper.floor_double(player.posZ * 32.0D);
    this.yaw = (byte)((int)(player.rotationYaw * 256.0F / 360.0F));
    this.pitch = (byte)((int)(player.rotationPitch * 256.0F / 360.0F));
    ItemStack itemstack = player.inventory.getCurrentItem();
    this.currentItem = itemstack == null ? 0 : Item.getIdFromItem(itemstack.getItem());
    this.watcher = player.getDataWatcher();
}
 
Example 10
Project: DecompiledMinecraft   File: EntityAIFollowOwner.java   View Source Code Vote up 5 votes
/**
 * Updates the task
 */
public void updateTask()
{
    this.thePet.getLookHelper().setLookPositionWithEntity(this.theOwner, 10.0F, (float)this.thePet.getVerticalFaceSpeed());

    if (!this.thePet.isSitting())
    {
        if (--this.field_75343_h <= 0)
        {
            this.field_75343_h = 10;

            if (!this.petPathfinder.tryMoveToEntityLiving(this.theOwner, this.followSpeed))
            {
                if (!this.thePet.getLeashed())
                {
                    if (this.thePet.getDistanceSqToEntity(this.theOwner) >= 144.0D)
                    {
                        int i = MathHelper.floor_double(this.theOwner.posX) - 2;
                        int j = MathHelper.floor_double(this.theOwner.posZ) - 2;
                        int k = MathHelper.floor_double(this.theOwner.getEntityBoundingBox().minY);

                        for (int l = 0; l <= 4; ++l)
                        {
                            for (int i1 = 0; i1 <= 4; ++i1)
                            {
                                if ((l < 1 || i1 < 1 || l > 3 || i1 > 3) && World.doesBlockHaveSolidTopSurface(this.theWorld, new BlockPos(i + l, k - 1, j + i1)) && this.func_181065_a(new BlockPos(i + l, k, j + i1)) && this.func_181065_a(new BlockPos(i + l, k + 1, j + i1)))
                                {
                                    this.thePet.setLocationAndAngles((double)((float)(i + l) + 0.5F), (double)k, (double)((float)(j + i1) + 0.5F), this.thePet.rotationYaw, this.thePet.rotationPitch);
                                    this.petPathfinder.clearPathEntity();
                                    return;
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
 
Example 11
Project: BaseClient   File: ViewFrustum.java   View Source Code Vote up 5 votes
public void updateChunkPositions(double viewEntityX, double viewEntityZ)
{
    int i = MathHelper.floor_double(viewEntityX) - 8;
    int j = MathHelper.floor_double(viewEntityZ) - 8;
    int k = this.countChunksX * 16;

    for (int l = 0; l < this.countChunksX; ++l)
    {
        int i1 = this.func_178157_a(i, k, l);

        for (int j1 = 0; j1 < this.countChunksZ; ++j1)
        {
            int k1 = this.func_178157_a(j, k, j1);

            for (int l1 = 0; l1 < this.countChunksY; ++l1)
            {
                int i2 = l1 * 16;
                RenderChunk renderchunk = this.renderChunks[(j1 * this.countChunksY + l1) * this.countChunksX + l];
                BlockPos blockpos = new BlockPos(i1, i2, k1);

                if (!blockpos.equals(renderchunk.getPosition()))
                {
                    renderchunk.setPosition(blockpos);
                }
            }
        }
    }
}
 
Example 12
Project: BaseClient   File: CustomColormap.java   View Source Code Vote up 5 votes
public int getColorSmooth(IBlockAccess p_getColorSmooth_1_, double p_getColorSmooth_2_, double p_getColorSmooth_4_, double p_getColorSmooth_6_, int p_getColorSmooth_8_)
{
    if (this.format == 2)
    {
        return this.color;
    }
    else
    {
        int i = MathHelper.floor_double(p_getColorSmooth_2_);
        int j = MathHelper.floor_double(p_getColorSmooth_4_);
        int k = MathHelper.floor_double(p_getColorSmooth_6_);
        int l = 0;
        int i1 = 0;
        int j1 = 0;
        int k1 = 0;
        BlockPosM blockposm = new BlockPosM(0, 0, 0);

        for (int l1 = i - p_getColorSmooth_8_; l1 <= i + p_getColorSmooth_8_; ++l1)
        {
            for (int i2 = k - p_getColorSmooth_8_; i2 <= k + p_getColorSmooth_8_; ++i2)
            {
                blockposm.setXyz(l1, j, i2);
                int j2 = this.getColor((IBlockAccess)p_getColorSmooth_1_, blockposm);
                l += j2 >> 16 & 255;
                i1 += j2 >> 8 & 255;
                j1 += j2 & 255;
                ++k1;
            }
        }

        int k2 = l / k1;
        int l2 = i1 / k1;
        int i3 = j1 / k1;
        return k2 << 16 | l2 << 8 | i3;
    }
}
 
Example 13
Project: DecompiledMinecraft   File: World.java   View Source Code Vote up 5 votes
public boolean isFlammableWithin(AxisAlignedBB bb)
{
    int i = MathHelper.floor_double(bb.minX);
    int j = MathHelper.floor_double(bb.maxX + 1.0D);
    int k = MathHelper.floor_double(bb.minY);
    int l = MathHelper.floor_double(bb.maxY + 1.0D);
    int i1 = MathHelper.floor_double(bb.minZ);
    int j1 = MathHelper.floor_double(bb.maxZ + 1.0D);

    if (this.isAreaLoaded(i, k, i1, j, l, j1, true))
    {
        BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();

        for (int k1 = i; k1 < j; ++k1)
        {
            for (int l1 = k; l1 < l; ++l1)
            {
                for (int i2 = i1; i2 < j1; ++i2)
                {
                    Block block = this.getBlockState(blockpos$mutableblockpos.func_181079_c(k1, l1, i2)).getBlock();

                    if (block == Blocks.fire || block == Blocks.flowing_lava || block == Blocks.lava)
                    {
                        return true;
                    }
                }
            }
        }
    }

    return false;
}
 
Example 14
Project: DecompiledMinecraft   File: EntityAnimal.java   View Source Code Vote up 5 votes
/**
 * Checks if the entity's current position is a valid location to spawn this entity.
 */
public boolean getCanSpawnHere()
{
    int i = MathHelper.floor_double(this.posX);
    int j = MathHelper.floor_double(this.getEntityBoundingBox().minY);
    int k = MathHelper.floor_double(this.posZ);
    BlockPos blockpos = new BlockPos(i, j, k);
    return this.worldObj.getBlockState(blockpos.down()).getBlock() == this.spawnableBlock && this.worldObj.getLight(blockpos) > 8 && super.getCanSpawnHere();
}
 
Example 15
Project: DecompiledMinecraft   File: EntityPlayerMP.java   View Source Code Vote up 5 votes
public EntityPlayerMP(MinecraftServer server, WorldServer worldIn, GameProfile profile, ItemInWorldManager interactionManager)
{
    super(worldIn, profile);
    interactionManager.thisPlayerMP = this;
    this.theItemInWorldManager = interactionManager;
    BlockPos blockpos = worldIn.getSpawnPoint();

    if (!worldIn.provider.getHasNoSky() && worldIn.getWorldInfo().getGameType() != WorldSettings.GameType.ADVENTURE)
    {
        int i = Math.max(5, server.getSpawnProtectionSize() - 6);
        int j = MathHelper.floor_double(worldIn.getWorldBorder().getClosestDistance((double)blockpos.getX(), (double)blockpos.getZ()));

        if (j < i)
        {
            i = j;
        }

        if (j <= 1)
        {
            i = 1;
        }

        blockpos = worldIn.getTopSolidOrLiquidBlock(blockpos.add(this.rand.nextInt(i * 2) - i, 0, this.rand.nextInt(i * 2) - i));
    }

    this.mcServer = server;
    this.statsFile = server.getConfigurationManager().getPlayerStatsFile(this);
    this.stepHeight = 0.0F;
    this.moveToBlockPosAndAngles(blockpos, 0.0F, 0.0F);

    while (!worldIn.getCollidingBoundingBoxes(this, this.getEntityBoundingBox()).isEmpty() && this.posY < 255.0D)
    {
        this.setPosition(this.posX, this.posY + 1.0D, this.posZ);
    }
}
 
Example 16
Project: BaseClient   File: BlockPosM.java   View Source Code Vote up 4 votes
public BlockPosM(double p_i14_1_, double p_i14_3_, double p_i14_5_)
{
    this(MathHelper.floor_double(p_i14_1_), MathHelper.floor_double(p_i14_3_), MathHelper.floor_double(p_i14_5_));
}
 
Example 17
Project: BaseClient   File: World.java   View Source Code Vote up 4 votes
/**
 * Calculates the color for the skybox
 */
public Vec3 getSkyColor(Entity entityIn, float partialTicks)
{
    float f = this.getCelestialAngle(partialTicks);
    float f1 = MathHelper.cos(f * (float)Math.PI * 2.0F) * 2.0F + 0.5F;
    f1 = MathHelper.clamp_float(f1, 0.0F, 1.0F);
    int i = MathHelper.floor_double(entityIn.posX);
    int j = MathHelper.floor_double(entityIn.posY);
    int k = MathHelper.floor_double(entityIn.posZ);
    BlockPos blockpos = new BlockPos(i, j, k);
    BiomeGenBase biomegenbase = this.getBiomeGenForCoords(blockpos);
    float f2 = biomegenbase.getFloatTemperature(blockpos);
    int l = biomegenbase.getSkyColorByTemp(f2);
    float f3 = (float)(l >> 16 & 255) / 255.0F;
    float f4 = (float)(l >> 8 & 255) / 255.0F;
    float f5 = (float)(l & 255) / 255.0F;
    f3 = f3 * f1;
    f4 = f4 * f1;
    f5 = f5 * f1;
    float f6 = this.getRainStrength(partialTicks);

    if (f6 > 0.0F)
    {
        float f7 = (f3 * 0.3F + f4 * 0.59F + f5 * 0.11F) * 0.6F;
        float f8 = 1.0F - f6 * 0.75F;
        f3 = f3 * f8 + f7 * (1.0F - f8);
        f4 = f4 * f8 + f7 * (1.0F - f8);
        f5 = f5 * f8 + f7 * (1.0F - f8);
    }

    float f10 = this.getThunderStrength(partialTicks);

    if (f10 > 0.0F)
    {
        float f11 = (f3 * 0.3F + f4 * 0.59F + f5 * 0.11F) * 0.2F;
        float f9 = 1.0F - f10 * 0.75F;
        f3 = f3 * f9 + f11 * (1.0F - f9);
        f4 = f4 * f9 + f11 * (1.0F - f9);
        f5 = f5 * f9 + f11 * (1.0F - f9);
    }

    if (this.lastLightningBolt > 0)
    {
        float f12 = (float)this.lastLightningBolt - partialTicks;

        if (f12 > 1.0F)
        {
            f12 = 1.0F;
        }

        f12 = f12 * 0.45F;
        f3 = f3 * (1.0F - f12) + 0.8F * f12;
        f4 = f4 * (1.0F - f12) + 0.8F * f12;
        f5 = f5 * (1.0F - f12) + 1.0F * f12;
    }

    return new Vec3((double)f3, (double)f4, (double)f5);
}
 
Example 18
Project: DecompiledMinecraft   File: NBTTagDouble.java   View Source Code Vote up 4 votes
public int getInt()
{
    return MathHelper.floor_double(this.data);
}
 
Example 19
Project: DecompiledMinecraft   File: RealmsMth.java   View Source Code Vote up 4 votes
public static int floor(double p_floor_0_)
{
    return MathHelper.floor_double(p_floor_0_);
}
 
Example 20
Project: BaseClient   File: World.java   View Source Code Vote up 4 votes
/**
 * handles the acceleration of an object whilst in water. Not sure if it is used elsewhere.
 */
public boolean handleMaterialAcceleration(AxisAlignedBB bb, Material materialIn, Entity entityIn)
{
    int i = MathHelper.floor_double(bb.minX);
    int j = MathHelper.floor_double(bb.maxX + 1.0D);
    int k = MathHelper.floor_double(bb.minY);
    int l = MathHelper.floor_double(bb.maxY + 1.0D);
    int i1 = MathHelper.floor_double(bb.minZ);
    int j1 = MathHelper.floor_double(bb.maxZ + 1.0D);

    if (!this.isAreaLoaded(i, k, i1, j, l, j1, true))
    {
        return false;
    }
    else
    {
        boolean flag = false;
        Vec3 vec3 = new Vec3(0.0D, 0.0D, 0.0D);
        BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();

        for (int k1 = i; k1 < j; ++k1)
        {
            for (int l1 = k; l1 < l; ++l1)
            {
                for (int i2 = i1; i2 < j1; ++i2)
                {
                    blockpos$mutableblockpos.func_181079_c(k1, l1, i2);
                    IBlockState iblockstate = this.getBlockState(blockpos$mutableblockpos);
                    Block block = iblockstate.getBlock();

                    if (block.getMaterial() == materialIn)
                    {
                        double d0 = (double)((float)(l1 + 1) - BlockLiquid.getLiquidHeightPercent(((Integer)iblockstate.getValue(BlockLiquid.LEVEL)).intValue()));

                        if ((double)l >= d0)
                        {
                            flag = true;
                            vec3 = block.modifyAcceleration(this, blockpos$mutableblockpos, entityIn, vec3);
                        }
                    }
                }
            }
        }

        if (vec3.lengthVector() > 0.0D && entityIn.isPushedByWater())
        {
            vec3 = vec3.normalize();
            double d1 = 0.014D;
            entityIn.motionX += vec3.xCoord * d1;
            entityIn.motionY += vec3.yCoord * d1;
            entityIn.motionZ += vec3.zCoord * d1;
        }

        return flag;
    }
}