use of net.minecraft.util.IIcon in project PneumaticCraft by MineMaarten.
the class WidgetTank method render.
@Override
public void render(int mouseX, int mouseY, float partialTick) {
GL11.glDisable(GL11.GL_LIGHTING);
Fluid fluid = tank.getFluid() != null ? tank.getFluid().getFluid() : null;
IIcon icon = fluid != null ? fluid.getStillIcon() : null;
int amt = tank.getFluidAmount();
int capacity = tank.getCapacity();
int height = 64;
int width = 16;
if (fluid != null && icon != null && amt > 0 && capacity > 0) {
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
double fluidPercentage = amt / (double) capacity;
double fluidHeight = height * fluidPercentage;
GL11.glPushMatrix();
{
GL11.glTranslated(0, height, 0);
GL11.glEnable(GL11.GL_BLEND);
while (fluidHeight > 0) {
double moved = Math.min(fluidHeight, icon.getIconHeight());
GL11.glTranslated(0, -moved, 0);
Tessellator t = Tessellator.instance;
t.startDrawingQuads();
t.setColorOpaque_I(fluid.getColor(tank.getFluid()));
{
t.addVertexWithUV(x, y, 0, icon.getMinU(), icon.getMinV() + (icon.getMaxV() - icon.getMinV()) * (1 - moved / icon.getIconHeight()));
t.addVertexWithUV(x, y + moved, 0, icon.getMinU(), icon.getMaxV());
t.addVertexWithUV(x + width, y + moved, 0, icon.getMaxU(), icon.getMaxV());
t.addVertexWithUV(x + width, y, 0, icon.getMaxU(), icon.getMinV() + (icon.getMaxV() - icon.getMinV()) * (1 - moved / icon.getIconHeight()));
}
t.draw();
fluidHeight -= moved;
}
GL11.glDisable(GL11.GL_BLEND);
}
GL11.glPopMatrix();
}
GL11.glColor4d(1, 1, 1, 1);
Minecraft.getMinecraft().getTextureManager().bindTexture(Textures.WIDGET_TANK);
Gui.func_146110_a(x, y, 0, 0, 16, 64, 16, 64);
}
use of net.minecraft.util.IIcon in project Minechem by iopleke.
the class FluidItemRenderingHandler method renderItem.
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
Fluid fluid = ((BlockFluidBase) ((ItemBlock) item.getItem()).field_150939_a).getFluid();
if (fluid instanceof FluidElement) {
RenderingUtil.setColorForElement(((FluidElement) fluid).element);
} else if (fluid instanceof FluidMolecule) {
MoleculeEnum molecule = ((FluidMolecule) fluid).molecule;
GL11.glColor3f(molecule.red, molecule.green, molecule.blue);
}
IIcon icon = ((ItemBlock) item.getItem()).field_150939_a.getBlockTextureFromSide(0);
switch(type) {
case INVENTORY:
RenderingUtil.drawTexturedRectUV(0, 0, 0, 16, 16, icon);
break;
case EQUIPPED_FIRST_PERSON:
case EQUIPPED:
ItemRenderer.renderItemIn2D(Tessellator.instance, icon.getMaxU(), icon.getMinV(), icon.getMinU(), icon.getMaxV(), icon.getIconWidth(), icon.getIconHeight(), 0.0625F);
break;
case ENTITY:
EntityItem entityItem = (EntityItem) data[1];
if (entityItem.worldObj == null) {
float angle = (Minecraft.getSystemTime() % 8000L) / 8000.0F * 360.0F;
GL11.glPushMatrix();
GL11.glRotatef(angle, 0.0F, 1.0F, 0.0F);
GL11.glTranslatef(-0.2F, -0.5F, 0.0F);
renderItemAsEntity(item, icon);
GL11.glPopMatrix();
} else {
renderItemAsEntity(item, icon);
}
break;
default:
break;
}
}
use of net.minecraft.util.IIcon in project Minechem by iopleke.
the class MoleculeItemRenderer method renderItem.
@Override
public void renderItem(ItemRenderType type, ItemStack itemstack, Object... data) {
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_ALPHA_TEST);
GL11.glDisable(GL11.GL_BLEND);
MoleculeItem item = (MoleculeItem) itemstack.getItem();
IIcon testtube = itemstack.getIconIndex();
switch(type) {
case INVENTORY:
renderItemInInventory(type, itemstack, item.filledMolecule, item.render_pass1, item.render_pass2);
break;
case EQUIPPED_FIRST_PERSON:
case EQUIPPED:
renderItemInEquipped(type, itemstack, testtube, item.render_pass1, item.render_pass2);
break;
case ENTITY:
EntityItem entityItem = (EntityItem) data[1];
if (entityItem.worldObj == null) {
float angle = (Minecraft.getSystemTime() % 8000L) / 8000.0F * 360.0F;
GL11.glPushMatrix();
GL11.glRotatef(angle, 0.0F, 1.0F, 0.0F);
GL11.glTranslatef(-0.2F, -0.5F, 0.0F);
renderItemAsEntity(type, itemstack, testtube, item.render_pass1, item.render_pass2);
GL11.glPopMatrix();
} else {
renderItemAsEntity(type, itemstack, testtube, item.render_pass1, item.render_pass2);
}
break;
default:
break;
}
GL11.glDisable(GL11.GL_BLEND);
GL11.glDisable(GL11.GL_ALPHA_TEST);
GL11.glEnable(GL11.GL_LIGHTING);
}
use of net.minecraft.util.IIcon in project Minechem by iopleke.
the class GuiFluidTank method draw.
public void draw(int x, int y, FluidStack fluidStack) {
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glColor3f(1.0F, 1.0F, 1.0F);
Minecraft.getMinecraft().renderEngine.bindTexture(Resources.Gui.TANK);
drawTexturedModalRect(x + posX, y + posY, 0, 0, 18, 39);
int iconHeightRemainder = (39 - 4) % 16;
if (fluidStack != null && fluidStack.amount > 0) {
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
IIcon fluidIcon = fluidStack.getFluid().getStillIcon();
drawTexturedModelRectFromIcon(x + posX + 1, y + posY + 2, fluidIcon, 16, iconHeightRemainder);
for (int i = 0; i < (39 - 6) / 16; i++) {
drawTexturedModelRectFromIcon(x + posX + 1, y + posY + 2 + i * 16 + iconHeightRemainder, fluidIcon, 16, 16);
}
Minecraft.getMinecraft().renderEngine.bindTexture(Resources.Gui.TANK);
drawTexturedModalRect(x + posX + 2, y + posY + 1, 1, 1, 15, 37 - ((int) ((38) * ((float) fluidStack.amount / capacity))));
}
Minecraft.getMinecraft().renderEngine.bindTexture(Resources.Gui.TANK);
drawTexturedModalRect(x + posX + 1, y + posY + 1, 19, 1, 16, 37);
GL11.glEnable(GL11.GL_LIGHTING);
}
use of net.minecraft.util.IIcon in project ArsMagica2 by Mithion.
the class AMIngameGUI method RenderManaBar.
private void RenderManaBar(int i, int j, FontRenderer fontRenderer) {
int barWidth = i / 8;
AMVector2 fatigue_hud = getShiftedVector(AMCore.config.getBurnoutHudPosition(), i, j);
AMVector2 mana_hud = getShiftedVector(AMCore.config.getManaHudPosition(), i, j);
float green = 0.5f;
float blue = 1.0f;
float red = 0.126f;
ExtendedProperties props = ExtendedProperties.For(mc.thePlayer);
// mana bar
float mana = props.getCurrentMana();
float bonusMana = props.getBonusCurrentMana();
float maxMana = props.getMaxMana();
float fatigueBarWidth = barWidth;
float fatigue = props.getCurrentFatigue();
float maxFatigue = props.getMaxFatigue();
if (mana + bonusMana > maxMana)
mana = maxMana;
float progressScaled = (mana / (maxMana + 0.01f));
if (AMCore.config.showHudBars()) {
// handle flashing of mana bar
float flashTimer = AMGuiHelper.instance.getFlashTimer(MANA_BAR_FLASH_SLOT);
if (flashTimer > 0) {
green = 0.0f;
float redShift = 1.0f - red;
float halfFlash = AMGuiHelper.instance.flashDuration / 2;
if (flashTimer > halfFlash) {
float pct = (flashTimer - halfFlash) / halfFlash;
red += redShift - (redShift * pct);
} else {
float pct = flashTimer / halfFlash;
red += (redShift * pct);
}
GL11.glColor3f(red, green, blue);
} else {
if (bonusMana > 0)
GL11.glColor3f(0.2f, 0.9f, 0.6f);
}
ItemStack curItem = Minecraft.getMinecraft().thePlayer.getCurrentEquippedItem();
if (curItem != null && (curItem.getItem() == ItemsCommonProxy.spell || curItem.getItem() == ItemsCommonProxy.spellBook || curItem.getItem() == ItemsCommonProxy.arcaneSpellbook)) {
ItemStack spellStack = curItem.getItem() == ItemsCommonProxy.spell ? curItem : ((ItemSpellBook) curItem.getItem()).GetActiveItemStack(curItem);
if (spellStack != null) {
int[] parts = SpellUtils.instance.getShapeGroupParts(spellStack);
int sx = mana_hud.iX - 2 * parts.length / 2;
int sy = mana_hud.iY - 2 * parts.length / 2;
for (int p : parts) {
IIcon icon = SpellIconManager.instance.getIcon(SkillManager.instance.getSkillName(SkillManager.instance.getSkill(p)));
if (icon != null) {
DrawIconAtXY(icon, "items", sx, sy, false);
sx += 3;
sy += 3;
}
}
}
}
DrawPartialIconAtXY(AMGuiIcons.manaLevel, progressScaled, 1, mana_hud.iX + 16, mana_hud.iY + 1f, (int) (barWidth * 0.97f), 40, false);
DrawIconAtXY(AMGuiIcons.manaBar, "items", mana_hud.iX + 15, mana_hud.iY + 3, barWidth, 50, false);
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
progressScaled = (fatigue / (maxFatigue + 0.01f));
DrawIconAtXY(AMGuiIcons.fatigueIcon, "items", fatigue_hud.iX + barWidth, fatigue_hud.iY, false);
DrawPartialIconAtXY(AMGuiIcons.fatigueLevel, progressScaled, 1, fatigue_hud.iX, fatigue_hud.iY + 3f, fatigueBarWidth, 40, false);
DrawIconAtXY(AMGuiIcons.fatigueBar, "items", fatigue_hud.iX, fatigue_hud.iY + 4, barWidth, 48, false);
green = 0.5f;
blue = 1.0f;
red = 0.126f;
// magic level
int manaBarColor = Math.round(red * 255);
manaBarColor = (manaBarColor << 8) + Math.round(green * 255);
manaBarColor = (manaBarColor << 8) + Math.round(blue * 255);
String magicLevel = (new StringBuilder()).append("").append(ExtendedProperties.For(mc.thePlayer).getMagicLevel()).toString();
AMVector2 magicLevelPos = getShiftedVector(AMCore.config.getLevelPosition(), i, j);
magicLevelPos.iX -= Minecraft.getMinecraft().fontRenderer.getStringWidth(magicLevel) / 2;
fontRenderer.drawStringWithShadow(magicLevel, magicLevelPos.iX, magicLevelPos.iY, manaBarColor);
if (flashTimer > 0) {
GL11.glColor3f(1.0f, 1.0f, 1.0f);
}
}
if (AMCore.config.getShowNumerics()) {
String manaStr = StatCollector.translateToLocal("am2.gui.mana") + ": " + (int) (mana + bonusMana) + "/" + (int) maxMana;
String burnoutStr = StatCollector.translateToLocal("am2.gui.burnout") + ": " + (int) props.getCurrentFatigue() + "/" + (int) props.getMaxFatigue();
AMVector2 manaNumericPos = getShiftedVector(AMCore.config.getManaNumericPosition(), i, j);
AMVector2 burnoutNumericPos = getShiftedVector(AMCore.config.getBurnoutNumericPosition(), i, j);
fontRenderer.drawString(manaStr, manaNumericPos.iX, manaNumericPos.iY, bonusMana > 0 ? 0xeae31c : 0x2080FF);
fontRenderer.drawString(burnoutStr, burnoutNumericPos.iX + 25 - fontRenderer.getStringWidth(burnoutStr), burnoutNumericPos.iY, 0xFF2020);
}
}
Aggregations