Advertisement
Guest User

Untitled

a guest
Jan 27th, 2017
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.37 KB | None | 0 0
  1. package uk.co.rascagneres.gasmod.gui;
  2.  
  3. import net.minecraft.client.gui.inventory.GuiContainer;
  4. import net.minecraft.client.renderer.texture.TextureAtlasSprite;
  5. import net.minecraft.client.renderer.texture.TextureMap;
  6. import net.minecraft.client.resources.I18n;
  7. import net.minecraft.entity.player.InventoryPlayer;
  8. import net.minecraft.init.Blocks;
  9. import net.minecraft.inventory.Container;
  10. import net.minecraft.inventory.IInventory;
  11. import net.minecraft.util.ResourceLocation;
  12. import net.minecraftforge.fluids.Fluid;
  13. import org.w3c.dom.css.Rect;
  14. import uk.co.rascagneres.gasmod.container.GasGeneratorContainer;
  15. import uk.co.rascagneres.gasmod.tileentity.GasGeneratorOneTE;
  16.  
  17. import java.awt.*;
  18. import java.util.*;
  19.  
  20. import static net.minecraft.client.renderer.GlStateManager.color;
  21.  
  22. /**
  23. * Created by Isaac on 23/01/2017.
  24. */
  25. public class GasGeneratorOneGui extends GuiContainer{
  26. private GasGeneratorOneTE gasGeneratorOneTE;
  27. private IInventory playerInv;
  28.  
  29. protected Rectangle fluidBar = new Rectangle(152, 23, 16, 47);
  30.  
  31. public GasGeneratorOneGui(Container inventorySlotsIn) {
  32. super(inventorySlotsIn);
  33. this.xSize = 176;
  34. this.ySize = 186;
  35. }
  36.  
  37. public GasGeneratorOneGui(InventoryPlayer inventory, GasGeneratorOneTE tileEntity) {
  38. this(new GasGeneratorContainer(inventory, tileEntity));
  39. gasGeneratorOneTE = tileEntity;
  40. playerInv = inventory;
  41. }
  42.  
  43. @Override
  44. protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
  45. int i = (this.width - this.xSize)/2;
  46. int j = (this.height - this.ySize)/2;
  47. color(1.0f, 1.0f, 1.0f, 1.0f);
  48. this.mc.getTextureManager().bindTexture(new ResourceLocation("gasmod:textures/gui/container/gas_generator_one_gui.png"));
  49. this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, this.xSize, this.ySize);
  50.  
  51. //Draw fluid
  52. Fluid fluid = gasGeneratorOneTE.getFluidType();
  53. TextureAtlasSprite fluidTexture = mc.getTextureMapBlocks().getTextureExtry(fluid.getStill().toString());
  54. mc.renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
  55. int fluidHeight = gasGeneratorOneTE.getFluidGuiHeight(fluidBar.height);
  56. drawTexturedModalRect(fluidBar.x + guiLeft, fluidBar.y + guiTop + (fluidBar.height - fluidHeight), fluidTexture, fluidBar.width, fluidHeight);
  57.  
  58. //Draw lines over fluid
  59. drawTexturedModalRect(fluidBar.x + guiLeft, fluidBar.y + guiTop, 187, 1, fluidBar.width, fluidBar.height);
  60. }
  61.  
  62. @Override
  63. protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
  64. int i = (this.width - this.xSize)/2;
  65. int j = (this.height - this.ySize)/2;
  66. String s = this.gasGeneratorOneTE.getName();
  67. this.fontRendererObj.drawString(s, 88 - this.fontRendererObj.getStringWidth(s) / 2, 6, 4210752); //#404040
  68. this.fontRendererObj.drawString(this.playerInv.getDisplayName().getUnformattedText(), 8, 92, 4210752);
  69. if(fluidBar.contains(mouseX-guiLeft, mouseY-guiTop));
  70.  
  71. java.util.List<String> list = new ArrayList<String>();
  72. list.add(gasGeneratorOneTE.getFluidType().getUnlocalizedName());
  73. list.add(gasGeneratorOneTE.gasTank.getFluidAmount() + " mB");
  74. this.drawHoveringText(list, mouseX -guiLeft, mouseY - guiTop);
  75.  
  76. }
  77.  
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement