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


Java MathHelper.clamp_double方法代码示例

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


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

示例1: moveDerailedMinecart

import net.minecraft.util.MathHelper; //导入方法依赖的package包/类
/**
 * Moves a minecart that is not attached to a rail
 */
protected void moveDerailedMinecart()
{
    double d0 = this.getMaximumSpeed();
    this.motionX = MathHelper.clamp_double(this.motionX, -d0, d0);
    this.motionZ = MathHelper.clamp_double(this.motionZ, -d0, d0);

    if (this.onGround)
    {
        this.motionX *= 0.5D;
        this.motionY *= 0.5D;
        this.motionZ *= 0.5D;
    }

    this.moveEntity(this.motionX, this.motionY, this.motionZ);

    if (!this.onGround)
    {
        this.motionX *= 0.949999988079071D;
        this.motionY *= 0.949999988079071D;
        this.motionZ *= 0.949999988079071D;
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:26,代码来源:EntityMinecart.java

示例2: pickRandomFlower

import net.minecraft.util.MathHelper; //导入方法依赖的package包/类
public BlockFlower.EnumFlowerType pickRandomFlower(Random rand, BlockPos pos)
{
    if (this.field_150632_aF == 1)
    {
        double d0 = MathHelper.clamp_double((1.0D + GRASS_COLOR_NOISE.func_151601_a((double)pos.getX() / 48.0D, (double)pos.getZ() / 48.0D)) / 2.0D, 0.0D, 0.9999D);
        BlockFlower.EnumFlowerType blockflower$enumflowertype = BlockFlower.EnumFlowerType.values()[(int)(d0 * (double)BlockFlower.EnumFlowerType.values().length)];
        return blockflower$enumflowertype == BlockFlower.EnumFlowerType.BLUE_ORCHID ? BlockFlower.EnumFlowerType.POPPY : blockflower$enumflowertype;
    }
    else
    {
        return super.pickRandomFlower(rand, pos);
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:14,代码来源:BiomeGenForest.java

示例3: clamp

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

示例4: getNormalizedVolume

import net.minecraft.util.MathHelper; //导入方法依赖的package包/类
/**
 * Normalizes volume level from parameters.  Range [0.0, 1.0]
 */
private float getNormalizedVolume(ISound sound, SoundPoolEntry entry, SoundCategory category)
{
    return (float)MathHelper.clamp_double((double)sound.getVolume() * entry.getVolume(), 0.0D, 1.0D) * this.getSoundCategoryVolume(category);
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:8,代码来源:SoundManager.java

示例5: transferEntityToWorld

import net.minecraft.util.MathHelper; //导入方法依赖的package包/类
/**
 * Transfers an entity from a world to another world.
 */
public void transferEntityToWorld(Entity entityIn, int p_82448_2_, WorldServer p_82448_3_, WorldServer p_82448_4_)
{
    double d0 = entityIn.posX;
    double d1 = entityIn.posZ;
    double d2 = 8.0D;
    float f = entityIn.rotationYaw;
    p_82448_3_.theProfiler.startSection("moving");

    if (entityIn.dimension == -1)
    {
        d0 = MathHelper.clamp_double(d0 / d2, p_82448_4_.getWorldBorder().minX() + 16.0D, p_82448_4_.getWorldBorder().maxX() - 16.0D);
        d1 = MathHelper.clamp_double(d1 / d2, p_82448_4_.getWorldBorder().minZ() + 16.0D, p_82448_4_.getWorldBorder().maxZ() - 16.0D);
        entityIn.setLocationAndAngles(d0, entityIn.posY, d1, entityIn.rotationYaw, entityIn.rotationPitch);

        if (entityIn.isEntityAlive())
        {
            p_82448_3_.updateEntityWithOptionalForce(entityIn, false);
        }
    }
    else if (entityIn.dimension == 0)
    {
        d0 = MathHelper.clamp_double(d0 * d2, p_82448_4_.getWorldBorder().minX() + 16.0D, p_82448_4_.getWorldBorder().maxX() - 16.0D);
        d1 = MathHelper.clamp_double(d1 * d2, p_82448_4_.getWorldBorder().minZ() + 16.0D, p_82448_4_.getWorldBorder().maxZ() - 16.0D);
        entityIn.setLocationAndAngles(d0, entityIn.posY, d1, entityIn.rotationYaw, entityIn.rotationPitch);

        if (entityIn.isEntityAlive())
        {
            p_82448_3_.updateEntityWithOptionalForce(entityIn, false);
        }
    }
    else
    {
        BlockPos blockpos;

        if (p_82448_2_ == 1)
        {
            blockpos = p_82448_4_.getSpawnPoint();
        }
        else
        {
            blockpos = p_82448_4_.getSpawnCoordinate();
        }

        d0 = (double)blockpos.getX();
        entityIn.posY = (double)blockpos.getY();
        d1 = (double)blockpos.getZ();
        entityIn.setLocationAndAngles(d0, entityIn.posY, d1, 90.0F, 0.0F);

        if (entityIn.isEntityAlive())
        {
            p_82448_3_.updateEntityWithOptionalForce(entityIn, false);
        }
    }

    p_82448_3_.theProfiler.endSection();

    if (p_82448_2_ != 1)
    {
        p_82448_3_.theProfiler.startSection("placing");
        d0 = (double)MathHelper.clamp_int((int)d0, -29999872, 29999872);
        d1 = (double)MathHelper.clamp_int((int)d1, -29999872, 29999872);

        if (entityIn.isEntityAlive())
        {
            entityIn.setLocationAndAngles(d0, entityIn.posY, d1, entityIn.rotationYaw, entityIn.rotationPitch);
            p_82448_4_.getDefaultTeleporter().placeInPortal(entityIn, f);
            p_82448_4_.spawnEntityInWorld(entityIn);
            p_82448_4_.updateEntityWithOptionalForce(entityIn, false);
        }

        p_82448_3_.theProfiler.endSection();
    }

    entityIn.setWorld(p_82448_4_);
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:79,代码来源:ServerConfigurationManager.java

示例6: updateAnimation

import net.minecraft.util.MathHelper; //导入方法依赖的package包/类
public void updateAnimation()
{
    if (!this.framesTextureData.isEmpty())
    {
        Minecraft minecraft = Minecraft.getMinecraft();
        double d0 = 0.0D;

        if (minecraft.theWorld != null && minecraft.thePlayer != null)
        {
            d0 = (double)minecraft.theWorld.getCelestialAngle(1.0F);

            if (!minecraft.theWorld.provider.isSurfaceWorld())
            {
                d0 = Math.random();
            }
        }

        double d1;

        for (d1 = d0 - this.field_94239_h; d1 < -0.5D; ++d1)
        {
            ;
        }

        while (d1 >= 0.5D)
        {
            --d1;
        }

        d1 = MathHelper.clamp_double(d1, -1.0D, 1.0D);
        this.field_94240_i += d1 * 0.1D;
        this.field_94240_i *= 0.8D;
        this.field_94239_h += this.field_94240_i;
        int i;

        for (i = (int)((this.field_94239_h + 1.0D) * (double)this.framesTextureData.size()) % this.framesTextureData.size(); i < 0; i = (i + this.framesTextureData.size()) % this.framesTextureData.size())
        {
            ;
        }

        if (i != this.frameCounter)
        {
            this.frameCounter = i;
            TextureUtil.uploadTextureMipmap((int[][])this.framesTextureData.get(this.frameCounter), this.width, this.height, this.originX, this.originY, false, false);
        }
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:48,代码来源:TextureClock.java

示例7: updateCompass

import net.minecraft.util.MathHelper; //导入方法依赖的package包/类
/**
 * Updates the compass based on the given x,z coords and camera direction
 */
public void updateCompass(World worldIn, double p_94241_2_, double p_94241_4_, double p_94241_6_, boolean p_94241_8_, boolean p_94241_9_)
{
    if (!this.framesTextureData.isEmpty())
    {
        double d0 = 0.0D;

        if (worldIn != null && !p_94241_8_)
        {
            BlockPos blockpos = worldIn.getSpawnPoint();
            double d1 = (double)blockpos.getX() - p_94241_2_;
            double d2 = (double)blockpos.getZ() - p_94241_4_;
            p_94241_6_ = p_94241_6_ % 360.0D;
            d0 = -((p_94241_6_ - 90.0D) * Math.PI / 180.0D - Math.atan2(d2, d1));

            if (!worldIn.provider.isSurfaceWorld())
            {
                d0 = Math.random() * Math.PI * 2.0D;
            }
        }

        if (p_94241_9_)
        {
            this.currentAngle = d0;
        }
        else
        {
            double d3;

            for (d3 = d0 - this.currentAngle; d3 < -Math.PI; d3 += (Math.PI * 2D))
            {
                ;
            }

            while (d3 >= Math.PI)
            {
                d3 -= (Math.PI * 2D);
            }

            d3 = MathHelper.clamp_double(d3, -1.0D, 1.0D);
            this.angleDelta += d3 * 0.1D;
            this.angleDelta *= 0.8D;
            this.currentAngle += this.angleDelta;
        }

        int i;

        for (i = (int)((this.currentAngle / (Math.PI * 2D) + 1.0D) * (double)this.framesTextureData.size()) % this.framesTextureData.size(); i < 0; i = (i + this.framesTextureData.size()) % this.framesTextureData.size())
        {
            ;
        }

        if (i != this.frameCounter)
        {
            this.frameCounter = i;
            TextureUtil.uploadTextureMipmap((int[][])this.framesTextureData.get(this.frameCounter), this.width, this.height, this.originX, this.originY, false, false);
        }
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:62,代码来源:TextureCompass.java

示例8: getNormalizedPitch

import net.minecraft.util.MathHelper; //导入方法依赖的package包/类
/**
 * Normalizes pitch from parameters and clamps to [0.5, 2.0]
 */
private float getNormalizedPitch(ISound sound, SoundPoolEntry entry)
{
    return (float)MathHelper.clamp_double((double)sound.getPitch() * entry.getPitch(), 0.5D, 2.0D);
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:8,代码来源:SoundManager.java

示例9: clampValue

import net.minecraft.util.MathHelper; //导入方法依赖的package包/类
public double clampValue(double p_111109_1_)
{
    p_111109_1_ = MathHelper.clamp_double(p_111109_1_, this.minimumValue, this.maximumValue);
    return p_111109_1_;
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:6,代码来源:RangedAttribute.java

示例10: updateCompass

import net.minecraft.util.MathHelper; //导入方法依赖的package包/类
/**
 * Updates the compass based on the given x,z coords and camera direction
 */
public void updateCompass(World worldIn, double p_94241_2_, double p_94241_4_, double p_94241_6_, boolean p_94241_8_, boolean p_94241_9_)
{
    if (!this.framesTextureData.isEmpty())
    {
        double d0 = 0.0D;

        if (worldIn != null && !p_94241_8_)
        {
            BlockPos blockpos = worldIn.getSpawnPoint();
            double d1 = (double)blockpos.getX() - p_94241_2_;
            double d2 = (double)blockpos.getZ() - p_94241_4_;
            p_94241_6_ = p_94241_6_ % 360.0D;
            d0 = -((p_94241_6_ - 90.0D) * Math.PI / 180.0D - Math.atan2(d2, d1));

            if (!worldIn.provider.isSurfaceWorld())
            {
                d0 = Math.random() * Math.PI * 2.0D;
            }
        }

        if (p_94241_9_)
        {
            this.currentAngle = d0;
        }
        else
        {
            double d3;

            for (d3 = d0 - this.currentAngle; d3 < -Math.PI; d3 += (Math.PI * 2D))
            {
                ;
            }

            while (d3 >= Math.PI)
            {
                d3 -= (Math.PI * 2D);
            }

            d3 = MathHelper.clamp_double(d3, -1.0D, 1.0D);
            this.angleDelta += d3 * 0.1D;
            this.angleDelta *= 0.8D;
            this.currentAngle += this.angleDelta;
        }

        int i;

        for (i = (int)((this.currentAngle / (Math.PI * 2D) + 1.0D) * (double)this.framesTextureData.size()) % this.framesTextureData.size(); i < 0; i = (i + this.framesTextureData.size()) % this.framesTextureData.size())
        {
            ;
        }

        if (i != this.frameCounter)
        {
            this.frameCounter = i;

            if (Config.isShaders())
            {
                ShadersTex.uploadTexSub((int[][])((int[][])this.framesTextureData.get(this.frameCounter)), this.width, this.height, this.originX, this.originY, false, false);
            }
            else
            {
                TextureUtil.uploadTextureMipmap((int[][])((int[][])this.framesTextureData.get(this.frameCounter)), this.width, this.height, this.originX, this.originY, false, false);
            }
        }
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:70,代码来源:TextureCompass.java

示例11: updateAnimation

import net.minecraft.util.MathHelper; //导入方法依赖的package包/类
public void updateAnimation()
{
    if (!this.framesTextureData.isEmpty())
    {
        Minecraft minecraft = Minecraft.getMinecraft();
        double d0 = 0.0D;

        if (minecraft.theWorld != null && minecraft.thePlayer != null)
        {
            d0 = (double)minecraft.theWorld.getCelestialAngle(1.0F);

            if (!minecraft.theWorld.provider.isSurfaceWorld())
            {
                d0 = Math.random();
            }
        }

        double d1;

        for (d1 = d0 - this.field_94239_h; d1 < -0.5D; ++d1)
        {
            ;
        }

        while (d1 >= 0.5D)
        {
            --d1;
        }

        d1 = MathHelper.clamp_double(d1, -1.0D, 1.0D);
        this.field_94240_i += d1 * 0.1D;
        this.field_94240_i *= 0.8D;
        this.field_94239_h += this.field_94240_i;
        int i;

        for (i = (int)((this.field_94239_h + 1.0D) * (double)this.framesTextureData.size()) % this.framesTextureData.size(); i < 0; i = (i + this.framesTextureData.size()) % this.framesTextureData.size())
        {
            ;
        }

        if (i != this.frameCounter)
        {
            this.frameCounter = i;

            if (Config.isShaders())
            {
                ShadersTex.uploadTexSub((int[][])((int[][])this.framesTextureData.get(this.frameCounter)), this.width, this.height, this.originX, this.originY, false, false);
            }
            else
            {
                TextureUtil.uploadTextureMipmap((int[][])((int[][])this.framesTextureData.get(this.frameCounter)), this.width, this.height, this.originX, this.originY, false, false);
            }
        }
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:56,代码来源:TextureClock.java


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