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


Java Potion.getPotionDurationString方法代码示例

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


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

示例1: addPotionEffectTooltip

import net.minecraft.potion.Potion; //导入方法依赖的package包/类
@SideOnly(Side.CLIENT)
public static void addPotionEffectTooltip(List<PotionEffect> list, List<String> lores, float durationFactor)
{
    List<Tuple<String, AttributeModifier>> attributeModifiers = Lists.newArrayList();

    if (list.isEmpty())
    {
        String s = I18n.translateToLocal("effect.none").trim();
        lores.add(TextFormatting.GRAY + s);
    }
    else
    {
        for (PotionEffect potioneffect : list)
        {
            String s1 = I18n.translateToLocal(potioneffect.getEffectName()).trim();
            Potion potion = potioneffect.getPotion();
            Map<IAttribute, AttributeModifier> map = potion.getAttributeModifierMap();

            if (!map.isEmpty())
            {
                for (Map.Entry<IAttribute, AttributeModifier> entry : map.entrySet())
                {
                    AttributeModifier attributemodifier = entry.getValue();
                    AttributeModifier attributemodifier1 = new AttributeModifier(attributemodifier.getName(), potion.getAttributeModifierAmount(potioneffect.getAmplifier(), attributemodifier), attributemodifier.getOperation());
                    attributeModifiers.add(new Tuple(((IAttribute)entry.getKey()).getName(), attributemodifier1));
                }
            }

            if (potioneffect.getAmplifier() > 0)
            {
                s1 = s1 + " " + I18n.translateToLocal("potion.potency." + potioneffect.getAmplifier()).trim();
            }

            if (potioneffect.getDuration() > 20)
            {
                s1 = s1 + " (" + Potion.getPotionDurationString(potioneffect, durationFactor) + ")";
            }

            if (potion.isBadEffect())
            {
                lores.add(TextFormatting.RED + s1);
            }
            else
            {
                lores.add(TextFormatting.BLUE + s1);
            }
        }
    }

    if (!attributeModifiers.isEmpty())
    {
        lores.add("");
        lores.add(TextFormatting.DARK_PURPLE + I18n.translateToLocal("potion.whenDrank"));

        for (Tuple<String, AttributeModifier> tuple : attributeModifiers)
        {
            AttributeModifier attributemodifier2 = tuple.getSecond();
            double d0 = attributemodifier2.getAmount();
            double d1;

            if (attributemodifier2.getOperation() != 1 && attributemodifier2.getOperation() != 2)
            {
                d1 = attributemodifier2.getAmount();
            }
            else
            {
                d1 = attributemodifier2.getAmount() * 100.0D;
            }

            if (d0 > 0.0D)
            {
                lores.add(TextFormatting.BLUE + I18n.translateToLocalFormatted("attribute.modifier.plus." + attributemodifier2.getOperation(), ItemStack.DECIMALFORMAT.format(d1), I18n.translateToLocal("attribute.name." + (String)tuple.getFirst())));
            }
            else if (d0 < 0.0D)
            {
                d1 = d1 * -1.0D;
                lores.add(TextFormatting.RED + I18n.translateToLocalFormatted("attribute.modifier.take." + attributemodifier2.getOperation(), ItemStack.DECIMALFORMAT.format(d1), I18n.translateToLocal("attribute.name." + (String)tuple.getFirst())));
            }
        }
    }
}
 
开发者ID:DaedalusGame,项目名称:Soot,代码行数:82,代码来源:MiscUtil.java

示例2: renderXDolfOverlay

import net.minecraft.potion.Potion; //导入方法依赖的package包/类
public void renderXDolfOverlay() {

		if(Wrapper.getMinecraft().gameSettings.showDebugInfo || hideGui || Wrapper.getMinecraft().currentScreen instanceof GuiChat) return;
		
		int width = Client.gameResolution.getScaledWidth();
		int height = Client.gameResolution.getScaledHeight();

		Fonts.roboto18.drawStringWithShadow("Xdolf", 2, 0, 0x55FF55);
		int count = 0;
		try {
			for(Module mod: Hacks.display) {
				int x2 = width - (Fonts.roboto18.getStringWidth(mod.getName()));
				int y = (10 * count);
				Fonts.roboto18.drawStringWithShadow(mod.getName(), x2 - 2, y, 0xffffff);
				count++;
			}
		} catch (Exception ex) {}


		Collection<PotionEffect> var4 = Wrapper.getPlayer().getActivePotionEffects();

		if (!var4.isEmpty()) {
			final ResourceLocation var5 = new ResourceLocation("textures/gui/container/inventory.png");
			int var6 = -23;
			int count2 = 0;

			for (PotionEffect potioneffect : Ordering.natural().sortedCopy(var4)) {
				count2++;
				Potion var9 = potioneffect.getPotion();
				Wrapper.getMinecraft().renderEngine.bindTexture(var5);

				String s1 = I18n.format(var9.getName(), new Object[0]);

				if (potioneffect.getAmplifier() == 1) {
					s1 = s1 + " II";
				} else if (potioneffect.getAmplifier() == 2) {
					s1 = s1 + " III";
				} else if (potioneffect.getAmplifier() == 3) {
					s1 = s1 + " IV";
				}

				String var11 = Potion.getPotionDurationString(potioneffect, 1.0F);
				int var14 = width -Fonts.roboto18.getStringWidth(s1) - 2 - 20;
				int var16 = width - (Fonts.roboto18.getStringWidth(var11) / 2) - 4 - 20;

				if (var9.hasStatusIcon()) {
					int var10 = var9.getStatusIconIndex();
					this.drawTexturedModalRect(width - 20, height - (count2 * 20), 0 + var10 % 8 * 18,
							198 + var10 / 8 * 18, 18, 18);
				}

				Fonts.roboto18.drawStringWithShadow(s1, var14, height - (count2 * 20),
						16777215);
				var14 = width - Fonts.roboto18.getStringWidth(var11) - 2;
				Fonts.roboto18.drawStringWithShadow(var11, (var16) - 8,
						height + 10 - (count2 * 20), 8355711);
			}
		}
		
		for(XdolfWindow window: XdolfGuiClick.windowList) {
			if(!(Wrapper.getMinecraft().currentScreen instanceof XdolfGuiClick)) {
				if(window.isPinned()) {
					window.draw(0, 0);
				}
			}
		}
	}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:68,代码来源:XDolfOverlay.java

示例3: drawActivePotionEffects

import net.minecraft.potion.Potion; //导入方法依赖的package包/类
/**
 * Display the potion effects list
 */
private void drawActivePotionEffects()
{
    int i = this.guiLeft - 124;
    int j = this.guiTop;
    int k = 166;
    Collection<PotionEffect> collection = this.mc.player.getActivePotionEffects();

    if (!collection.isEmpty())
    {
        GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
        GlStateManager.disableLighting();
        int l = 33;

        if (collection.size() > 5)
        {
            l = 132 / (collection.size() - 1);
        }

        for (PotionEffect potioneffect : Ordering.natural().sortedCopy(collection))
        {
            Potion potion = potioneffect.getPotion();
            GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
            this.mc.getTextureManager().bindTexture(INVENTORY_BACKGROUND);
            this.drawTexturedModalRect(i, j, 0, 166, 140, 32);

            if (potion.hasStatusIcon())
            {
                int i1 = potion.getStatusIconIndex();
                this.drawTexturedModalRect(i + 6, j + 7, 0 + i1 % 8 * 18, 198 + i1 / 8 * 18, 18, 18);
            }

            String s1 = I18n.format(potion.getName(), new Object[0]);

            if (potioneffect.getAmplifier() == 1)
            {
                s1 = s1 + " " + I18n.format("enchantment.level.2", new Object[0]);
            }
            else if (potioneffect.getAmplifier() == 2)
            {
                s1 = s1 + " " + I18n.format("enchantment.level.3", new Object[0]);
            }
            else if (potioneffect.getAmplifier() == 3)
            {
                s1 = s1 + " " + I18n.format("enchantment.level.4", new Object[0]);
            }

            this.fontRendererObj.drawStringWithShadow(s1, (float)(i + 10 + 18), (float)(j + 6), 16777215);
            String s = Potion.getPotionDurationString(potioneffect, 1.0F);
            this.fontRendererObj.drawStringWithShadow(s, (float)(i + 10 + 18), (float)(j + 6 + 10), 8355711);
            j += l;
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:57,代码来源:InventoryEffectRenderer.java

示例4: drawActivePotionEffects

import net.minecraft.potion.Potion; //导入方法依赖的package包/类
/**
 * Display the potion effects list
 */
private void drawActivePotionEffects()
{
    int i = this.guiLeft - 124;
    int j = this.guiTop;
    int k = 166;
    Collection<PotionEffect> collection = this.mc.thePlayer.getActivePotionEffects();

    if (!collection.isEmpty())
    {
        GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
        GlStateManager.disableLighting();
        int l = 33;

        if (collection.size() > 5)
        {
            l = 132 / (collection.size() - 1);
        }

        for (PotionEffect potioneffect : Ordering.natural().sortedCopy(collection))
        {
            Potion potion = potioneffect.getPotion();
            if(!potion.shouldRender(potioneffect)) continue;
            GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
            this.mc.getTextureManager().bindTexture(INVENTORY_BACKGROUND);
            this.drawTexturedModalRect(i, j, 0, 166, 140, 32);

            if (potion.hasStatusIcon())
            {
                int i1 = potion.getStatusIconIndex();
                this.drawTexturedModalRect(i + 6, j + 7, 0 + i1 % 8 * 18, 198 + i1 / 8 * 18, 18, 18);
            }

            potion.renderInventoryEffect(i, j, potioneffect, mc);
            if (!potion.shouldRenderInvText(potioneffect)) { j += l; continue; }
            String s1 = I18n.format(potion.getName(), new Object[0]);

            if (potioneffect.getAmplifier() == 1)
            {
                s1 = s1 + " " + I18n.format("enchantment.level.2", new Object[0]);
            }
            else if (potioneffect.getAmplifier() == 2)
            {
                s1 = s1 + " " + I18n.format("enchantment.level.3", new Object[0]);
            }
            else if (potioneffect.getAmplifier() == 3)
            {
                s1 = s1 + " " + I18n.format("enchantment.level.4", new Object[0]);
            }

            this.fontRendererObj.drawStringWithShadow(s1, (float)(i + 10 + 18), (float)(j + 6), 16777215);
            String s = Potion.getPotionDurationString(potioneffect, 1.0F);
            this.fontRendererObj.drawStringWithShadow(s, (float)(i + 10 + 18), (float)(j + 6 + 10), 8355711);
            j += l;
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:60,代码来源:InventoryEffectRenderer.java


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