-
Notifications
You must be signed in to change notification settings - Fork 497
/
GuiHandler.java
77 lines (58 loc) · 2.01 KB
/
GuiHandler.java
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 buildcraft.factory;
import buildcraft.core.GuiIds;
import buildcraft.factory.gui.ContainerAutoWorkbench;
import buildcraft.factory.gui.ContainerHopper;
import buildcraft.factory.gui.ContainerRefinery;
import buildcraft.factory.gui.GuiAutoCrafting;
import buildcraft.factory.gui.GuiHopper;
import buildcraft.factory.gui.GuiRefinery;
import cpw.mods.fml.common.network.IGuiHandler;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class GuiHandler implements IGuiHandler {
@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
if (!world.blockExists(x, y, z))
return null;
TileEntity tile = world.getBlockTileEntity(x, y, z);
switch (ID) {
case GuiIds.AUTO_CRAFTING_TABLE:
if (!(tile instanceof TileAutoWorkbench))
return null;
return new GuiAutoCrafting(player.inventory, world, (TileAutoWorkbench) tile);
case GuiIds.REFINERY:
if (!(tile instanceof TileRefinery))
return null;
return new GuiRefinery(player.inventory, (TileRefinery) tile);
case GuiIds.HOPPER:
if (!(tile instanceof TileHopper))
return null;
return new GuiHopper(player.inventory, (TileHopper) tile);
default:
return null;
}
}
@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
if (!world.blockExists(x, y, z))
return null;
TileEntity tile = world.getBlockTileEntity(x, y, z);
switch (ID) {
case GuiIds.AUTO_CRAFTING_TABLE:
if (!(tile instanceof TileAutoWorkbench))
return null;
return new ContainerAutoWorkbench(player.inventory, (TileAutoWorkbench) tile);
case GuiIds.REFINERY:
if (!(tile instanceof TileRefinery))
return null;
return new ContainerRefinery(player.inventory, (TileRefinery) tile);
case GuiIds.HOPPER:
if (!(tile instanceof TileHopper))
return null;
return new ContainerHopper(player.inventory, (TileHopper) tile);
default:
return null;
}
}
}