Guest User

CC-GuiContainer1

a guest
May 3rd, 2015
391
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.55 KB | None | 0 0
  1. package com.cclloyd.ccmodpack;
  2.  
  3. import net.minecraft.client.Minecraft;
  4. import net.minecraft.client.gui.GuiButton;
  5. import net.minecraft.client.gui.inventory.GuiContainer;
  6. import net.minecraft.client.renderer.GlStateManager;
  7. import net.minecraft.entity.player.InventoryPlayer;
  8. import net.minecraft.util.ResourceLocation;
  9. import net.minecraftforge.fml.relauncher.Side;
  10. import net.minecraftforge.fml.relauncher.SideOnly;
  11.  
  12. @SideOnly(Side.CLIENT)
  13. public class WirelessChestGuiContainer extends GuiContainer {
  14.    
  15.     /**
  16.      * GuiInventoryBasic is a simple gui that does nothing but draw a background image and a line of text on the screen
  17.      * everything else is handled by the vanilla container code
  18.      */
  19.    
  20.     private static final ResourceLocation texture = new ResourceLocation("ccmodpack", "textures/gui/container/wirelessChest.png");
  21.     private WirelessChestEntity wirelessChestEntity;
  22.    
  23.     public WirelessChestGuiContainer(InventoryPlayer invPlayer, WirelessChestEntity tile) {
  24.         super(new WirelessChestContainer(invPlayer, tile));
  25.         wirelessChestEntity = tile;
  26.         // Set the width and height of the gui.  Should match the size of the texture!
  27.         xSize = 176;
  28.         ySize = 184;
  29.         this.xSize = 176;
  30.         this.ySize = 184;
  31.  
  32.     }
  33.  
  34.  
  35.     // draw the background for the GUI - rendered first
  36.     @Override
  37.     protected void drawGuiContainerBackgroundLayer(float partialTicks, int x, int y) {
  38.         // Bind the image texture of our custom container
  39.         Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
  40.         // Draw the image
  41.         GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
  42.         drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
  43.     }
  44.  
  45.     // draw the foreground for the GUI - rendered after the slots, but before the dragged items and tooltips
  46.     // renders relative to the top left corner of the background
  47.     @Override
  48.     protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
  49.         //final int LABEL_XPOS = 5;
  50.         //final int LABEL_YPOS = 5;
  51.         //fontRendererObj.drawString(wirelessChestEntity.getDisplayName().getUnformattedText(), LABEL_XPOS, LABEL_YPOS, Color.darkGray.getRGB());
  52.         this.buttonList.add(new GuiButton(1, this.width / 2 - 20, 18, 40, 20, "-1000"));
  53.         this.buttonList.add(new GuiButton(2, this.height / 2 + 20, 18, 40, 20, "+1000"));
  54.     }
  55.    
  56.     @Override
  57.     protected void actionPerformed(GuiButton button) {
  58.         if(button.id==1){
  59.             WirelessChestChangeFrequencyGuiScreen wirelessChestChangeFrequencyScreen = new WirelessChestChangeFrequencyGuiScreen();
  60.             this.mc.displayGuiScreen((WirelessChestChangeFrequencyGuiScreen)wirelessChestChangeFrequencyScreen);
  61.         }
  62.     }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment