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


Java MathHelper.clamp_float方法代码示例

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


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

示例1: getAo

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
protected float getAo(float x, float y, float z)
{
    int sx = x < 0 ? 1 : 2;
    int sy = y < 0 ? 1 : 2;
    int sz = z < 0 ? 1 : 2;

    if(x < 0) x++;
    if(y < 0) y++;
    if(z < 0) z++;

    float a = 0;
    float[][][] ao = blockInfo.getAo();
    a += ao[sx - 1][sy - 1][sz - 1] * (1 - x) * (1 - y) * (1 - z);
    a += ao[sx - 1][sy - 1][sz - 0] * (1 - x) * (1 - y) * (0 + z);
    a += ao[sx - 1][sy - 0][sz - 1] * (1 - x) * (0 + y) * (1 - z);
    a += ao[sx - 1][sy - 0][sz - 0] * (1 - x) * (0 + y) * (0 + z);
    a += ao[sx - 0][sy - 1][sz - 1] * (0 + x) * (1 - y) * (1 - z);
    a += ao[sx - 0][sy - 1][sz - 0] * (0 + x) * (1 - y) * (0 + z);
    a += ao[sx - 0][sy - 0][sz - 1] * (0 + x) * (0 + y) * (1 - z);
    a += ao[sx - 0][sy - 0][sz - 0] * (0 + x) * (0 + y) * (0 + z);

    a = MathHelper.clamp_float(a, 0, 1);
    return a;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:25,代码来源:VertexLighterSmoothAo.java

示例2: getBrightnessForRender

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
public int getBrightnessForRender(float p_189214_1_)
{
    float f = ((float)this.particleAge + p_189214_1_) / (float)this.particleMaxAge;
    f = MathHelper.clamp_float(f, 0.0F, 1.0F);
    int i = super.getBrightnessForRender(p_189214_1_);
    int j = i & 255;
    int k = i >> 16 & 255;
    j = j + (int)(f * 15.0F * 16.0F);

    if (j > 240)
    {
        j = 240;
    }

    return j | k << 16;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:17,代码来源:ParticleFlame.java

示例3: mouseDragged

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
/**
 * Fired when the mouse button is dragged. Equivalent of MouseListener.mouseDragged(MouseEvent e).
 */
protected void mouseDragged(Minecraft mc, int mouseX, int mouseY)
{
    if (this.visible)
    {
        if (this.dragging)
        {
            this.sliderValue = (float)(mouseX - (this.xPosition + 4)) / (float)(this.width - 8);
            this.sliderValue = MathHelper.clamp_float(this.sliderValue, 0.0F, 1.0F);
            float f = this.options.denormalizeValue(this.sliderValue);
            mc.gameSettings.setOptionFloatValue(this.options, f);
            this.sliderValue = this.options.normalizeValue(f);
            this.displayString = mc.gameSettings.getKeyBinding(this.options);
        }

        mc.getTextureManager().bindTexture(BUTTON_TEXTURES);
        GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
        this.drawTexturedModalRect(this.xPosition + (int)(this.sliderValue * (float)(this.width - 8)), this.yPosition, 0, 66, 4, 20);
        this.drawTexturedModalRect(this.xPosition + (int)(this.sliderValue * (float)(this.width - 8)) + 4, this.yPosition, 196, 66, 4, 20);
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:24,代码来源:GuiOptionSlider.java

示例4: getBrightnessForRender

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
@SideOnly(Side.CLIENT)
public int getBrightnessForRender(float partialTicks)
{
    float f = 0.5F;
    f = MathHelper.clamp_float(f, 0.0F, 1.0F);
    int i = super.getBrightnessForRender(partialTicks);
    int j = i & 255;
    int k = i >> 16 & 255;
    j = j + (int)(f * 15.0F * 16.0F);

    if (j > 240)
    {
        j = 240;
    }

    return j | k << 16;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:18,代码来源:EntityXPOrb.java

示例5: mousePressed

import net.minecraft.util.math.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:F1r3w477,项目名称:CustomWorldGen,代码行数:21,代码来源:GuiOptionSlider.java

示例6: B3DState

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
public B3DState(Animation animation, int frame, int nextFrame, float progress, IModelState parent)
{
    this.animation = animation;
    this.frame = frame;
    this.nextFrame = nextFrame;
    this.progress = MathHelper.clamp_float(progress, 0, 1);
    this.parent = getParent(parent);
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:9,代码来源:B3DLoader.java

示例7: updateEquippedItem

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
public void updateEquippedItem()
{
    this.prevEquippedProgressMainHand = this.equippedProgressMainHand;
    this.prevEquippedProgressOffHand = this.equippedProgressOffHand;
    EntityPlayerSP entityplayersp = this.mc.thePlayer;
    ItemStack itemstack = entityplayersp.getHeldItemMainhand();
    ItemStack itemstack1 = entityplayersp.getHeldItemOffhand();

    if (entityplayersp.isRowingBoat())
    {
        this.equippedProgressMainHand = MathHelper.clamp_float(this.equippedProgressMainHand - 0.4F, 0.0F, 1.0F);
        this.equippedProgressOffHand = MathHelper.clamp_float(this.equippedProgressOffHand - 0.4F, 0.0F, 1.0F);
    }
    else
    {
        float f = entityplayersp.getCooledAttackStrength(1.0F);
        this.equippedProgressMainHand += MathHelper.clamp_float((!net.minecraftforge.client.ForgeHooksClient.shouldCauseReequipAnimation(this.itemStackMainHand, itemstack, entityplayersp.inventory.currentItem) ? f * f * f : 0.0F) - this.equippedProgressMainHand, -0.4F, 0.4F);
        this.equippedProgressOffHand += MathHelper.clamp_float((float)(!net.minecraftforge.client.ForgeHooksClient.shouldCauseReequipAnimation(this.itemStackOffHand, itemstack1, -1) ? 1 : 0) - this.equippedProgressOffHand, -0.4F, 0.4F);
    }

    if (this.equippedProgressMainHand < 0.1F)
    {
        this.itemStackMainHand = itemstack;
    }

    if (this.equippedProgressOffHand < 0.1F)
    {
        this.itemStackOffHand = itemstack1;
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:31,代码来源:ItemRenderer.java

示例8: renderParticle

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
/**
 * Renders the particle
 */
public void renderParticle(VertexBuffer worldRendererIn, Entity entityIn, float partialTicks, float rotationX, float rotationZ, float rotationYZ, float rotationXY, float rotationXZ)
{
    float f = ((float)this.particleAge + partialTicks) / (float)this.particleMaxAge * 32.0F;
    f = MathHelper.clamp_float(f, 0.0F, 1.0F);
    this.particleScale = this.particleScaleOverTime * f;
    super.renderParticle(worldRendererIn, entityIn, partialTicks, rotationX, rotationZ, rotationYZ, rotationXY, rotationXZ);
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:11,代码来源:ParticleHeart.java

示例9: getFogColor

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
/**
 * Return Vec3D with biome specific fog color
 */
@SideOnly(Side.CLIENT)
public Vec3d getFogColor(float p_76562_1_, float p_76562_2_)
{
    int i = 10518688;
    float f = MathHelper.cos(p_76562_1_ * ((float)Math.PI * 2F)) * 2.0F + 0.5F;
    f = MathHelper.clamp_float(f, 0.0F, 1.0F);
    float f1 = 0.627451F;
    float f2 = 0.5019608F;
    float f3 = 0.627451F;
    f1 = f1 * (f * 0.0F + 0.15F);
    f2 = f2 * (f * 0.0F + 0.15F);
    f3 = f3 * (f * 0.0F + 0.15F);
    return new Vec3d((double)f1, (double)f2, (double)f3);
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:18,代码来源:WorldProviderEnd.java

示例10: getMapAngleFromPitch

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
/**
 * Return the angle to render the Map
 */
private float getMapAngleFromPitch(float pitch)
{
    float f = 1.0F - pitch / 45.0F + 0.1F;
    f = MathHelper.clamp_float(f, 0.0F, 1.0F);
    f = -MathHelper.cos(f * (float)Math.PI) * 0.5F + 0.5F;
    return f;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:11,代码来源:ItemRenderer.java

示例11: renderParticle

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
/**
 * Renders the particle
 */
public void renderParticle(VertexBuffer worldRendererIn, Entity entityIn, float partialTicks, float rotationX, float rotationZ, float rotationYZ, float rotationXY, float rotationXZ)
{
    float f = ((float)this.particleAge + partialTicks) / (float)this.particleMaxAge * 32.0F;
    f = MathHelper.clamp_float(f, 0.0F, 1.0F);
    this.particleScale = this.snowDigParticleScale * f;
    super.renderParticle(worldRendererIn, entityIn, partialTicks, rotationX, rotationZ, rotationYZ, rotationXY, rotationXZ);
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:11,代码来源:ParticleSnowShovel.java

示例12: bindAmountScrolled

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
/**
 * Stop the thing from scrolling out of bounds
 */
protected void bindAmountScrolled()
{
    this.amountScrolled = MathHelper.clamp_float(this.amountScrolled, 0.0F, (float)this.getMaxScroll());
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:8,代码来源:GuiSlot.java

示例13: renderPotionEffects

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
protected void renderPotionEffects(ScaledResolution resolution)
{
    Collection<PotionEffect> collection = this.mc.thePlayer.getActivePotionEffects();

    if (!collection.isEmpty())
    {
        this.mc.getTextureManager().bindTexture(GuiContainer.INVENTORY_BACKGROUND);
        GlStateManager.enableBlend();
        int i = 0;
        int j = 0;

        for (PotionEffect potioneffect : Ordering.natural().reverse().sortedCopy(collection))
        {
            Potion potion = potioneffect.getPotion();

            if (!potion.shouldRenderHUD(potioneffect)) continue;
            // Rebind in case previous renderHUDEffect changed texture
            this.mc.getTextureManager().bindTexture(GuiContainer.INVENTORY_BACKGROUND);
            if (potioneffect.doesShowParticles())
            {
                int k = resolution.getScaledWidth();
                int l = 1;
                int i1 = potion.getStatusIconIndex();

                if (potion.isBeneficial())
                {
                    ++i;
                    k = k - 25 * i;
                }
                else
                {
                    ++j;
                    k = k - 25 * j;
                    l += 26;
                }

                GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
                float f = 1.0F;

                if (potioneffect.getIsAmbient())
                {
                    this.drawTexturedModalRect(k, l, 165, 166, 24, 24);
                }
                else
                {
                    this.drawTexturedModalRect(k, l, 141, 166, 24, 24);

                    if (potioneffect.getDuration() <= 200)
                    {
                        int j1 = 10 - potioneffect.getDuration() / 20;
                        f = MathHelper.clamp_float((float)potioneffect.getDuration() / 10.0F / 5.0F * 0.5F, 0.0F, 0.5F) + MathHelper.cos((float)potioneffect.getDuration() * (float)Math.PI / 5.0F) * MathHelper.clamp_float((float)j1 / 10.0F * 0.25F, 0.0F, 0.25F);
                    }
                }

                GlStateManager.color(1.0F, 1.0F, 1.0F, f);
                // FORGE - Move status icon check down from above so renderHUDEffect will still be called without a status icon
                if (potion.hasStatusIcon())
                this.drawTexturedModalRect(k + 3, l + 3, i1 % 8 * 18, 198 + i1 / 8 * 18, 18, 18);
                potion.renderHUDEffect(k, l, potioneffect, mc, f);
            }
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:64,代码来源:GuiIngame.java

示例14: drawScreen

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
/**
 * Draws the screen and all the components in it.
 */
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{
    boolean flag = Mouse.isButtonDown(0);
    int i = this.guiLeft;
    int j = this.guiTop;
    int k = i + 175;
    int l = j + 18;
    int i1 = k + 14;
    int j1 = l + 112;

    if (!this.wasClicking && flag && mouseX >= k && mouseY >= l && mouseX < i1 && mouseY < j1)
    {
        this.isScrolling = this.needsScrollBars();
    }

    if (!flag)
    {
        this.isScrolling = false;
    }

    this.wasClicking = flag;

    if (this.isScrolling)
    {
        this.currentScroll = ((float)(mouseY - l) - 7.5F) / ((float)(j1 - l) - 15.0F);
        this.currentScroll = MathHelper.clamp_float(this.currentScroll, 0.0F, 1.0F);
        ((GuiContainerCreative.ContainerCreative)this.inventorySlots).scrollTo(this.currentScroll);
    }

    super.drawScreen(mouseX, mouseY, partialTicks);
    int start = tabPage * 10;
    int end = Math.min(CreativeTabs.CREATIVE_TAB_ARRAY.length, ((tabPage + 1) * 10) + 2);
    if (tabPage != 0) start += 2;
    boolean rendered = false;

    for (CreativeTabs creativetabs : java.util.Arrays.copyOfRange(CreativeTabs.CREATIVE_TAB_ARRAY,start,end))
    {
        if (creativetabs == null) continue;
        if (this.renderCreativeInventoryHoveringText(creativetabs, mouseX, mouseY))
        {
            rendered = true;
            break;
        }
    }

    if (!rendered && !renderCreativeInventoryHoveringText(CreativeTabs.SEARCH, mouseX, mouseY))
    {
        renderCreativeInventoryHoveringText(CreativeTabs.INVENTORY, mouseX, mouseY);
    }

    if (this.destroyItemSlot != null && selectedTabIndex == CreativeTabs.INVENTORY.getTabIndex() && this.isPointInRegion(this.destroyItemSlot.xDisplayPosition, this.destroyItemSlot.yDisplayPosition, 16, 16, mouseX, mouseY))
    {
        this.drawCreativeTabHoveringText(I18n.format("inventory.binSlot", new Object[0]), mouseX, mouseY);
    }

    if (maxPages != 0)
    {
        String page = String.format("%d / %d", tabPage + 1, maxPages + 1);
        int width = fontRendererObj.getStringWidth(page);
        GlStateManager.disableLighting();
        this.zLevel = 300.0F;
        itemRender.zLevel = 300.0F;
        fontRendererObj.drawString(page, guiLeft + (xSize / 2) - (width / 2), guiTop - 44, -1);
        this.zLevel = 0.0F;
        itemRender.zLevel = 0.0F;
    }

    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    GlStateManager.disableLighting();
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:74,代码来源:GuiContainerCreative.java

示例15: doRenderLayer

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
public void doRenderLayer(AbstractClientPlayer entitylivingbaseIn, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale)
{
    if (entitylivingbaseIn.hasPlayerInfo() && !entitylivingbaseIn.isInvisible() && entitylivingbaseIn.isWearing(EnumPlayerModelParts.CAPE) && entitylivingbaseIn.getLocationCape() != null)
    {
        ItemStack itemstack = entitylivingbaseIn.getItemStackFromSlot(EntityEquipmentSlot.CHEST);

        if (itemstack == null || itemstack.getItem() != Items.ELYTRA)
        {
            GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
            this.playerRenderer.bindTexture(entitylivingbaseIn.getLocationCape());
            GlStateManager.pushMatrix();
            GlStateManager.translate(0.0F, 0.0F, 0.125F);
            double d0 = entitylivingbaseIn.prevChasingPosX + (entitylivingbaseIn.chasingPosX - entitylivingbaseIn.prevChasingPosX) * (double)partialTicks - (entitylivingbaseIn.prevPosX + (entitylivingbaseIn.posX - entitylivingbaseIn.prevPosX) * (double)partialTicks);
            double d1 = entitylivingbaseIn.prevChasingPosY + (entitylivingbaseIn.chasingPosY - entitylivingbaseIn.prevChasingPosY) * (double)partialTicks - (entitylivingbaseIn.prevPosY + (entitylivingbaseIn.posY - entitylivingbaseIn.prevPosY) * (double)partialTicks);
            double d2 = entitylivingbaseIn.prevChasingPosZ + (entitylivingbaseIn.chasingPosZ - entitylivingbaseIn.prevChasingPosZ) * (double)partialTicks - (entitylivingbaseIn.prevPosZ + (entitylivingbaseIn.posZ - entitylivingbaseIn.prevPosZ) * (double)partialTicks);
            float f = entitylivingbaseIn.prevRenderYawOffset + (entitylivingbaseIn.renderYawOffset - entitylivingbaseIn.prevRenderYawOffset) * partialTicks;
            double d3 = (double)MathHelper.sin(f * 0.017453292F);
            double d4 = (double)(-MathHelper.cos(f * 0.017453292F));
            float f1 = (float)d1 * 10.0F;
            f1 = MathHelper.clamp_float(f1, -6.0F, 32.0F);
            float f2 = (float)(d0 * d3 + d2 * d4) * 100.0F;
            float f3 = (float)(d0 * d4 - d2 * d3) * 100.0F;

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

            float f4 = entitylivingbaseIn.prevCameraYaw + (entitylivingbaseIn.cameraYaw - entitylivingbaseIn.prevCameraYaw) * partialTicks;
            f1 = f1 + MathHelper.sin((entitylivingbaseIn.prevDistanceWalkedModified + (entitylivingbaseIn.distanceWalkedModified - entitylivingbaseIn.prevDistanceWalkedModified) * partialTicks) * 6.0F) * 32.0F * f4;

            if (entitylivingbaseIn.isSneaking())
            {
                f1 += 25.0F;
            }

            GlStateManager.rotate(6.0F + f2 / 2.0F + f1, 1.0F, 0.0F, 0.0F);
            GlStateManager.rotate(f3 / 2.0F, 0.0F, 0.0F, 1.0F);
            GlStateManager.rotate(-f3 / 2.0F, 0.0F, 1.0F, 0.0F);
            GlStateManager.rotate(180.0F, 0.0F, 1.0F, 0.0F);
            this.playerRenderer.getMainModel().renderCape(0.0625F);
            GlStateManager.popMatrix();
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:46,代码来源:LayerCape.java


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