Advertisement
Guest User

GuiAdvancedFurnace.java

a guest
Apr 4th, 2019
306
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.13 KB | None | 0 0
  1. package com.herobrine.future.tile.advancedfurnace;
  2.  
  3. import com.herobrine.future.blocks.BlockFurnaceAdvanced;
  4. import net.minecraft.client.gui.inventory.GuiContainer;
  5. import net.minecraft.client.renderer.GlStateManager;
  6. import net.minecraft.client.resources.I18n;
  7. import net.minecraft.entity.player.InventoryPlayer;
  8. import net.minecraft.util.ResourceLocation;
  9.  
  10. public class GuiAdvancedFurnace extends GuiContainer {
  11.     private static final int WIDTH = 176;
  12.     private static final int HEIGHT = 166;
  13.     private final TileAdvancedFurnace te;
  14.     private final InventoryPlayer playerInventory;
  15.  
  16.     private static final ResourceLocation background = new ResourceLocation("textures/gui/container/furnace.png");
  17.  
  18.     public GuiAdvancedFurnace(InventoryPlayer playerInventory, TileAdvancedFurnace te) {
  19.         super(new ContainerAdvancedFurnace(playerInventory, te));
  20.         this.te = te;
  21.         this.playerInventory = playerInventory;
  22.  
  23.         xSize = WIDTH;
  24.         ySize = HEIGHT;
  25.     }
  26.  
  27.     @Override
  28.     protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
  29.         if(te.getType() == BlockFurnaceAdvanced.FurnaceType.SMOKER) {
  30.             String s = I18n.format("container.Smoker");
  31.             this.fontRenderer.drawString(s, this.xSize / 2 - this.fontRenderer.getStringWidth(s) / 2, 6, 4210752);
  32.             this.fontRenderer.drawString(playerInventory.getDisplayName().getUnformattedText(), 8, this.ySize - 93, 4210752);
  33.         }
  34.         if(te.getType() == BlockFurnaceAdvanced.FurnaceType.BLAST_FURNACE) {
  35.             String s = I18n.format("container.BlastFurnace");
  36.             this.fontRenderer.drawString(s, this.xSize / 2 - this.fontRenderer.getStringWidth(s) / 2, 6, 4210752);
  37.             this.fontRenderer.drawString(playerInventory.getDisplayName().getUnformattedText(), 8, this.ySize - 93, 4210752);
  38.         }
  39.     }
  40.  
  41.     @Override
  42.     protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
  43.         GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
  44.         mc.getTextureManager().bindTexture(background);
  45.         int i = (this.width - this.xSize) / 2;
  46.         int j = (this.height - this.ySize) / 2;
  47.  
  48.         this.drawTexturedModalRect(i, j, 0, 0, WIDTH, HEIGHT);
  49.  
  50.         if(this.te.isBurning) {
  51.             int k = getBurnLength();
  52.             this.drawTexturedModalRect(i + 56, j + 36 + 12 - k, 176, 12 - k, 14, k + 1);
  53.         }
  54.  
  55.         int l = getProgressLength();
  56.         this.drawTexturedModalRect(i + 79, j + 34, 176, 14, l + 1, 16);
  57.     }
  58.  
  59.     @Override
  60.     public void drawScreen(int mouseX, int mouseY, float partialTicks) {
  61.         this.drawDefaultBackground();
  62.         super.drawScreen(mouseX, mouseY, partialTicks);
  63.         this.renderHoveredToolTip(mouseX, mouseY);
  64.  
  65.     }
  66.  
  67.     private int getBurnLength() {
  68.         int i = te.itemOriginalFuel;
  69.         if(i == 0) {
  70.             i = 200;
  71.         }
  72.         return te.fuelLeft * 13 / i;
  73.     }
  74.  
  75.     private int getProgressLength() {
  76.         int progress = te.progress;
  77.         int maxProgress = 100;
  78.         return  maxProgress != progress && progress != 0 ? progress * 24 / maxProgress : 0;
  79.     }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement