grossik

Untitled

Jul 26th, 2016
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.08 KB | None | 0 0
  1. package cz.grossik.farmcraft2.crushing;
  2.  
  3. import net.minecraft.client.gui.inventory.GuiContainer;
  4. import net.minecraft.client.renderer.GlStateManager;
  5. import net.minecraft.entity.player.InventoryPlayer;
  6. import net.minecraft.inventory.IInventory;
  7. import net.minecraft.util.ResourceLocation;
  8. import net.minecraftforge.fml.relauncher.Side;
  9. import net.minecraftforge.fml.relauncher.SideOnly;
  10.  
  11. @SideOnly(Side.CLIENT)
  12. public class GuiCrushing extends GuiContainer
  13. {
  14. private static final ResourceLocation furnaceGuiTextures = new ResourceLocation("farmcraft2:textures/gui/container/crushing.png");
  15. /** The player inventory bound to this GUI. */
  16. private final InventoryPlayer playerInventory;
  17. private IInventory tileFurnace;
  18.  
  19. public GuiCrushing(InventoryPlayer playerInv, TileEntityCrushing furnaceInv)
  20. {
  21. super(new ContainerCrushing(playerInv, furnaceInv));
  22. this.playerInventory = playerInv;
  23. this.tileFurnace = furnaceInv;
  24. }
  25.  
  26. /**
  27. * Draw the foreground layer for the GuiContainer (everything in front of the items)
  28. *
  29. * @param mouseX Mouse x coordinate
  30. * @param mouseY Mouse y coordinate
  31. */
  32. protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
  33. {
  34. String s = this.tileFurnace.getDisplayName().getUnformattedText();
  35. this.fontRendererObj.drawString(s, this.xSize / 2 - this.fontRendererObj.getStringWidth(s) / 2, 6, 4210752);
  36. this.fontRendererObj.drawString(this.playerInventory.getDisplayName().getUnformattedText(), 8, this.ySize - 96 + 2, 4210752);
  37. }
  38.  
  39. /**
  40. * Draws the background layer of this container (behind the items).
  41. *
  42. * @param partialTicks How far into the current tick the game is, with 0.0 being the start of the tick and 1.0 being
  43. * the end.
  44. * @param mouseX Mouse x coordinate
  45. * @param mouseY Mouse y coordinate
  46. */
  47. protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY)
  48. {
  49. GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
  50. this.mc.getTextureManager().bindTexture(furnaceGuiTextures);
  51. int i = (this.width - this.xSize) / 2;
  52. int j = (this.height - this.ySize) / 2;
  53. this.drawTexturedModalRect(i, j, 0, 0, this.xSize, this.ySize);
  54.  
  55. if (TileEntityCrushing.isBurning(this.tileFurnace))
  56. {
  57. int k = this.getCookProgressScaled(24);
  58. this.drawTexturedModalRect(i + 56, j + 36 + 12 - k, 176, 12 - k, 14, k + 1);
  59. }
  60.  
  61. int l = this.getCookProgressScaled(24);
  62. this.drawTexturedModalRect(i + 79, j + 34, 176, 14, l + 1, 16);
  63. }
  64.  
  65. private int getCookProgressScaled(int pixels)
  66. {
  67. int i = this.tileFurnace.getField(2);
  68. int j = this.tileFurnace.getField(3);
  69. return j != 0 && i != 0 ? i * pixels / j : 0;
  70. }
  71.  
  72. private int getBurnLeftScaled(int pixels)
  73. {
  74. int i = this.tileFurnace.getField(1);
  75.  
  76. if (i == 0)
  77. {
  78. i = 200;
  79. }
  80.  
  81. return this.tileFurnace.getField(0) * pixels / i;
  82. }
  83. }
Add Comment
Please, Sign In to add comment