2015-08-29 14:33:25 +02:00
|
|
|
/*
|
2016-05-16 22:52:27 +02:00
|
|
|
* This file ("GuiCoffeeMachine.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;
|
2015-06-12 19:12:06 +02:00
|
|
|
|
2016-01-05 04:47:35 +01:00
|
|
|
import de.ellpeck.actuallyadditions.mod.inventory.ContainerCoffeeMachine;
|
2016-06-15 16:43:59 +02:00
|
|
|
import de.ellpeck.actuallyadditions.mod.network.PacketClientToServer;
|
2016-01-05 04:47:35 +01:00
|
|
|
import de.ellpeck.actuallyadditions.mod.network.PacketHandler;
|
|
|
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
|
|
|
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityCoffeeMachine;
|
|
|
|
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
|
|
|
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
|
|
|
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
2015-06-12 19:12:06 +02:00
|
|
|
import net.minecraft.client.Minecraft;
|
|
|
|
import net.minecraft.client.gui.GuiButton;
|
|
|
|
import net.minecraft.client.gui.inventory.GuiContainer;
|
2016-01-08 15:21:05 +01:00
|
|
|
import net.minecraft.client.renderer.GlStateManager;
|
2015-06-12 19:12:06 +02:00
|
|
|
import net.minecraft.entity.player.InventoryPlayer;
|
2016-06-15 16:43:59 +02:00
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
2015-06-12 19:12:06 +02:00
|
|
|
import net.minecraft.util.ResourceLocation;
|
|
|
|
import net.minecraft.world.World;
|
2016-01-07 18:20:59 +01:00
|
|
|
import net.minecraftforge.fml.relauncher.Side;
|
|
|
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
2015-06-12 19:12:06 +02:00
|
|
|
|
|
|
|
import java.util.Collections;
|
|
|
|
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
public class GuiCoffeeMachine extends GuiContainer{
|
|
|
|
|
2016-06-17 23:50:38 +02:00
|
|
|
private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("guiCoffeeMachine");
|
2016-05-19 20:05:12 +02:00
|
|
|
private final TileEntityCoffeeMachine machine;
|
|
|
|
private final int x;
|
|
|
|
private final int y;
|
|
|
|
private final int z;
|
|
|
|
private final World world;
|
2015-06-12 19:12:06 +02:00
|
|
|
|
|
|
|
public GuiCoffeeMachine(InventoryPlayer inventory, TileEntityBase tile, int x, int y, int z, World world){
|
|
|
|
super(new ContainerCoffeeMachine(inventory, tile));
|
|
|
|
this.machine = (TileEntityCoffeeMachine)tile;
|
|
|
|
this.xSize = 176;
|
|
|
|
this.ySize = 93+86;
|
|
|
|
this.x = x;
|
|
|
|
this.y = y;
|
|
|
|
this.z = z;
|
|
|
|
this.world = world;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void initGui(){
|
|
|
|
super.initGui();
|
|
|
|
|
2016-05-02 17:46:53 +02:00
|
|
|
GuiButton buttonOkay = new GuiButton(0, this.guiLeft+60, this.guiTop+11, 58, 20, StringUtil.localize("info."+ModUtil.MOD_ID+".gui.ok"));
|
2015-06-12 19:12:06 +02:00
|
|
|
this.buttonList.add(buttonOkay);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-10-03 10:19:40 +02:00
|
|
|
public void drawScreen(int x, int y, float f){
|
|
|
|
super.drawScreen(x, y, f);
|
|
|
|
|
|
|
|
String text1 = this.machine.storage.getEnergyStored()+"/"+this.machine.storage.getMaxEnergyStored()+" RF";
|
2016-05-02 17:46:53 +02:00
|
|
|
if(x >= this.guiLeft+16 && y >= this.guiTop+5 && x <= this.guiLeft+23 && y <= this.guiTop+89){
|
2016-01-08 08:10:55 +01:00
|
|
|
this.drawHoveringText(Collections.singletonList(text1), x, y);
|
2015-10-03 10:19:40 +02:00
|
|
|
}
|
2015-12-27 21:56:32 +01:00
|
|
|
String text3 = StringUtil.getFluidInfo(this.machine.tank);
|
2016-05-02 17:46:53 +02:00
|
|
|
if(x >= this.guiLeft+27 && y >= this.guiTop+5 && x <= this.guiLeft+33 && y <= this.guiTop+70){
|
2016-01-08 08:10:55 +01:00
|
|
|
this.drawHoveringText(Collections.singletonList(text3), x, y);
|
2015-10-03 10:19:40 +02:00
|
|
|
}
|
|
|
|
|
2016-04-20 21:39:03 +02:00
|
|
|
String text2 = this.machine.coffeeCacheAmount+"/"+TileEntityCoffeeMachine.COFFEE_CACHE_MAX_AMOUNT+" "+StringUtil.localize("info."+ModUtil.MOD_ID+".gui.coffee");
|
2016-05-02 17:46:53 +02:00
|
|
|
if(x >= this.guiLeft+40 && y >= this.guiTop+25 && x <= this.guiLeft+49 && y <= this.guiTop+56){
|
2016-01-08 08:10:55 +01:00
|
|
|
this.drawHoveringText(Collections.singletonList(text2), x, y);
|
2015-10-03 10:19:40 +02:00
|
|
|
}
|
2015-06-12 19:12:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void drawGuiContainerForegroundLayer(int x, int y){
|
2016-05-02 17:46:53 +02:00
|
|
|
AssetUtil.displayNameString(this.fontRendererObj, this.xSize, -10, this.machine.getName());
|
2015-06-12 19:12:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void drawGuiContainerBackgroundLayer(float f, int x, int y){
|
2016-01-08 15:21:05 +01:00
|
|
|
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
2015-06-12 19:12:06 +02:00
|
|
|
|
|
|
|
this.mc.getTextureManager().bindTexture(AssetUtil.GUI_INVENTORY_LOCATION);
|
|
|
|
this.drawTexturedModalRect(this.guiLeft, this.guiTop+93, 0, 0, 176, 86);
|
|
|
|
|
2016-06-17 23:50:38 +02:00
|
|
|
this.mc.getTextureManager().bindTexture(RES_LOC);
|
2015-06-12 19:12:06 +02:00
|
|
|
this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93);
|
|
|
|
|
2015-07-02 02:04:51 +02:00
|
|
|
if(this.machine.storage.getEnergyStored() > 0){
|
2015-06-12 19:12:06 +02:00
|
|
|
int i = this.machine.getEnergyScaled(83);
|
2016-05-02 17:46:53 +02:00
|
|
|
this.drawTexturedModalRect(this.guiLeft+17, this.guiTop+89-i, 176, 0, 6, i);
|
2015-06-28 03:12:32 +02:00
|
|
|
}
|
|
|
|
if(this.machine.tank.getFluidAmount() > 0){
|
|
|
|
int i = this.machine.getWaterScaled(64);
|
2016-05-02 17:46:53 +02:00
|
|
|
this.drawTexturedModalRect(this.guiLeft+27, this.guiTop+70-i, 182, 0, 6, i);
|
2015-06-12 19:12:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if(this.machine.coffeeCacheAmount > 0){
|
|
|
|
int i = this.machine.getCoffeeScaled(30);
|
2016-05-02 17:46:53 +02:00
|
|
|
this.drawTexturedModalRect(this.guiLeft+41, this.guiTop+56-i, 192, 0, 8, i);
|
2015-06-12 19:12:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if(this.machine.brewTime > 0){
|
|
|
|
int i = this.machine.getBrewScaled(23);
|
2016-05-02 17:46:53 +02:00
|
|
|
this.drawTexturedModalRect(this.guiLeft+53, this.guiTop+42, 192, 30, i, 16);
|
2015-06-12 19:12:06 +02:00
|
|
|
|
|
|
|
int j = this.machine.getBrewScaled(26);
|
2016-05-02 17:46:53 +02:00
|
|
|
this.drawTexturedModalRect(this.guiLeft+99+25-j, this.guiTop+44, 192+25-j, 46, j, 12);
|
2015-06-12 19:12:06 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-10-03 10:19:40 +02:00
|
|
|
public void actionPerformed(GuiButton button){
|
2016-06-15 16:43:59 +02:00
|
|
|
NBTTagCompound compound = new NBTTagCompound();
|
|
|
|
compound.setInteger("X", this.x);
|
|
|
|
compound.setInteger("Y", this.y);
|
|
|
|
compound.setInteger("Z", this.z);
|
|
|
|
compound.setInteger("WorldID", this.world.provider.getDimension());
|
|
|
|
compound.setInteger("PlayerID", Minecraft.getMinecraft().thePlayer.getEntityId());
|
|
|
|
compound.setInteger("ButtonID", button.id);
|
|
|
|
PacketHandler.theNetwork.sendToServer(new PacketClientToServer(compound, PacketHandler.GUI_BUTTON_TO_TILE_HANDLER));
|
2015-06-12 19:12:06 +02:00
|
|
|
}
|
|
|
|
}
|