Guest User

GuiClayGolem

a guest
May 9th, 2014
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.20 KB | None | 0 0
  1. package claygolem.client.gui;
  2.  
  3. import java.util.ArrayList; [..]
  4.  
  5. @SideOnly(Side.CLIENT)
  6. public class GuiClayGolem extends GuiContainer
  7. {
  8.     private static final ResourceLocation _horseGuiTextures = new ResourceLocation(ModConst._MODID, "textures/gui/container/claygolem.png");
  9.     private IInventory _playerInventory;
  10.     private IInventory _claygolemInventory;
  11.     private EntityClayGolem _claygolem;
  12.     private float _screenWidth;
  13.     private float _screenHeight;
  14.     private static final String __OBFID = "CL_00000760";
  15.     private boolean _showOptions = false;
  16.     private String _enabled = "enabled";
  17.     private String _disabled = "disabled";
  18.     protected GuiButton _nbtButton;
  19.  
  20.     public GuiClayGolem(IInventory par1IInventory, IInventory par2IInventory, EntityClayGolem par3ClayGolem)
  21.     {
  22.         super(new ContainerClayGolem(par1IInventory, par2IInventory, par3ClayGolem));
  23.         this._playerInventory = par1IInventory;
  24.         this._claygolemInventory = par2IInventory;
  25.         this._claygolem = par3ClayGolem;
  26.         this.allowUserInput = false;
  27.     }
  28.  
  29.     @Override
  30.     public void initGui()
  31.     {
  32.         int width = (this.width - this.xSize) / 2;
  33.         int height = (this.height - this.ySize) / 2;
  34.         this.buttonList.add(0, new GuiButtonOptions(0, width + 5, height + 40));
  35.         this._nbtButton = new GuiButton(1, width + 26, height + 50, 52, 20, _disabled);
  36.         this.buttonList.add(_nbtButton);
  37.         super.initGui();
  38.     }
  39.    
  40.     @Override
  41.     protected void actionPerformed(GuiButton guibutton)
  42.     {
  43.         if (guibutton instanceof GuiButtonOptions)
  44.             _showOptions = !_showOptions;
  45.         else if (guibutton instanceof GuiButton)
  46.             if(guibutton.id == 1)
  47.                 ClayGolem.packetPipeline.sendToServer(new PacketUpdateClayGolem(this._claygolem, !this._claygolem.isSetWithNBT()));
  48.     }
  49.    
  50.     /**
  51.      * Draw the foreground layer for the GuiContainer (everything in front of the items)
  52.      */
  53.     @Override
  54.     protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_)
  55.     {
  56.         this.fontRendererObj.drawString(this._claygolemInventory.hasCustomInventoryName() ? this._claygolemInventory.getInventoryName() : I18n.format(this._claygolemInventory.getInventoryName(), new Object[0]), 8, 6, 4210752);
  57.         this.fontRendererObj.drawString(this._playerInventory.hasCustomInventoryName() ? this._playerInventory.getInventoryName() : I18n.format(this._playerInventory.getInventoryName(), new Object[0]), 8, this.ySize - 96 + 2, 4210752);
  58.     }
  59.    
  60.     @Override
  61.     protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_)
  62.     {
  63.         GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
  64.         this.mc.getTextureManager().bindTexture(_horseGuiTextures);
  65.         int k = (this.width - this.xSize) / 2;
  66.         int l = (this.height - this.ySize) / 2;
  67.         this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
  68.  
  69.         if (this._claygolem.isChested())
  70.         {
  71.             this.drawTexturedModalRect(k + 79, l + 17, 0, this.ySize, 90, 54);
  72.         }
  73.        
  74.         if(_showOptions) {
  75.             drawCenteredString(fontRendererObj, "\247fsome text", (width / 2)-40, (height / 2)-60, 0xffffaa);
  76.             this._nbtButton.visible = true;
  77.            
  78.             if(_claygolem.GetItemStack() != null) {
  79.                 System.out.println(_claygolem.GetItemStack());
  80.             }
  81.            
  82.             if(_claygolem.isSetWithNBT())
  83.                 this._nbtButton.displayString = _enabled;
  84.             else
  85.                 this._nbtButton.displayString = _disabled;
  86.         }
  87.         else {
  88.             GuiInventory.func_147046_a(k + 51, l + 60, 30, (float)(k + 51) - this._screenWidth, (float)(l + 75 - 50) - this._screenHeight, this._claygolem);
  89.             this._nbtButton.visible = false;
  90.         }
  91.     }
  92.  
  93.     /**
  94.      * Draws the screen and all the components in it.
  95.      */
  96.     @Override
  97.     public void drawScreen(int par1, int par2, float par3)
  98.     {
  99.         this._screenWidth = (float)par1;
  100.         this._screenHeight = (float)par2;
  101.         try{
  102.             super.drawScreen(par1, par2, par3);
  103.         }catch (Exception e){
  104.             System.out.println("Prevented guiscreen from opening server-sided");
  105.         }
  106.     }
  107. }
Advertisement
Add Comment
Please, Sign In to add comment