forked from xjboss/KCauldronX
Initial commit (Forge 1291).
This commit is contained in:
@ -0,0 +1,51 @@
|
||||
--- ../src-base/minecraft/cpw/mods/fml/common/network/internal/FMLNetworkHandler.java
|
||||
+++ ../src-work/minecraft/cpw/mods/fml/common/network/internal/FMLNetworkHandler.java
|
||||
@@ -47,6 +47,16 @@
|
||||
import cpw.mods.fml.common.registry.EntityRegistry.EntityRegistration;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
+//Cauldron start
|
||||
+import net.minecraft.inventory.IInventory;
|
||||
+import net.minecraft.server.MinecraftServer;
|
||||
+import net.minecraft.tileentity.TileEntity;
|
||||
+import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftInventory;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftInventoryView;
|
||||
+import org.bukkit.event.inventory.InventoryType;
|
||||
+// Cauldron end
|
||||
|
||||
public class FMLNetworkHandler
|
||||
{
|
||||
@@ -75,6 +85,31 @@
|
||||
Container remoteGuiContainer = NetworkRegistry.INSTANCE.getRemoteGuiContainer(mc, entityPlayerMP, modGuiId, world, x, y, z);
|
||||
if (remoteGuiContainer != null)
|
||||
{
|
||||
+ // Cauldron start - create bukkitView for passed container then fire open event.
|
||||
+ if (entityPlayer != null)
|
||||
+ {
|
||||
+ if (remoteGuiContainer.getBukkitView() == null)
|
||||
+ {
|
||||
+ TileEntity te = entityPlayer.worldObj.getTileEntity(x, y, z);
|
||||
+ if (te != null && te instanceof IInventory)
|
||||
+ {
|
||||
+ IInventory teInv = (IInventory)te;
|
||||
+ CraftInventory inventory = new CraftInventory(teInv);
|
||||
+ remoteGuiContainer.bukkitView = new CraftInventoryView(entityPlayer.getBukkitEntity(), inventory, remoteGuiContainer);
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ remoteGuiContainer.bukkitView = new CraftInventoryView(entityPlayer.getBukkitEntity(), MinecraftServer.getServer().server.createInventory(entityPlayer.getBukkitEntity(), InventoryType.CHEST), remoteGuiContainer);
|
||||
+ }
|
||||
+
|
||||
+ remoteGuiContainer = CraftEventFactory.callInventoryOpenEvent((EntityPlayerMP)entityPlayer, remoteGuiContainer, false);
|
||||
+ if (remoteGuiContainer == null)
|
||||
+ {
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ // Cauldron end
|
||||
entityPlayerMP.getNextWindowId();
|
||||
entityPlayerMP.closeContainer();
|
||||
int windowId = entityPlayerMP.currentWindowId;
|
@ -0,0 +1,18 @@
|
||||
--- ../src-base/minecraft/cpw/mods/fml/common/network/internal/HandshakeCompletionHandler.java
|
||||
+++ ../src-work/minecraft/cpw/mods/fml/common/network/internal/HandshakeCompletionHandler.java
|
||||
@@ -13,9 +13,15 @@
|
||||
@Override
|
||||
protected void channelRead0(ChannelHandlerContext ctx, CompleteHandshake msg) throws Exception
|
||||
{
|
||||
+ // Cauldron start - attempt to fix race condition with attr being null
|
||||
+ Object attr = ctx.channel().attr(NetworkDispatcher.FML_DISPATCHER);
|
||||
+ if (attr != null)
|
||||
+ {
|
||||
NetworkDispatcher dispatcher = ctx.channel().attr(NetworkDispatcher.FML_DISPATCHER).getAndRemove();
|
||||
dispatcher.completeHandshake(msg.target);
|
||||
}
|
||||
+ // Cauldron end
|
||||
+ }
|
||||
|
||||
@Override
|
||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception
|
Reference in New Issue
Block a user