Advertisement
Guest User

Untitled

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