| package com.legacy.aether.client.overlay; |
| |
| import net.minecraft.block.material.Material; |
| import net.minecraft.block.state.IBlockState; |
| import net.minecraft.client.Minecraft; |
| import net.minecraft.client.gui.Gui; |
| import net.minecraft.client.gui.ScaledResolution; |
| import net.minecraft.client.renderer.GlStateManager; |
| import net.minecraft.client.renderer.GlStateManager.DestFactor; |
| import net.minecraft.client.renderer.GlStateManager.SourceFactor; |
| import net.minecraft.client.renderer.Tessellator; |
| import net.minecraft.client.renderer.VertexBuffer; |
| import net.minecraft.client.renderer.texture.TextureAtlasSprite; |
| import net.minecraft.client.renderer.vertex.DefaultVertexFormats; |
| import net.minecraft.entity.EntityLiving; |
| import net.minecraft.entity.player.EntityPlayer; |
| import net.minecraft.util.ResourceLocation; |
| import net.minecraftforge.fml.relauncher.Side; |
| import net.minecraftforge.fml.relauncher.SideOnly; |
| |
| import org.lwjgl.opengl.GL11; |
| |
| import com.legacy.aether.server.blocks.BlocksAether; |
| import com.legacy.aether.server.entities.bosses.slider.EntitySlider; |
| import com.legacy.aether.server.entities.bosses.sun_spirit.EntitySunSpirit; |
| import com.legacy.aether.server.entities.bosses.valkyrie_queen.EntityValkyrieQueen; |
| import com.legacy.aether.server.entities.passive.mountable.EntityMoa; |
| import com.legacy.aether.server.items.ItemsAether; |
| import com.legacy.aether.server.player.PlayerAether; |
| |
| @SideOnly(Side.CLIENT) |
| public class AetherOverlay |
| { |
| |
| private static final ResourceLocation TEXTURE_JUMPS = new ResourceLocation("aether_legacy", "textures/gui/jumps.png"); |
| |
| private static final ResourceLocation TEXTURE_COOLDOWN_BAR = new ResourceLocation("aether_legacy", "textures/gui/cooldown_bar.png"); |
| |
| private static final ResourceLocation TEXTURE_POISON_VIGNETTE = new ResourceLocation("aether_legacy", "textures/blur/poison_vignette.png"); |
| |
| private static final ResourceLocation TEXTURE_CURE_VIGNETTE = new ResourceLocation("aether_legacy", "textures/blur/cure_vignette.png"); |
| |
| public static void renderPoison(Minecraft mc) |
| { |
| PlayerAether playerAether = PlayerAether.get(mc.thePlayer); |
| |
| if(playerAether.isPoisoned()) |
| { |
| ScaledResolution scaledresolution = new ScaledResolution(mc); |
| Tessellator tessellator = Tessellator.getInstance(); |
| VertexBuffer renderer = tessellator.getBuffer(); |
| |
| float alpha = getPoisonAlpha((float)(playerAether.poisonInstance().poisonTime % 50) / 50F); |
| |
| int width = scaledresolution.getScaledWidth(); |
| int height = scaledresolution.getScaledHeight(); |
| |
| GlStateManager.pushMatrix(); |
| GlStateManager.enableBlend(); |
| GlStateManager.disableDepth(); |
| GlStateManager.depthMask(false); |
| GlStateManager.blendFunc(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA); |
| GlStateManager.color(0.5F, 0.5F, 0.5F, alpha); |
| GlStateManager.disableAlpha(); |
| |
| mc.renderEngine.bindTexture(TEXTURE_POISON_VIGNETTE); |
| |
| renderer.begin(7, DefaultVertexFormats.POSITION_TEX); |
| renderer.pos(0.0D, (double)height, -90.0D).tex(0.0D, 1.0D).endVertex(); |
| renderer.pos((double)width, (double)height, -90.0D).tex(1.0D, 1.0D).endVertex(); |
| renderer.pos((double)width, 0.0D, -90.0D).tex(1.0D, 0.0D).endVertex(); |
| renderer.pos(0.0D, 0.0D, -90.0D).tex(0.0D, 0.0D).endVertex(); |
| tessellator.draw(); |
| |
| GlStateManager.depthMask(true); |
| GlStateManager.enableDepth(); |
| GlStateManager.enableAlpha(); |
| GlStateManager.color(1.0F, 1.0F, 1.0F, alpha); |
| GlStateManager.popMatrix(); |
| } |
| } |
| |
| public static void renderCure(Minecraft mc) |
| { |
| PlayerAether playerAether = PlayerAether.get(mc.thePlayer); |
| |
| if(playerAether.isCured()) |
| { |
| ScaledResolution scaledresolution = new ScaledResolution(mc); |
| Tessellator tessellator = Tessellator.getInstance(); |
| VertexBuffer renderer = tessellator.getBuffer(); |
| |
| float alpha = getCureAlpha((-(float)playerAether.poisonInstance().poisonTime % 50)) / 100.0F; |
| int width = scaledresolution.getScaledWidth(); |
| int height = scaledresolution.getScaledHeight(); |
| |
| GlStateManager.pushMatrix(); |
| GlStateManager.enableBlend(); |
| GlStateManager.disableDepth(); |
| GlStateManager.depthMask(false); |
| GlStateManager.blendFunc(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA); |
| GlStateManager.color(0.5F, 0.5F, 0.5F, alpha); |
| GlStateManager.disableAlpha(); |
| |
| mc.renderEngine.bindTexture(TEXTURE_CURE_VIGNETTE); |
| |
| renderer.begin(7, DefaultVertexFormats.POSITION_TEX); |
| renderer.pos(0.0D, (double)height, -90.0D).tex(0.0D, 1.0D).endVertex(); |
| renderer.pos((double)width, (double)height, -90.0D).tex(1.0D, 1.0D).endVertex(); |
| renderer.pos((double)width, 0.0D, -90.0D).tex(1.0D, 0.0D).endVertex(); |
| renderer.pos(0.0D, 0.0D, -90.0D).tex(0.0D, 0.0D).endVertex(); |
| tessellator.draw(); |
| |
| GlStateManager.depthMask(true); |
| GlStateManager.enableDepth(); |
| GlStateManager.enableAlpha(); |
| GlStateManager.color(1.0F, 1.0F, 1.0F, alpha); |
| GlStateManager.popMatrix(); |
| } |
| } |
| |
| public static void renderIronBubble(Minecraft mc) |
| { |
| ScaledResolution scaledresolution = new ScaledResolution(mc); |
| |
| int width = scaledresolution.getScaledWidth(); |
| int height = scaledresolution.getScaledHeight(); |
| |
| GlStateManager.pushMatrix(); |
| GlStateManager.enableBlend(); |
| GlStateManager.disableDepth(); |
| GlStateManager.depthMask(false); |
| GlStateManager.blendFunc(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA); |
| GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); |
| GlStateManager.disableAlpha(); |
| |
| mc.renderEngine.bindTexture(Gui.ICONS); |
| |
| int bubbleAmount = PlayerAether.get(mc.thePlayer).getAccessoryCount(ItemsAether.iron_bubble); |
| |
| if (mc.playerController.shouldDrawHUD() && mc.thePlayer.isInWater() && mc.thePlayer.isInsideOfMaterial(Material.WATER)) |
| { |
| for (int i = 0; i < bubbleAmount; ++i) |
| { |
| drawTexturedModalRect((width / 2 - 8 * i) + 81, height - 49, 16, 18, 9, 9); |
| } |
| } |
| |
| GlStateManager.depthMask(true); |
| GlStateManager.enableDepth(); |
| GlStateManager.enableAlpha(); |
| GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); |
| GlStateManager.popMatrix(); |
| } |
| |
| public static void renderCooldown(Minecraft mc) |
| { |
| PlayerAether playerInfo = PlayerAether.get(mc.thePlayer); |
| |
| if (playerInfo.getCooldown() != 0) |
| { |
| ScaledResolution scaledresolution = new ScaledResolution(mc); |
| |
| int cooldownRemaining = (int) ((float) (playerInfo.getCooldown()) / (float) (playerInfo.getCooldownMax()) * 128F); |
| int width = scaledresolution.getScaledWidth(); |
| |
| mc.fontRendererObj.drawStringWithShadow(playerInfo.getCooldownName() + " Cooldown", (width / 2) - (mc.fontRendererObj.getStringWidth(playerInfo.getCooldownName() + " Cooldown") / 2), 32, 0xffffffff); |
| |
| GlStateManager.pushMatrix(); |
| |
| GlStateManager.enableBlend(); |
| GlStateManager.disableDepth(); |
| GlStateManager.depthMask(false); |
| GlStateManager.blendFunc(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA); |
| GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); |
| GlStateManager.disableAlpha(); |
| |
| mc.renderEngine.bindTexture(TEXTURE_COOLDOWN_BAR); |
| |
| drawTexturedModalRect(width / 2 - 64, 42, 0, 8, 128, 8); |
| |
| drawTexturedModalRect(width / 2 - 64, 42, 0, 0, cooldownRemaining, 8); |
| |
| GlStateManager.depthMask(true); |
| GlStateManager.enableDepth(); |
| GlStateManager.enableAlpha(); |
| GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); |
| |
| GlStateManager.popMatrix(); |
| } |
| } |
| |
| public static void renderJumps(Minecraft mc) |
| { |
| EntityPlayer player = mc.thePlayer; |
| |
| if (player == null || player.getRidingEntity() == null || !(player.getRidingEntity() instanceof EntityMoa)) |
| { |
| return; |
| } |
| |
| ScaledResolution scaledresolution = new ScaledResolution(mc); |
| |
| EntityMoa moa = (EntityMoa) (player.getRidingEntity()); |
| |
| int width = scaledresolution.getScaledWidth(); |
| |
| GlStateManager.pushMatrix(); |
| |
| mc.renderEngine.bindTexture(TEXTURE_JUMPS); |
| |
| GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); |
| |
| for (int jump = 0; jump < moa.getMaxJumps(); jump++) |
| { |
| int yPos = 18; |
| int xPos = ((width / 2) + (jump * 8)) - (moa.getMaxJumps() * 8) / 2; |
| |
| if (jump < moa.getRemainingJumps()) |
| { |
| drawTexturedModalRect(xPos, yPos, 0, 0, 9, 11); |
| } |
| else |
| { |
| drawTexturedModalRect(xPos, yPos, 10, 0, 9, 11); |
| } |
| } |
| |
| GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); |
| |
| GlStateManager.popMatrix(); |
| } |
| |
| public static void renderPortal(float portalTime, int scaledWidth, int scaledHeight) |
| { |
| if (portalTime < 1.0F) |
| { |
| portalTime *= portalTime; |
| portalTime *= portalTime; |
| portalTime = portalTime * 0.8F + 0.2F; |
| } |
| |
| GlStateManager.pushMatrix(); |
| GlStateManager.disableAlpha(); |
| GlStateManager.disableDepth(); |
| GlStateManager.depthMask(false); |
| GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_CONSTANT_ALPHA); |
| GlStateManager.color(1.0F, 1.0F, 1.0F, portalTime); |
| IBlockState portal = BlocksAether.aether_portal.getDefaultState(); |
| TextureAtlasSprite sprite = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getTexture(portal); |
| Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation("aether_legacy", "textures/blocks/aether_portal.png")); |
| float f1 = sprite.getMinU(); |
| float f2 = sprite.getMinV(); |
| float f3 = sprite.getMaxU(); |
| float f4 = sprite.getMaxV(); |
| Tessellator tessellator = Tessellator.getInstance(); |
| VertexBuffer renderer = tessellator.getBuffer(); |
| renderer.begin(7, DefaultVertexFormats.POSITION_TEX); |
| renderer.pos(0.0D, scaledHeight, -90.0D).tex(f1, f4).endVertex(); |
| renderer.pos(scaledWidth, scaledHeight, -90.0D).tex(f3, f4).endVertex(); |
| renderer.pos(scaledWidth, 0.0D, -90.0D).tex(f3, f2).endVertex(); |
| renderer.pos(0.0D, 0.0D, -90.0D).tex(f1, f2).endVertex(); |
| tessellator.draw(); |
| GlStateManager.depthMask(true); |
| GlStateManager.enableDepth(); |
| GlStateManager.enableAlpha(); |
| GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); |
| GlStateManager.popMatrix(); |
| } |
| |
| public static void renderBossHP(Minecraft mc) |
| { |
| PlayerAether player = PlayerAether.get(mc.thePlayer); |
| |
| EntityLiving boss = (EntityLiving) player.getCurrentBoss(); |
| |
| if (player.getCurrentBoss() != null) |
| { |
| String bossTitle = ""; |
| ScaledResolution scaledresolution = new ScaledResolution(mc); |
| |
| int healthRemaining = (int) (boss.getHealth() / boss.getMaxHealth() * 256F); |
| int width = scaledresolution.getScaledWidth(); |
| |
| if (boss instanceof EntitySlider) |
| { bossTitle = ((EntitySlider)boss).getBossTitle(); } |
| else if (boss instanceof EntityValkyrieQueen) |
| { bossTitle = ((EntityValkyrieQueen)boss).getBossTitle(); } |
| else |
| { bossTitle = ((EntitySunSpirit)boss).getBossTitle(); } |
| |
| GlStateManager.pushMatrix(); |
| |
| mc.fontRendererObj.drawStringWithShadow(bossTitle, width / 2 - (mc.fontRendererObj.getStringWidth(bossTitle) / 2), 2, 0xffffffff); |
| |
| mc.renderEngine.bindTexture(new ResourceLocation("aether_legacy", "textures/gui/boss_bar.png")); |
| |
| GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); |
| |
| drawTexturedModalRect(width / 2 - 128, 12, 0, 16, 256, 32); |
| |
| drawTexturedModalRect(width/ 2 - 128, 12, 0, 0, healthRemaining, 16); |
| |
| GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); |
| |
| GlStateManager.popMatrix(); |
| } |
| } |
| |
| public static void drawTexturedModalRect(float x, float y, float u, float v, float width, float height) |
| { |
| float zLevel = -90.0F; |
| |
| float var7 = 0.00390625F; |
| float var8 = 0.00390625F; |
| Tessellator var9 = Tessellator.getInstance(); |
| VertexBuffer renderer = var9.getBuffer(); |
| renderer.begin(7, DefaultVertexFormats.POSITION_TEX); |
| renderer.pos((double) (x + 0), (double) (y + height), (double) zLevel).tex((double) ((float) (u + 0) * var7), (double) ((float) (v + height) * var8)).endVertex(); |
| renderer.pos((double) (x + width), (double) (y + height), (double) zLevel).tex((double) ((float) (u + width) * var7), (double) ((float) (v + height) * var8)).endVertex(); |
| renderer.pos((double) (x + width), (double) (y + 0), (double) zLevel).tex((double) ((float) (u + width) * var7), (double) ((float) (v + 0) * var8)).endVertex(); |
| renderer.pos((double) (x + 0), (double) (y + 0), (double) zLevel).tex((double) ((float) (u + 0) * var7), (double) ((float) (v + 0) * var8)).endVertex(); |
| var9.draw(); |
| } |
| |
| public static float getPoisonAlpha(float f) |
| { |
| return f * f / 5.0F + 0.4F; |
| } |
| |
| public static float getCureAlpha(float f) |
| { |
| return f * f / 10.0F + 0.4F; |
| } |
| |
| } |