Advertisement
Guest User

Untitled

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