| 1 | package net.minecraft.client.gui.inventory;
|
| 2 |
|
| 3 | import net.minecraft.client.Minecraft;
|
| 4 | import net.minecraft.client.renderer.GlStateManager;
|
| 5 | import net.minecraft.entity.passive.EntityHorse;
|
| 6 | import net.minecraft.inventory.ContainerHorseInventory;
|
| 7 | import net.minecraft.inventory.IInventory;
|
| 8 | import net.minecraft.util.ResourceLocation;
|
| 9 |
|
| 10 | public class GuiScreenHorseInventory extends GuiContainer
|
| 11 | {
|
| 12 | private static final ResourceLocation horseGuiTextures = new ResourceLocation("textures/gui/container/horse.png");
|
| 13 |
|
| 14 | /** The player inventory bound to this GUI. */
|
| 15 | private IInventory playerInventory;
|
| 16 |
|
| 17 | /** The horse inventory bound to this GUI. */
|
| 18 | private IInventory horseInventory;
|
| 19 |
|
| 20 | /** The EntityHorse whose inventory is currently being accessed. */
|
| 21 | private EntityHorse horseEntity;
|
| 22 |
|
| 23 | /** The mouse x-position recorded during the last rendered frame. */
|
| 24 | private float mousePosx;
|
| 25 |
|
| 26 | /** The mouse y-position recorded during the last renderered frame. */
|
| 27 | private float mousePosY;
|
| 28 |
|
| 29 | public GuiScreenHorseInventory(IInventory playerInv, IInventory horseInv, EntityHorse horse)
|
| 30 | {
|
| 31 | super(new ContainerHorseInventory(playerInv, horseInv, horse, Minecraft.getMinecraft().thePlayer));
|
| 32 | this.playerInventory = playerInv;
|
| 33 | this.horseInventory = horseInv;
|
| 34 | this.horseEntity = horse;
|
| 35 | this.allowUserInput = false;
|
| 36 | }
|
| 37 |
|
| 38 | /**
|
| 39 | * Draw the foreground layer for the GuiContainer (everything in front of the items). Args : mouseX, mouseY
|
| 40 | */
|
| 41 | protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
|
| 42 | {
|
| 43 | this.fontRendererObj.drawString(this.horseInventory.getDisplayName().getUnformattedText(), 8, 6, 4210752);
|
| 44 | this.fontRendererObj.drawString(this.playerInventory.getDisplayName().getUnformattedText(), 8, this.ySize - 96 + 2, 4210752);
|
| 45 | }
|
| 46 |
|
| 47 | /**
|
| 48 | * Args : renderPartialTicks, mouseX, mouseY
|
| 49 | */
|
| 50 | protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY)
|
| 51 | {
|
| 52 | GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
| 53 | this.mc.getTextureManager().bindTexture(horseGuiTextures);
|
| 54 | int i = (this.width - this.xSize) / 2;
|
| 55 | int j = (this.height - this.ySize) / 2;
|
| 56 | this.drawTexturedModalRect(i, j, 0, 0, this.xSize, this.ySize);
|
| 57 |
|
| 58 | if (this.horseEntity.isChested())
|
| 59 | {
|
| 60 | this.drawTexturedModalRect(i + 79, j + 17, 0, this.ySize, 90, 54);
|
| 61 | }
|
| 62 |
|
| 63 | if (this.horseEntity.canWearArmor())
|
| 64 | {
|
| 65 | this.drawTexturedModalRect(i + 7, j + 35, 0, this.ySize + 54, 18, 18);
|
| 66 | }
|
| 67 |
|
| 68 | GuiInventory.drawEntityOnScreen(i + 51, j + 60, 17, (float)(i + 51) - this.mousePosx, (float)(j + 75 - 50) - this.mousePosY, this.horseEntity);
|
| 69 | }
|
| 70 |
|
| 71 | /**
|
| 72 | * Draws the screen and all the components in it. Args : mouseX, mouseY, renderPartialTicks
|
| 73 | */
|
| 74 | public void drawScreen(int mouseX, int mouseY, float partialTicks)
|
| 75 | {
|
| 76 | this.mousePosx = (float)mouseX;
|
| 77 | this.mousePosY = (float)mouseY;
|
| 78 | super.drawScreen(mouseX, mouseY, partialTicks);
|
| 79 | }
|
| 80 | }
|
| 81 |
|