当前位置: 首页>>代码示例>>Java>>正文


Java MathHelper.sqrt_double方法代码示例

本文整理汇总了Java中net.minecraft.util.MathHelper.sqrt_double方法的典型用法代码示例。如果您正苦于以下问题:Java MathHelper.sqrt_double方法的具体用法?Java MathHelper.sqrt_double怎么用?Java MathHelper.sqrt_double使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraft.util.MathHelper的用法示例。


在下文中一共展示了MathHelper.sqrt_double方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: applyDrag

import net.minecraft.util.MathHelper; //导入方法依赖的package包/类
protected void applyDrag()
{
    double d0 = this.pushX * this.pushX + this.pushZ * this.pushZ;

    if (d0 > 1.0E-4D)
    {
        d0 = (double)MathHelper.sqrt_double(d0);
        this.pushX /= d0;
        this.pushZ /= d0;
        double d1 = 1.0D;
        this.motionX *= 0.800000011920929D;
        this.motionY *= 0.0D;
        this.motionZ *= 0.800000011920929D;
        this.motionX += this.pushX * d1;
        this.motionZ += this.pushZ * d1;
    }
    else
    {
        this.motionX *= 0.9800000190734863D;
        this.motionY *= 0.0D;
        this.motionZ *= 0.9800000190734863D;
    }

    super.applyDrag();
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:26,代码来源:EntityMinecartFurnace.java

示例2: EntityFireball

import net.minecraft.util.MathHelper; //导入方法依赖的package包/类
public EntityFireball(World worldIn, EntityLivingBase shooter, double accelX, double accelY, double accelZ)
{
    super(worldIn);
    this.shootingEntity = shooter;
    this.setSize(1.0F, 1.0F);
    this.setLocationAndAngles(shooter.posX, shooter.posY, shooter.posZ, shooter.rotationYaw, shooter.rotationPitch);
    this.setPosition(this.posX, this.posY, this.posZ);
    this.motionX = this.motionY = this.motionZ = 0.0D;
    accelX = accelX + this.rand.nextGaussian() * 0.4D;
    accelY = accelY + this.rand.nextGaussian() * 0.4D;
    accelZ = accelZ + this.rand.nextGaussian() * 0.4D;
    double d0 = (double)MathHelper.sqrt_double(accelX * accelX + accelY * accelY + accelZ * accelZ);
    this.accelerationX = accelX / d0 * 0.1D;
    this.accelerationY = accelY / d0 * 0.1D;
    this.accelerationZ = accelZ / d0 * 0.1D;
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:17,代码来源:EntityFireball.java

示例3: setThrowableHeading

import net.minecraft.util.MathHelper; //导入方法依赖的package包/类
/**
 * 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.prevRotationYaw = this.rotationYaw = (float)(MathHelper.func_181159_b(x, z) * 180.0D / Math.PI);
    this.prevRotationPitch = this.rotationPitch = (float)(MathHelper.func_181159_b(y, (double)f1) * 180.0D / Math.PI);
    this.ticksInGround = 0;
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:24,代码来源:EntityThrowable.java

示例4: onUpdateMoveHelper

import net.minecraft.util.MathHelper; //导入方法依赖的package包/类
public void onUpdateMoveHelper()
{
    if (this.update)
    {
        double d0 = this.posX - this.parentEntity.posX;
        double d1 = this.posY - this.parentEntity.posY;
        double d2 = this.posZ - this.parentEntity.posZ;
        double d3 = d0 * d0 + d1 * d1 + d2 * d2;

        if (this.courseChangeCooldown-- <= 0)
        {
            this.courseChangeCooldown += this.parentEntity.getRNG().nextInt(5) + 2;
            d3 = (double)MathHelper.sqrt_double(d3);

            if (this.isNotColliding(this.posX, this.posY, this.posZ, d3))
            {
                this.parentEntity.motionX += d0 / d3 * 0.1D;
                this.parentEntity.motionY += d1 / d3 * 0.1D;
                this.parentEntity.motionZ += d2 / d3 * 0.1D;
            }
            else
            {
                this.update = false;
            }
        }
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:28,代码来源:EntityGhast.java

示例5: EntityArrow

import net.minecraft.util.MathHelper; //导入方法依赖的package包/类
public EntityArrow(World worldIn, EntityLivingBase shooter, EntityLivingBase p_i1755_3_, float p_i1755_4_, float p_i1755_5_)
{
    super(worldIn);
    this.renderDistanceWeight = 10.0D;
    this.shootingEntity = shooter;

    if (shooter instanceof EntityPlayer)
    {
        this.canBePickedUp = 1;
    }

    this.posY = shooter.posY + (double)shooter.getEyeHeight() - 0.10000000149011612D;
    double d0 = p_i1755_3_.posX - shooter.posX;
    double d1 = p_i1755_3_.getEntityBoundingBox().minY + (double)(p_i1755_3_.height / 3.0F) - this.posY;
    double d2 = p_i1755_3_.posZ - shooter.posZ;
    double d3 = (double)MathHelper.sqrt_double(d0 * d0 + d2 * d2);

    if (d3 >= 1.0E-7D)
    {
        float f = (float)(MathHelper.func_181159_b(d2, d0) * 180.0D / Math.PI) - 90.0F;
        float f1 = (float)(-(MathHelper.func_181159_b(d1, d3) * 180.0D / Math.PI));
        double d4 = d0 / d3;
        double d5 = d2 / d3;
        this.setLocationAndAngles(shooter.posX + d4, this.posY, shooter.posZ + d5, f, f1);
        float f2 = (float)(d3 * 0.20000000298023224D);
        this.setThrowableHeading(d0, d1 + (double)f2, d2, p_i1755_4_, p_i1755_5_);
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:29,代码来源:EntityArrow.java

示例6: setVelocity

import net.minecraft.util.MathHelper; //导入方法依赖的package包/类
/**
 * Sets the velocity to the args. Args: x, y, z
 */
public void setVelocity(double x, double y, double z)
{
    this.motionX = x;
    this.motionY = y;
    this.motionZ = z;

    if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F)
    {
        float f = MathHelper.sqrt_double(x * x + z * z);
        this.prevRotationYaw = this.rotationYaw = (float)(MathHelper.func_181159_b(x, z) * 180.0D / Math.PI);
        this.prevRotationPitch = this.rotationPitch = (float)(MathHelper.func_181159_b(y, (double)f) * 180.0D / Math.PI);
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:17,代码来源:EntityThrowable.java

示例7: EntityFX

import net.minecraft.util.MathHelper; //导入方法依赖的package包/类
public EntityFX(World worldIn, double xCoordIn, double yCoordIn, double zCoordIn, double xSpeedIn, double ySpeedIn, double zSpeedIn)
{
    this(worldIn, xCoordIn, yCoordIn, zCoordIn);
    this.motionX = xSpeedIn + (Math.random() * 2.0D - 1.0D) * 0.4000000059604645D;
    this.motionY = ySpeedIn + (Math.random() * 2.0D - 1.0D) * 0.4000000059604645D;
    this.motionZ = zSpeedIn + (Math.random() * 2.0D - 1.0D) * 0.4000000059604645D;
    float f = (float)(Math.random() + Math.random() + 1.0D) * 0.15F;
    float f1 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ);
    this.motionX = this.motionX / (double)f1 * (double)f * 0.4000000059604645D;
    this.motionY = this.motionY / (double)f1 * (double)f * 0.4000000059604645D + 0.10000000149011612D;
    this.motionZ = this.motionZ / (double)f1 * (double)f * 0.4000000059604645D;
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:13,代码来源:EntityFX.java

示例8: attackEntityWithRangedAttack

import net.minecraft.util.MathHelper; //导入方法依赖的package包/类
/**
 * Attack the specified entity using a ranged attack.
 */
public void attackEntityWithRangedAttack(EntityLivingBase p_82196_1_, float p_82196_2_)
{
    EntitySnowball entitysnowball = new EntitySnowball(this.worldObj, this);
    double d0 = p_82196_1_.posY + (double)p_82196_1_.getEyeHeight() - 1.100000023841858D;
    double d1 = p_82196_1_.posX - this.posX;
    double d2 = d0 - entitysnowball.posY;
    double d3 = p_82196_1_.posZ - this.posZ;
    float f = MathHelper.sqrt_double(d1 * d1 + d3 * d3) * 0.2F;
    entitysnowball.setThrowableHeading(d1, d2 + (double)f, d3, 1.6F, 12.0F);
    this.playSound("random.bow", 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F));
    this.worldObj.spawnEntityInWorld(entitysnowball);
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:16,代码来源:EntitySnowman.java

示例9: onUpdate

import net.minecraft.util.MathHelper; //导入方法依赖的package包/类
/**
 * Called to update the entity's position/logic.
 */
public void onUpdate()
{
    this.renderOffsetY = 0.0F;
    super.onUpdate();
    this.prevLimbSwingAmount = this.limbSwingAmount;
    double d0 = this.posX - this.prevPosX;
    double d1 = this.posZ - this.prevPosZ;
    float f = MathHelper.sqrt_double(d0 * d0 + d1 * d1) * 4.0F;

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

    this.limbSwingAmount += (f - this.limbSwingAmount) * 0.4F;
    this.limbSwing += this.limbSwingAmount;

    if (!this.isItemInUse && this.isEating() && this.inventory.mainInventory[this.inventory.currentItem] != null)
    {
        ItemStack itemstack = this.inventory.mainInventory[this.inventory.currentItem];
        this.setItemInUse(this.inventory.mainInventory[this.inventory.currentItem], itemstack.getItem().getMaxItemUseDuration(itemstack));
        this.isItemInUse = true;
    }
    else if (this.isItemInUse && !this.isEating())
    {
        this.clearItemInUse();
        this.isItemInUse = false;
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:33,代码来源:EntityOtherPlayerMP.java

示例10: applyEntityCollision

import net.minecraft.util.MathHelper; //导入方法依赖的package包/类
/**
 * Applies a velocity to each of the entities pushing them away from each other. Args: entity
 */
public void applyEntityCollision(Entity entityIn)
{
    if (entityIn.riddenByEntity != this && entityIn.ridingEntity != this)
    {
        if (!entityIn.noClip && !this.noClip)
        {
            double d0 = entityIn.posX - this.posX;
            double d1 = entityIn.posZ - this.posZ;
            double d2 = MathHelper.abs_max(d0, d1);

            if (d2 >= 0.009999999776482582D)
            {
                d2 = (double)MathHelper.sqrt_double(d2);
                d0 = d0 / d2;
                d1 = d1 / d2;
                double d3 = 1.0D / d2;

                if (d3 > 1.0D)
                {
                    d3 = 1.0D;
                }

                d0 = d0 * d3;
                d1 = d1 * d3;
                d0 = d0 * 0.05000000074505806D;
                d1 = d1 * 0.05000000074505806D;
                d0 = d0 * (double)(1.0F - this.entityCollisionReduction);
                d1 = d1 * (double)(1.0F - this.entityCollisionReduction);

                if (this.riddenByEntity == null)
                {
                    this.addVelocity(-d0, 0.0D, -d1);
                }

                if (entityIn.riddenByEntity == null)
                {
                    entityIn.addVelocity(d0, 0.0D, d1);
                }
            }
        }
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:46,代码来源:Entity.java

示例11: handleHookRetraction

import net.minecraft.util.MathHelper; //导入方法依赖的package包/类
public int handleHookRetraction()
{
    if (this.worldObj.isRemote)
    {
        return 0;
    }
    else
    {
        int i = 0;

        if (this.caughtEntity != null)
        {
            double d0 = this.angler.posX - this.posX;
            double d2 = this.angler.posY - this.posY;
            double d4 = this.angler.posZ - this.posZ;
            double d6 = (double)MathHelper.sqrt_double(d0 * d0 + d2 * d2 + d4 * d4);
            double d8 = 0.1D;
            this.caughtEntity.motionX += d0 * d8;
            this.caughtEntity.motionY += d2 * d8 + (double)MathHelper.sqrt_double(d6) * 0.08D;
            this.caughtEntity.motionZ += d4 * d8;
            i = 3;
        }
        else if (this.ticksCatchable > 0)
        {
            EntityItem entityitem = new EntityItem(this.worldObj, this.posX, this.posY, this.posZ, this.getFishingResult());
            double d1 = this.angler.posX - this.posX;
            double d3 = this.angler.posY - this.posY;
            double d5 = this.angler.posZ - this.posZ;
            double d7 = (double)MathHelper.sqrt_double(d1 * d1 + d3 * d3 + d5 * d5);
            double d9 = 0.1D;
            entityitem.motionX = d1 * d9;
            entityitem.motionY = d3 * d9 + (double)MathHelper.sqrt_double(d7) * 0.08D;
            entityitem.motionZ = d5 * d9;
            this.worldObj.spawnEntityInWorld(entityitem);
            this.angler.worldObj.spawnEntityInWorld(new EntityXPOrb(this.angler.worldObj, this.angler.posX, this.angler.posY + 0.5D, this.angler.posZ + 0.5D, this.rand.nextInt(6) + 1));
            i = 1;
        }

        if (this.inGround)
        {
            i = 2;
        }

        this.setDead();
        this.angler.fishEntity = null;
        return i;
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:49,代码来源:EntityFishHook.java

示例12: onUpdateMoveHelper

import net.minecraft.util.MathHelper; //导入方法依赖的package包/类
public void onUpdateMoveHelper()
{
    if (this.update && !this.entityGuardian.getNavigator().noPath())
    {
        double d0 = this.posX - this.entityGuardian.posX;
        double d1 = this.posY - this.entityGuardian.posY;
        double d2 = this.posZ - this.entityGuardian.posZ;
        double d3 = d0 * d0 + d1 * d1 + d2 * d2;
        d3 = (double)MathHelper.sqrt_double(d3);
        d1 = d1 / d3;
        float f = (float)(MathHelper.func_181159_b(d2, d0) * 180.0D / Math.PI) - 90.0F;
        this.entityGuardian.rotationYaw = this.limitAngle(this.entityGuardian.rotationYaw, f, 30.0F);
        this.entityGuardian.renderYawOffset = this.entityGuardian.rotationYaw;
        float f1 = (float)(this.speed * this.entityGuardian.getEntityAttribute(SharedMonsterAttributes.movementSpeed).getAttributeValue());
        this.entityGuardian.setAIMoveSpeed(this.entityGuardian.getAIMoveSpeed() + (f1 - this.entityGuardian.getAIMoveSpeed()) * 0.125F);
        double d4 = Math.sin((double)(this.entityGuardian.ticksExisted + this.entityGuardian.getEntityId()) * 0.5D) * 0.05D;
        double d5 = Math.cos((double)(this.entityGuardian.rotationYaw * (float)Math.PI / 180.0F));
        double d6 = Math.sin((double)(this.entityGuardian.rotationYaw * (float)Math.PI / 180.0F));
        this.entityGuardian.motionX += d4 * d5;
        this.entityGuardian.motionZ += d4 * d6;
        d4 = Math.sin((double)(this.entityGuardian.ticksExisted + this.entityGuardian.getEntityId()) * 0.75D) * 0.05D;
        this.entityGuardian.motionY += d4 * (d6 + d5) * 0.25D;
        this.entityGuardian.motionY += (double)this.entityGuardian.getAIMoveSpeed() * d1 * 0.1D;
        EntityLookHelper entitylookhelper = this.entityGuardian.getLookHelper();
        double d7 = this.entityGuardian.posX + d0 / d3 * 2.0D;
        double d8 = (double)this.entityGuardian.getEyeHeight() + this.entityGuardian.posY + d1 / d3 * 1.0D;
        double d9 = this.entityGuardian.posZ + d2 / d3 * 2.0D;
        double d10 = entitylookhelper.getLookPosX();
        double d11 = entitylookhelper.getLookPosY();
        double d12 = entitylookhelper.getLookPosZ();

        if (!entitylookhelper.getIsLooking())
        {
            d10 = d7;
            d11 = d8;
            d12 = d9;
        }

        this.entityGuardian.getLookHelper().setLookPosition(d10 + (d7 - d10) * 0.125D, d11 + (d8 - d11) * 0.125D, d12 + (d9 - d12) * 0.125D, 10.0F, 40.0F);
        this.entityGuardian.func_175476_l(true);
    }
    else
    {
        this.entityGuardian.setAIMoveSpeed(0.0F);
        this.entityGuardian.func_175476_l(false);
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:48,代码来源:EntityGuardian.java

示例13: moveEntityWithHeading

import net.minecraft.util.MathHelper; //导入方法依赖的package包/类
/**
 * Moves the entity based on the specified heading.  Args: strafe, forward
 */
public void moveEntityWithHeading(float strafe, float forward)
{
    if (this.isInWater())
    {
        this.moveFlying(strafe, forward, 0.02F);
        this.moveEntity(this.motionX, this.motionY, this.motionZ);
        this.motionX *= 0.800000011920929D;
        this.motionY *= 0.800000011920929D;
        this.motionZ *= 0.800000011920929D;
    }
    else if (this.isInLava())
    {
        this.moveFlying(strafe, forward, 0.02F);
        this.moveEntity(this.motionX, this.motionY, this.motionZ);
        this.motionX *= 0.5D;
        this.motionY *= 0.5D;
        this.motionZ *= 0.5D;
    }
    else
    {
        float f = 0.91F;

        if (this.onGround)
        {
            f = this.worldObj.getBlockState(new BlockPos(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.getEntityBoundingBox().minY) - 1, MathHelper.floor_double(this.posZ))).getBlock().slipperiness * 0.91F;
        }

        float f1 = 0.16277136F / (f * f * f);
        this.moveFlying(strafe, forward, this.onGround ? 0.1F * f1 : 0.02F);
        f = 0.91F;

        if (this.onGround)
        {
            f = this.worldObj.getBlockState(new BlockPos(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.getEntityBoundingBox().minY) - 1, MathHelper.floor_double(this.posZ))).getBlock().slipperiness * 0.91F;
        }

        this.moveEntity(this.motionX, this.motionY, this.motionZ);
        this.motionX *= (double)f;
        this.motionY *= (double)f;
        this.motionZ *= (double)f;
    }

    this.prevLimbSwingAmount = this.limbSwingAmount;
    double d1 = this.posX - this.prevPosX;
    double d0 = this.posZ - this.prevPosZ;
    float f2 = MathHelper.sqrt_double(d1 * d1 + d0 * d0) * 4.0F;

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

    this.limbSwingAmount += (f2 - this.limbSwingAmount) * 0.4F;
    this.limbSwing += this.limbSwingAmount;
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:59,代码来源:EntityFlying.java

示例14: sqrt

import net.minecraft.util.MathHelper; //导入方法依赖的package包/类
public static float sqrt(double p_sqrt_0_)
{
    return MathHelper.sqrt_double(p_sqrt_0_);
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:5,代码来源:RealmsMth.java


注:本文中的net.minecraft.util.MathHelper.sqrt_double方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。