dispatcher.clientToServerHandshake();
}
public static void openGui(EntityPlayer entityPlayer, Object mod, int modGuiId, World world, int x, int y, int z)
{
ModContainer mc = FMLCommonHandler.instance().findContainerFor(mod);
if (entityPlayer instanceof EntityPlayerMP)
{
EntityPlayerMP entityPlayerMP = (EntityPlayerMP) entityPlayer;
Container remoteGuiContainer = NetworkRegistry.INSTANCE.getRemoteGuiContainer(mc, entityPlayerMP, modGuiId, world, x, y, z);
if (remoteGuiContainer != null)
{
entityPlayerMP.getNextWindowId();
entityPlayerMP.closeContainer();
int windowId = entityPlayerMP.currentWindowId;
FMLMessage.OpenGui openGui = new FMLMessage.OpenGui(windowId, mc.getModId(), modGuiId, x, y, z);
EmbeddedChannel embeddedChannel = channelPair.get(Side.SERVER);
embeddedChannel.attr(FMLOutboundHandler.FML_MESSAGETARGET).set(OutboundTarget.PLAYER);
embeddedChannel.attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(entityPlayerMP);
embeddedChannel.writeOutbound(openGui);
entityPlayerMP.openContainer = remoteGuiContainer;
entityPlayerMP.openContainer.windowId = windowId;
entityPlayerMP.openContainer.addCraftingToCrafters(entityPlayerMP);
}
}
else if (FMLCommonHandler.instance().getSide().equals(Side.CLIENT))
{
Object guiContainer = NetworkRegistry.INSTANCE.getLocalGuiContainer(mc, entityPlayer, modGuiId, world, x, y, z);
FMLCommonHandler.instance().showGuiScreen(guiContainer);
}
else
{
FMLLog.fine("Invalid attempt to open a local GUI on a dedicated server. This is likely a bug. GUIID: %s,%d", mc.getModId(), modGuiId);
}
}