當前位置: 首頁>>代碼示例>>Java>>正文


Java MathHelper類代碼示例

本文整理匯總了Java中net.minecraft.util.MathHelper的典型用法代碼示例。如果您正苦於以下問題:Java MathHelper類的具體用法?Java MathHelper怎麽用?Java MathHelper使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


MathHelper類屬於net.minecraft.util包,在下文中一共展示了MathHelper類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: updatePower

import net.minecraft.util.MathHelper; //導入依賴的package包/類
public void updatePower(World worldIn, BlockPos pos)
{
    if (!worldIn.provider.getHasNoSky())
    {
        IBlockState iblockstate = worldIn.getBlockState(pos);
        int i = worldIn.getLightFor(EnumSkyBlock.SKY, pos) - worldIn.getSkylightSubtracted();
        float f = worldIn.getCelestialAngleRadians(1.0F);
        float f1 = f < (float)Math.PI ? 0.0F : ((float)Math.PI * 2F);
        f = f + (f1 - f) * 0.2F;
        i = Math.round((float)i * MathHelper.cos(f));
        i = MathHelper.clamp_int(i, 0, 15);

        if (this.inverted)
        {
            i = 15 - i;
        }

        if (((Integer)iblockstate.getValue(POWER)).intValue() != i)
        {
            worldIn.setBlockState(pos, iblockstate.withProperty(POWER, Integer.valueOf(i)), 3);
        }
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:24,代碼來源:BlockDaylightDetector.java

示例2: attackEntityFromPart

import net.minecraft.util.MathHelper; //導入依賴的package包/類
public boolean attackEntityFromPart(EntityDragonPart dragonPart, DamageSource source, float p_70965_3_)
{
    if (dragonPart != this.dragonPartHead)
    {
        p_70965_3_ = p_70965_3_ / 4.0F + 1.0F;
    }

    float f = this.rotationYaw * (float)Math.PI / 180.0F;
    float f1 = MathHelper.sin(f);
    float f2 = MathHelper.cos(f);
    this.targetX = this.posX + (double)(f1 * 5.0F) + (double)((this.rand.nextFloat() - 0.5F) * 2.0F);
    this.targetY = this.posY + (double)(this.rand.nextFloat() * 3.0F) + 1.0D;
    this.targetZ = this.posZ - (double)(f2 * 5.0F) + (double)((this.rand.nextFloat() - 0.5F) * 2.0F);
    this.target = null;

    if (source.getEntity() instanceof EntityPlayer || source.isExplosion())
    {
        this.attackDragonFrom(source, p_70965_3_);
    }

    return true;
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:23,代碼來源:EntityDragon.java

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

示例4: update

import net.minecraft.util.MathHelper; //導入依賴的package包/類
/**
 * Like the old updateEntity(), except more generic.
 */
public void update()
{
    if (this.minecart.isDead)
    {
        this.donePlaying = true;
    }
    else
    {
        this.xPosF = (float)this.minecart.posX;
        this.yPosF = (float)this.minecart.posY;
        this.zPosF = (float)this.minecart.posZ;
        float f = MathHelper.sqrt_double(this.minecart.motionX * this.minecart.motionX + this.minecart.motionZ * this.minecart.motionZ);

        if ((double)f >= 0.01D)
        {
            this.distance = MathHelper.clamp_float(this.distance + 0.0025F, 0.0F, 1.0F);
            this.volume = 0.0F + MathHelper.clamp_float(f, 0.0F, 0.5F) * 0.7F;
        }
        else
        {
            this.distance = 0.0F;
            this.volume = 0.0F;
        }
    }
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:29,代碼來源:MovingSoundMinecart.java

示例5: getEntitiesWithinAABB

import net.minecraft.util.MathHelper; //導入依賴的package包/類
public <T extends Entity> List<T> getEntitiesWithinAABB(Class <? extends T > clazz, AxisAlignedBB aabb, Predicate <? super T > filter)
{
    int i = MathHelper.floor_double((aabb.minX - 2.0D) / 16.0D);
    int j = MathHelper.floor_double((aabb.maxX + 2.0D) / 16.0D);
    int k = MathHelper.floor_double((aabb.minZ - 2.0D) / 16.0D);
    int l = MathHelper.floor_double((aabb.maxZ + 2.0D) / 16.0D);
    List<T> list = Lists.<T>newArrayList();

    for (int i1 = i; i1 <= j; ++i1)
    {
        for (int j1 = k; j1 <= l; ++j1)
        {
            if (this.isChunkLoaded(i1, j1, true))
            {
                this.getChunkFromChunkCoords(i1, j1).getEntitiesOfTypeWithinAAAB(clazz, aabb, list, filter);
            }
        }
    }

    return list;
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:22,代碼來源:World.java

示例6: getStarBrightness

import net.minecraft.util.MathHelper; //導入依賴的package包/類
@Override
@SideOnly(Side.CLIENT)
public float getStarBrightness(float par1)
{
    final float var2 = this.worldObj.getCelestialAngle(par1);
    float var3 = 1.0F - (MathHelper.cos(var2 * (float) Math.PI * 2.0F) * 2.0F + 0.25F);

    if (var3 < 0.0F)
    {
        var3 = 0.0F;
    }

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

    return var3 * var3 * 0.5F + 0.3F;
}
 
開發者ID:BlesseNtumble,項目名稱:TRAPPIST-1,代碼行數:20,代碼來源:WorldProviderTrappistOneB.java

示例7: dropMagazine

import net.minecraft.util.MathHelper; //導入依賴的package包/類
private void dropMagazine(World world, ItemStack stack, Entity entity)
{
	if (!(entity instanceof EntityPlayer)) // For QuiverMobs/Arms Assistants
	{
		this.setCooldown(stack, 60);
		return;
	}

	ItemStack clipStack = Helper.getAmmoStack(ObsidianMagazine.class, MathHelper.floor_double(stack.getItemDamage() / 2) + 1);	// Unloading all ammo into that clip, with some loss

	stack.setItemDamage(this.getMaxDamage());	// Emptying out

	// Creating the clip
	EntityItem entityitem = new EntityItem(world, entity.posX, entity.posY + 1.0d, entity.posZ, clipStack);
	entityitem.delayBeforeCanPickup = 10;

	// And dropping it
	if (entity.captureDrops) { entity.capturedDrops.add(entityitem); }
	else { world.spawnEntityInWorld(entityitem); }

	// SFX
	world.playSoundAtEntity(entity, "random.click", 1.7F, 0.3F);
}
 
開發者ID:Domochevsky,項目名稱:minecraft-quiverbow,代碼行數:24,代碼來源:OSP.java

示例8: removeSunnyPath

import net.minecraft.util.MathHelper; //導入依賴的package包/類
/**
 * Trims path data from the end to the first sun covered block
 */
protected void removeSunnyPath()
{
    super.removeSunnyPath();

    if (this.shouldAvoidSun)
    {
        if (this.worldObj.canSeeSky(new BlockPos(MathHelper.floor_double(this.theEntity.posX), (int)(this.theEntity.getEntityBoundingBox().minY + 0.5D), MathHelper.floor_double(this.theEntity.posZ))))
        {
            return;
        }

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

            if (this.worldObj.canSeeSky(new BlockPos(pathpoint.xCoord, pathpoint.yCoord, pathpoint.zCoord)))
            {
                this.currentPath.setCurrentPathLength(i - 1);
                return;
            }
        }
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:27,代碼來源:PathNavigateGround.java

示例9: getWeakPower

import net.minecraft.util.MathHelper; //導入依賴的package包/類
public int getWeakPower(IBlockAccess worldIn, BlockPos pos, IBlockState state, EnumFacing side)
{
    if (!this.canProvidePower())
    {
        return 0;
    }
    else
    {
        int i = 0;
        TileEntity tileentity = worldIn.getTileEntity(pos);

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

        return MathHelper.clamp_int(i, 0, 15);
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:20,代碼來源:BlockChest.java

示例10: onUpdateNavigation

import net.minecraft.util.MathHelper; //導入依賴的package包/類
public void onUpdateNavigation()
{
    if (!this.noPath())
    {
        super.onUpdateNavigation();
    }
    else
    {
        if (this.targetPosition != null)
        {
            double d0 = (double)(this.theEntity.width * this.theEntity.width);

            if (this.theEntity.getDistanceSqToCenter(this.targetPosition) >= d0 && (this.theEntity.posY <= (double)this.targetPosition.getY() || this.theEntity.getDistanceSqToCenter(new BlockPos(this.targetPosition.getX(), MathHelper.floor_double(this.theEntity.posY), this.targetPosition.getZ())) >= d0))
            {
                this.theEntity.getMoveHelper().setMoveTo((double)this.targetPosition.getX(), (double)this.targetPosition.getY(), (double)this.targetPosition.getZ(), this.speed);
            }
            else
            {
                this.targetPosition = null;
            }
        }
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:24,代碼來源:PathNavigateClimber.java

示例11: setRotationAngles

import net.minecraft.util.MathHelper; //導入依賴的package包/類
/**
 * 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 p_78087_1_, float p_78087_2_, float p_78087_3_, float p_78087_4_, float p_78087_5_, float p_78087_6_, Entity entityIn)
{
    super.setRotationAngles(p_78087_1_, p_78087_2_, p_78087_3_, p_78087_4_, p_78087_5_, p_78087_6_, entityIn);
    float f = MathHelper.sin(this.swingProgress * (float)Math.PI);
    float f1 = MathHelper.sin((1.0F - (1.0F - this.swingProgress) * (1.0F - this.swingProgress)) * (float)Math.PI);
    this.bipedRightArm.rotateAngleZ = 0.0F;
    this.bipedLeftArm.rotateAngleZ = 0.0F;
    this.bipedRightArm.rotateAngleY = -(0.1F - f * 0.6F);
    this.bipedLeftArm.rotateAngleY = 0.1F - f * 0.6F;
    this.bipedRightArm.rotateAngleX = -((float)Math.PI / 2F);
    this.bipedLeftArm.rotateAngleX = -((float)Math.PI / 2F);
    this.bipedRightArm.rotateAngleX -= f * 1.2F - f1 * 0.4F;
    this.bipedLeftArm.rotateAngleX -= f * 1.2F - f1 * 0.4F;
    this.bipedRightArm.rotateAngleZ += MathHelper.cos(p_78087_3_ * 0.09F) * 0.05F + 0.05F;
    this.bipedLeftArm.rotateAngleZ -= MathHelper.cos(p_78087_3_ * 0.09F) * 0.05F + 0.05F;
    this.bipedRightArm.rotateAngleX += MathHelper.sin(p_78087_3_ * 0.067F) * 0.05F;
    this.bipedLeftArm.rotateAngleX -= MathHelper.sin(p_78087_3_ * 0.067F) * 0.05F;
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:24,代碼來源:ModelZombie.java

示例12: EntityThrowable

import net.minecraft.util.MathHelper; //導入依賴的package包/類
public EntityThrowable(World worldIn, EntityLivingBase throwerIn)
{
    super(worldIn);
    this.thrower = throwerIn;
    this.setSize(0.25F, 0.25F);
    this.setLocationAndAngles(throwerIn.posX, throwerIn.posY + (double)throwerIn.getEyeHeight(), throwerIn.posZ, throwerIn.rotationYaw, throwerIn.rotationPitch);
    this.posX -= (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F);
    this.posY -= 0.10000000149011612D;
    this.posZ -= (double)(MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F);
    this.setPosition(this.posX, this.posY, this.posZ);
    float f = 0.4F;
    this.motionX = (double)(-MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI) * f);
    this.motionZ = (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI) * f);
    this.motionY = (double)(-MathHelper.sin((this.rotationPitch + this.getInaccuracy()) / 180.0F * (float)Math.PI) * f);
    this.setThrowableHeading(this.motionX, this.motionY, this.motionZ, this.getVelocity(), 1.0F);
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:17,代碼來源:EntityThrowable.java

示例13: updateRotation

import net.minecraft.util.MathHelper; //導入依賴的package包/類
private float updateRotation(float p_75652_1_, float p_75652_2_, float p_75652_3_)
{
    float f = MathHelper.wrapAngleTo180_float(p_75652_2_ - p_75652_1_);

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

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

    return p_75652_1_ + f;
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:17,代碼來源:EntityLookHelper.java

示例14: getFacingFromEntity

import net.minecraft.util.MathHelper; //導入依賴的package包/類
public static EnumFacing getFacingFromEntity(World worldIn, BlockPos clickedBlock, EntityLivingBase entityIn)
{
    if (MathHelper.abs((float)entityIn.posX - (float)clickedBlock.getX()) < 2.0F && MathHelper.abs((float)entityIn.posZ - (float)clickedBlock.getZ()) < 2.0F)
    {
        double d0 = entityIn.posY + (double)entityIn.getEyeHeight();

        if (d0 - (double)clickedBlock.getY() > 2.0D)
        {
            return EnumFacing.UP;
        }

        if ((double)clickedBlock.getY() - d0 > 0.0D)
        {
            return EnumFacing.DOWN;
        }
    }

    return entityIn.getHorizontalFacing().getOpposite();
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:20,代碼來源:BlockPistonBase.java

示例15: func_181015_d

import net.minecraft.util.MathHelper; //導入依賴的package包/類
public void func_181015_d(BlockPos p_181015_1_)
{
    if (this.timeUntilPortal > 0)
    {
        this.timeUntilPortal = this.getPortalCooldown();
    }
    else
    {
        if (!this.worldObj.isRemote && !p_181015_1_.equals(this.field_181016_an))
        {
            this.field_181016_an = p_181015_1_;
            BlockPattern.PatternHelper blockpattern$patternhelper = Blocks.portal.func_181089_f(this.worldObj, p_181015_1_);
            double d0 = blockpattern$patternhelper.getFinger().getAxis() == EnumFacing.Axis.X ? (double)blockpattern$patternhelper.func_181117_a().getZ() : (double)blockpattern$patternhelper.func_181117_a().getX();
            double d1 = blockpattern$patternhelper.getFinger().getAxis() == EnumFacing.Axis.X ? this.posZ : this.posX;
            d1 = Math.abs(MathHelper.func_181160_c(d1 - (double)(blockpattern$patternhelper.getFinger().rotateY().getAxisDirection() == EnumFacing.AxisDirection.NEGATIVE ? 1 : 0), d0, d0 - (double)blockpattern$patternhelper.func_181118_d()));
            double d2 = MathHelper.func_181160_c(this.posY - 1.0D, (double)blockpattern$patternhelper.func_181117_a().getY(), (double)(blockpattern$patternhelper.func_181117_a().getY() - blockpattern$patternhelper.func_181119_e()));
            this.field_181017_ao = new Vec3(d1, d2, 0.0D);
            this.field_181018_ap = blockpattern$patternhelper.getFinger();
        }

        this.inPortal = true;
    }
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:24,代碼來源:Entity.java


注:本文中的net.minecraft.util.MathHelper類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。