package link.infra.simpleprocessors.proxy;

import link.infra.simpleprocessors.blocks.programmer.ProgrammerContainer;
import link.infra.simpleprocessors.blocks.programmer.ProgrammerTileEntity;
import link.infra.simpleprocessors.gui.ProgrammerGui;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.network.IGuiHandler;

public class GuiProxy implements IGuiHandler {

	@Override
	public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
		BlockPos pos = new BlockPos(x, y, z);
		TileEntity te = world.getTileEntity(pos);
		if (te instanceof ProgrammerTileEntity) {
			return new ProgrammerContainer(player.inventory, (ProgrammerTileEntity) te);
		}
		return null;
	}

	@Override
	public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
		BlockPos pos = new BlockPos(x, y, z);
		TileEntity te = world.getTileEntity(pos);
		if (te instanceof ProgrammerTileEntity) {
			ProgrammerTileEntity containerTileEntity = (ProgrammerTileEntity) te;
			return new ProgrammerGui(containerTileEntity, new ProgrammerContainer(player.inventory, containerTileEntity));
		}
		return null;
	}
}

@@ -37,16 +37,81 @@
 proxy;%0A%0A
+import link.infra.simpleprocessors.blocks.programmer.Programmer;%0A
 import l
@@ -683,32 +683,66 @@
 int y, int z) %7B%0A
+%09%09if (ID == Programmer.GUI_ID) %7B%0A%09
 %09%09BlockPos pos =
@@ -757,32 +757,33 @@
 ckPos(x, y, z);%0A
+%09
 %09%09TileEntity te 
@@ -802,32 +802,33 @@
 ileEntity(pos);%0A
+%09
 %09%09if (te instanc
@@ -854,24 +854,25 @@
 ntity) %7B%0A%09%09%09
+%09
 return new P
@@ -936,20 +936,25 @@
 y) te);%0A
+%09
 %09%09%7D%0A
+%09%09%7D%0A
 %09%09return
@@ -1075,16 +1075,50 @@
 nt z) %7B%0A
+%09%09if (ID == Programmer.GUI_ID) %7B%0A%09
 %09%09BlockP
@@ -1149,16 +1149,17 @@
  y, z);%0A
+%09
 %09%09TileEn
@@ -1194,16 +1194,17 @@
 y(pos);%0A
+%09
 %09%09if (te
@@ -1242,16 +1242,17 @@
 y) %7B%0A%09%09%09
+%09
 Programm
@@ -1313,16 +1313,17 @@
 ty) te;%0A
+%09
 %09%09%09retur
@@ -1428,16 +1428,21 @@
 tity));%0A
+%09%09%09%7D%0A
 %09%09%7D%0A%09%09re

check GUI_ID