Java 类net.minecraft.util.math.MathHelper 实例源码

项目:CustomWorldGen    文件:Item.java   
protected RayTraceResult rayTrace(World worldIn, EntityPlayer playerIn, boolean useLiquids)
{
    float f = playerIn.rotationPitch;
    float f1 = playerIn.rotationYaw;
    double d0 = playerIn.posX;
    double d1 = playerIn.posY + (double)playerIn.getEyeHeight();
    double d2 = playerIn.posZ;
    Vec3d vec3d = new Vec3d(d0, d1, d2);
    float f2 = MathHelper.cos(-f1 * 0.017453292F - (float)Math.PI);
    float f3 = MathHelper.sin(-f1 * 0.017453292F - (float)Math.PI);
    float f4 = -MathHelper.cos(-f * 0.017453292F);
    float f5 = MathHelper.sin(-f * 0.017453292F);
    float f6 = f3 * f4;
    float f7 = f2 * f4;
    double d3 = 5.0D;
    if (playerIn instanceof net.minecraft.entity.player.EntityPlayerMP)
    {
        d3 = ((net.minecraft.entity.player.EntityPlayerMP)playerIn).interactionManager.getBlockReachDistance();
    }
    Vec3d vec3d1 = vec3d.addVector((double)f6 * d3, (double)f5 * d3, (double)f7 * d3);
    return worldIn.rayTraceBlocks(vec3d, vec3d1, useLiquids, !useLiquids, false);
}
项目:CustomWorldGen    文件:EntityLiving.java   
/**
 * Arguments: current rotation, intended rotation, max increment.
 */
private float updateRotation(float angle, float targetAngle, float maxIncrease)
{
    float f = MathHelper.wrapDegrees(targetAngle - angle);

    if (f > maxIncrease)
    {
        f = maxIncrease;
    }

    if (f < -maxIncrease)
    {
        f = -maxIncrease;
    }

    return angle + f;
}
项目:Backmemed    文件:DebugRendererPathfinding.java   
public void renderPathLine(float p_190067_1_, Path p_190067_2_)
{
    Tessellator tessellator = Tessellator.getInstance();
    VertexBuffer vertexbuffer = tessellator.getBuffer();
    vertexbuffer.begin(3, DefaultVertexFormats.POSITION_COLOR);

    for (int i = 0; i < p_190067_2_.getCurrentPathLength(); ++i)
    {
        PathPoint pathpoint = p_190067_2_.getPathPointFromIndex(i);

        if (this.addDistanceToPlayer(pathpoint) <= 40.0F)
        {
            float f = (float)i / (float)p_190067_2_.getCurrentPathLength() * 0.33F;
            int j = i == 0 ? 0 : MathHelper.hsvToRGB(f, 0.9F, 0.9F);
            int k = j >> 16 & 255;
            int l = j >> 8 & 255;
            int i1 = j & 255;
            vertexbuffer.pos((double)pathpoint.xCoord - this.xo + 0.5D, (double)pathpoint.yCoord - this.yo + 0.5D, (double)pathpoint.zCoord - this.zo + 0.5D).color(k, l, i1, 255).endVertex();
        }
    }

    tessellator.draw();
}
项目:uniquecrops    文件:TileShyPlant.java   
private RayTraceResult rayTraceFromEntity(World world, Entity player, boolean par3, double range) {

    float f = 1.0F;
    float f1 = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * f;
    float f2 = player.prevRotationYaw + (player.rotationYaw - player.prevRotationYaw) * f;
    double d0 = player.prevPosX + (player.posX - player.prevPosX) * f;
    double d1 = player.prevPosY + (player.posY - player.prevPosY) * f;
    if (player instanceof EntityPlayer)
        d1 += ((EntityPlayer)player).eyeHeight;
    double d2 = player.prevPosZ + (player.posZ - player.prevPosZ) * f;
    Vec3d vec3 = new Vec3d(d0, d1, d2);
    float f3 = MathHelper.cos(-f2 * 0.017453292F - (float)Math.PI);
    float f4 = MathHelper.sin(-f2 * 0.017453292F - (float)Math.PI);
    float f5 = -MathHelper.cos(-f1 * 0.017453292F);
    float f6 = MathHelper.sin(-f1 * 0.017453292F);
    float f7 = f4 * f5;
    float f8 = f3 * f5;
    double d3 = range;
    Vec3d vec31 = vec3.addVector(f7 * d3, f6 * d3, f8 * d3);
    return world.rayTraceBlocks(vec3, vec31, par3);
}
项目:Backmemed    文件:MapGenVillage.java   
public MapGenVillage(Map<String, String> map)
{
    this();

    for (Entry<String, String> entry : map.entrySet())
    {
        if (((String)entry.getKey()).equals("size"))
        {
            this.size = MathHelper.getInt((String)entry.getValue(), this.size, 0);
        }
        else if (((String)entry.getKey()).equals("distance"))
        {
            this.distance = MathHelper.getInt((String)entry.getValue(), this.distance, 9);
        }
    }
}
项目:Backmemed    文件:ModelSnowMan.java   
/**
 * Sets the model's various rotation angles. For bipeds, par1 and par2 are used for animating the movement of arms
 * and legs, where par1 represents the time(so that arms and legs swing back and forth) and par2 represents how
 * "far" arms and legs can swing at most.
 */
public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn)
{
    super.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scaleFactor, entityIn);
    this.head.rotateAngleY = netHeadYaw * 0.017453292F;
    this.head.rotateAngleX = headPitch * 0.017453292F;
    this.body.rotateAngleY = netHeadYaw * 0.017453292F * 0.25F;
    float f = MathHelper.sin(this.body.rotateAngleY);
    float f1 = MathHelper.cos(this.body.rotateAngleY);
    this.rightHand.rotateAngleZ = 1.0F;
    this.leftHand.rotateAngleZ = -1.0F;
    this.rightHand.rotateAngleY = 0.0F + this.body.rotateAngleY;
    this.leftHand.rotateAngleY = (float)Math.PI + this.body.rotateAngleY;
    this.rightHand.rotationPointX = f1 * 5.0F;
    this.rightHand.rotationPointZ = -f * 5.0F;
    this.leftHand.rotationPointX = -f1 * 5.0F;
    this.leftHand.rotationPointZ = f * 5.0F;
}
项目:CustomWorldGen    文件:RenderDragon.java   
protected void rotateCorpse(EntityDragon entityLiving, float p_77043_2_, float p_77043_3_, float partialTicks)
{
    float f = (float)entityLiving.getMovementOffsets(7, partialTicks)[0];
    float f1 = (float)(entityLiving.getMovementOffsets(5, partialTicks)[1] - entityLiving.getMovementOffsets(10, partialTicks)[1]);
    GlStateManager.rotate(-f, 0.0F, 1.0F, 0.0F);
    GlStateManager.rotate(f1 * 10.0F, 1.0F, 0.0F, 0.0F);
    GlStateManager.translate(0.0F, 0.0F, 1.0F);

    if (entityLiving.deathTime > 0)
    {
        float f2 = ((float)entityLiving.deathTime + partialTicks - 1.0F) / 20.0F * 1.6F;
        f2 = MathHelper.sqrt_float(f2);

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

        GlStateManager.rotate(f2 * this.getDeathMaxRotation(entityLiving), 0.0F, 0.0F, 1.0F);
    }
}
项目:CustomWorldGen    文件:EntityArrow.java   
/**
 * Similar to setArrowHeading, it's point the throwable entity to a x, y, z direction.
 */
public void setThrowableHeading(double x, double y, double z, float velocity, float inaccuracy)
{
    float f = MathHelper.sqrt_double(x * x + y * y + z * z);
    x = x / (double)f;
    y = y / (double)f;
    z = z / (double)f;
    x = x + this.rand.nextGaussian() * 0.007499999832361937D * (double)inaccuracy;
    y = y + this.rand.nextGaussian() * 0.007499999832361937D * (double)inaccuracy;
    z = z + this.rand.nextGaussian() * 0.007499999832361937D * (double)inaccuracy;
    x = x * (double)velocity;
    y = y * (double)velocity;
    z = z * (double)velocity;
    this.motionX = x;
    this.motionY = y;
    this.motionZ = z;
    float f1 = MathHelper.sqrt_double(x * x + z * z);
    this.rotationYaw = (float)(MathHelper.atan2(x, z) * (180D / Math.PI));
    this.rotationPitch = (float)(MathHelper.atan2(y, (double)f1) * (180D / Math.PI));
    this.prevRotationYaw = this.rotationYaw;
    this.prevRotationPitch = this.rotationPitch;
    this.ticksInGround = 0;
}
项目:Genesis    文件:WorldGenTreeDryophyllum.java   
private void generateLeaves(World world, Random rand, Vec3d pos) {
    int leavesRadius = MathHelper.ceil(variant.leavesRadius);
    double expConst = variant.distanceExpConstant;

    for (int dx = -leavesRadius; dx <= leavesRadius; dx++) {
        for (int dy = -leavesRadius; dy <= leavesRadius; dy++) {
            for (int dz = -leavesRadius; dz <= leavesRadius; dz++) {
                // lower value of p makes it closer to diamond shape, higher value makes it closer to cube, value p=2 is perfect sphere.
                if (Math.pow(Math.abs(dx), expConst) + Math.pow(Math.abs(dy), expConst) + Math.pow(Math.abs(dz), expConst)
                        - rand.nextFloat() * variant.leavesShapeRandomization * Math.pow(leavesRadius, expConst) <= Math
                        .pow(leavesRadius, expConst)) {
                    setBlockInWorld(world, new BlockPos(pos.addVector(dx, dy, dz)), LEAF);
                }
            }
        }
    }
}
项目:Backmemed    文件:Entity.java   
/**
 * Adds 15% to the entity's yaw and subtracts 15% from the pitch. Clamps pitch from -90 to 90. Both arguments in
 * degrees.
 */
public void setAngles(float yaw, float pitch)
{
    float f = this.rotationPitch;
    float f1 = this.rotationYaw;
    this.rotationYaw = (float)((double)this.rotationYaw + (double)yaw * 0.15D);
    this.rotationPitch = (float)((double)this.rotationPitch - (double)pitch * 0.15D);
    this.rotationPitch = MathHelper.clamp(this.rotationPitch, -90.0F, 90.0F);
    this.prevRotationPitch += this.rotationPitch - f;
    this.prevRotationYaw += this.rotationYaw - f1;

    if (this.ridingEntity != null)
    {
        this.ridingEntity.applyOrientationToEntity(this);
    }
}
项目:Backmemed    文件:EntityLivingBase.java   
protected void updateFallState(double y, boolean onGroundIn, IBlockState state, BlockPos pos)
{
    if (!this.isInWater())
    {
        this.handleWaterMovement();
    }

    if (!this.world.isRemote && this.fallDistance > 3.0F && onGroundIn)
    {
        float f = (float)MathHelper.ceil(this.fallDistance - 3.0F);

        if (state.getMaterial() != Material.AIR)
        {
            double d0 = Math.min((double)(0.2F + f / 15.0F), 2.5D);
            int i = (int)(150.0D * d0);
            ((WorldServer)this.world).spawnParticle(EnumParticleTypes.BLOCK_DUST, this.posX, this.posY, this.posZ, i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D, new int[] {Block.getStateId(state)});
        }
    }

    super.updateFallState(y, onGroundIn, state, pos);
}
项目:CustomWorldGen    文件:EntityVillager.java   
/**
 * Affects the given MerchantRecipeList to possibly add or remove MerchantRecipes.
 */
public void modifyMerchantRecipeList(MerchantRecipeList recipeList, Random random)
{
    Enchantment enchantment = (Enchantment)Enchantment.REGISTRY.getRandomObject(random);
    int i = MathHelper.getRandomIntegerInRange(random, enchantment.getMinLevel(), enchantment.getMaxLevel());
    ItemStack itemstack = Items.ENCHANTED_BOOK.getEnchantedItemStack(new EnchantmentData(enchantment, i));
    int j = 2 + random.nextInt(5 + i * 10) + 3 * i;

    if (enchantment.isTreasureEnchantment())
    {
        j *= 2;
    }

    if (j > 64)
    {
        j = 64;
    }

    recipeList.add(new MerchantRecipe(new ItemStack(Items.BOOK), new ItemStack(Items.EMERALD, j), itemstack));
}
项目:Backmemed    文件:EntityLivingBase.java   
/**
 * returns true if this entity is by a ladder, false otherwise
 */
public boolean isOnLadder()
{
    int i = MathHelper.floor(this.posX);
    int j = MathHelper.floor(this.getEntityBoundingBox().minY);
    int k = MathHelper.floor(this.posZ);

    if (this instanceof EntityPlayer && ((EntityPlayer)this).isSpectator())
    {
        return false;
    }
    else
    {
        BlockPos blockpos = new BlockPos(i, j, k);
        IBlockState iblockstate = this.world.getBlockState(blockpos);
        Block block = iblockstate.getBlock();
        return block != Blocks.LADDER && block != Blocks.VINE ? block instanceof BlockTrapDoor && this.canGoThroughtTrapDoorOnLadder(blockpos, iblockstate) : true;
    }
}
项目:CustomWorldGen    文件:EntityEnderEye.java   
public void moveTowards(BlockPos pos)
{
    double d0 = (double)pos.getX();
    int i = pos.getY();
    double d1 = (double)pos.getZ();
    double d2 = d0 - this.posX;
    double d3 = d1 - this.posZ;
    float f = MathHelper.sqrt_double(d2 * d2 + d3 * d3);

    if (f > 12.0F)
    {
        this.targetX = this.posX + d2 / (double)f * 12.0D;
        this.targetZ = this.posZ + d3 / (double)f * 12.0D;
        this.targetY = this.posY + 8.0D;
    }
    else
    {
        this.targetX = d0;
        this.targetY = (double)i;
        this.targetZ = d1;
    }

    this.despawnTimer = 0;
    this.shatterOrDrop = this.rand.nextInt(5) > 0;
}
项目:CustomWorldGen    文件:EntityMinecart.java   
/**
 * Moved to allow overrides.
 * This code handles minecart movement and speed capping when on a rail.
 */
public void moveMinecartOnRail(BlockPos pos)
{
    double mX = this.motionX;
    double mZ = this.motionZ;

    if (this.isBeingRidden())
    {
        mX *= 0.75D;
        mZ *= 0.75D;
    }

    double max = this.getMaxSpeed();
    mX = MathHelper.clamp_double(mX, -max, max);
    mZ = MathHelper.clamp_double(mZ, -max, max);
    this.moveEntity(mX, 0.0D, mZ);
}
项目:CustomWorldGen    文件:RenderShulkerBullet.java   
/**
 * Renders the desired {@code T} type Entity.
 */
public void doRender(EntityShulkerBullet entity, double x, double y, double z, float entityYaw, float partialTicks)
{
    GlStateManager.pushMatrix();
    float f = this.rotLerp(entity.prevRotationYaw, entity.rotationYaw, partialTicks);
    float f1 = entity.prevRotationPitch + (entity.rotationPitch - entity.prevRotationPitch) * partialTicks;
    float f2 = (float)entity.ticksExisted + partialTicks;
    GlStateManager.translate((float)x, (float)y + 0.15F, (float)z);
    GlStateManager.rotate(MathHelper.sin(f2 * 0.1F) * 180.0F, 0.0F, 1.0F, 0.0F);
    GlStateManager.rotate(MathHelper.cos(f2 * 0.1F) * 180.0F, 1.0F, 0.0F, 0.0F);
    GlStateManager.rotate(MathHelper.sin(f2 * 0.15F) * 360.0F, 0.0F, 0.0F, 1.0F);
    float f3 = 0.03125F;
    GlStateManager.enableRescaleNormal();
    GlStateManager.scale(-1.0F, -1.0F, 1.0F);
    this.bindEntityTexture(entity);
    this.model.render(entity, 0.0F, 0.0F, 0.0F, f, f1, 0.03125F);
    GlStateManager.enableBlend();
    GlStateManager.color(1.0F, 1.0F, 1.0F, 0.5F);
    GlStateManager.scale(1.5F, 1.5F, 1.5F);
    this.model.render(entity, 0.0F, 0.0F, 0.0F, f, f1, 0.03125F);
    GlStateManager.disableBlend();
    GlStateManager.popMatrix();
    super.doRender(entity, x, y, z, entityYaw, partialTicks);
}
项目:Infernum    文件:EntityWitheringBolt.java   
@Override
public void setThrowableHeading(double x, double y, double z, float velocity, float inaccuracy) {
    float f = MathHelper.sqrt(x * x + y * y + z * z);
    x = x / (double) f;
    y = y / (double) f;
    z = z / (double) f;
    x = x + this.rand.nextGaussian() * 0.007499999832361937D * (double) inaccuracy;
    y = y + this.rand.nextGaussian() * 0.007499999832361937D * (double) inaccuracy;
    z = z + this.rand.nextGaussian() * 0.007499999832361937D * (double) inaccuracy;
    x = x * (double) velocity;
    y = y * (double) velocity;
    z = z * (double) velocity;
    this.motionX = x;
    this.motionY = y;
    this.motionZ = z;
}
项目:CustomWorldGen    文件:EntityRenderer.java   
private void renderCloudsCheck(RenderGlobal renderGlobalIn, float partialTicks, int pass)
{
    if (this.mc.gameSettings.shouldRenderClouds() != 0)
    {
        this.mc.mcProfiler.endStartSection("clouds");
        GlStateManager.matrixMode(5889);
        GlStateManager.loadIdentity();
        Project.gluPerspective(this.getFOVModifier(partialTicks, true), (float)this.mc.displayWidth / (float)this.mc.displayHeight, 0.05F, this.farPlaneDistance * 4.0F);
        GlStateManager.matrixMode(5888);
        GlStateManager.pushMatrix();
        this.setupFog(0, partialTicks);
        renderGlobalIn.renderClouds(partialTicks, pass);
        GlStateManager.disableFog();
        GlStateManager.popMatrix();
        GlStateManager.matrixMode(5889);
        GlStateManager.loadIdentity();
        Project.gluPerspective(this.getFOVModifier(partialTicks, true), (float)this.mc.displayWidth / (float)this.mc.displayHeight, 0.05F, this.farPlaneDistance * MathHelper.SQRT_2);
        GlStateManager.matrixMode(5888);
    }
}
项目:CustomWorldGen    文件:EntityMinecartFurnace.java   
protected void moveAlongTrack(BlockPos pos, IBlockState state)
{
    super.moveAlongTrack(pos, state);
    double d0 = this.pushX * this.pushX + this.pushZ * this.pushZ;

    if (d0 > 1.0E-4D && this.motionX * this.motionX + this.motionZ * this.motionZ > 0.001D)
    {
        d0 = (double)MathHelper.sqrt_double(d0);
        this.pushX /= d0;
        this.pushZ /= d0;

        if (this.pushX * this.motionX + this.pushZ * this.motionZ < 0.0D)
        {
            this.pushX = 0.0D;
            this.pushZ = 0.0D;
        }
        else
        {
            double d1 = d0 / this.getMaximumSpeed();
            this.pushX *= d1;
            this.pushZ *= d1;
        }
    }
}
项目:Backmemed    文件:BlockChest.java   
public int getWeakPower(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side)
{
    if (!blockState.canProvidePower())
    {
        return 0;
    }
    else
    {
        int i = 0;
        TileEntity tileentity = blockAccess.getTileEntity(pos);

        if (tileentity instanceof TileEntityChest)
        {
            i = ((TileEntityChest)tileentity).numPlayersUsing;
        }

        return MathHelper.clamp(i, 0, 15);
    }
}
项目:CustomWorldGen    文件:Container.java   
/**
 * Compute the new stack size, Returns the stack with the new size. Args : dragSlots, dragMode, dragStack,
 * slotStackSize
 */
public static void computeStackSize(Set<Slot> dragSlotsIn, int dragModeIn, ItemStack stack, int slotStackSize)
{
    switch (dragModeIn)
    {
        case 0:
            stack.stackSize = MathHelper.floor_float((float)stack.stackSize / (float)dragSlotsIn.size());
            break;
        case 1:
            stack.stackSize = 1;
            break;
        case 2:
            stack.stackSize = stack.getMaxStackSize();
    }

    stack.stackSize += slotStackSize;
}
项目:Backmemed    文件:EntityMoveHelper.java   
/**
 * Limits the given angle to a upper and lower limit.
 */
protected float limitAngle(float p_75639_1_, float p_75639_2_, float p_75639_3_)
{
    float f = MathHelper.wrapDegrees(p_75639_2_ - p_75639_1_);

    if (f > p_75639_3_)
    {
        f = p_75639_3_;
    }

    if (f < -p_75639_3_)
    {
        f = -p_75639_3_;
    }

    float f1 = p_75639_1_ + f;

    if (f1 < 0.0F)
    {
        f1 += 360.0F;
    }
    else if (f1 > 360.0F)
    {
        f1 -= 360.0F;
    }

    return f1;
}
项目:Mods    文件:EntityBulletTracer.java   
public EntityBulletTracer(World par1World, double startX, double startY, double startZ, double x, double y,
        double z, int duration, int crits, EntityLivingBase shooter,boolean special) {
    super(par1World, startX, startY, startZ);
    this.particleScale = 0.2f;
    this.duration = duration;
    this.special = special;

    this.motionX = (x - startX) / duration;
    this.motionY = (y - startY) / duration;
    this.motionZ = (z - startZ) / duration;

    if(special) {
        crits=2;
        this.motionX *= 0.001;
        this.motionY *= 0.001;
        this.motionZ *= 0.001;
    }
    this.particleMaxAge = 200;
    this.setSize(0.025f, 0.025f);
    // this.setParticleIcon(Item.itemsList[2498+256].getIconFromDamage(0));
    this.setParticleTexture(TF2EventsClient.pelletIcon);
    // this.setParticleTextureIndex(81);
    this.multipleParticleScaleBy(2);

    // TODO Auto-generated constructor stub
    if (crits != 2)
        this.setRBGColorF(0.97f, 0.76f, 0.51f);
    else {
        int color = TF2Util.getTeamColor(shooter);
        this.setRBGColorF(MathHelper.clamp((color >> 16) / 255f, 0.2f, 1f), 
                MathHelper.clamp((color >> 8 & 255) / 255f, 0.2f, 1f), MathHelper.clamp((color & 255) / 255f, 0.2f, 1f));
    }
}
项目:CustomWorldGen    文件:ModelOcelot.java   
/**
 * Sets the model's various rotation angles. For bipeds, par1 and par2 are used for animating the movement of arms
 * and legs, where par1 represents the time(so that arms and legs swing back and forth) and par2 represents how
 * "far" arms and legs can swing at most.
 */
public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn)
{
    this.ocelotHead.rotateAngleX = headPitch * 0.017453292F;
    this.ocelotHead.rotateAngleY = netHeadYaw * 0.017453292F;

    if (this.state != 3)
    {
        this.ocelotBody.rotateAngleX = ((float)Math.PI / 2F);

        if (this.state == 2)
        {
            this.ocelotBackLeftLeg.rotateAngleX = MathHelper.cos(limbSwing * 0.6662F) * limbSwingAmount;
            this.ocelotBackRightLeg.rotateAngleX = MathHelper.cos(limbSwing * 0.6662F + 0.3F) * limbSwingAmount;
            this.ocelotFrontLeftLeg.rotateAngleX = MathHelper.cos(limbSwing * 0.6662F + (float)Math.PI + 0.3F) * limbSwingAmount;
            this.ocelotFrontRightLeg.rotateAngleX = MathHelper.cos(limbSwing * 0.6662F + (float)Math.PI) * limbSwingAmount;
            this.ocelotTail2.rotateAngleX = 1.7278761F + ((float)Math.PI / 10F) * MathHelper.cos(limbSwing) * limbSwingAmount;
        }
        else
        {
            this.ocelotBackLeftLeg.rotateAngleX = MathHelper.cos(limbSwing * 0.6662F) * limbSwingAmount;
            this.ocelotBackRightLeg.rotateAngleX = MathHelper.cos(limbSwing * 0.6662F + (float)Math.PI) * limbSwingAmount;
            this.ocelotFrontLeftLeg.rotateAngleX = MathHelper.cos(limbSwing * 0.6662F + (float)Math.PI) * limbSwingAmount;
            this.ocelotFrontRightLeg.rotateAngleX = MathHelper.cos(limbSwing * 0.6662F) * limbSwingAmount;

            if (this.state == 1)
            {
                this.ocelotTail2.rotateAngleX = 1.7278761F + ((float)Math.PI / 4F) * MathHelper.cos(limbSwing) * limbSwingAmount;
            }
            else
            {
                this.ocelotTail2.rotateAngleX = 1.7278761F + 0.47123894F * MathHelper.cos(limbSwing) * limbSwingAmount;
            }
        }
    }
}
项目:Backmemed    文件:EntityVex.java   
public void onUpdateMoveHelper()
{
    if (this.action == EntityMoveHelper.Action.MOVE_TO)
    {
        double d0 = this.posX - EntityVex.this.posX;
        double d1 = this.posY - EntityVex.this.posY;
        double d2 = this.posZ - EntityVex.this.posZ;
        double d3 = d0 * d0 + d1 * d1 + d2 * d2;
        d3 = (double)MathHelper.sqrt(d3);

        if (d3 < EntityVex.this.getEntityBoundingBox().getAverageEdgeLength())
        {
            this.action = EntityMoveHelper.Action.WAIT;
            EntityVex.this.motionX *= 0.5D;
            EntityVex.this.motionY *= 0.5D;
            EntityVex.this.motionZ *= 0.5D;
        }
        else
        {
            EntityVex.this.motionX += d0 / d3 * 0.05D * this.speed;
            EntityVex.this.motionY += d1 / d3 * 0.05D * this.speed;
            EntityVex.this.motionZ += d2 / d3 * 0.05D * this.speed;

            if (EntityVex.this.getAttackTarget() == null)
            {
                EntityVex.this.rotationYaw = -((float)MathHelper.atan2(EntityVex.this.motionX, EntityVex.this.motionZ)) * (180F / (float)Math.PI);
                EntityVex.this.renderYawOffset = EntityVex.this.rotationYaw;
            }
            else
            {
                double d4 = EntityVex.this.getAttackTarget().posX - EntityVex.this.posX;
                double d5 = EntityVex.this.getAttackTarget().posZ - EntityVex.this.posZ;
                EntityVex.this.rotationYaw = -((float)MathHelper.atan2(d4, d5)) * (180F / (float)Math.PI);
                EntityVex.this.renderYawOffset = EntityVex.this.rotationYaw;
            }
        }
    }
}
项目:Backmemed    文件:Potion.java   
public static String getPotionDurationString(PotionEffect p_188410_0_, float p_188410_1_)
{
    if (p_188410_0_.getIsPotionDurationMax())
    {
        return "**:**";
    }
    else
    {
        int i = MathHelper.floor((float)p_188410_0_.getDuration() * p_188410_1_);
        return StringUtils.ticksToElapsedTime(i);
    }
}
项目:FoodCraft-Reloaded    文件:GuiContainerPressureCooker.java   
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
    String s = I18n.format("container.pressure_cooker");
    Optional.ofNullable(fluidTank.getFluid()).ifPresent(fluidStack -> {
        int fluidHeight = MathHelper.ceil(((float) fluidTank.getFluidAmount() / (float) fluidTank.getCapacity()) * (float) fluidBar.getHeight());
        GuiUtils.renderTiledFluid(fluidBar.getX() + guiLeft, fluidBar.getY() + guiTop + (fluidBar.getHeight() - fluidHeight), fluidBar.getWidth(), fluidHeight, this.zLevel, fluidStack);
    });
    this.fontRenderer.drawString(s, this.xSize / 2 - this.fontRenderer.getStringWidth(s) / 2, 4, 4210752);
    this.fontRenderer.drawString(this.playerInventory.getDisplayName().getUnformattedText(), 8, this.ySize - 96 + 4, 4210752);
}
项目:CustomWorldGen    文件:NoiseGeneratorOctaves.java   
/**
 * pars:(par2,3,4=noiseOffset ; so that adjacent noise segments connect) (pars5,6,7=x,y,zArraySize),(pars8,10,12 =
 * x,y,z noiseScale)
 */
public double[] generateNoiseOctaves(double[] noiseArray, int xOffset, int yOffset, int zOffset, int xSize, int ySize, int zSize, double xScale, double yScale, double zScale)
{
    if (noiseArray == null)
    {
        noiseArray = new double[xSize * ySize * zSize];
    }
    else
    {
        for (int i = 0; i < noiseArray.length; ++i)
        {
            noiseArray[i] = 0.0D;
        }
    }

    double d3 = 1.0D;

    for (int j = 0; j < this.octaves; ++j)
    {
        double d0 = (double)xOffset * d3 * xScale;
        double d1 = (double)yOffset * d3 * yScale;
        double d2 = (double)zOffset * d3 * zScale;
        long k = MathHelper.floor_double_long(d0);
        long l = MathHelper.floor_double_long(d2);
        d0 = d0 - (double)k;
        d2 = d2 - (double)l;
        k = k % 16777216L;
        l = l % 16777216L;
        d0 = d0 + (double)k;
        d2 = d2 + (double)l;
        this.generatorCollection[j].populateNoiseArray(noiseArray, d0, d1, d2, xSize, ySize, zSize, xScale * d3, yScale * d3, zScale * d3, d3);
        d3 /= 2.0D;
    }

    return noiseArray;
}
项目:Backmemed    文件:CooldownTracker.java   
public float getCooldown(Item itemIn, float partialTicks)
{
    CooldownTracker.Cooldown cooldowntracker$cooldown = (CooldownTracker.Cooldown)this.cooldowns.get(itemIn);

    if (cooldowntracker$cooldown != null)
    {
        float f = (float)(cooldowntracker$cooldown.expireTicks - cooldowntracker$cooldown.createTicks);
        float f1 = (float)cooldowntracker$cooldown.expireTicks - ((float)this.ticks + partialTicks);
        return MathHelper.clamp(f1 / f, 0.0F, 1.0F);
    }
    else
    {
        return 0.0F;
    }
}
项目:Backmemed    文件:ParticleHeart.java   
/**
 * Renders the particle
 */
public void renderParticle(VertexBuffer worldRendererIn, Entity entityIn, float partialTicks, float rotationX, float rotationZ, float rotationYZ, float rotationXY, float rotationXZ)
{
    float f = ((float)this.particleAge + partialTicks) / (float)this.particleMaxAge * 32.0F;
    f = MathHelper.clamp(f, 0.0F, 1.0F);
    this.particleScale = this.particleScaleOverTime * f;
    super.renderParticle(worldRendererIn, entityIn, partialTicks, rotationX, rotationZ, rotationYZ, rotationXY, rotationXZ);
}
项目:Backmemed    文件:MapGenMineshaft.java   
public MapGenMineshaft(Map<String, String> p_i2034_1_)
{
    for (Entry<String, String> entry : p_i2034_1_.entrySet())
    {
        if (((String)entry.getKey()).equals("chance"))
        {
            this.chance = MathHelper.getDouble((String)entry.getValue(), this.chance);
        }
    }
}
项目:Backmemed    文件:Entity.java   
/**
 * Returns the distance to the entity.
 */
public float getDistanceToEntity(Entity entityIn)
{
    float f = (float)(this.posX - entityIn.posX);
    float f1 = (float)(this.posY - entityIn.posY);
    float f2 = (float)(this.posZ - entityIn.posZ);
    return MathHelper.sqrt(f * f + f1 * f1 + f2 * f2);
}
项目:CustomWorldGen    文件:Entity.java   
/**
 * 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]);
    }
}
项目:CustomWorldGen    文件:RenderEntityItem.java   
private int transformModelCount(EntityItem itemIn, double p_177077_2_, double p_177077_4_, double p_177077_6_, float p_177077_8_, IBakedModel p_177077_9_)
{
    ItemStack itemstack = itemIn.getEntityItem();
    Item item = itemstack.getItem();

    if (item == null)
    {
        return 0;
    }
    else
    {
        boolean flag = p_177077_9_.isGui3d();
        int i = this.getModelCount(itemstack);
        float f = 0.25F;
        float f1 = shouldBob() ? MathHelper.sin(((float)itemIn.getAge() + p_177077_8_) / 10.0F + itemIn.hoverStart) * 0.1F + 0.1F : 0;
        float f2 = p_177077_9_.getItemCameraTransforms().getTransform(ItemCameraTransforms.TransformType.GROUND).scale.y;
        GlStateManager.translate((float)p_177077_2_, (float)p_177077_4_ + f1 + 0.25F * f2, (float)p_177077_6_);

        if (flag || this.renderManager.options != null)
        {
            float f3 = (((float)itemIn.getAge() + p_177077_8_) / 20.0F + itemIn.hoverStart) * (180F / (float)Math.PI);
            GlStateManager.rotate(f3, 0.0F, 1.0F, 0.0F);
        }

        GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
        return i;
    }
}
项目:Backmemed    文件:ModelQuadruped.java   
/**
 * Sets the model's various rotation angles. For bipeds, par1 and par2 are used for animating the movement of arms
 * and legs, where par1 represents the time(so that arms and legs swing back and forth) and par2 represents how
 * "far" arms and legs can swing at most.
 */
public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn)
{
    this.head.rotateAngleX = headPitch * 0.017453292F;
    this.head.rotateAngleY = netHeadYaw * 0.017453292F;
    this.body.rotateAngleX = ((float)Math.PI / 2F);
    this.leg1.rotateAngleX = MathHelper.cos(limbSwing * 0.6662F) * 1.4F * limbSwingAmount;
    this.leg2.rotateAngleX = MathHelper.cos(limbSwing * 0.6662F + (float)Math.PI) * 1.4F * limbSwingAmount;
    this.leg3.rotateAngleX = MathHelper.cos(limbSwing * 0.6662F + (float)Math.PI) * 1.4F * limbSwingAmount;
    this.leg4.rotateAngleX = MathHelper.cos(limbSwing * 0.6662F) * 1.4F * limbSwingAmount;
}
项目:Backmemed    文件:Teleporter.java   
public void placeInPortal(Entity entityIn, float rotationYaw)
{
    if (this.worldServerInstance.provider.getDimensionType().getId() != 1)
    {
        if (!this.placeInExistingPortal(entityIn, rotationYaw))
        {
            this.makePortal(entityIn);
            this.placeInExistingPortal(entityIn, rotationYaw);
        }
    }
    else
    {
        int i = MathHelper.floor(entityIn.posX);
        int j = MathHelper.floor(entityIn.posY) - 1;
        int k = MathHelper.floor(entityIn.posZ);
        int l = 1;
        int i1 = 0;

        for (int j1 = -2; j1 <= 2; ++j1)
        {
            for (int k1 = -2; k1 <= 2; ++k1)
            {
                for (int l1 = -1; l1 < 3; ++l1)
                {
                    int i2 = i + k1 * 1 + j1 * 0;
                    int j2 = j + l1;
                    int k2 = k + k1 * 0 - j1 * 1;
                    boolean flag = l1 < 0;
                    this.worldServerInstance.setBlockState(new BlockPos(i2, j2, k2), flag ? Blocks.OBSIDIAN.getDefaultState() : Blocks.AIR.getDefaultState());
                }
            }
        }

        entityIn.setLocationAndAngles((double)i, (double)j, (double)k, entityIn.rotationYaw, 0.0F);
        entityIn.motionX = 0.0D;
        entityIn.motionY = 0.0D;
        entityIn.motionZ = 0.0D;
    }
}
项目:Thermionics    文件:FX.java   
private static void pickRing(float r, float angularDensity) {
    for(float theta = 0; theta<TAU; theta+=angularDensity) {
        float x = MathHelper.cos(theta)*r;
        float z = MathHelper.sin(theta)*r;
        locationBuffer.add(new Vec2f(x,z));
    }
}
项目:CustomWorldGen    文件:WorldEntitySpawner.java   
private static BlockPos getRandomChunkPosition(World worldIn, int x, int z)
{
    Chunk chunk = worldIn.getChunkFromChunkCoords(x, z);
    int i = x * 16 + worldIn.rand.nextInt(16);
    int j = z * 16 + worldIn.rand.nextInt(16);
    int k = MathHelper.roundUp(chunk.getHeight(new BlockPos(i, 0, j)) + 1, 16);
    int l = worldIn.rand.nextInt(k > 0 ? k : chunk.getTopFilledSegment() + 16 - 1);
    return new BlockPos(i, l, j);
}
项目:Solar    文件:ParticleBase.java   
/**
 * Fix for particle wobbliness
 */
private void renderEasy(BufferBuilder buffer, float partialTicks, float rotationX, float rotationZ, float rotationYZ, float rotationXY, float rotationXZ, double uMin, double uMax, double vMin, double vMax) {
    int light = getBrightnessForRender(partialTicks);
    float scale = 0.1F * particleScale;

    double x = prevPosX + (posX - prevPosX) * partialTicks - interpPosX;
    double y = prevPosY + (posY - prevPosY) * partialTicks - interpPosY;
    double z = prevPosZ + (posZ - prevPosZ) * partialTicks - interpPosZ;
    Vec3d vec0 = new Vec3d(-rotationX * scale - rotationXY * scale, -rotationZ * scale, -rotationYZ * scale - rotationXZ * scale);
    Vec3d vec1 = new Vec3d(-rotationX * scale + rotationXY * scale, rotationZ * scale, -rotationYZ * scale + rotationXZ * scale);
    Vec3d vec2 = new Vec3d(rotationX * scale + rotationXY * scale, rotationZ * scale, rotationYZ * scale + rotationXZ * scale);
    Vec3d vec3 = new Vec3d(rotationX * scale - rotationXY * scale, -rotationZ * scale, rotationYZ * scale - rotationXZ * scale);

    if(this.particleAngle != 0.0F) {
        float life = this.particleAngle + (this.particleAngle - this.prevParticleAngle) * partialTicks;
        //Press F to pay respect
        float f = MathHelper.cos(life * 0.5F);
        float ff = MathHelper.sin(life * 0.5F) * (float) cameraViewDir.x;
        float fff = MathHelper.sin(life * 0.5F) * (float) cameraViewDir.y;
        float ffff = MathHelper.sin(life * 0.5F) * (float) cameraViewDir.z;
        Vec3d vec = new Vec3d((double) ff, (double) fff, (double) ffff);

        vec0 = vec.scale(2.0D * vec0.dotProduct(vec)).add(vec0.scale((f * f) - vec.dotProduct(vec))).add(vec.crossProduct(vec0).scale(2.0F * f));
        vec1 = vec.scale(2.0D * vec1.dotProduct(vec)).add(vec1.scale((f * f) - vec.dotProduct(vec))).add(vec.crossProduct(vec1).scale(2.0F * f));
        vec2 = vec.scale(2.0D * vec2.dotProduct(vec)).add(vec2.scale((f * f) - vec.dotProduct(vec))).add(vec.crossProduct(vec2).scale(2.0F * f));
        vec3 = vec.scale(2.0D * vec3.dotProduct(vec)).add(vec3.scale((f * f) - vec.dotProduct(vec))).add(vec.crossProduct(vec3).scale(2.0F * f));
    }

    buffer.pos(x + vec0.x, y + vec0.y, z + vec0.z).tex(uMax, vMax).color(getRedColorF(), getGreenColorF(), getBlueColorF(), particleAlpha).lightmap(light, light).endVertex();
    buffer.pos(x + vec1.x, y + vec1.y, z + vec1.z).tex(uMax, vMin).color(getRedColorF(), getGreenColorF(), getBlueColorF(), particleAlpha).lightmap(light, light).endVertex();
    buffer.pos(x + vec2.x, y + vec2.y, z + vec2.z).tex(uMin, vMin).color(getRedColorF(), getGreenColorF(), getBlueColorF(), particleAlpha).lightmap(light, light).endVertex();
    buffer.pos(x + vec3.x, y + vec3.y, z + vec3.z).tex(uMin, vMax).color(getRedColorF(), getGreenColorF(), getBlueColorF(), particleAlpha).lightmap(light, light).endVertex();
}
项目:CustomWorldGen    文件:Potion.java   
@SideOnly(Side.CLIENT)
public static String getPotionDurationString(PotionEffect p_188410_0_, float p_188410_1_)
{
    if (p_188410_0_.getIsPotionDurationMax())
    {
        return "**:**";
    }
    else
    {
        int i = MathHelper.floor_float((float)p_188410_0_.getDuration() * p_188410_1_);
        return StringUtils.ticksToElapsedTime(i);
    }
}