Guest User

GUICalculatorBasic

a guest
Jan 3rd, 2016
26
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.limplungs.invcalc.gui;
  2.  
  3. import com.limplungs.invcalc.containers.ContainerCalculatorBasic;
  4. import com.limplungs.invcalc.help.Reference;
  5. import net.minecraft.client.Minecraft;
  6. import net.minecraft.client.gui.GuiButton;
  7. import net.minecraft.client.gui.inventory.GuiContainer;
  8. import net.minecraft.entity.player.InventoryPlayer;
  9. import net.minecraft.util.ResourceLocation;
  10.  
  11. public class GUICalculatorBasic extends GuiContainer
  12. {
  13.  
  14. public GUICalculatorBasic(InventoryPlayer inventory)
  15. {
  16. super(new ContainerCalculatorBasic(inventory));
  17.  
  18. this.xSize = 194;
  19. this.ySize = 108;
  20. }
  21.  
  22. ResourceLocation texture = new ResourceLocation(Reference.MODID, "textures/gui/calculators/calcbasic.png");
  23.  
  24. @Override
  25. protected void drawGuiContainerBackgroundLayer(float f, int x, int y)
  26. {
  27. this.xSize = 194;
  28. this.ySize = 108;
  29.  
  30. Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
  31.  
  32. drawTexturedModalRect((this.width / 2) - 97, (this.height - this.ySize), 0, 0, this.xSize, this.ySize);
  33. }
  34.  
  35. @Override
  36. protected void drawGuiContainerForegroundLayer(int x, int y)
  37. {
  38. this.xSize = 194;
  39. this.ySize = 108;
  40.  
  41. //this.fontRendererObj.drawString("Basic Calculator", (this.width / 2) + 8, (this.height - this.ySize) + 77, 4210752);
  42. }
  43.  
  44. @Override
  45. @SuppressWarnings("unchecked")
  46. public void initGui()
  47. {
  48. this.xSize = 194;
  49. this.ySize = 108;
  50.  
  51. if (Minecraft.getMinecraft().theWorld.isRemote)
  52. {
  53. this.buttonList.add(new GuiButton(10, (this.width / 2) - 97 + 95, (this.height - this.ySize) + 3, 20, 20, "0"));
  54. this.buttonList.add(new GuiButton(17, (this.width / 2) - 97 + 6, (this.height - this.ySize) + 3, 20, 20, "7"));
  55. this.buttonList.add(new GuiButton(18, (this.width / 2) - 97 + 37, (this.height - this.ySize) + 3, 20, 20, "8"));
  56. this.buttonList.add(new GuiButton(19, (this.width / 2) - 97 + 68, (this.height - this.ySize) + 3, 20, 20, "9"));
  57. this.buttonList.add(new GuiButton(14, (this.width / 2) - 97 + 6, (this.height - this.ySize) + 33, 20, 20, "4"));
  58. this.buttonList.add(new GuiButton(15, (this.width / 2) - 97 + 37, (this.height - this.ySize) + 33, 20, 20, "5"));
  59. this.buttonList.add(new GuiButton(16, (this.width / 2) - 97 + 68, (this.height - this.ySize) + 33, 20, 20, "6"));
  60. this.buttonList.add(new GuiButton(11, (this.width / 2) - 97 + 6, (this.height - this.ySize) + 63, 20, 20, "1"));
  61. this.buttonList.add(new GuiButton(12, (this.width / 2) - 97 + 37, (this.height - this.ySize) + 63, 20, 20, "2"));
  62. this.buttonList.add(new GuiButton(13, (this.width / 2) - 97 + 68, (this.height - this.ySize) + 63, 20, 20, "3"));
  63. }
  64. }
  65.  
  66. @Override
  67. public void actionPerformed(GuiButton button)
  68. {
  69. if (Minecraft.getMinecraft().theWorld.isRemote)
  70. {
  71. if (button.id == 11)
  72. Minecraft.getMinecraft().thePlayer.sendChatMessage("1");
  73.  
  74. if (button.id == 12)
  75. Minecraft.getMinecraft().thePlayer.sendChatMessage("2");
  76.  
  77. if (button.id == 13)
  78. Minecraft.getMinecraft().thePlayer.sendChatMessage("3");
  79.  
  80. if (button.id == 14)
  81. Minecraft.getMinecraft().thePlayer.sendChatMessage("4");
  82.  
  83. if (button.id == 15)
  84. Minecraft.getMinecraft().thePlayer.sendChatMessage("5");
  85.  
  86. if (button.id == 16)
  87. Minecraft.getMinecraft().thePlayer.sendChatMessage("6");
  88.  
  89. if (button.id == 17)
  90. Minecraft.getMinecraft().thePlayer.sendChatMessage("7");
  91.  
  92. if (button.id == 18)
  93. Minecraft.getMinecraft().thePlayer.sendChatMessage("8");
  94.  
  95. if (button.id == 19)
  96. Minecraft.getMinecraft().thePlayer.sendChatMessage("9");
  97.  
  98. }
  99. }
  100. }
RAW Paste Data