Advertisement
Guest User

Untitled

a guest
Oct 28th, 2016
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.87 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. System.out.println("printing from drawscreen");
  46. System.out.println("te null: " + testBlockTE == null);
  47. System.out.println("rf: " + testBlockTE.getEnergyStored(null));
  48. this.fontRendererObj.drawString("RF: " + testBlockTE.getEnergyStored(null) + "/" + testBlockTE.getMaxEnergyStored(null), this.guiLeft + 61, this.guiTop + 14, 4210752);
  49. if (testBlockTE.gastank.getGas() == null) this.fontRendererObj.drawString("No gas", this.guiLeft + 53, this.guiTop + 60, 4210752);
  50. else this.fontRendererObj.drawString("Gas: " + testBlockTE.gastank.getGas().getGas().getLocalizedName() + ", " + testBlockTE.gastank.getStored() + "/" + testBlockTE.gastank.getMaxGas(), this.guiLeft + 53, this.guiTop + 60, 4210752);
  51. }
  52.  
  53. @Override
  54. public void initGui() {
  55. super.initGui();
  56. GuiButton btn = new GuiButton(0, this.guiLeft + 50, this.guiTop + 29, "Dump");
  57. buttonList.add(btn);
  58. }
  59.  
  60. @Override
  61. protected void actionPerformed(GuiButton button) {
  62. if (button.id == 0) {
  63. TestMod.snw.sendToServer(new GuiMessage(0, 0, testBlockTE.getPos().getX(), testBlockTE.getPos().getY(), testBlockTE.getPos().getZ()));
  64. }
  65. }
  66.  
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement