From 5074f26ccd99eead77b8defb4c8312f6b28e1033 Mon Sep 17 00:00:00 2001 From: cpw Date: Wed, 2 Sep 2015 13:34:16 -0400 Subject: [PATCH] FMLNetworkHandler.openGui should not try and open a GUI on a FakePlayer. Fixes #2082 and probably dozens of mod errors. Also, side benefit of the merged codebase! FML code can ref Forge code! --- .../fml/common/network/internal/FMLNetworkHandler.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/minecraftforge/fml/common/network/internal/FMLNetworkHandler.java b/src/main/java/net/minecraftforge/fml/common/network/internal/FMLNetworkHandler.java index 01ac4a2935..657bb22ddc 100644 --- a/src/main/java/net/minecraftforge/fml/common/network/internal/FMLNetworkHandler.java +++ b/src/main/java/net/minecraftforge/fml/common/network/internal/FMLNetworkHandler.java @@ -29,6 +29,7 @@ import net.minecraft.network.NetworkManager; import net.minecraft.network.Packet; import net.minecraft.server.management.ServerConfigurationManager; import net.minecraft.world.World; +import net.minecraftforge.common.util.FakePlayer; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.FMLContainer; import net.minecraftforge.fml.common.FMLLog; @@ -73,7 +74,7 @@ public class FMLNetworkHandler 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) + if (entityPlayer instanceof EntityPlayerMP && !(entityPlayer instanceof FakePlayer)) { EntityPlayerMP entityPlayerMP = (EntityPlayerMP) entityPlayer; Container remoteGuiContainer = NetworkRegistry.INSTANCE.getRemoteGuiContainer(mc, entityPlayerMP, modGuiId, world, x, y, z); @@ -92,6 +93,10 @@ public class FMLNetworkHandler entityPlayerMP.openContainer.addCraftingToCrafters(entityPlayerMP); } } + else if (entityPlayer instanceof FakePlayer) + { + // NO OP - I won't even log a message! + } else if (FMLCommonHandler.instance().getSide().equals(Side.CLIENT)) { Object guiContainer = NetworkRegistry.INSTANCE.getLocalGuiContainer(mc, entityPlayer, modGuiId, world, x, y, z);