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

The following are Jave code examples for showing how to use ceiling_float_int() 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: EntityLivingBase.java   Source Code and License Vote up 6 votes
public void fall(float distance, float damageMultiplier)
{
    super.fall(distance, damageMultiplier);
    PotionEffect potioneffect = this.getActivePotionEffect(Potion.jump);
    float f = potioneffect != null ? (float)(potioneffect.getAmplifier() + 1) : 0.0F;
    int i = MathHelper.ceiling_float_int((distance - 3.0F - f) * damageMultiplier);

    if (i > 0)
    {
        this.playSound(this.getFallSoundString(i), 1.0F, 1.0F);
        this.attackEntityFrom(DamageSource.fall, (float)i);
        int j = MathHelper.floor_double(this.posX);
        int k = MathHelper.floor_double(this.posY - 0.20000000298023224D);
        int l = MathHelper.floor_double(this.posZ);
        Block block = this.worldObj.getBlockState(new BlockPos(j, k, l)).getBlock();

        if (block.getMaterial() != Material.air)
        {
            Block.SoundType block$soundtype = block.stepSound;
            this.playSound(block$soundtype.getStepSound(), block$soundtype.getVolume() * 0.5F, block$soundtype.getFrequency() * 0.75F);
        }
    }
}
 
Example 2
Project: BaseClient   File: ScoreHealthCriteria.java   Source Code and License Vote up 6 votes
public int func_96635_a(List<EntityPlayer> p_96635_1_)
{
    float f = 0.0F;

    for (EntityPlayer entityplayer : p_96635_1_)
    {
        f += entityplayer.getHealth() + entityplayer.getAbsorptionAmount();
    }

    if (p_96635_1_.size() > 0)
    {
        f /= (float)p_96635_1_.size();
    }

    return MathHelper.ceiling_float_int(f);
}
 
Example 3
Project: BaseClient   File: EntityFallingBlock.java   Source Code and License Vote up 5 votes
public void fall(float distance, float damageMultiplier)
{
    Block block = this.fallTile.getBlock();

    if (this.hurtEntities)
    {
        int i = MathHelper.ceiling_float_int(distance - 1.0F);

        if (i > 0)
        {
            List<Entity> list = Lists.newArrayList(this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.getEntityBoundingBox()));
            boolean flag = block == Blocks.anvil;
            DamageSource damagesource = flag ? DamageSource.anvil : DamageSource.fallingBlock;

            for (Entity entity : list)
            {
                entity.attackEntityFrom(damagesource, (float)Math.min(MathHelper.floor_float((float)i * this.fallHurtAmount), this.fallHurtMax));
            }

            if (flag && (double)this.rand.nextFloat() < 0.05000000074505806D + (double)i * 0.05D)
            {
                int j = ((Integer)this.fallTile.getValue(BlockAnvil.DAMAGE)).intValue();
                ++j;

                if (j > 2)
                {
                    this.canSetAsBlock = true;
                }
                else
                {
                    this.fallTile = this.fallTile.withProperty(BlockAnvil.DAMAGE, Integer.valueOf(j));
                }
            }
        }
    }
}
 
Example 4
Project: BaseClient   File: EntityHorse.java   Source Code and License Vote up 5 votes
public void fall(float distance, float damageMultiplier)
{
    if (distance > 1.0F)
    {
        this.playSound("mob.horse.land", 0.4F, 1.0F);
    }

    int i = MathHelper.ceiling_float_int((distance * 0.5F - 3.0F) * damageMultiplier);

    if (i > 0)
    {
        this.attackEntityFrom(DamageSource.fall, (float)i);

        if (this.riddenByEntity != null)
        {
            this.riddenByEntity.attackEntityFrom(DamageSource.fall, (float)i);
        }

        Block block = this.worldObj.getBlockState(new BlockPos(this.posX, this.posY - 0.2D - (double)this.prevRotationYaw, this.posZ)).getBlock();

        if (block.getMaterial() != Material.air && !this.isSilent())
        {
            Block.SoundType block$soundtype = block.stepSound;
            this.worldObj.playSoundAtEntity(this, block$soundtype.getStepSound(), block$soundtype.getVolume() * 0.5F, block$soundtype.getFrequency() * 0.75F);
        }
    }
}
 
Example 5
Project: BaseClient   File: EntityHorse.java   Source Code and License Vote up 5 votes
public void fall(float distance, float damageMultiplier)
{
    if (distance > 1.0F)
    {
        this.playSound("mob.horse.land", 0.4F, 1.0F);
    }

    int i = MathHelper.ceiling_float_int((distance * 0.5F - 3.0F) * damageMultiplier);

    if (i > 0)
    {
        this.attackEntityFrom(DamageSource.fall, (float)i);

        if (this.riddenByEntity != null)
        {
            this.riddenByEntity.attackEntityFrom(DamageSource.fall, (float)i);
        }

        Block block = this.worldObj.getBlockState(new BlockPos(this.posX, this.posY - 0.2D - (double)this.prevRotationYaw, this.posZ)).getBlock();

        if (block.getMaterial() != Material.air && !this.isSilent())
        {
            Block.SoundType block$soundtype = block.stepSound;
            this.worldObj.playSoundAtEntity(this, block$soundtype.getStepSound(), block$soundtype.getVolume() * 0.5F, block$soundtype.getFrequency() * 0.75F);
        }
    }
}
 
Example 6
Project: BaseClient   File: EntityFallingBlock.java   Source Code and License Vote up 5 votes
public void fall(float distance, float damageMultiplier)
{
    Block block = this.fallTile.getBlock();

    if (this.hurtEntities)
    {
        int i = MathHelper.ceiling_float_int(distance - 1.0F);

        if (i > 0)
        {
            List<Entity> list = Lists.newArrayList(this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.getEntityBoundingBox()));
            boolean flag = block == Blocks.anvil;
            DamageSource damagesource = flag ? DamageSource.anvil : DamageSource.fallingBlock;

            for (Entity entity : list)
            {
                entity.attackEntityFrom(damagesource, (float)Math.min(MathHelper.floor_float((float)i * this.fallHurtAmount), this.fallHurtMax));
            }

            if (flag && (double)this.rand.nextFloat() < 0.05000000074505806D + (double)i * 0.05D)
            {
                int j = ((Integer)this.fallTile.getValue(BlockAnvil.DAMAGE)).intValue();
                ++j;

                if (j > 2)
                {
                    this.canSetAsBlock = true;
                }
                else
                {
                    this.fallTile = this.fallTile.withProperty(BlockAnvil.DAMAGE, Integer.valueOf(j));
                }
            }
        }
    }
}
 
Example 7
Project: BaseClient   File: BlockPressurePlateWeighted.java   Source Code and License Vote up 5 votes
protected int computeRedstoneStrength(World worldIn, BlockPos pos)
{
    int i = Math.min(worldIn.getEntitiesWithinAABB(Entity.class, this.getSensitiveAABB(pos)).size(), this.field_150068_a);

    if (i > 0)
    {
        float f = (float)Math.min(this.field_150068_a, i) / (float)this.field_150068_a;
        return MathHelper.ceiling_float_int(f * 15.0F);
    }
    else
    {
        return 0;
    }
}
 
Example 8
Project: BaseClient   File: PathNavigate.java   Source Code and License Vote up 4 votes
protected void pathFollow()
{
    Vec3 vec3 = this.getEntityPosition();
    int i = this.currentPath.getCurrentPathLength();

    for (int j = this.currentPath.getCurrentPathIndex(); j < this.currentPath.getCurrentPathLength(); ++j)
    {
        if (this.currentPath.getPathPointFromIndex(j).yCoord != (int)vec3.yCoord)
        {
            i = j;
            break;
        }
    }

    float f = this.theEntity.width * this.theEntity.width * this.heightRequirement;

    for (int k = this.currentPath.getCurrentPathIndex(); k < i; ++k)
    {
        Vec3 vec31 = this.currentPath.getVectorFromIndex(this.theEntity, k);

        if (vec3.squareDistanceTo(vec31) < (double)f)
        {
            this.currentPath.setCurrentPathIndex(k + 1);
        }
    }

    int j1 = MathHelper.ceiling_float_int(this.theEntity.width);
    int k1 = (int)this.theEntity.height + 1;
    int l = j1;

    for (int i1 = i - 1; i1 >= this.currentPath.getCurrentPathIndex(); --i1)
    {
        if (this.isDirectPathBetweenPoints(vec3, this.currentPath.getVectorFromIndex(this.theEntity, i1), j1, k1, l))
        {
            this.currentPath.setCurrentPathIndex(i1);
            break;
        }
    }

    this.checkForStuck(vec3);
}
 
Example 9
Project: BaseClient   File: PathNavigate.java   Source Code and License Vote up 4 votes
protected void pathFollow()
{
    Vec3 vec3 = this.getEntityPosition();
    int i = this.currentPath.getCurrentPathLength();

    for (int j = this.currentPath.getCurrentPathIndex(); j < this.currentPath.getCurrentPathLength(); ++j)
    {
        if (this.currentPath.getPathPointFromIndex(j).yCoord != (int)vec3.yCoord)
        {
            i = j;
            break;
        }
    }

    float f = this.theEntity.width * this.theEntity.width * this.heightRequirement;

    for (int k = this.currentPath.getCurrentPathIndex(); k < i; ++k)
    {
        Vec3 vec31 = this.currentPath.getVectorFromIndex(this.theEntity, k);

        if (vec3.squareDistanceTo(vec31) < (double)f)
        {
            this.currentPath.setCurrentPathIndex(k + 1);
        }
    }

    int j1 = MathHelper.ceiling_float_int(this.theEntity.width);
    int k1 = (int)this.theEntity.height + 1;
    int l = j1;

    for (int i1 = i - 1; i1 >= this.currentPath.getCurrentPathIndex(); --i1)
    {
        if (this.isDirectPathBetweenPoints(vec3, this.currentPath.getVectorFromIndex(this.theEntity, i1), j1, k1, l))
        {
            this.currentPath.setCurrentPathIndex(i1);
            break;
        }
    }

    this.checkForStuck(vec3);
}
 
Example 10
Project: BaseClient   File: SlotFurnaceOutput.java   Source Code and License Vote up 4 votes
/**
 * the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood.
 */
protected void onCrafting(ItemStack stack)
{
    stack.onCrafting(this.thePlayer.worldObj, this.thePlayer, this.field_75228_b);

    if (!this.thePlayer.worldObj.isRemote)
    {
        int i = this.field_75228_b;
        float f = FurnaceRecipes.instance().getSmeltingExperience(stack);

        if (f == 0.0F)
        {
            i = 0;
        }
        else if (f < 1.0F)
        {
            int j = MathHelper.floor_float((float)i * f);

            if (j < MathHelper.ceiling_float_int((float)i * f) && Math.random() < (double)((float)i * f - (float)j))
            {
                ++j;
            }

            i = j;
        }

        while (i > 0)
        {
            int k = EntityXPOrb.getXPSplit(i);
            i -= k;
            this.thePlayer.worldObj.spawnEntityInWorld(new EntityXPOrb(this.thePlayer.worldObj, this.thePlayer.posX, this.thePlayer.posY + 0.5D, this.thePlayer.posZ + 0.5D, k));
        }
    }

    this.field_75228_b = 0;

    if (stack.getItem() == Items.iron_ingot)
    {
        this.thePlayer.triggerAchievement(AchievementList.acquireIron);
    }

    if (stack.getItem() == Items.cooked_fish)
    {
        this.thePlayer.triggerAchievement(AchievementList.cookFish);
    }
}
 
Example 11
Project: BaseClient   File: RealmsMth.java   Source Code and License Vote up 4 votes
public static int ceil(float p_ceil_0_)
{
    return MathHelper.ceiling_float_int(p_ceil_0_);
}