概述
import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
/**
* Renders the stack size and/or damage bar for the given ItemStack.
*/
public void renderItemOverlayIntoGUI(FontRenderer fr, ItemStack stack, int xPosition, int yPosition, @Nullable String text)
{
if (!stack.func_190926_b())
{
if (stack.func_190916_E() != 1 || text != null)
{
String s = text == null ? String.valueOf(stack.func_190916_E()) : text;
GlStateManager.disableLighting();
GlStateManager.disableDepth();
GlStateManager.disableBlend();
fr.drawStringWithShadow(s, (float)(xPosition + 19 - 2 - fr.getStringWidth(s)), (float)(yPosition + 6 + 3), 16777215);
GlStateManager.enableLighting();
GlStateManager.enableDepth();
GlStateManager.enableBlend();
}
if (ReflectorForge.isItemDamaged(stack))
{
GlStateManager.disableLighting();
GlStateManager.disableDepth();
GlStateManager.disableTexture2D();
GlStateManager.disableAlpha();
GlStateManager.disableBlend();
Tessellator tessellator = Tessellator.getInstance();
VertexBuffer vertexbuffer = tessellator.getBuffer();
float f = (float)stack.getItemDamage();
float f1 = (float)stack.getMaxDamage();
float f2 = Math.max(0.0F, (f1 - f) / f1);
int i = Math.round(13.0F - f * 13.0F / f1);
int j = MathHelper.hsvToRGB(f2 / 3.0F, 1.0F, 1.0F);
if (Reflector.ForgeItem_getDurabilityForDisplay.exists() && Reflector.ForgeItem_getRGBDurabilityForDisplay.exists())
{
double d0 = Reflector.callDouble(stack.getItem(), Reflector.ForgeItem_getDurabilityForDisplay, new Object[] {stack});
int k = Reflector.callInt(stack.getItem(), Reflector.ForgeItem_getRGBDurabilityForDisplay, new Object[] {stack});
i = Math.round(13.0F - (float)d0 * 13.0F);
j = k;
}
if (Config.isCustomColors())
{
j = CustomColors.getDurabilityColor(f2, j);
}
this.draw(vertexbuffer, xPosition + 2, yPosition + 13, 13, 2, 0, 0, 0, 255);
this.draw(vertexbuffer, xPosition + 2, yPosition + 13, i, 1, j >> 16 & 255, j >> 8 & 255, j & 255, 255);
GlStateManager.enableBlend();
GlStateManager.enableAlpha();
GlStateManager.enableTexture2D();
GlStateManager.enableLighting();
GlStateManager.enableDepth();
}
EntityPlayerSP entityplayersp = Minecraft.getMinecraft().player;
float f3 = entityplayersp == null ? 0.0F : entityplayersp.getCooldownTracker().getCooldown(stack.getItem(), Minecraft.getMinecraft().getRenderPartialTicks());
if (f3 > 0.0F)
{
GlStateManager.disableLighting();
GlStateManager.disableDepth();
GlStateManager.disableTexture2D();
Tessellator tessellator1 = Tessellator.getInstance();
VertexBuffer vertexbuffer1 = tessellator1.getBuffer();
this.draw(vertexbuffer1, xPosition, yPosition + MathHelper.floor(16.0F * (1.0F - f3)), 16, MathHelper.ceil(16.0F * f3), 255, 255, 255, 127);
GlStateManager.enableTexture2D();
GlStateManager.enableLighting();
GlStateManager.enableDepth();
}
}
}
最后
以上就是隐形汽车为你收集整理的hsv java_Java MathHelper.hsvToRGB方法代码示例的全部内容,希望文章能够帮你解决hsv java_Java MathHelper.hsvToRGB方法代码示例所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复