Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.46 KB | None | 0 0
  1. package melonslise.runicinscription.client.gui;
  2.  
  3. import org.lwjgl.opengl.GL11;
  4.  
  5. import melonslise.runicinscription.RunicInscription;
  6. import melonslise.runicinscription.common.container.ContainerRuneInscription;
  7. import net.minecraft.client.Minecraft;
  8. import net.minecraft.client.gui.inventory.GuiContainer;
  9. import net.minecraft.entity.player.InventoryPlayer;
  10. import net.minecraft.util.ResourceLocation;
  11. import net.minecraft.world.World;
  12.  
  13. public class GUIRuneInscription extends GuiContainer
  14. {
  15.     private ResourceLocation texture = new ResourceLocation(RunicInscription.ID + ":" + "textures/gui/RuneInscription.png");
  16.     private ContainerRuneInscription containerInscription = (ContainerRuneInscription) this.inventorySlots;
  17.    
  18.     public GUIRuneInscription(InventoryPlayer inventoryPlayer, World world, int x, int y, int z)
  19.     {
  20.         super(new ContainerRuneInscription(inventoryPlayer, world, x, y, z));
  21.        
  22.         this.xSize = 176;
  23.         this.ySize = 206;
  24.     }
  25.    
  26.     @Override
  27.     protected void drawGuiContainerBackgroundLayer(float f1, int i1, int i2)
  28.     {
  29.         GL11.glColor4f(1F, 1F, 1F, 1F);
  30.        
  31.         Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
  32.        
  33.         drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
  34.        
  35.         renderCarvingGrid();
  36.     }
  37.    
  38.     protected void drawGuiContainerForegroundLayer(int i, int j)
  39.     {
  40.         //Draw text
  41.     }
  42.    
  43.     public void mouseClicked(int mouseX, int mouseY, int mouseButton)
  44.     {
  45.         super.mouseClicked(mouseX, mouseY, mouseButton);
  46.        
  47.         if (mouseButton == 0)
  48.         {  
  49.             for (int x = 0; x < 5; ++x)
  50.             {
  51.                 for (int y = 0; y < 7; ++y)
  52.                 {
  53.                     if ((((mouseX - guiLeft) >= 43 + x * 16) && ((mouseX - guiLeft) < 43 + (x + 1) * 16)) && (((mouseY - guiTop) >= 6 + y * 16) && ((mouseY - guiTop) < 6 + (y + 1) * 16)))
  54.                     {
  55.                         this.containerInscription.grid[x][y] = true;
  56.                         this.containerInscription.onMatrixChanged();
  57.                     }
  58.                 }
  59.             }
  60.         }
  61.     }
  62.  
  63.     public void onGuiClosed()
  64.     {
  65.         super.onGuiClosed();
  66.     }
  67.    
  68.     public void renderCarvingGrid()
  69.     {
  70.         GL11.glColor4f(1F, 1F, 1F, 1F);
  71.        
  72.         mc.getTextureManager().bindTexture(texture);
  73.        
  74.         for(int x = 0; x < 5; ++x)
  75.         {
  76.             for(int y = 0; y < 7; ++y)
  77.             {
  78.                 if (this.containerInscription.grid[x][y] == false)
  79.                 {
  80.                     drawTexturedModalRect(guiLeft + 43 + x * 16, guiTop + 6 + y * 16, 0, 206, 16, 16);
  81.                 }
  82.                 else if (this.containerInscription.grid[x][y] == true)
  83.                 {
  84.                     drawTexturedModalRect(guiLeft + 43 + x * 16, guiTop + 6 + y * 16, 16, 206, 16, 16);
  85.                 }
  86.             }
  87.         }
  88.     }
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement