3
0

Initial commit (Forge 1291).

This commit is contained in:
gamerforEA
2015-03-22 20:38:04 +03:00
commit 16773ead6a
611 changed files with 64826 additions and 0 deletions

View File

@ -0,0 +1,35 @@
--- ../src-base/minecraft/cpw/mods/fml/common/network/handshake/ChannelRegistrationHandler.java
+++ ../src-work/minecraft/cpw/mods/fml/common/network/handshake/ChannelRegistrationHandler.java
@@ -2,6 +2,8 @@
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
+
+import java.io.UnsupportedEncodingException;
import java.util.Set;
import net.minecraft.network.NetworkManager;
import org.apache.logging.log4j.Level;
@@ -24,6 +26,23 @@
msg.payload().readBytes(data);
String channels = new String(data,Charsets.UTF_8);
String[] split = channels.split("\0");
+ // Cauldron start - register bukkit channels for players
+ NetworkDispatcher dispatcher = ctx.channel().attr(NetworkDispatcher.FML_DISPATCHER).get();
+ if (msg.channel().equals("REGISTER"))
+ {
+ for (String channel : split)
+ {
+ dispatcher.player.getBukkitEntity().addChannel(channel);
+ }
+ }
+ else
+ {
+ for (String channel : split)
+ {
+ dispatcher.player.getBukkitEntity().removeChannel(channel);
+ }
+ }
+ // Cauldron end
Set<String> channelSet = ImmutableSet.copyOf(split);
FMLCommonHandler.instance().fireNetRegistrationEvent(manager, channelSet, msg.channel(), side);
}

View File

@ -0,0 +1,45 @@
--- ../src-base/minecraft/cpw/mods/fml/common/network/handshake/NetworkDispatcher.java
+++ ../src-work/minecraft/cpw/mods/fml/common/network/handshake/NetworkDispatcher.java
@@ -72,7 +72,7 @@
public static final AttributeKey<Boolean> IS_LOCAL = new AttributeKey<Boolean>("fml:isLocal");
public final NetworkManager manager;
private final ServerConfigurationManager scm;
- private EntityPlayerMP player;
+ public EntityPlayerMP player; // Cauldron
private ConnectionState state;
private ConnectionType connectionType;
private final Side side;
@@ -202,7 +202,7 @@
}
else
{
- FMLLog.info("Unexpected packet during modded negotiation - assuming vanilla or keepalives : %s", msg.getClass().getName());
+ //FMLLog.info("Unexpected packet during modded negotiation - assuming vanilla or keepalives : %s", msg.getClass().getName()); // Cauldron - unneeded spam
}
return false;
}
@@ -287,6 +287,7 @@
state = ConnectionState.HANDSHAKING;
}
String channelName = msg.func_149559_c();
+ player.getBukkitEntity().addChannel(channelName); // Cauldron - register channel for bukkit player
if ("FML|HS".equals(channelName) || "REGISTER".equals(channelName) || "UNREGISTER".equals(channelName))
{
FMLProxyPacket proxy = new FMLProxyPacket(msg);
@@ -308,6 +309,7 @@
else if (NetworkRegistry.INSTANCE.hasChannel(channelName, Side.SERVER))
{
FMLProxyPacket proxy = new FMLProxyPacket(msg);
+ serverHandler.getCraftServer().getMessenger().dispatchIncomingMessage(player.getBukkitEntity(), msg.func_149559_c(), msg.func_149558_e()); // pass msg to bukkit
proxy.setDispatcher(this);
context.fireChannelRead(proxy);
return true;
@@ -465,7 +467,7 @@
// Stop the epic channel closed spam at close
if (!(cause instanceof ClosedChannelException))
{
- FMLLog.log(Level.ERROR, cause, "NetworkDispatcher exception");
+ //FMLLog.log(Level.ERROR, cause, "NetworkDispatcher exception"); // Cauldron - disable unneeded spam
}
super.exceptionCaught(ctx, cause);
}

View File

@ -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;

View File

@ -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