Advertisement
Guest User

Untitled

a guest
Jul 2nd, 2017
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.42 KB | None | 0 0
  1. package com.minecolonies.coremod.inventory;
  2.  
  3. import com.minecolonies.coremod.tileentities.TileEntityRack;
  4. import net.minecraft.client.gui.inventory.GuiContainer;
  5. import net.minecraft.client.renderer.GlStateManager;
  6. import net.minecraft.entity.player.InventoryPlayer;
  7. import net.minecraft.util.ResourceLocation;
  8. import net.minecraft.util.math.BlockPos;
  9. import net.minecraft.world.World;
  10. import net.minecraftforge.fml.relauncher.Side;
  11. import net.minecraftforge.fml.relauncher.SideOnly;
  12. import net.minecraftforge.items.IItemHandler;
  13.  
  14. @SideOnly(Side.CLIENT)
  15. public class GuiRack extends GuiContainer
  16. {
  17. /** The ResourceLocation containing the chest GUI texture. */
  18. private static final ResourceLocation CHEST_GUI_TEXTURE = new ResourceLocation("textures/gui/container/generic_54.png");
  19. private final IItemHandler upperChestInventory;
  20. private final IItemHandler lowerChestInventory;
  21. /** window height is calculated with these values; the more rows, the heigher */
  22. private final int inventoryRows;
  23.  
  24. public GuiRack(final InventoryPlayer parInventoryPlayer, final TileEntityRack tileEntity, final World world, final BlockPos location)
  25. {
  26. super(new ContainerRack(tileEntity, parInventoryPlayer, world, location));
  27. this.upperChestInventory = tileEntity.getInventory();
  28. final TileEntityRack neighborRack = tileEntity.getOtherChest();
  29. if(neighborRack != null)
  30. {
  31. this.lowerChestInventory = neighborRack.getInventory();
  32. this.inventoryRows = lowerChestInventory.getSlots() / 9;
  33. }
  34. else
  35. {
  36. this.lowerChestInventory = null;
  37. this.inventoryRows = upperChestInventory.getSlots() / 9;
  38. }
  39. this.allowUserInput = false;
  40. this.ySize = 114 + this.inventoryRows * 18;
  41. }
  42.  
  43. /**
  44. * Draws the background layer of this container (behind the items).
  45. */
  46. protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY)
  47. {
  48. GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
  49. this.mc.getTextureManager().bindTexture(CHEST_GUI_TEXTURE);
  50. int i = (this.width - this.xSize) / 2;
  51. int j = (this.height - this.ySize) / 2;
  52. this.drawTexturedModalRect(i, j, 0, 0, this.xSize, this.inventoryRows * 18 + 17);
  53. this.drawTexturedModalRect(i, j + this.inventoryRows * 18 + 17, 0, 126, this.xSize, 96);
  54. }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement