Guest User

GuiBoiler

a guest
May 13th, 2015
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.49 KB | None | 0 0
  1. package com.chef.mod.gui;
  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.util.EnumChatFormatting;
  7. import net.minecraft.util.ResourceLocation;
  8. import net.minecraftforge.fml.relauncher.Side;
  9. import net.minecraftforge.fml.relauncher.SideOnly;
  10.  
  11. import com.chef.mod.Debugger;
  12. import com.chef.mod.Reference;
  13. import com.chef.mod.container.ContainerBoiler;
  14. import com.chef.mod.tileentity.TileEntityBoiler;
  15.  
  16. @SideOnly(Side.CLIENT)
  17. public class GuiBoiler extends GuiContainer {
  18.     private static final ResourceLocation furnaceGuiTextures = new ResourceLocation(Reference.MOD_ID + ":"
  19.             + "textures/gui/container/boiler.png");
  20.     private final InventoryPlayer playerInventory;
  21.     public TileEntityBoiler boiler;
  22.  
  23.     public GuiBoiler(InventoryPlayer playerInv, TileEntityBoiler teBoiler) {
  24.         super(new ContainerBoiler(playerInv, teBoiler));
  25.         this.playerInventory = playerInv;
  26.         this.boiler = teBoiler;
  27.     }
  28.  
  29.     protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
  30.        
  31.         String status;
  32.        
  33.         if (!this.boiler.hasWater()) {
  34.            
  35.             status = EnumChatFormatting.DARK_RED + "No water!";
  36.            
  37.         } else if (this.boiler.water <= 10000) {
  38.            
  39.             status = EnumChatFormatting.DARK_RED + "Not enough water!";
  40.            
  41.         } else if (this.boiler.heath >= 0 && this.boiler.heath < 300) {
  42.            
  43.             status = EnumChatFormatting.DARK_RED + "Too cold!";
  44.            
  45.         } else if (this.boiler.heath < 600) {
  46.            
  47.             status = EnumChatFormatting.YELLOW + "Warm";
  48.            
  49.         } else if (this.boiler.heath < 1200) {
  50.            
  51.             status = EnumChatFormatting.GREEN + "Hot";
  52.            
  53.         } else {
  54.            
  55.             status = EnumChatFormatting.AQUA + "Boiling";
  56.            
  57.         }
  58.        
  59.         this.fontRendererObj.drawString(status, this.xSize / 2 - this.fontRendererObj.getStringWidth(status) + 70, 20, 4210752);
  60.        
  61.         //Debugger.log("THE HEATH OF THE BOILER: " + this.boiler.heath);
  62.         String s = this.boiler.getDisplayName().getUnformattedText();
  63.         this.fontRendererObj.drawString(s, this.xSize / 2 - this.fontRendererObj.getStringWidth(s) / 2, 6, 4210752);
  64.         this.fontRendererObj.drawString(this.playerInventory.getDisplayName().getUnformattedText(), 42, this.ySize - 96 + 3, 4210752);
  65.     }
  66.  
  67.     protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
  68.         GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
  69.         this.mc.getTextureManager().bindTexture(furnaceGuiTextures);
  70.         int k = (this.width - this.xSize) / 2;
  71.         int l = (this.height - this.ySize) / 2;
  72.         this.drawTexturedModalRect(guiLeft, guiTop, 0, 0, this.xSize, this.ySize);
  73.         int time;
  74.  
  75.         // this.drawTexturedModalRect(pixels measured from the left, pixels
  76.         // measured from the top, xSize, from where it begins meeting, lenght,
  77.         // width);
  78.  
  79.         /*
  80.          * this.drawTexturedModalRect(pixels measured from the left,
  81.          * pixelsmeasured from the top, xSize, from where it begins meeting,
  82.          * lenght, width);
  83.          */
  84.        
  85.  
  86.         if (boiler.isBurning()) {
  87.        
  88.         // Fuel remaining bar
  89.         time = boiler.getBurnTimeRemainingScaled(13);
  90.         this.drawTexturedModalRect(guiLeft + 18, guiTop + 48 + 12 - time, 176, 12 - time, 14, time + 1);
  91.  
  92.        
  93.         }
  94.        
  95.         if (boiler.hasWater()) {
  96.            
  97.         time = boiler.getWaterRemainingScaled(25);
  98.         this.drawTexturedModalRect(guiLeft + 16, guiTop + 44 - time, 176, 39 - time, 21, time);
  99.  
  100.         }
  101.        
  102.         // Progress bar
  103.         time = boiler.getCookProgressScaled(24);
  104.         this.drawTexturedModalRect(guiLeft + 99, guiTop + 49, 176, 39, time + 1, 16);
  105.     }
  106. }
Advertisement
Add Comment
Please, Sign In to add comment