aboutsummaryrefslogtreecommitdiff
path: root/src/Java/binnie/craftgui/extratrees/dictionary/WindowPress.java
blob: 773bc70323287a146ea9b660ac47233514b71aba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package binnie.craftgui.extratrees.dictionary;

import binnie.core.AbstractMod;
import binnie.core.machines.IMachine;
import binnie.core.machines.Machine;
import binnie.core.machines.MachinePackage;
import binnie.core.machines.power.ErrorState.InsufficientPower;
import binnie.craftgui.core.geometry.Position;
import binnie.craftgui.minecraft.ContainerCraftGUI;
import binnie.craftgui.minecraft.InventoryType;
import binnie.craftgui.minecraft.Window;
import binnie.craftgui.minecraft.control.ControlEnergyBar;
import binnie.craftgui.minecraft.control.ControlErrorState;
import binnie.craftgui.minecraft.control.ControlLiquidTank;
import binnie.craftgui.minecraft.control.ControlPlayerInventory;
import binnie.craftgui.minecraft.control.ControlSlot;
import binnie.extratrees.ExtraTrees;
import binnie.extratrees.machines.Press;
import binnie.extratrees.machines.Press.ComponentFruitPressLogic;
import cpw.mods.fml.relauncher.Side;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.nbt.NBTTagCompound;

public class WindowPress
  extends Window
{
  public WindowPress(EntityPlayer player, IInventory inventory, Side side)
  {
    super(194.0F, 192.0F, player, inventory, side);
  }
  
  protected AbstractMod getMod()
  {
    return ExtraTrees.instance;
  }
  
  protected String getName()
  {
    return "Press";
  }
  
  public void initialiseClient()
  {
    setTitle(Machine.getMachine(getInventory()).getPackage().getDisplayName());
    new ControlSlot(this, 24.0F, 52.0F).assign(Press.slotFruit);
    new ControlLiquidTank(this, 99, 32).setTankID(Press.tankWater);
    new ControlEnergyBar(this, 154, 32, 16, 60, Position.Bottom);
    new ControlPlayerInventory(this);
    new ControlErrorState(this, 128.0F, 54.0F);
    new ControlFruitPressProgress(this, 62.0F, 24.0F);
    
    ((Window)getSuperParent()).getContainer().getOrCreateSlot(InventoryType.Machine, Press.slotCurrent);
  }
  
  public static Window create(EntityPlayer player, IInventory inventory, Side side)
  {
    return new WindowPress(player, inventory, side);
  }
  
  public void recieveGuiNBT(Side side, EntityPlayer player, String name, NBTTagCompound action)
  {
    Press.ComponentFruitPressLogic logic = (Press.ComponentFruitPressLogic)Machine.getInterface(Press.ComponentFruitPressLogic.class, getInventory());
    super.recieveGuiNBT(side, player, name, action);
    if ((side == Side.SERVER) && (name.equals("fruitpress-click"))) {
      if ((logic.canWork() == null) && ((logic.canProgress() == null) || ((logic.canProgress() instanceof ErrorState.InsufficientPower))))
      {
        logic.alterProgress(2.0F);
      }
      else if ((side == Side.SERVER) && (name.equals("clear-fruit")))
      {
        logic.setProgress(0.0F);
        getInventory().setInventorySlotContents(Press.slotCurrent, null);
      }
    }
  }
}