Advertisement
Guest User

Halo Event Handler

a guest
Feb 28th, 2015
285
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package halocraft;
  2.  
  3. import java.util.Collection;
  4. import java.util.Iterator;
  5.  
  6. import org.lwjgl.opengl.GL11;
  7.  
  8. import net.minecraft.client.Minecraft;
  9. import net.minecraft.client.gui.Gui;
  10. import net.minecraft.client.gui.ScaledResolution;
  11. import net.minecraft.client.renderer.Tessellator;
  12. import net.minecraft.client.renderer.WorldRenderer;
  13. import net.minecraft.entity.player.EntityPlayer;
  14. import net.minecraft.item.ItemStack;
  15. import net.minecraft.potion.Potion;
  16. import net.minecraft.potion.PotionEffect;
  17. import net.minecraft.util.ResourceLocation;
  18. import net.minecraftforge.client.event.RenderGameOverlayEvent;
  19. import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType;
  20. import net.minecraftforge.fml.common.eventhandler.EventPriority;
  21. import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
  22. import net.minecraftforge.fml.common.gameevent.TickEvent.RenderTickEvent;
  23.  
  24. public class HaloEventHandler extends Gui{
  25.     private Minecraft mc;
  26.     ResourceLocation res = new ResourceLocation("halocraft:textures/gui/HaloOverlay.png");
  27.      public HaloEventHandler(Minecraft mc){
  28.         super();
  29.         // We need this to invoke the render engine.
  30.         this.mc = mc;
  31.       }
  32.      /**
  33.          * Draws textured rectangles of sizes other than 256x256
  34.          * @param x The x value of the top-left corner point on the screen where drawing to starts
  35.          * @param y The y value of the top-left corner point on the screen where drawing to starts
  36.          * @param u The u (x) value of top-left corner point of the texture to start drawing from
  37.          * @param v The v (y) value of top-left corner point of the texture to start drawing from
  38.          * @param width The width of the rectangle to draw on screen
  39.          * @param height The height of the rectangle to draw on screen
  40.          * @param textureWidth The width of the whole texture
  41.          * @param textureHeight The height of the whole texture
  42.          */
  43.         protected void drawNonStandardTexturedRect(int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight)
  44.         {
  45.             double f = 1F / (double)textureWidth;
  46.             double f1 = 1F / (double)textureHeight;
  47.             WorldRenderer tessellator = Tessellator.getInstance().getWorldRenderer();
  48.             tessellator.startDrawingQuads();
  49.             tessellator.addVertexWithUV(x, y + height, 0, u * f, (v + height) * f1);
  50.             tessellator.addVertexWithUV(x + width, y + height, 0, (u + width) * f, (v + height) * f1);
  51.             tessellator.addVertexWithUV(x + width, y, 0, (u + width) * f, v * f1);
  52.             tessellator.addVertexWithUV(x, y, 0, u * f, v * f1);
  53.             Tessellator.getInstance().draw();
  54.         }
  55.         private static final int BUFF_ICON_SIZE = 256;
  56.         @SubscribeEvent(priority = EventPriority.NORMAL)
  57.         public void onRenderGameOverlay(RenderGameOverlayEvent event)
  58.         {
  59.             if(event.isCancelable() || event.type != ElementType.EXPERIENCE){
  60.                 return;
  61.             }
  62.             //if (((EntityPlayer)mc.thePlayer).inventory.armorInventory[3].getItem() == halocraft.Main.SpartanHelmet){
  63.                 int xPos = 0;
  64.                 int yPos = 0;
  65.                 GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
  66.                 GL11.glDisable(GL11.GL_LIGHTING);
  67.                 this.mc.renderEngine.bindTexture(res);
  68.                 ScaledResolution Scaled = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
  69.                 this.drawNonStandardTexturedRect(xPos, yPos, 0, 0, mc.displayWidth, mc.displayHeight, 420, 250);
  70.             //}
  71.      }
  72. }
Advertisement
RAW Paste Data Copied
Advertisement