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


Java MathHelper.func_181159_b方法代码示例

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


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

示例1: 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() * (double)(this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * (double)inaccuracy;
    y = y + this.rand.nextGaussian() * (double)(this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * (double)inaccuracy;
    z = z + this.rand.nextGaussian() * (double)(this.rand.nextBoolean() ? -1 : 1) * 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,代码来源:EntityArrow.java

示例2: 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);
        this.prevRotationPitch = this.rotationPitch;
        this.prevRotationYaw = this.rotationYaw;
        this.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, this.rotationPitch);
        this.ticksInGround = 0;
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:21,代码来源:EntityArrow.java

示例3: faceEntity

import net.minecraft.util.MathHelper; //导入方法依赖的package包/类
/**
 * Changes pitch and yaw so that the entity calling the function is facing the entity provided as an argument.
 */
public void faceEntity(Entity entityIn, float p_70625_2_, float p_70625_3_)
{
    double d0 = entityIn.posX - this.posX;
    double d2 = entityIn.posZ - this.posZ;
    double d1;

    if (entityIn instanceof EntityLivingBase)
    {
        EntityLivingBase entitylivingbase = (EntityLivingBase)entityIn;
        d1 = entitylivingbase.posY + (double)entitylivingbase.getEyeHeight() - (this.posY + (double)this.getEyeHeight());
    }
    else
    {
        d1 = (entityIn.getEntityBoundingBox().minY + entityIn.getEntityBoundingBox().maxY) / 2.0D - (this.posY + (double)this.getEyeHeight());
    }

    double d3 = (double)MathHelper.sqrt_double(d0 * d0 + d2 * d2);
    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));
    this.rotationPitch = this.updateRotation(this.rotationPitch, f1, p_70625_3_);
    this.rotationYaw = this.updateRotation(this.rotationYaw, f, p_70625_2_);
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:26,代码来源:EntityLiving.java

示例4: 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:Notoh,项目名称:DecompiledMinecraft,代码行数:24,代码来源:EntityThrowable.java

示例5: updateTask

import net.minecraft.util.MathHelper; //导入方法依赖的package包/类
public void updateTask()
{
    if (this.parentEntity.getAttackTarget() == null)
    {
        this.parentEntity.renderYawOffset = this.parentEntity.rotationYaw = -((float)MathHelper.func_181159_b(this.parentEntity.motionX, this.parentEntity.motionZ)) * 180.0F / (float)Math.PI;
    }
    else
    {
        EntityLivingBase entitylivingbase = this.parentEntity.getAttackTarget();
        double d0 = 64.0D;

        if (entitylivingbase.getDistanceSqToEntity(this.parentEntity) < d0 * d0)
        {
            double d1 = entitylivingbase.posX - this.parentEntity.posX;
            double d2 = entitylivingbase.posZ - this.parentEntity.posZ;
            this.parentEntity.renderYawOffset = this.parentEntity.rotationYaw = -((float)MathHelper.func_181159_b(d1, d2)) * 180.0F / (float)Math.PI;
        }
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:20,代码来源:EntityGhast.java

示例6: handleHookCasting

import net.minecraft.util.MathHelper; //导入方法依赖的package包/类
public void handleHookCasting(double p_146035_1_, double p_146035_3_, double p_146035_5_, float p_146035_7_, float p_146035_8_)
{
    float f = MathHelper.sqrt_double(p_146035_1_ * p_146035_1_ + p_146035_3_ * p_146035_3_ + p_146035_5_ * p_146035_5_);
    p_146035_1_ = p_146035_1_ / (double)f;
    p_146035_3_ = p_146035_3_ / (double)f;
    p_146035_5_ = p_146035_5_ / (double)f;
    p_146035_1_ = p_146035_1_ + this.rand.nextGaussian() * 0.007499999832361937D * (double)p_146035_8_;
    p_146035_3_ = p_146035_3_ + this.rand.nextGaussian() * 0.007499999832361937D * (double)p_146035_8_;
    p_146035_5_ = p_146035_5_ + this.rand.nextGaussian() * 0.007499999832361937D * (double)p_146035_8_;
    p_146035_1_ = p_146035_1_ * (double)p_146035_7_;
    p_146035_3_ = p_146035_3_ * (double)p_146035_7_;
    p_146035_5_ = p_146035_5_ * (double)p_146035_7_;
    this.motionX = p_146035_1_;
    this.motionY = p_146035_3_;
    this.motionZ = p_146035_5_;
    float f1 = MathHelper.sqrt_double(p_146035_1_ * p_146035_1_ + p_146035_5_ * p_146035_5_);
    this.prevRotationYaw = this.rotationYaw = (float)(MathHelper.func_181159_b(p_146035_1_, p_146035_5_) * 180.0D / Math.PI);
    this.prevRotationPitch = this.rotationPitch = (float)(MathHelper.func_181159_b(p_146035_3_, (double)f1) * 180.0D / Math.PI);
    this.ticksInGround = 0;
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:21,代码来源:EntityFishHook.java

示例7: 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

示例8: 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,代码来源:EntityEnderEye.java

示例9: update

import net.minecraft.util.MathHelper; //导入方法依赖的package包/类
/**
 * Like the old updateEntity(), except more generic.
 */
public void update()
{
    this.bookSpreadPrev = this.bookSpread;
    this.bookRotationPrev = this.bookRotation;
    EntityPlayer entityplayer = this.worldObj.getClosestPlayer((double)((float)this.pos.getX() + 0.5F), (double)((float)this.pos.getY() + 0.5F), (double)((float)this.pos.getZ() + 0.5F), 3.0D);

    if (entityplayer != null)
    {
        double d0 = entityplayer.posX - (double)((float)this.pos.getX() + 0.5F);
        double d1 = entityplayer.posZ - (double)((float)this.pos.getZ() + 0.5F);
        this.field_145924_q = (float)MathHelper.func_181159_b(d1, d0);
        this.bookSpread += 0.1F;

        if (this.bookSpread < 0.5F || rand.nextInt(40) == 0)
        {
            float f1 = this.field_145932_k;

            while (true)
            {
                this.field_145932_k += (float)(rand.nextInt(4) - rand.nextInt(4));

                if (f1 != this.field_145932_k)
                {
                    break;
                }
            }
        }
    }
    else
    {
        this.field_145924_q += 0.02F;
        this.bookSpread -= 0.1F;
    }

    while (this.bookRotation >= (float)Math.PI)
    {
        this.bookRotation -= ((float)Math.PI * 2F);
    }

    while (this.bookRotation < -(float)Math.PI)
    {
        this.bookRotation += ((float)Math.PI * 2F);
    }

    while (this.field_145924_q >= (float)Math.PI)
    {
        this.field_145924_q -= ((float)Math.PI * 2F);
    }

    while (this.field_145924_q < -(float)Math.PI)
    {
        this.field_145924_q += ((float)Math.PI * 2F);
    }

    float f2;

    for (f2 = this.field_145924_q - this.bookRotation; f2 >= (float)Math.PI; f2 -= ((float)Math.PI * 2F))
    {
        ;
    }

    while (f2 < -(float)Math.PI)
    {
        f2 += ((float)Math.PI * 2F);
    }

    this.bookRotation += f2 * 0.4F;
    this.bookSpread = MathHelper.clamp_float(this.bookSpread, 0.0F, 1.0F);
    ++this.tickCount;
    this.pageFlipPrev = this.pageFlip;
    float f = (this.field_145932_k - this.pageFlip) * 0.4F;
    float f3 = 0.2F;
    f = MathHelper.clamp_float(f, -f3, f3);
    this.field_145929_l += (f - this.field_145929_l) * 0.9F;
    this.pageFlip += this.field_145929_l;
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:80,代码来源:TileEntityEnchantmentTable.java

示例10: onUpdate

import net.minecraft.util.MathHelper; //导入方法依赖的package包/类
/**
 * Called to update the entity's position/logic.
 */
public void onUpdate()
{
    this.lastTickPosX = this.posX;
    this.lastTickPosY = this.posY;
    this.lastTickPosZ = this.posZ;
    super.onUpdate();
    this.motionX *= 1.15D;
    this.motionZ *= 1.15D;
    this.motionY += 0.04D;
    this.moveEntity(this.motionX, this.motionY, this.motionZ);
    float f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
    this.rotationYaw = (float)(MathHelper.func_181159_b(this.motionX, this.motionZ) * 180.0D / Math.PI);

    for (this.rotationPitch = (float)(MathHelper.func_181159_b(this.motionY, (double)f) * 180.0D / Math.PI); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F)
    {
        ;
    }

    while (this.rotationPitch - this.prevRotationPitch >= 180.0F)
    {
        this.prevRotationPitch += 360.0F;
    }

    while (this.rotationYaw - this.prevRotationYaw < -180.0F)
    {
        this.prevRotationYaw -= 360.0F;
    }

    while (this.rotationYaw - this.prevRotationYaw >= 180.0F)
    {
        this.prevRotationYaw += 360.0F;
    }

    this.rotationPitch = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F;
    this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F;

    if (this.fireworkAge == 0 && !this.isSilent())
    {
        this.worldObj.playSoundAtEntity(this, "fireworks.launch", 3.0F, 1.0F);
    }

    ++this.fireworkAge;

    if (this.worldObj.isRemote && this.fireworkAge % 2 < 2)
    {
        this.worldObj.spawnParticle(EnumParticleTypes.FIREWORKS_SPARK, this.posX, this.posY - 0.3D, this.posZ, this.rand.nextGaussian() * 0.05D, -this.motionY * 0.5D, this.rand.nextGaussian() * 0.05D, new int[0]);
    }

    if (!this.worldObj.isRemote && this.fireworkAge > this.lifetime)
    {
        this.worldObj.setEntityState(this, (byte)17);
        this.setDead();
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:58,代码来源:EntityFireworkRocket.java

示例11: calculateRotationYaw

import net.minecraft.util.MathHelper; //导入方法依赖的package包/类
private void calculateRotationYaw(double x, double z)
{
    this.rotationYaw = (float)(MathHelper.func_181159_b(z - this.posZ, x - this.posX) * 180.0D / Math.PI) - 90.0F;
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:5,代码来源:EntityRabbit.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:Notoh,项目名称:DecompiledMinecraft,代码行数:48,代码来源:EntityGuardian.java

示例13: updateAITasks

import net.minecraft.util.MathHelper; //导入方法依赖的package包/类
protected void updateAITasks()
{
    super.updateAITasks();
    BlockPos blockpos = new BlockPos(this);
    BlockPos blockpos1 = blockpos.up();

    if (this.getIsBatHanging())
    {
        if (!this.worldObj.getBlockState(blockpos1).getBlock().isNormalCube())
        {
            this.setIsBatHanging(false);
            this.worldObj.playAuxSFXAtEntity((EntityPlayer)null, 1015, blockpos, 0);
        }
        else
        {
            if (this.rand.nextInt(200) == 0)
            {
                this.rotationYawHead = (float)this.rand.nextInt(360);
            }

            if (this.worldObj.getClosestPlayerToEntity(this, 4.0D) != null)
            {
                this.setIsBatHanging(false);
                this.worldObj.playAuxSFXAtEntity((EntityPlayer)null, 1015, blockpos, 0);
            }
        }
    }
    else
    {
        if (this.spawnPosition != null && (!this.worldObj.isAirBlock(this.spawnPosition) || this.spawnPosition.getY() < 1))
        {
            this.spawnPosition = null;
        }

        if (this.spawnPosition == null || this.rand.nextInt(30) == 0 || this.spawnPosition.distanceSq((double)((int)this.posX), (double)((int)this.posY), (double)((int)this.posZ)) < 4.0D)
        {
            this.spawnPosition = new BlockPos((int)this.posX + this.rand.nextInt(7) - this.rand.nextInt(7), (int)this.posY + this.rand.nextInt(6) - 2, (int)this.posZ + this.rand.nextInt(7) - this.rand.nextInt(7));
        }

        double d0 = (double)this.spawnPosition.getX() + 0.5D - this.posX;
        double d1 = (double)this.spawnPosition.getY() + 0.1D - this.posY;
        double d2 = (double)this.spawnPosition.getZ() + 0.5D - this.posZ;
        this.motionX += (Math.signum(d0) * 0.5D - this.motionX) * 0.10000000149011612D;
        this.motionY += (Math.signum(d1) * 0.699999988079071D - this.motionY) * 0.10000000149011612D;
        this.motionZ += (Math.signum(d2) * 0.5D - this.motionZ) * 0.10000000149011612D;
        float f = (float)(MathHelper.func_181159_b(this.motionZ, this.motionX) * 180.0D / Math.PI) - 90.0F;
        float f1 = MathHelper.wrapAngleTo180_float(f - this.rotationYaw);
        this.moveForward = 0.5F;
        this.rotationYaw += f1;

        if (this.rand.nextInt(100) == 0 && this.worldObj.getBlockState(blockpos1).getBlock().isNormalCube())
        {
            this.setIsBatHanging(true);
        }
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:57,代码来源:EntityBat.java


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