CampFireInventoryGui.java 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. package me.km.networking;
  2. import me.km.KajetansMod;
  3. import me.km.inventory.ContainerCampFire;
  4. import net.minecraft.client.renderer.GlStateManager;
  5. import net.minecraft.inventory.IInventory;
  6. import net.minecraft.util.ResourceLocation;
  7. import net.minecraftforge.fml.relauncher.Side;
  8. import net.minecraftforge.fml.relauncher.SideOnly;
  9. import net.minecraft.client.gui.inventory.GuiContainer;
  10. import net.minecraft.entity.player.InventoryPlayer;
  11. @SideOnly(Side.CLIENT)
  12. public class CampFireInventoryGui extends GuiContainer
  13. {
  14. private static final ResourceLocation FURNACE_GUI_TEXTURES = new ResourceLocation(KajetansMod.MODID, "textures/gui/container/campfire.png");
  15. private final InventoryPlayer pInv;
  16. private final IInventory tileFurnace;
  17. public CampFireInventoryGui(InventoryPlayer pInv, IInventory fireInv)
  18. {
  19. super(new ContainerCampFire(pInv, fireInv));
  20. this.pInv = pInv;
  21. this.tileFurnace = fireInv;
  22. }
  23. @Override
  24. public void drawScreen(int mouseX, int mouseY, float partialTicks)
  25. {
  26. this.drawDefaultBackground();
  27. super.drawScreen(mouseX, mouseY, partialTicks);
  28. this.renderHoveredToolTip(mouseX, mouseY);
  29. }
  30. @Override
  31. protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
  32. {
  33. String s = this.tileFurnace.getDisplayName().getUnformattedText();
  34. this.fontRenderer.drawString(s, this.xSize / 2 - this.fontRenderer.getStringWidth(s) / 2, 6, 4210752);
  35. this.fontRenderer.drawString(this.pInv.getDisplayName().getUnformattedText(), 8, this.ySize - 96 + 2, 4210752);
  36. }
  37. @Override
  38. protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY)
  39. {
  40. GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
  41. this.mc.getTextureManager().bindTexture(FURNACE_GUI_TEXTURES);
  42. int i = (this.width - this.xSize) / 2;
  43. int j = (this.height - this.ySize) / 2;
  44. this.drawTexturedModalRect(i, j, 0, 0, this.xSize, this.ySize);
  45. int l = this.getCookProgressScaled(0);
  46. this.drawTexturedModalRect(i + 75, j + 16, 176, 14, l + 1, 16);
  47. l = this.getCookProgressScaled(1);
  48. this.drawTexturedModalRect(i + 75, j + 34, 176, 14, l + 1, 16);
  49. l = this.getCookProgressScaled(2);
  50. this.drawTexturedModalRect(i + 75, j + 52, 176, 14, l + 1, 16);
  51. }
  52. private int getCookProgressScaled(int id)
  53. {
  54. int i = this.tileFurnace.getField(id);
  55. int j = 200;
  56. return j != 0 && i != 0 ? i * 24 / j : 0;
  57. }
  58. }