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

The following are Jave code examples for showing how to use floor_float() 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.
Example 1
Project: BaseClient   File: Container.java   Source Code and License Vote up 6 votes
public static int calcRedstoneFromInventory(IInventory inv)
{
    if (inv == null)
    {
        return 0;
    }
    else
    {
        int i = 0;
        float f = 0.0F;

        for (int j = 0; j < inv.getSizeInventory(); ++j)
        {
            ItemStack itemstack = inv.getStackInSlot(j);

            if (itemstack != null)
            {
                f += (float)itemstack.stackSize / (float)Math.min(inv.getInventoryStackLimit(), itemstack.getMaxStackSize());
                ++i;
            }
        }

        f = f / (float)inv.getSizeInventory();
        return MathHelper.floor_float(f * 14.0F) + (i > 0 ? 1 : 0);
    }
}
 
Example 2
Project: BaseClient   File: NodeProcessor.java   Source Code and License Vote up 5 votes
public void initProcessor(IBlockAccess iblockaccessIn, Entity entityIn)
{
    this.blockaccess = iblockaccessIn;
    this.pointMap.clearMap();
    this.entitySizeX = MathHelper.floor_float(entityIn.width + 1.0F);
    this.entitySizeY = MathHelper.floor_float(entityIn.height + 1.0F);
    this.entitySizeZ = MathHelper.floor_float(entityIn.width + 1.0F);
}
 
Example 3
Project: BaseClient   File: EntityTrackerEntry.java   Source Code and License Vote up 5 votes
public EntityTrackerEntry(Entity trackedEntityIn, int trackingDistanceThresholdIn, int updateFrequencyIn, boolean sendVelocityUpdatesIn)
{
    this.trackedEntity = trackedEntityIn;
    this.trackingDistanceThreshold = trackingDistanceThresholdIn;
    this.updateFrequency = updateFrequencyIn;
    this.sendVelocityUpdates = sendVelocityUpdatesIn;
    this.encodedPosX = MathHelper.floor_double(trackedEntityIn.posX * 32.0D);
    this.encodedPosY = MathHelper.floor_double(trackedEntityIn.posY * 32.0D);
    this.encodedPosZ = MathHelper.floor_double(trackedEntityIn.posZ * 32.0D);
    this.encodedRotationYaw = MathHelper.floor_float(trackedEntityIn.rotationYaw * 256.0F / 360.0F);
    this.encodedRotationPitch = MathHelper.floor_float(trackedEntityIn.rotationPitch * 256.0F / 360.0F);
    this.lastHeadMotion = MathHelper.floor_float(trackedEntityIn.getRotationYawHead() * 256.0F / 360.0F);
    this.onGround = trackedEntityIn.onGround;
}
 
Example 4
Project: BaseClient   File: EnchantmentProtection.java   Source Code and License Vote up 5 votes
/**
 * Calculates the damage protection of the enchantment based on level and damage source passed.
 */
public int calcModifierDamage(int level, DamageSource source)
{
    if (source.canHarmInCreative())
    {
        return 0;
    }
    else
    {
        float f = (float)(6 + level * level) / 3.0F;
        return this.protectionType == 0 ? MathHelper.floor_float(f * 0.75F) : (this.protectionType == 1 && source.isFireDamage() ? MathHelper.floor_float(f * 1.25F) : (this.protectionType == 2 && source == DamageSource.fall ? MathHelper.floor_float(f * 2.5F) : (this.protectionType == 3 && source.isExplosion() ? MathHelper.floor_float(f * 1.5F) : (this.protectionType == 4 && source.isProjectile() ? MathHelper.floor_float(f * 1.5F) : 0))));
    }
}
 
Example 5
Project: BaseClient   File: GuiNewChat.java   Source Code and License Vote up 4 votes
public static int calculateChatboxHeight(float p_146243_0_)
{
    int i = 180;
    int j = 20;
    return MathHelper.floor_float(p_146243_0_ * (float)(i - j) + (float)j);
}
 
Example 6
Project: BaseClient   File: NBTTagFloat.java   Source Code and License Vote up 4 votes
public int getInt()
{
    return MathHelper.floor_float(this.data);
}
 
Example 7
Project: BaseClient   File: NBTTagFloat.java   Source Code and License Vote up 4 votes
public int getInt()
{
    return MathHelper.floor_float(this.data);
}
 
Example 8
Project: BaseClient   File: NBTTagFloat.java   Source Code and License Vote up 4 votes
public short getShort()
{
    return (short)(MathHelper.floor_float(this.data) & 65535);
}
 
Example 9
Project: BaseClient   File: GuiNewChat.java   Source Code and License Vote up 4 votes
public static int calculateChatboxWidth(float p_146233_0_)
{
    int i = 320;
    int j = 40;
    return MathHelper.floor_float(p_146233_0_ * (float)(i - j) + (float)j);
}
 
Example 10
Project: BaseClient   File: EntityAIArrowAttack.java   Source Code and License Vote up 4 votes
/**
 * Updates the task
 */
public void updateTask()
{
    double d0 = this.entityHost.getDistanceSq(this.attackTarget.posX, this.attackTarget.getEntityBoundingBox().minY, this.attackTarget.posZ);
    boolean flag = this.entityHost.getEntitySenses().canSee(this.attackTarget);

    if (flag)
    {
        ++this.field_75318_f;
    }
    else
    {
        this.field_75318_f = 0;
    }

    if (d0 <= (double)this.maxAttackDistance && this.field_75318_f >= 20)
    {
        this.entityHost.getNavigator().clearPathEntity();
    }
    else
    {
        this.entityHost.getNavigator().tryMoveToEntityLiving(this.attackTarget, this.entityMoveSpeed);
    }

    this.entityHost.getLookHelper().setLookPositionWithEntity(this.attackTarget, 30.0F, 30.0F);

    if (--this.rangedAttackTime == 0)
    {
        if (d0 > (double)this.maxAttackDistance || !flag)
        {
            return;
        }

        float f = MathHelper.sqrt_double(d0) / this.field_96562_i;
        float lvt_5_1_ = MathHelper.clamp_float(f, 0.1F, 1.0F);
        this.rangedAttackEntityHost.attackEntityWithRangedAttack(this.attackTarget, lvt_5_1_);
        this.rangedAttackTime = MathHelper.floor_float(f * (float)(this.maxRangedAttackTime - this.field_96561_g) + (float)this.field_96561_g);
    }
    else if (this.rangedAttackTime < 0)
    {
        float f2 = MathHelper.sqrt_double(d0) / this.field_96562_i;
        this.rangedAttackTime = MathHelper.floor_float(f2 * (float)(this.maxRangedAttackTime - this.field_96561_g) + (float)this.field_96561_g);
    }
}
 
Example 11
Project: BaseClient   File: RealmsMth.java   Source Code and License Vote up 4 votes
public static int floor(float p_floor_0_)
{
    return MathHelper.floor_float(p_floor_0_);
}