ActuallyAdditions/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiGiantChest.java

88 lines
3.6 KiB
Java
Raw Normal View History

2015-08-29 14:33:25 +02:00
/*
2016-05-16 22:52:27 +02:00
* This file ("GuiGiantChest.java") is part of the Actually Additions mod for Minecraft.
2015-08-29 14:33:25 +02:00
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
2016-05-16 22:52:27 +02:00
* http://ellpeck.de/actaddlicense
2015-08-29 14:33:25 +02:00
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
2016-05-16 22:54:42 +02:00
* © 2015-2016 Ellpeck
2015-08-29 14:33:25 +02:00
*/
2016-01-05 04:47:35 +01:00
package de.ellpeck.actuallyadditions.mod.inventory.gui;
2016-01-05 04:47:35 +01:00
import de.ellpeck.actuallyadditions.mod.inventory.ContainerGiantChest;
2016-06-27 20:19:04 +02:00
import de.ellpeck.actuallyadditions.mod.network.PacketClientToServer;
import de.ellpeck.actuallyadditions.mod.network.PacketHandler;
2016-01-05 04:47:35 +01:00
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityGiantChest;
2016-06-27 20:19:04 +02:00
import de.ellpeck.actuallyadditions.mod.tile.TileEntityGiantChestLarge;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityGiantChestMedium;
2016-01-05 04:47:35 +01:00
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
2016-06-27 20:19:04 +02:00
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.player.InventoryPlayer;
2016-06-27 20:19:04 +02:00
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;
2016-01-07 18:20:59 +01:00
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
2016-06-27 20:19:04 +02:00
import java.io.IOException;
@SideOnly(Side.CLIENT)
public class GuiGiantChest extends GuiContainer{
2016-06-17 23:50:38 +02:00
private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("guiGiantChest");
2016-06-27 20:19:04 +02:00
private final TileEntityGiantChest chest;
private final int page;
2015-04-19 01:50:02 +02:00
2016-06-27 20:19:04 +02:00
public GuiGiantChest(InventoryPlayer inventory, TileEntityBase tile, int page){
super(new ContainerGiantChest(inventory, tile, page));
2015-04-19 01:50:02 +02:00
this.chest = (TileEntityGiantChest)tile;
2016-06-27 20:19:04 +02:00
this.page = page;
this.xSize = 242;
2015-03-19 21:27:56 +01:00
this.ySize = 172+86;
}
2016-06-27 20:19:04 +02:00
@Override
public void initGui(){
super.initGui();
if(this.page > 0){
this.buttonList.add(new GuiButton(this.page-1, this.guiLeft+13, this.guiTop+172, 20, 20, "<"));
}
if((this.page == 0 && this.chest instanceof TileEntityGiantChestMedium) || (this.page <= 1 && this.chest instanceof TileEntityGiantChestLarge)){
this.buttonList.add(new GuiButton(this.page+1, this.guiLeft+209, this.guiTop+172, 20, 20, ">"));
}
}
@Override
protected void actionPerformed(GuiButton button) throws IOException{
NBTTagCompound compound = new NBTTagCompound();
compound.setInteger("X", this.chest.getPos().getX());
compound.setInteger("Y", this.chest.getPos().getY());
compound.setInteger("Z", this.chest.getPos().getZ());
compound.setInteger("PlayerID", Minecraft.getMinecraft().thePlayer.getEntityId());
compound.setInteger("WorldID", this.chest.getWorld().provider.getDimension());
compound.setInteger("ButtonID", button.id);
PacketHandler.theNetwork.sendToServer(new PacketClientToServer(compound, PacketHandler.GUI_BUTTON_TO_TILE_HANDLER));
}
2015-04-19 01:50:02 +02:00
@Override
public void drawGuiContainerForegroundLayer(int x, int y){
AssetUtil.displayNameString(this.fontRendererObj, this.xSize, -10, this.chest);
2015-04-19 01:50:02 +02:00
}
@Override
public void drawGuiContainerBackgroundLayer(float f, int x, int y){
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
2016-06-17 23:50:38 +02:00
this.mc.getTextureManager().bindTexture(RES_LOC);
2015-03-19 21:27:56 +01:00
this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 242, 190);
2015-03-29 15:29:05 +02:00
this.mc.getTextureManager().bindTexture(AssetUtil.GUI_INVENTORY_LOCATION);
2015-03-19 21:27:56 +01:00
this.drawTexturedModalRect(this.guiLeft+33, this.guiTop+172, 0, 0, 176, 86);
}
}