Advertisement
Guest User

Untitled

a guest
May 28th, 2016
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.32 KB | None | 0 0
  1. package maelstromphoenix.waih;
  2.  
  3. import net.minecraft.client.Minecraft;
  4. import net.minecraft.client.gui.GuiScreen;
  5. import net.minecraft.client.gui.ScaledResolution;
  6. import net.minecraft.client.renderer.GlStateManager;
  7. import net.minecraft.client.renderer.Tessellator;
  8. import net.minecraft.client.renderer.VertexBuffer;
  9. import net.minecraft.client.renderer.texture.TextureManager;
  10. import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
  11. import net.minecraft.entity.player.EntityPlayer;
  12. import net.minecraft.item.ItemStack;
  13. import net.minecraft.util.ResourceLocation;
  14. import org.lwjgl.opengl.GL11;
  15.  
  16. /**
  17. * Created by Sven on 5/27/16.
  18. */
  19. public class Overlay extends GuiScreen{
  20.  
  21. public static Minecraft minecraft = Minecraft.getMinecraft();
  22. public static EntityPlayer player = minecraft.thePlayer;
  23. public static TextureManager textureManager = minecraft.renderEngine;
  24. public static Tessellator tessellator = Tessellator.getInstance();
  25. public static VertexBuffer vertexBuffer = tessellator.getBuffer();
  26.  
  27. public void render(){
  28. ItemStack currentItem = player.inventory.getCurrentItem();
  29. if(currentItem == null)
  30. return;
  31.  
  32. ScaledResolution scaledResolution = new ScaledResolution(minecraft);
  33. float width = scaledResolution.getScaledWidth();
  34. float height = scaledResolution.getScaledHeight();
  35.  
  36. drawTexturedRectangle(width/4, height - height/4, 50, 50, 0, "rounded_rectangle.png");
  37.  
  38.  
  39.  
  40. }
  41.  
  42. public void drawTexturedRectangle(double x, double y, double width, double height, double zIndex, String texture){
  43. textureManager.bindTexture(new ResourceLocation(WAIH.MODID, texture));
  44. GlStateManager.enableAlpha();
  45. vertexBuffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR);
  46. vertexBuffer.pos(x - width/2, y - height/2, zIndex).tex(0, 0).color(1.0f, 1.0f, 1.0f, 0.1f).endVertex();
  47. vertexBuffer.pos(x - width/2, y + height/2, zIndex).tex(0, 1).color(1.0f, 1.0f, 1.0f, 0.1f).endVertex();
  48. vertexBuffer.pos(x + width/2, y + height/2, zIndex).tex(1, 1).color(1.0f, 1.0f, 1.0f, 0.1f).endVertex();
  49. vertexBuffer.pos(x + width/2, y - height/2, zIndex).tex(1, 0).color(1.0f, 1.0f, 1.0f, 0.1f).endVertex();
  50. tessellator.draw();
  51. GlStateManager.disableAlpha();
  52. }
  53.  
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement