Advertisement
Guest User

Untitled

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