Skip to content

Instantly share code, notes, and snippets.

@JayZX535
Last active September 27, 2017 00:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JayZX535/1b9d46ce36a83574cbadf6013d950784 to your computer and use it in GitHub Desktop.
Save JayZX535/1b9d46ce36a83574cbadf6013d950784 to your computer and use it in GitHub Desktop.
package com.wildcraft.wildcraft.client.gui;
import com.wildcraft.wildcraft.entity.canine.EntityWildCraftCanine;
import com.wildcraft.wildcraft.entity.canine.EntityWildCraftWolf;
import com.wildcraft.wildcraft.entity.util.container.WCCanineInventoryContainer;
import com.wildcraft.wildcraft.items.genetics.WCGeneTester;
import com.wildcraft.wildcraft.items.util.container.WCGeneTesterContainer;
import com.wildcraft.wildcraft.util.ModItems;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.network.IGuiHandler;
import net.minecraftforge.items.CapabilityItemHandler;
public class GuiHandler implements IGuiHandler{
public static final int GENE_TESTER = -1;
public static final int CANINE_INVENTORY = 0;
@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
if (ID == CANINE_INVENTORY)
{
EntityWildCraftCanine canine = (EntityWildCraftCanine)world.getEntityByID(x);
if (canine != null)
{
return new WCCanineInventoryContainer(player.inventory, canine);
}
}
if (ID == GENE_TESTER)
{
ItemStack stack = player.getHeldItem(player.getActiveHand());
if (stack != null)
{
System.out.println("Server: Player hand stack is not null");
if (stack.getItem() == ModItems.genetester)
{
System.out.println("Server: Open Gene Tester GUI");
WCGeneTester gt = (WCGeneTester)stack.getItem();
return new WCGeneTesterContainer(player.inventory, gt);
}
}
}
return null;
}
@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
if (ID == CANINE_INVENTORY)
{
EntityWildCraftCanine canine = (EntityWildCraftCanine)world.getEntityByID(x);
if (canine != null)
{
return new GuiWCCanineInv(player.inventory, canine);
}
if (ID == GENE_TESTER)
{
ItemStack stack = player.getHeldItem(player.getActiveHand());
if (stack != null)
{
System.out.println("Client: Player hand stack is not null");
if (stack.getItem() == ModItems.genetester)
{
System.out.println("Client: Open Gene Tester GUI");
WCGeneTester gt = (WCGeneTester)stack.getItem();
return new GuiWCGeneTester(player.inventory, gt);
}
}
}
}
return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment