Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2018
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.20 KB | None | 0 0
  1. package forgingaura.forgeyourworld.ffactory.gui;
  2.  
  3. import forgingaura.forgeyourworld.ffactory.tileentity.TileEntitySteampunkFurnace;
  4. import net.minecraft.client.gui.inventory.GuiContainer;
  5. import net.minecraft.client.renderer.GlStateManager;
  6. import net.minecraft.entity.player.InventoryPlayer;
  7. import net.minecraft.inventory.ContainerFurnace;
  8. import net.minecraft.inventory.IInventory;
  9. import net.minecraft.tileentity.TileEntityFurnace;
  10. import net.minecraft.util.ResourceLocation;
  11. import net.minecraftforge.fml.common.registry.GameRegistry;
  12.  
  13. public class GuiSteampunkFurnace extends GuiContainer {
  14. private static final ResourceLocation FURNACE_GUI_TEXTURES = new ResourceLocation("ffactory:textures/gui/steampunk_furnace.png");
  15. /** The player inventory bound to this GUI. */
  16. private final InventoryPlayer playerInventory;
  17. private final IInventory tileFurnace;
  18.  
  19. public GuiSteampunkFurnace(InventoryPlayer playerInv, IInventory furnaceInv)
  20. {
  21. super(new ContainerFurnace(playerInv, furnaceInv));
  22. this.playerInventory = playerInv;
  23. this.tileFurnace = furnaceInv;
  24. }
  25.  
  26. /**
  27. * Draws the screen and all the components in it.
  28. */
  29. public void drawScreen(int mouseX, int mouseY, float partialTicks)
  30. {
  31. this.drawDefaultBackground();
  32. super.drawScreen(mouseX, mouseY, partialTicks);
  33. this.renderHoveredToolTip(mouseX, mouseY);
  34. }
  35.  
  36. /**
  37. * Draw the foreground layer for the GuiContainer (everything in front of the items)
  38. */
  39. protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
  40. {
  41. String s = this.tileFurnace.getDisplayName().getUnformattedText();
  42. this.fontRenderer.drawString(s, this.xSize / 2 - this.fontRenderer.getStringWidth(s) / 2, 6, 4210752);
  43. this.fontRenderer.drawString(this.playerInventory.getDisplayName().getUnformattedText(), 8, this.ySize - 96 + 2, 4210752);
  44. }
  45.  
  46. /**
  47. * Draws the background layer of this container (behind the items).
  48. */
  49. protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY)
  50. {
  51. GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
  52. this.mc.getTextureManager().bindTexture(FURNACE_GUI_TEXTURES);
  53. int i = (this.width - this.xSize) / 2;
  54. int j = (this.height - this.ySize) / 2;
  55. this.drawTexturedModalRect(i, j, 0, 0, this.xSize, this.ySize);
  56.  
  57. if (TileEntitySteampunkFurnace.isBurning(this.tileFurnace))
  58. {
  59. int k = this.getBurnLeftScaled(13);
  60. this.drawTexturedModalRect(i + 56, j + 36 + 12 - k, 176, 12 - k, 14, k + 1);
  61. }
  62.  
  63. int l = this.getCookProgressScaled(24);
  64. this.drawTexturedModalRect(i + 79, j + 34, 176, 14, l + 1, 16);
  65. }
  66.  
  67. private int getCookProgressScaled(int pixels)
  68. {
  69. int i = this.tileFurnace.getField(2);
  70. int j = this.tileFurnace.getField(3);
  71. return j != 0 && i != 0 ? i * pixels / j : 0;
  72. }
  73.  
  74. private int getBurnLeftScaled(int pixels)
  75. {
  76. int i = this.tileFurnace.getField(1);
  77.  
  78. if (i == 0)
  79. {
  80. i = 200;
  81. }
  82.  
  83. return this.tileFurnace.getField(0) * pixels / i;
  84. }
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement