Advertisement
Guest User

Untitled

a guest
Oct 25th, 2016
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.07 KB | None | 0 0
  1. package greatblitz.testmod.client.gui;
  2.  
  3. import java.io.IOException;
  4.  
  5. import greatblitz.testmod.TestMod;
  6. import greatblitz.testmod.common.container.ContainerTileEntityTestBlock;
  7. import greatblitz.testmod.tileentity.TileEntityTestBlock;
  8. import net.minecraft.client.gui.GuiButton;
  9. import net.minecraft.client.gui.inventory.GuiContainer;
  10. import net.minecraft.client.renderer.GlStateManager;
  11. import net.minecraft.entity.player.EntityPlayer;
  12. import net.minecraft.entity.player.InventoryPlayer;
  13. import net.minecraft.util.ResourceLocation;
  14.  
  15. public class GuiContainerTileEntityTestBlock extends GuiContainer{
  16.  
  17. TileEntityTestBlock testBlockTE;
  18. InventoryPlayer playerInv;
  19.  
  20. public GuiContainerTileEntityTestBlock(InventoryPlayer player, TileEntityTestBlock te) {
  21. super(new ContainerTileEntityTestBlock (player, te));
  22. playerInv = player;
  23. testBlockTE = te;
  24. this.xSize = 176;
  25. this.ySize = 166;
  26. }
  27.  
  28. @Override
  29. protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
  30. GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f);
  31. this.mc.getTextureManager().bindTexture(new ResourceLocation("testmod:textures/gui/container/tile.png"));
  32. this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, this.xSize, this.ySize);
  33. }
  34.  
  35. @Override
  36. protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
  37. String s = "Test Block Tile Entity";
  38. this.fontRendererObj.drawString(s, 88 - this.fontRendererObj.getStringWidth(s) / 2, 6, 4210752);
  39. this.fontRendererObj.drawString(this.playerInv.getDisplayName().getUnformattedText(), 8, 72, 4210752);
  40. }
  41.  
  42. @Override
  43. public void drawScreen(int mouseX, int mouseY, float partialTicks) {
  44. super.drawScreen(mouseX, mouseY, partialTicks);
  45. this.fontRendererObj.drawString("RF: " + testBlockTE.getEnergyStored(null) + "/" + testBlockTE.getMaxEnergyStored(null), this.guiLeft + 61, this.guiTop + 14, 4210752);
  46. if (testBlockTE.gastank.getGas() == null) this.fontRendererObj.drawString("No gas", this.guiLeft + 53, this.guiTop + 60, 4210752);
  47. else this.fontRendererObj.drawString("Gas: " + testBlockTE.gastank.getGas().getGas().getLocalizedName() + ", " + testBlockTE.gastank.getStored() + "/" + testBlockTE.gastank.getMaxGas(), this.guiLeft + 53, this.guiTop + 60, 4210752);
  48. //this.fontRendererObj.drawString("Gas: " + testBlockTE.gastank.getGas().getGas().getLocalizedName() + ", " + testBlockTE.gastank.getStored() + "/" + testBlockTE.gastank.getMaxGas(), this.guiLeft + 53, this.guiTop + 60, 4210752);
  49. }
  50.  
  51. @Override
  52. public void initGui() {
  53. super.initGui();
  54. GuiButton btn = new GuiButton(0, this.guiLeft + 50, this.guiTop + 29, "Dump");
  55. buttonList.add(btn);
  56. }
  57.  
  58. @Override
  59. protected void actionPerformed(GuiButton button) {
  60. try {
  61. if (button.id == 0) {
  62. TestMod.snw.sendToServer(new GuiMessage(0, 0, testBlockTE.getPos().getX(), testBlockTE.getPos().getY(), testBlockTE.getPos().getZ()));
  63. }
  64. else super.actionPerformed(button);
  65. }
  66. catch (IOException e) {
  67. System.out.println("Caught an IOException!");
  68. }
  69.  
  70. }
  71.  
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement