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


Java MathHelper.clamp_float方法代碼示例

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


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

示例1: mousePressed

import net.minecraft.util.MathHelper; //導入方法依賴的package包/類
/**
 * Returns true if the mouse has been pressed on this control. Equivalent of MouseListener.mousePressed(MouseEvent
 * e).
 */
public boolean mousePressed(Minecraft mc, int mouseX, int mouseY)
{
    if (super.mousePressed(mc, mouseX, mouseY))
    {
        this.sliderValue = (float)(mouseX - (this.xPosition + 4)) / (float)(this.width - 8);
        this.sliderValue = MathHelper.clamp_float(this.sliderValue, 0.0F, 1.0F);
        mc.gameSettings.setOptionFloatValue(this.options, this.options.denormalizeValue(this.sliderValue));
        this.displayString = mc.gameSettings.getKeyBinding(this.options);
        this.dragging = true;
        return true;
    }
    else
    {
        return false;
    }
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:21,代碼來源:GuiOptionSlider.java

示例2: handleMouseInput

import net.minecraft.util.MathHelper; //導入方法依賴的package包/類
/**
 * Handles mouse input.
 */
public void handleMouseInput() throws IOException
{
    super.handleMouseInput();
    int i = Mouse.getEventDWheel();

    if (i != 0 && this.needsScrollBars())
    {
        int j = ((GuiContainerCreative.ContainerCreative)this.inventorySlots).itemList.size() / 9 - 5;

        if (i > 0)
        {
            i = 1;
        }

        if (i < 0)
        {
            i = -1;
        }

        this.currentScroll = (float)((double)this.currentScroll - (double)i / (double)j);
        this.currentScroll = MathHelper.clamp_float(this.currentScroll, 0.0F, 1.0F);
        ((GuiContainerCreative.ContainerCreative)this.inventorySlots).scrollTo(this.currentScroll);
    }
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:28,代碼來源:GuiContainerCreative.java

示例3: calculateAdditionalDifficulty

import net.minecraft.util.MathHelper; //導入方法依賴的package包/類
private float calculateAdditionalDifficulty(EnumDifficulty difficulty, long worldTime, long chunkInhabitedTime, float moonPhaseFactor)
{
    if (difficulty == EnumDifficulty.PEACEFUL)
    {
        return 0.0F;
    }
    else
    {
        boolean flag = difficulty == EnumDifficulty.HARD;
        float f = 0.75F;
        float f1 = MathHelper.clamp_float(((float)worldTime + -72000.0F) / 1440000.0F, 0.0F, 1.0F) * 0.25F;
        f = f + f1;
        float f2 = 0.0F;
        f2 = f2 + MathHelper.clamp_float((float)chunkInhabitedTime / 3600000.0F, 0.0F, 1.0F) * (flag ? 1.0F : 0.75F);
        f2 = f2 + MathHelper.clamp_float(moonPhaseFactor * 0.25F, 0.0F, f1);

        if (difficulty == EnumDifficulty.EASY)
        {
            f2 *= 0.5F;
        }

        f = f + f2;
        return (float)difficulty.getDifficultyId() * f;
    }
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:26,代碼來源:DifficultyInstance.java

示例4: renderParticle

import net.minecraft.util.MathHelper; //導入方法依賴的package包/類
/**
 * Renders the particle
 */
public void renderParticle(WorldRenderer worldRendererIn, Entity entityIn, float partialTicks, float p_180434_4_, float p_180434_5_, float p_180434_6_, float p_180434_7_, float p_180434_8_)
{
    float f = ((float)this.particleAge + partialTicks) / (float)this.particleMaxAge * 32.0F;
    f = MathHelper.clamp_float(f, 0.0F, 1.0F);
    this.particleScale = this.field_70569_a * f;
    super.renderParticle(worldRendererIn, entityIn, partialTicks, p_180434_4_, p_180434_5_, p_180434_6_, p_180434_7_, p_180434_8_);
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:11,代碼來源:EntityCloudFX.java

示例5: getFogColor

import net.minecraft.util.MathHelper; //導入方法依賴的package包/類
/**
 * Return Vec3D with biome specific fog color
 */
public Vec3 getFogColor(float p_76562_1_, float p_76562_2_)
{
    int i = 10518688;
    float f = MathHelper.cos(p_76562_1_ * (float)Math.PI * 2.0F) * 2.0F + 0.5F;
    f = MathHelper.clamp_float(f, 0.0F, 1.0F);
    float f1 = (float)(i >> 16 & 255) / 255.0F;
    float f2 = (float)(i >> 8 & 255) / 255.0F;
    float f3 = (float)(i & 255) / 255.0F;
    f1 = f1 * (f * 0.0F + 0.15F);
    f2 = f2 * (f * 0.0F + 0.15F);
    f3 = f3 * (f * 0.0F + 0.15F);
    return new Vec3((double)f1, (double)f2, (double)f3);
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:17,代碼來源:WorldProviderEnd.java

示例6: getCloudColour

import net.minecraft.util.MathHelper; //導入方法依賴的package包/類
public Vec3 getCloudColour(float partialTicks)
{
    float f = this.getCelestialAngle(partialTicks);
    float f1 = MathHelper.cos(f * (float)Math.PI * 2.0F) * 2.0F + 0.5F;
    f1 = MathHelper.clamp_float(f1, 0.0F, 1.0F);
    float f2 = (float)(this.cloudColour >> 16 & 255L) / 255.0F;
    float f3 = (float)(this.cloudColour >> 8 & 255L) / 255.0F;
    float f4 = (float)(this.cloudColour & 255L) / 255.0F;
    float f5 = this.getRainStrength(partialTicks);

    if (f5 > 0.0F)
    {
        float f6 = (f2 * 0.3F + f3 * 0.59F + f4 * 0.11F) * 0.6F;
        float f7 = 1.0F - f5 * 0.95F;
        f2 = f2 * f7 + f6 * (1.0F - f7);
        f3 = f3 * f7 + f6 * (1.0F - f7);
        f4 = f4 * f7 + f6 * (1.0F - f7);
    }

    f2 = f2 * (f1 * 0.9F + 0.1F);
    f3 = f3 * (f1 * 0.9F + 0.1F);
    f4 = f4 * (f1 * 0.85F + 0.15F);
    float f9 = this.getThunderStrength(partialTicks);

    if (f9 > 0.0F)
    {
        float f10 = (f2 * 0.3F + f3 * 0.59F + f4 * 0.11F) * 0.2F;
        float f8 = 1.0F - f9 * 0.95F;
        f2 = f2 * f8 + f10 * (1.0F - f8);
        f3 = f3 * f8 + f10 * (1.0F - f8);
        f4 = f4 * f8 + f10 * (1.0F - f8);
    }

    return new Vec3((double)f2, (double)f3, (double)f4);
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:36,代碼來源:World.java

示例7: clicked

import net.minecraft.util.MathHelper; //導入方法依賴的package包/類
public void clicked(int p_clicked_1_, int p_clicked_2_)
{
    this.value = (float)(p_clicked_1_ - (this.getProxy().xPosition + 4)) / (float)(this.getProxy().getButtonWidth() - 8);
    this.value = MathHelper.clamp_float(this.value, 0.0F, 1.0F);
    this.clicked(this.toValue(this.value));
    this.getProxy().displayString = this.getMessage();
    this.sliding = true;
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:9,代碼來源:RealmsSliderButton.java

示例8: preRenderCallback

import net.minecraft.util.MathHelper; //導入方法依賴的package包/類
/**
 * Allows the render to do any OpenGL state modifications necessary before the model is rendered. Args:
 * entityLiving, partialTickTime
 */
protected void preRenderCallback(EntityCreeper entitylivingbaseIn, float partialTickTime)
{
    float f = entitylivingbaseIn.getCreeperFlashIntensity(partialTickTime);
    float f1 = 1.0F + MathHelper.sin(f * 100.0F) * f * 0.01F;
    f = MathHelper.clamp_float(f, 0.0F, 1.0F);
    f = f * f;
    f = f * f;
    float f2 = (1.0F + f * 0.4F) * f1;
    float f3 = (1.0F + f * 0.1F) / f1;
    GlStateManager.scale(f2, f3, f2);
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:16,代碼來源:RenderCreeper.java

示例9: deserialize

import net.minecraft.util.MathHelper; //導入方法依賴的package包/類
public ItemTransformVec3f deserialize(JsonElement p_deserialize_1_, Type p_deserialize_2_, JsonDeserializationContext p_deserialize_3_) throws JsonParseException
{
    JsonObject jsonobject = p_deserialize_1_.getAsJsonObject();
    Vector3f vector3f = this.parseVector3f(jsonobject, "rotation", ROTATION_DEFAULT);
    Vector3f vector3f1 = this.parseVector3f(jsonobject, "translation", TRANSLATION_DEFAULT);
    vector3f1.scale(0.0625F);
    vector3f1.x = MathHelper.clamp_float(vector3f1.x, -1.5F, 1.5F);
    vector3f1.y = MathHelper.clamp_float(vector3f1.y, -1.5F, 1.5F);
    vector3f1.z = MathHelper.clamp_float(vector3f1.z, -1.5F, 1.5F);
    Vector3f vector3f2 = this.parseVector3f(jsonobject, "scale", SCALE_DEFAULT);
    vector3f2.x = MathHelper.clamp_float(vector3f2.x, -4.0F, 4.0F);
    vector3f2.y = MathHelper.clamp_float(vector3f2.y, -4.0F, 4.0F);
    vector3f2.z = MathHelper.clamp_float(vector3f2.z, -4.0F, 4.0F);
    return new ItemTransformVec3f(vector3f, vector3f1, vector3f2);
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:16,代碼來源:ItemTransformVec3f.java

示例10: renderParticle

import net.minecraft.util.MathHelper; //導入方法依賴的package包/類
/**
 * Renders the particle
 */
public void renderParticle(WorldRenderer worldRendererIn, Entity entityIn, float partialTicks, float p_180434_4_, float p_180434_5_, float p_180434_6_, float p_180434_7_, float p_180434_8_)
{
    float f = ((float)this.particleAge + partialTicks) / (float)this.particleMaxAge * 32.0F;
    f = MathHelper.clamp_float(f, 0.0F, 1.0F);
    this.particleScale = this.noteParticleScale * f;
    super.renderParticle(worldRendererIn, entityIn, partialTicks, p_180434_4_, p_180434_5_, p_180434_6_, p_180434_7_, p_180434_8_);
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:11,代碼來源:EntityNoteFX.java

示例11: func_180560_a

import net.minecraft.util.MathHelper; //導入方法依賴的package包/類
protected void func_180560_a(EntityMinecartTNT minecart, float partialTicks, IBlockState state)
{
    int i = minecart.getFuseTicks();

    if (i > -1 && (float)i - partialTicks + 1.0F < 10.0F)
    {
        float f = 1.0F - ((float)i - partialTicks + 1.0F) / 10.0F;
        f = MathHelper.clamp_float(f, 0.0F, 1.0F);
        f = f * f;
        f = f * f;
        float f1 = 1.0F + f * 0.3F;
        GlStateManager.scale(f1, f1, f1);
    }

    super.func_180560_a(minecart, partialTicks, state);

    if (i > -1 && i / 5 % 2 == 0)
    {
        BlockRendererDispatcher blockrendererdispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
        GlStateManager.disableTexture2D();
        GlStateManager.disableLighting();
        GlStateManager.enableBlend();
        GlStateManager.blendFunc(770, 772);
        GlStateManager.color(1.0F, 1.0F, 1.0F, (1.0F - ((float)i - partialTicks + 1.0F) / 100.0F) * 0.8F);
        GlStateManager.pushMatrix();
        blockrendererdispatcher.renderBlockBrightness(Blocks.tnt.getDefaultState(), 1.0F);
        GlStateManager.popMatrix();
        GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
        GlStateManager.disableBlend();
        GlStateManager.enableLighting();
        GlStateManager.enableTexture2D();
    }
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:34,代碼來源:RenderTntMinecart.java

示例12: getSkyColorByTemp

import net.minecraft.util.MathHelper; //導入方法依賴的package包/類
/**
 * takes temperature, returns color
 */
public int getSkyColorByTemp(float p_76731_1_)
{
    p_76731_1_ = p_76731_1_ / 3.0F;
    p_76731_1_ = MathHelper.clamp_float(p_76731_1_, -1.0F, 1.0F);
    return MathHelper.func_181758_c(0.62222224F - p_76731_1_ * 0.05F, 0.5F + p_76731_1_ * 0.1F, 1.0F);
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:10,代碼來源:BiomeGenBase.java

示例13: getBrightnessForRender

import net.minecraft.util.MathHelper; //導入方法依賴的package包/類
public int getBrightnessForRender(float partialTicks)
{
    float f = ((float)this.particleAge + partialTicks) / (float)this.particleMaxAge;
    f = MathHelper.clamp_float(f, 0.0F, 1.0F);
    int i = super.getBrightnessForRender(partialTicks);
    int j = 240;
    int k = i >> 16 & 255;
    return j | k << 16;
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:10,代碼來源:EntityLavaFX.java

示例14: getSunBrightness

import net.minecraft.util.MathHelper; //導入方法依賴的package包/類
/**
 * Returns the sun brightness - checks time of day, rain and thunder
 */
public float getSunBrightness(float p_72971_1_)
{
    float f = this.getCelestialAngle(p_72971_1_);
    float f1 = 1.0F - (MathHelper.cos(f * (float)Math.PI * 2.0F) * 2.0F + 0.2F);
    f1 = MathHelper.clamp_float(f1, 0.0F, 1.0F);
    f1 = 1.0F - f1;
    f1 = (float)((double)f1 * (1.0D - (double)(this.getRainStrength(p_72971_1_) * 5.0F) / 16.0D));
    f1 = (float)((double)f1 * (1.0D - (double)(this.getThunderStrength(p_72971_1_) * 5.0F) / 16.0D));
    return f1 * 0.8F + 0.2F;
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:14,代碼來源:World.java

示例15: func_175265_c

import net.minecraft.util.MathHelper; //導入方法依賴的package包/類
private float func_175265_c()
{
    long i = this.field_175270_h - Minecraft.getSystemTime() + 5000L;
    return MathHelper.clamp_float((float)i / 2000.0F, 0.0F, 1.0F);
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:6,代碼來源:GuiSpectator.java


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