tigres810

Untitled

Feb 28th, 2019
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.38 KB | None | 0 0
  1. package com.tigres810.adventurermod.blocks.gui;
  2.  
  3. import com.tigres810.adventurermod.blocks.machines.container.ContainerFluxGenerator;
  4. import com.tigres810.adventurermod.blocks.machines.tileentity.TileEntityFluxGenerator;
  5. import com.tigres810.adventurermod.util.Reference;
  6.  
  7. import net.minecraft.client.gui.inventory.GuiContainer;
  8. import net.minecraft.client.renderer.GlStateManager;
  9. import net.minecraft.entity.player.InventoryPlayer;
  10. import net.minecraft.util.ResourceLocation;
  11.  
  12. public class GUIFluxGenerator extends GuiContainer
  13. {
  14. private static final ResourceLocation TEXTURES = new ResourceLocation(Reference.MOD_ID + ":textures/gui/flux_generator_block.png");
  15. private final InventoryPlayer player;
  16. private final TileEntityFluxGenerator tileentity;
  17.  
  18. public GUIFluxGenerator(InventoryPlayer player, TileEntityFluxGenerator tileentity)
  19. {
  20. super(new ContainerFluxGenerator(player, tileentity));
  21. this.player = player;
  22. this.tileentity = tileentity;
  23. }
  24.  
  25. @Override
  26. protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
  27. {
  28. String tileName = this.tileentity.getDisplayName().getUnformattedText();
  29. this.fontRenderer.drawString(tileName, (this.xSize / 2 - this.fontRenderer.getStringWidth(tileName) / 2) -5, 6, 4210752);
  30. this.fontRenderer.drawString(this.player.getDisplayName().getUnformattedText(), 7, this.ySize - 96 + 2, 4210752);
  31. this.fontRenderer.drawString(Integer.toString(this.tileentity.getEnergyStored()), 115, 72, 4210752);
  32. }
  33.  
  34. @Override
  35. protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY)
  36. {
  37. GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f);
  38. this.mc.getTextureManager().bindTexture(TEXTURES);
  39. this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, this.xSize, this.ySize);
  40.  
  41. int l = this.getCookProgressScaled(24);
  42. this.drawTexturedModalRect(this.guiLeft + 113, this.guiTop + 32, 176, 14, l + 1, 16);
  43.  
  44. int k = this.getEnergyStoredScaled(75);
  45. this.drawTexturedModalRect(this.guiLeft + 152, this.guiTop + 7, 176, 32, 16, 76 - k);
  46. }
  47.  
  48. private int getEnergyStoredScaled(int pixels)
  49. {
  50. int i = this.tileentity.getEnergyStored();
  51. int j = this.tileentity.getMaxEnergyStored();
  52. return i != 0 && j != 0 ? i * pixels / j : 0;
  53. }
  54.  
  55. private int getCookProgressScaled(int pixels)
  56. {
  57. int i = this.tileentity.getCookTimeValue();
  58. return i != 0 ? i * pixels / 25 : 0;
  59. }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment