diff --git a/fml/patches/minecraft/net/minecraft/client/Minecraft.java.patch b/fml/patches/minecraft/net/minecraft/client/Minecraft.java.patch index dd4c8406d..2d13c36f1 100644 --- a/fml/patches/minecraft/net/minecraft/client/Minecraft.java.patch +++ b/fml/patches/minecraft/net/minecraft/client/Minecraft.java.patch @@ -44,7 +44,7 @@ Display.setVSyncEnabled(this.field_71474_y.field_74352_v); } -@@ -916,9 +925,11 @@ +@@ -915,9 +924,11 @@ if (!this.field_71454_w) { @@ -56,7 +56,7 @@ } GL11.glFlush(); -@@ -1491,11 +1502,15 @@ +@@ -1490,11 +1501,15 @@ public void func_71407_l() { @@ -72,7 +72,7 @@ this.field_71424_I.func_76320_a("gui"); if (!this.field_71445_n) -@@ -1978,6 +1993,8 @@ +@@ -1977,6 +1992,8 @@ this.field_71453_ak.func_74428_b(); } diff --git a/fml/patches/minecraft/net/minecraft/client/network/NetHandlerLoginClient.java.patch b/fml/patches/minecraft/net/minecraft/client/network/NetHandlerLoginClient.java.patch index 071f23c26..d51cde63c 100644 --- a/fml/patches/minecraft/net/minecraft/client/network/NetHandlerLoginClient.java.patch +++ b/fml/patches/minecraft/net/minecraft/client/network/NetHandlerLoginClient.java.patch @@ -5,7 +5,7 @@ import com.mojang.authlib.minecraft.MinecraftSessionService; import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService; + -+import cpw.mods.fml.common.network.FMLNetworkHandler; ++import cpw.mods.fml.common.network.internal.FMLNetworkHandler; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import io.netty.util.concurrent.Future; diff --git a/fml/patches/minecraft/net/minecraft/entity/EntityTrackerEntry.java.patch b/fml/patches/minecraft/net/minecraft/entity/EntityTrackerEntry.java.patch index b823e8030..17616ed0c 100644 --- a/fml/patches/minecraft/net/minecraft/entity/EntityTrackerEntry.java.patch +++ b/fml/patches/minecraft/net/minecraft/entity/EntityTrackerEntry.java.patch @@ -4,7 +4,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -+import cpw.mods.fml.common.network.FMLNetworkHandler; ++import cpw.mods.fml.common.network.internal.FMLNetworkHandler; + public class EntityTrackerEntry { @@ -18,7 +18,7 @@ + int posZ = MathHelper.func_76128_c(this.field_73132_a.field_70161_v * 32.0D); + if (posX != this.field_73128_d || posY != this.field_73129_e || posZ != this.field_73126_f) + { -+ FMLNetworkHandler.makeEntitySpawnAdjustment(this.field_73132_a.func_145782_y(), p_73117_1_, this.field_73128_d, this.field_73129_e, this.field_73126_f); ++ FMLNetworkHandler.makeEntitySpawnAdjustment(this.field_73132_a, p_73117_1_, this.field_73128_d, this.field_73129_e, this.field_73126_f); + } + if (this.field_73143_t && !(packet instanceof S0FPacketSpawnMob)) diff --git a/fml/patches/minecraft/net/minecraft/entity/player/EntityPlayer.java.patch b/fml/patches/minecraft/net/minecraft/entity/player/EntityPlayer.java.patch index 052754460..ba5d33a20 100644 --- a/fml/patches/minecraft/net/minecraft/entity/player/EntityPlayer.java.patch +++ b/fml/patches/minecraft/net/minecraft/entity/player/EntityPlayer.java.patch @@ -6,7 +6,7 @@ import com.mojang.authlib.GameProfile; + +import cpw.mods.fml.common.FMLCommonHandler; -+import cpw.mods.fml.common.network.FMLNetworkHandler; ++import cpw.mods.fml.common.network.internal.FMLNetworkHandler; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import java.util.Collection; diff --git a/fml/patches/minecraft/net/minecraft/network/NetworkManager.java.patch b/fml/patches/minecraft/net/minecraft/network/NetworkManager.java.patch index 1c6db6c3e..296b6b8ba 100644 --- a/fml/patches/minecraft/net/minecraft/network/NetworkManager.java.patch +++ b/fml/patches/minecraft/net/minecraft/network/NetworkManager.java.patch @@ -5,7 +5,7 @@ import com.google.common.collect.Queues; import com.google.common.util.concurrent.ThreadFactoryBuilder; + -+import cpw.mods.fml.common.network.FMLProxyPacket; ++import cpw.mods.fml.common.network.internal.FMLProxyPacket; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import io.netty.bootstrap.Bootstrap; diff --git a/fml/patches/minecraft/net/minecraft/network/NetworkSystem.java.patch b/fml/patches/minecraft/net/minecraft/network/NetworkSystem.java.patch index c2da21019..30499b805 100644 --- a/fml/patches/minecraft/net/minecraft/network/NetworkSystem.java.patch +++ b/fml/patches/minecraft/net/minecraft/network/NetworkSystem.java.patch @@ -5,7 +5,7 @@ import com.google.common.util.concurrent.ThreadFactoryBuilder; + -+import cpw.mods.fml.common.network.FMLNetworkHandler; ++import cpw.mods.fml.common.network.internal.FMLNetworkHandler; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import io.netty.bootstrap.ServerBootstrap; diff --git a/fml/patches/minecraft/net/minecraft/server/network/NetHandlerLoginServer.java.patch b/fml/patches/minecraft/net/minecraft/server/network/NetHandlerLoginServer.java.patch index 29175a0cd..8890e8b52 100644 --- a/fml/patches/minecraft/net/minecraft/server/network/NetHandlerLoginServer.java.patch +++ b/fml/patches/minecraft/net/minecraft/server/network/NetHandlerLoginServer.java.patch @@ -5,7 +5,7 @@ import com.mojang.authlib.GameProfile; import com.mojang.authlib.exceptions.AuthenticationUnavailableException; + -+import cpw.mods.fml.common.network.FMLNetworkHandler; ++import cpw.mods.fml.common.network.internal.FMLNetworkHandler; import io.netty.util.concurrent.GenericFutureListener; import java.math.BigInteger; import java.security.PrivateKey; diff --git a/fml/src/main/java/cpw/mods/fml/client/FMLClientHandler.java b/fml/src/main/java/cpw/mods/fml/client/FMLClientHandler.java index deccfae51..fb19b35bc 100644 --- a/fml/src/main/java/cpw/mods/fml/client/FMLClientHandler.java +++ b/fml/src/main/java/cpw/mods/fml/client/FMLClientHandler.java @@ -30,12 +30,10 @@ import net.minecraft.client.resources.IReloadableResourceManager; import net.minecraft.client.resources.IResourcePack; import net.minecraft.crash.CrashReport; import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLiving; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.launchwrapper.Launch; import net.minecraft.network.NetworkManager; import net.minecraft.server.MinecraftServer; -import net.minecraft.world.World; import com.google.common.base.Throwables; import com.google.common.collect.ImmutableList; @@ -57,12 +55,6 @@ import cpw.mods.fml.common.ModContainer; import cpw.mods.fml.common.ModMetadata; import cpw.mods.fml.common.ObfuscationReflectionHelper; import cpw.mods.fml.common.WrongMinecraftVersionException; -import cpw.mods.fml.common.network.FMLMessage.EntitySpawnMessage; -import cpw.mods.fml.common.network.packet.EntitySpawnAdjustmentPacket; -import cpw.mods.fml.common.network.packet.EntitySpawnPacket; -import cpw.mods.fml.common.registry.EntityRegistry.EntityRegistration; -import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData; -import cpw.mods.fml.common.registry.IThrowableEntity; import cpw.mods.fml.common.toposort.ModSortingException; import cpw.mods.fml.relauncher.Side; @@ -389,22 +381,6 @@ public class FMLClientHandler implements IFMLSidedHandler return client.field_71439_g; } - @Override - public void adjustEntityLocationOnClient(EntitySpawnAdjustmentPacket packet) - { - Entity ent = client.field_71441_e.func_73045_a(packet.entityId); - if (ent != null) - { - ent.field_70118_ct = packet.serverX; - ent.field_70117_cu = packet.serverY; - ent.field_70116_cv = packet.serverZ; - } - else - { - FMLLog.fine("Attempted to adjust the position of entity %d which is not present on the client", packet.entityId); - } - } - @Override public void beginServerLoading(MinecraftServer server) { diff --git a/fml/src/main/java/cpw/mods/fml/common/FMLCommonHandler.java b/fml/src/main/java/cpw/mods/fml/common/FMLCommonHandler.java index 3e299b3a3..9701c409a 100644 --- a/fml/src/main/java/cpw/mods/fml/common/FMLCommonHandler.java +++ b/fml/src/main/java/cpw/mods/fml/common/FMLCommonHandler.java @@ -41,7 +41,6 @@ import com.google.common.collect.MapMaker; import com.google.common.collect.Maps; import com.google.common.collect.Sets; -import cpw.mods.fml.common.network.packet.EntitySpawnAdjustmentPacket; import cpw.mods.fml.common.registry.TickRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.server.FMLServerHandler; @@ -325,11 +324,6 @@ public class FMLCommonHandler sidedDelegate.showGuiScreen(clientGuiElement); } - public void adjustEntityLocationOnClient(EntitySpawnAdjustmentPacket entitySpawnAdjustmentPacket) - { - sidedDelegate.adjustEntityLocationOnClient(entitySpawnAdjustmentPacket); - } - public void onServerStart(MinecraftServer dedicatedServer) { FMLServerHandler.instance(); diff --git a/fml/src/main/java/cpw/mods/fml/common/FMLContainer.java b/fml/src/main/java/cpw/mods/fml/common/FMLContainer.java index 78faba510..0ecc0ce23 100644 --- a/fml/src/main/java/cpw/mods/fml/common/FMLContainer.java +++ b/fml/src/main/java/cpw/mods/fml/common/FMLContainer.java @@ -12,12 +12,9 @@ package cpw.mods.fml.common; -import io.netty.channel.embedded.EmbeddedChannel; - import java.io.File; import java.security.cert.Certificate; import java.util.Arrays; -import java.util.EnumMap; import java.util.Map; import java.util.Map.Entry; import java.util.logging.Level; @@ -36,13 +33,9 @@ import cpw.mods.fml.client.FMLFileResourcePack; import cpw.mods.fml.client.FMLFolderResourcePack; import cpw.mods.fml.common.asm.FMLSanityChecker; import cpw.mods.fml.common.event.FMLConstructionEvent; -import cpw.mods.fml.common.network.EntitySpawnHandler; -import cpw.mods.fml.common.network.FMLNetworkHandler; -import cpw.mods.fml.common.network.FMLRuntimeCodec; import cpw.mods.fml.common.network.NetworkCheckHandler; -import cpw.mods.fml.common.network.NetworkModHolder; import cpw.mods.fml.common.network.NetworkRegistry; -import cpw.mods.fml.common.network.OpenGuiHandler; +import cpw.mods.fml.common.network.internal.FMLNetworkHandler; import cpw.mods.fml.common.registry.GameData; import cpw.mods.fml.relauncher.Side; @@ -52,8 +45,6 @@ import cpw.mods.fml.relauncher.Side; */ public class FMLContainer extends DummyModContainer implements WorldAccessContainer { - private EnumMap channelPair; - public FMLContainer() { super(new ModMetadata()); diff --git a/fml/src/main/java/cpw/mods/fml/common/IFMLSidedHandler.java b/fml/src/main/java/cpw/mods/fml/common/IFMLSidedHandler.java index afd62b9be..3e06d7f86 100644 --- a/fml/src/main/java/cpw/mods/fml/common/IFMLSidedHandler.java +++ b/fml/src/main/java/cpw/mods/fml/common/IFMLSidedHandler.java @@ -14,12 +14,8 @@ package cpw.mods.fml.common; import java.util.List; -import net.minecraft.entity.Entity; import net.minecraft.network.NetworkManager; import net.minecraft.server.MinecraftServer; -import cpw.mods.fml.common.network.packet.EntitySpawnAdjustmentPacket; -import cpw.mods.fml.common.network.packet.EntitySpawnPacket; -import cpw.mods.fml.common.registry.EntityRegistry.EntityRegistration; import cpw.mods.fml.relauncher.Side; public interface IFMLSidedHandler @@ -32,8 +28,6 @@ public interface IFMLSidedHandler void showGuiScreen(Object clientGuiElement); - void adjustEntityLocationOnClient(EntitySpawnAdjustmentPacket entitySpawnAdjustmentPacket); - void beginServerLoading(MinecraftServer server); void finishServerLoading(); diff --git a/fml/src/main/java/cpw/mods/fml/common/ModContainer.java b/fml/src/main/java/cpw/mods/fml/common/ModContainer.java index ee837ff62..eaeb9c583 100644 --- a/fml/src/main/java/cpw/mods/fml/common/ModContainer.java +++ b/fml/src/main/java/cpw/mods/fml/common/ModContainer.java @@ -21,7 +21,6 @@ import java.util.Set; import com.google.common.collect.ImmutableMap; import com.google.common.eventbus.EventBus; -import cpw.mods.fml.common.network.NetworkModHolder; import cpw.mods.fml.common.versioning.ArtifactVersion; import cpw.mods.fml.common.versioning.VersionRange; diff --git a/fml/src/main/java/cpw/mods/fml/common/ModMetadata.java b/fml/src/main/java/cpw/mods/fml/common/ModMetadata.java index 61978d869..59da5d6a5 100644 --- a/fml/src/main/java/cpw/mods/fml/common/ModMetadata.java +++ b/fml/src/main/java/cpw/mods/fml/common/ModMetadata.java @@ -12,7 +12,6 @@ package cpw.mods.fml.common; -import java.util.Collection; import java.util.List; import java.util.Set; diff --git a/fml/src/main/java/cpw/mods/fml/common/asm/FMLSanityChecker.java b/fml/src/main/java/cpw/mods/fml/common/asm/FMLSanityChecker.java index d3c40a137..0e9b0a173 100644 --- a/fml/src/main/java/cpw/mods/fml/common/asm/FMLSanityChecker.java +++ b/fml/src/main/java/cpw/mods/fml/common/asm/FMLSanityChecker.java @@ -22,15 +22,8 @@ import java.util.jar.JarEntry; import java.util.jar.JarFile; import java.util.logging.Level; -import javax.swing.JOptionPane; - import net.minecraft.launchwrapper.LaunchClassLoader; -import org.objectweb.asm.ClassReader; -import org.objectweb.asm.ClassVisitor; -import org.objectweb.asm.FieldVisitor; -import org.objectweb.asm.Opcodes; - import com.google.common.base.Charsets; import com.google.common.io.ByteStreams; diff --git a/fml/src/main/java/cpw/mods/fml/common/event/FMLModIdMappingEvent.java b/fml/src/main/java/cpw/mods/fml/common/event/FMLModIdMappingEvent.java index 80b482059..b25671c6f 100644 --- a/fml/src/main/java/cpw/mods/fml/common/event/FMLModIdMappingEvent.java +++ b/fml/src/main/java/cpw/mods/fml/common/event/FMLModIdMappingEvent.java @@ -40,7 +40,7 @@ public class FMLModIdMappingEvent extends FMLEvent { @Override public int compare(ModRemapping o1, ModRemapping o2) { - return Integer.compare(o1.newId,o2.newId); + return (o1.newId < o2.newId) ? -1 : ((o1.newId == o2.newId) ? 0 : 1); } }); remappedIds = ImmutableList.copyOf(remappings); diff --git a/fml/src/main/java/cpw/mods/fml/common/network/FMLIndexedMessageToMessageCodec.java b/fml/src/main/java/cpw/mods/fml/common/network/FMLIndexedMessageToMessageCodec.java index 564a8fbee..4ed506a6b 100644 --- a/fml/src/main/java/cpw/mods/fml/common/network/FMLIndexedMessageToMessageCodec.java +++ b/fml/src/main/java/cpw/mods/fml/common/network/FMLIndexedMessageToMessageCodec.java @@ -2,6 +2,8 @@ package cpw.mods.fml.common.network; import java.util.List; +import cpw.mods.fml.common.network.internal.FMLProxyPacket; + import gnu.trove.map.hash.TByteObjectHashMap; import gnu.trove.map.hash.TObjectByteHashMap; import io.netty.buffer.ByteBuf; diff --git a/fml/src/main/java/cpw/mods/fml/common/network/FMLOutboundHandler.java b/fml/src/main/java/cpw/mods/fml/common/network/FMLOutboundHandler.java index 3bf5188ef..72de8d60a 100644 --- a/fml/src/main/java/cpw/mods/fml/common/network/FMLOutboundHandler.java +++ b/fml/src/main/java/cpw/mods/fml/common/network/FMLOutboundHandler.java @@ -15,6 +15,7 @@ import com.google.common.collect.ImmutableList; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint; import cpw.mods.fml.common.network.handshake.NetworkDispatcher; +import cpw.mods.fml.common.network.internal.FMLProxyPacket; import cpw.mods.fml.relauncher.Side; public class FMLOutboundHandler extends ChannelOutboundHandlerAdapter { diff --git a/fml/src/main/java/cpw/mods/fml/common/network/IFMLMessage.java b/fml/src/main/java/cpw/mods/fml/common/network/IFMLMessage.java deleted file mode 100644 index 41d54a759..000000000 --- a/fml/src/main/java/cpw/mods/fml/common/network/IFMLMessage.java +++ /dev/null @@ -1,9 +0,0 @@ -package cpw.mods.fml.common.network; - -import io.netty.buffer.ByteBuf; - -public interface IFMLMessage { - IMessageHandler handler(); - void fromBytes(ByteBuf source); - void toBytes(ByteBuf target); -} diff --git a/fml/src/main/java/cpw/mods/fml/common/network/IMessageHandler.java b/fml/src/main/java/cpw/mods/fml/common/network/IMessageHandler.java deleted file mode 100644 index 28ec9f0f8..000000000 --- a/fml/src/main/java/cpw/mods/fml/common/network/IMessageHandler.java +++ /dev/null @@ -1,14 +0,0 @@ -package cpw.mods.fml.common.network; - -import cpw.mods.fml.common.network.handshake.NetworkDispatcher; - - -public interface IMessageHandler { - /** - * Unsigned byte for the discriminator - * @return an unsigned byte - */ - short discriminator(); - Class messageType(short discriminator); - void receiveMessage(M message, NetworkDispatcher dispatcher); -} diff --git a/fml/src/main/java/cpw/mods/fml/common/network/NetworkRegistry.java b/fml/src/main/java/cpw/mods/fml/common/network/NetworkRegistry.java index 57f44c1a3..58540c55b 100644 --- a/fml/src/main/java/cpw/mods/fml/common/network/NetworkRegistry.java +++ b/fml/src/main/java/cpw/mods/fml/common/network/NetworkRegistry.java @@ -26,6 +26,7 @@ import java.util.logging.Level; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.world.World; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; import cpw.mods.fml.common.FMLCommonHandler; @@ -33,6 +34,8 @@ import cpw.mods.fml.common.FMLLog; import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.ModContainer; import cpw.mods.fml.common.discovery.ASMDataTable; +import cpw.mods.fml.common.network.internal.FMLProxyPacket; +import cpw.mods.fml.common.network.internal.NetworkModHolder; import cpw.mods.fml.relauncher.Side; /** @@ -411,9 +414,9 @@ public enum NetworkRegistry registry.put(fmlModContainer, networkModHolder); } - Map registry() + public Map registry() { - return registry; + return ImmutableMap.copyOf(registry); } public Set channelNamesFor(Side side) diff --git a/fml/src/main/java/cpw/mods/fml/common/network/handshake/ChannelRegistrationHandler.java b/fml/src/main/java/cpw/mods/fml/common/network/handshake/ChannelRegistrationHandler.java index e0e4cb080..d76719ec5 100644 --- a/fml/src/main/java/cpw/mods/fml/common/network/handshake/ChannelRegistrationHandler.java +++ b/fml/src/main/java/cpw/mods/fml/common/network/handshake/ChannelRegistrationHandler.java @@ -2,8 +2,8 @@ package cpw.mods.fml.common.network.handshake; import com.google.common.base.Charsets; -import cpw.mods.fml.common.network.FMLProxyPacket; import cpw.mods.fml.common.network.NetworkRegistry; +import cpw.mods.fml.common.network.internal.FMLProxyPacket; import cpw.mods.fml.relauncher.Side; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.SimpleChannelInboundHandler; diff --git a/fml/src/main/java/cpw/mods/fml/common/network/handshake/FMLHandshakeClientState.java b/fml/src/main/java/cpw/mods/fml/common/network/handshake/FMLHandshakeClientState.java index 529e01d22..313be96cd 100644 --- a/fml/src/main/java/cpw/mods/fml/common/network/handshake/FMLHandshakeClientState.java +++ b/fml/src/main/java/cpw/mods/fml/common/network/handshake/FMLHandshakeClientState.java @@ -3,8 +3,8 @@ package cpw.mods.fml.common.network.handshake; import io.netty.channel.ChannelHandlerContext; import cpw.mods.fml.common.FMLLog; import cpw.mods.fml.common.Loader; -import cpw.mods.fml.common.network.FMLNetworkHandler; import cpw.mods.fml.common.network.NetworkRegistry; +import cpw.mods.fml.common.network.internal.FMLNetworkHandler; import cpw.mods.fml.common.registry.GameData; import cpw.mods.fml.relauncher.Side; diff --git a/fml/src/main/java/cpw/mods/fml/common/network/handshake/FMLHandshakeMessage.java b/fml/src/main/java/cpw/mods/fml/common/network/handshake/FMLHandshakeMessage.java index 6a85c5970..a9e8d475c 100644 --- a/fml/src/main/java/cpw/mods/fml/common/network/handshake/FMLHandshakeMessage.java +++ b/fml/src/main/java/cpw/mods/fml/common/network/handshake/FMLHandshakeMessage.java @@ -16,8 +16,8 @@ import com.google.common.collect.Maps; import cpw.mods.fml.common.ModContainer; import cpw.mods.fml.common.network.ByteBufUtils; -import cpw.mods.fml.common.network.FMLProxyPacket; import cpw.mods.fml.common.network.NetworkRegistry; +import cpw.mods.fml.common.network.internal.FMLProxyPacket; public abstract class FMLHandshakeMessage { public static FMLProxyPacket makeCustomChannelRegistration(Set channels) diff --git a/fml/src/main/java/cpw/mods/fml/common/network/handshake/FMLHandshakeServerState.java b/fml/src/main/java/cpw/mods/fml/common/network/handshake/FMLHandshakeServerState.java index ac40a9468..9bde3e1ae 100644 --- a/fml/src/main/java/cpw/mods/fml/common/network/handshake/FMLHandshakeServerState.java +++ b/fml/src/main/java/cpw/mods/fml/common/network/handshake/FMLHandshakeServerState.java @@ -3,8 +3,8 @@ package cpw.mods.fml.common.network.handshake; import io.netty.channel.ChannelHandlerContext; import cpw.mods.fml.common.FMLLog; import cpw.mods.fml.common.Loader; -import cpw.mods.fml.common.network.FMLNetworkHandler; import cpw.mods.fml.common.network.NetworkRegistry; +import cpw.mods.fml.common.network.internal.FMLNetworkHandler; import cpw.mods.fml.common.registry.GameData; import cpw.mods.fml.relauncher.Side; diff --git a/fml/src/main/java/cpw/mods/fml/common/network/handshake/HandshakeInjector.java b/fml/src/main/java/cpw/mods/fml/common/network/handshake/HandshakeInjector.java index 3a4e5f998..e17cb13b6 100644 --- a/fml/src/main/java/cpw/mods/fml/common/network/handshake/HandshakeInjector.java +++ b/fml/src/main/java/cpw/mods/fml/common/network/handshake/HandshakeInjector.java @@ -1,6 +1,6 @@ package cpw.mods.fml.common.network.handshake; -import cpw.mods.fml.common.network.FMLProxyPacket; +import cpw.mods.fml.common.network.internal.FMLProxyPacket; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelOutboundHandlerAdapter; import io.netty.channel.ChannelPromise; diff --git a/fml/src/main/java/cpw/mods/fml/common/network/handshake/NetworkDispatcher.java b/fml/src/main/java/cpw/mods/fml/common/network/handshake/NetworkDispatcher.java index d2445e623..ca25d3be9 100644 --- a/fml/src/main/java/cpw/mods/fml/common/network/handshake/NetworkDispatcher.java +++ b/fml/src/main/java/cpw/mods/fml/common/network/handshake/NetworkDispatcher.java @@ -26,8 +26,8 @@ import net.minecraft.network.play.server.S40PacketDisconnect; import net.minecraft.server.management.ServerConfigurationManager; import net.minecraft.util.ChatComponentText; import cpw.mods.fml.common.FMLLog; -import cpw.mods.fml.common.network.FMLProxyPacket; import cpw.mods.fml.common.network.NetworkRegistry; +import cpw.mods.fml.common.network.internal.FMLProxyPacket; import cpw.mods.fml.relauncher.Side; public class NetworkDispatcher extends SimpleChannelInboundHandler implements ChannelOutboundHandler { diff --git a/fml/src/main/java/cpw/mods/fml/common/network/EntitySpawnHandler.java b/fml/src/main/java/cpw/mods/fml/common/network/internal/EntitySpawnHandler.java similarity index 79% rename from fml/src/main/java/cpw/mods/fml/common/network/EntitySpawnHandler.java rename to fml/src/main/java/cpw/mods/fml/common/network/internal/EntitySpawnHandler.java index 4d008828e..bebf1fb35 100644 --- a/fml/src/main/java/cpw/mods/fml/common/network/EntitySpawnHandler.java +++ b/fml/src/main/java/cpw/mods/fml/common/network/internal/EntitySpawnHandler.java @@ -1,27 +1,29 @@ -package cpw.mods.fml.common.network; +package cpw.mods.fml.common.network.internal; + +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.SimpleChannelInboundHandler; import java.util.List; import java.util.logging.Level; -import com.google.common.base.Throwables; - import net.minecraft.client.entity.EntityClientPlayerMP; import net.minecraft.client.multiplayer.WorldClient; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLiving; import net.minecraft.world.World; + +import com.google.common.base.Throwables; + import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.common.FMLLog; import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.ModContainer; -import cpw.mods.fml.common.network.FMLMessage.EntityMessage; -import cpw.mods.fml.common.network.FMLMessage.EntitySpawnMessage; +import cpw.mods.fml.common.network.internal.FMLMessage.EntityAdjustMessage; +import cpw.mods.fml.common.network.internal.FMLMessage.EntityMessage; import cpw.mods.fml.common.registry.EntityRegistry; +import cpw.mods.fml.common.registry.EntityRegistry.EntityRegistration; import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData; import cpw.mods.fml.common.registry.IThrowableEntity; -import cpw.mods.fml.common.registry.EntityRegistry.EntityRegistration; -import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.SimpleChannelInboundHandler; public class EntitySpawnHandler extends SimpleChannelInboundHandler { @Override @@ -29,14 +31,33 @@ public class EntitySpawnHandler extends SimpleChannelInboundHandler { addDiscriminator(1,FMLMessage.OpenGui.class); addDiscriminator(2,FMLMessage.EntitySpawnMessage.class); + addDiscriminator(3,FMLMessage.EntityAdjustMessage.class); } @Override public void encodeInto(ChannelHandlerContext ctx, FMLMessage msg, ByteBuf target) throws Exception diff --git a/fml/src/main/java/cpw/mods/fml/common/network/NetworkModHolder.java b/fml/src/main/java/cpw/mods/fml/common/network/internal/NetworkModHolder.java similarity index 98% rename from fml/src/main/java/cpw/mods/fml/common/network/NetworkModHolder.java rename to fml/src/main/java/cpw/mods/fml/common/network/internal/NetworkModHolder.java index 2a5288995..a2a6b087c 100644 --- a/fml/src/main/java/cpw/mods/fml/common/network/NetworkModHolder.java +++ b/fml/src/main/java/cpw/mods/fml/common/network/internal/NetworkModHolder.java @@ -10,7 +10,7 @@ * cpw - implementation */ -package cpw.mods.fml.common.network; +package cpw.mods.fml.common.network.internal; import java.lang.reflect.Method; import java.util.Map; @@ -25,6 +25,7 @@ import cpw.mods.fml.common.FMLLog; import cpw.mods.fml.common.ModContainer; import cpw.mods.fml.common.discovery.ASMDataTable; import cpw.mods.fml.common.discovery.ASMDataTable.ASMData; +import cpw.mods.fml.common.network.NetworkCheckHandler; import cpw.mods.fml.common.versioning.DefaultArtifactVersion; import cpw.mods.fml.common.versioning.InvalidVersionSpecificationException; import cpw.mods.fml.common.versioning.VersionRange; diff --git a/fml/src/main/java/cpw/mods/fml/common/network/OpenGuiHandler.java b/fml/src/main/java/cpw/mods/fml/common/network/internal/OpenGuiHandler.java similarity index 85% rename from fml/src/main/java/cpw/mods/fml/common/network/OpenGuiHandler.java rename to fml/src/main/java/cpw/mods/fml/common/network/internal/OpenGuiHandler.java index 184c7fe9f..815b2959c 100644 --- a/fml/src/main/java/cpw/mods/fml/common/network/OpenGuiHandler.java +++ b/fml/src/main/java/cpw/mods/fml/common/network/internal/OpenGuiHandler.java @@ -1,10 +1,10 @@ -package cpw.mods.fml.common.network; +package cpw.mods.fml.common.network.internal; import net.minecraft.entity.player.EntityPlayer; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.SimpleChannelInboundHandler; import cpw.mods.fml.client.FMLClientHandler; -import cpw.mods.fml.common.network.FMLMessage.OpenGui; +import cpw.mods.fml.common.network.internal.FMLMessage.OpenGui; public class OpenGuiHandler extends SimpleChannelInboundHandler { @Override diff --git a/fml/src/main/java/cpw/mods/fml/common/network/packet/EntitySpawnAdjustmentPacket.java b/fml/src/main/java/cpw/mods/fml/common/network/packet/EntitySpawnAdjustmentPacket.java deleted file mode 100644 index 8300fa00e..000000000 --- a/fml/src/main/java/cpw/mods/fml/common/network/packet/EntitySpawnAdjustmentPacket.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Forge Mod Loader - * Copyright (c) 2012-2013 cpw. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser Public License v2.1 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html - * - * Contributors: - * cpw - implementation - */ - -package cpw.mods.fml.common.network.packet; - -import net.minecraft.network.INetworkManager; -import net.minecraft.network.packet.NetHandler; - -import com.google.common.io.ByteArrayDataInput; -import com.google.common.io.ByteArrayDataOutput; -import com.google.common.io.ByteStreams; - -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.network.FMLNetworkHandler; - -public class EntitySpawnAdjustmentPacket extends FMLOldPacket -{ - - public EntitySpawnAdjustmentPacket() - { - super(Type.ENTITYSPAWNADJUSTMENT); - } - - public int entityId; - public int serverX; - public int serverY; - public int serverZ; - - @Override - public byte[] generatePacketData(Object... data) - { - ByteArrayDataOutput dat = ByteStreams.newDataOutput(); - dat.writeInt((Integer) data[0]); - dat.writeInt((Integer) data[1]); - dat.writeInt((Integer) data[2]); - dat.writeInt((Integer) data[3]); - return dat.toByteArray(); - } - - @Override - public FMLOldPacket consumePacketData(byte[] data) - { - ByteArrayDataInput dat = ByteStreams.newDataInput(data); - entityId = dat.readInt(); - serverX = dat.readInt(); - serverY = dat.readInt(); - serverZ = dat.readInt(); - return this; - } - - @Override - public void execute(INetworkManager network, FMLNetworkHandler handler, NetHandler netHandler, String userName) - { - FMLCommonHandler.instance().adjustEntityLocationOnClient(this); - } - -} diff --git a/fml/src/main/java/cpw/mods/fml/common/network/packet/EntitySpawnPacket.java b/fml/src/main/java/cpw/mods/fml/common/network/packet/EntitySpawnPacket.java deleted file mode 100644 index 80acd26ab..000000000 --- a/fml/src/main/java/cpw/mods/fml/common/network/packet/EntitySpawnPacket.java +++ /dev/null @@ -1,201 +0,0 @@ -/* - * Forge Mod Loader - * Copyright (c) 2012-2013 cpw. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser Public License v2.1 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html - * - * Contributors: - * cpw - implementation - */ - -package cpw.mods.fml.common.network.packet; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; -import java.util.List; -import java.util.logging.Level; - -import net.minecraft.entity.*; -import net.minecraft.network.INetworkManager; -import net.minecraft.network.packet.NetHandler; -import net.minecraft.util.MathHelper; - -import com.google.common.io.ByteArrayDataInput; -import com.google.common.io.ByteArrayDataOutput; -import com.google.common.io.ByteStreams; - -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.FMLLog; -import cpw.mods.fml.common.ModContainer; -import cpw.mods.fml.common.network.FMLNetworkHandler; -import cpw.mods.fml.common.network.NetworkModHolder; -import cpw.mods.fml.common.registry.EntityRegistry; -import cpw.mods.fml.common.registry.EntityRegistry.EntityRegistration; -import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData; -import cpw.mods.fml.common.registry.IThrowableEntity; - -public class EntitySpawnPacket extends FMLOldPacket -{ - - public int networkId; - public int modEntityId; - public int entityId; - public double scaledX; - public double scaledY; - public double scaledZ; - public float scaledYaw; - public float scaledPitch; - public float scaledHeadYaw; - @SuppressWarnings("rawtypes") - public List metadata; - public int throwerId; - public double speedScaledX; - public double speedScaledY; - public double speedScaledZ; - public ByteArrayDataInput dataStream; - public int rawX; - public int rawY; - public int rawZ; - - public EntitySpawnPacket() - { - super(Type.ENTITYSPAWN); - } - - @Override - public byte[] generatePacketData(Object... data) - { - EntityRegistration er = (EntityRegistration) data[0]; - Entity ent = (Entity) data[1]; - NetworkModHolder handler = (NetworkModHolder) data[2]; - ByteArrayDataOutput dat = ByteStreams.newDataOutput(); - - dat.writeInt(handler.getNetworkId()); - dat.writeInt(er.getModEntityId()); - // entity id - dat.writeInt(ent.field_70157_k); - - // entity pos x,y,z - dat.writeInt(MathHelper.func_76128_c(ent.field_70165_t * 32D)); - dat.writeInt(MathHelper.func_76128_c(ent.field_70163_u * 32D)); - dat.writeInt(MathHelper.func_76128_c(ent.field_70161_v * 32D)); - - // yaw, pitch - dat.writeByte((byte) (ent.field_70177_z * 256.0F / 360.0F)); - dat.writeByte((byte) (ent.field_70125_A * 256.0F / 360.0F)); - - // head yaw - if (ent instanceof EntityLiving) - { - dat.writeByte((byte) (((EntityLiving)ent).field_70759_as * 256.0F / 360.0F)); - } - else - { - dat.writeByte(0); - } - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - DataOutputStream dos = new DataOutputStream(bos); - try - { - ent.func_70096_w().func_75689_a(dos); - } - catch (IOException e) - { - // unpossible - } - - dat.write(bos.toByteArray()); - - if (ent instanceof IThrowableEntity) - { - Entity owner = ((IThrowableEntity)ent).getThrower(); - dat.writeInt(owner == null ? ent.field_70157_k : owner.field_70157_k); - double maxVel = 3.9D; - double mX = ent.field_70159_w; - double mY = ent.field_70181_x; - double mZ = ent.field_70179_y; - if (mX < -maxVel) mX = -maxVel; - if (mY < -maxVel) mY = -maxVel; - if (mZ < -maxVel) mZ = -maxVel; - if (mX > maxVel) mX = maxVel; - if (mY > maxVel) mY = maxVel; - if (mZ > maxVel) mZ = maxVel; - dat.writeInt((int)(mX * 8000D)); - dat.writeInt((int)(mY * 8000D)); - dat.writeInt((int)(mZ * 8000D)); - } - else - { - dat.writeInt(0); - } - if (ent instanceof IEntityAdditionalSpawnData) - { - ((IEntityAdditionalSpawnData)ent).writeSpawnData(dat); - } - - return dat.toByteArray(); - } - - @Override - public FMLOldPacket consumePacketData(byte[] data) - { - ByteArrayDataInput dat = ByteStreams.newDataInput(data); - networkId = dat.readInt(); - modEntityId = dat.readInt(); - entityId = dat.readInt(); - rawX = dat.readInt(); - rawY = dat.readInt(); - rawZ = dat.readInt(); - scaledX = rawX / 32D; - scaledY = rawY / 32D; - scaledZ = rawZ / 32D; - scaledYaw = dat.readByte() * 360F / 256F; - scaledPitch = dat.readByte() * 360F / 256F; - scaledHeadYaw = dat.readByte() * 360F / 256F; - ByteArrayInputStream bis = new ByteArrayInputStream(data, 27, data.length - 27); - DataInputStream dis = new DataInputStream(bis); - try - { - metadata = DataWatcher.func_75686_a(dis); - } - catch (IOException e) - { - // Nope - } - dat.skipBytes(data.length - bis.available() - 27); - throwerId = dat.readInt(); - if (throwerId != 0) - { - speedScaledX = dat.readInt() / 8000D; - speedScaledY = dat.readInt() / 8000D; - speedScaledZ = dat.readInt() / 8000D; - } - - this.dataStream = dat; - return this; - } - - @Override - public void execute(INetworkManager network, FMLNetworkHandler handler, NetHandler netHandler, String userName) - { - NetworkModHolder nmh = handler.findNetworkModHandler(networkId); - ModContainer mc = nmh.getContainer(); - - EntityRegistration registration = EntityRegistry.instance().lookupModSpawn(mc, modEntityId); - if (registration == null || registration.getEntityClass() == null) - { - FMLLog.log(Level.WARNING, "Missing mod entity information for %s : %d", mc.getModId(), modEntityId); - return; - } - - - @SuppressWarnings("unused") - Entity entity = FMLCommonHandler.instance().spawnEntityIntoClientWorld(registration, this); - } - -} diff --git a/fml/src/main/java/cpw/mods/fml/common/network/packet/FMLOldPacket.java b/fml/src/main/java/cpw/mods/fml/common/network/packet/FMLOldPacket.java deleted file mode 100644 index 9e59e609b..000000000 --- a/fml/src/main/java/cpw/mods/fml/common/network/packet/FMLOldPacket.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Forge Mod Loader - * Copyright (c) 2012-2013 cpw. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser Public License v2.1 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html - * - * Contributors: - * cpw - implementation - */ - -package cpw.mods.fml.common.network.packet; - -import java.util.Arrays; -import java.util.concurrent.Callable; -import java.util.concurrent.ConcurrentMap; -import java.util.logging.Level; - -import net.minecraft.network.INetworkManager; -import net.minecraft.network.packet.NetHandler; - -import com.google.common.base.Throwables; -import com.google.common.collect.MapMaker; -import com.google.common.primitives.Bytes; -import com.google.common.primitives.Ints; -import com.google.common.primitives.UnsignedBytes; - -import cpw.mods.fml.common.FMLLog; -import cpw.mods.fml.common.network.FMLNetworkException; -import cpw.mods.fml.common.network.FMLNetworkHandler; - -public abstract class FMLOldPacket -{ - enum Type - { - /** - * Opening salutation from the server to the client -> request all mods from the client - */ - MOD_LIST_REQUEST(ModListRequestPacket.class, false), - /** - * The client responds with the list of mods and versions it has. This is verified by the server. - */ - MOD_LIST_RESPONSE(ModListResponsePacket.class, false), - /** - * At which point the server tells the client the mod identifiers for this session. - */ - MOD_IDENTIFIERS(ModIdentifiersPacket.class, false), - /** - * Or, if there is missing stuff, the server tells the client what's missing and drops the connection. - */ - MOD_MISSING(ModMissingPacket.class, false), - /** - * Open a GUI on the client from the server - */ - GUIOPEN(OpenGuiPacket.class, false, "OpenGuiHandler"), - /** - * Spawn an entity on the client from the server - */ - ENTITYSPAWN(EntitySpawnPacket.class, false), - /** - * Fixes entity location data after spawning - */ - ENTITYSPAWNADJUSTMENT(EntitySpawnAdjustmentPacket.class, false), - /** - * The ID map to send to the client - */ - MOD_IDMAP(ModIdMapPacket.class, true); - - - private Class packetType; - private boolean isMultipart; - private String executorClass; - - private ConcurrentMap partTracker; - - private Type(Class clazz, boolean isMultipart, String executorClass) - { - this.packetType = clazz; - this.isMultipart = isMultipart; - this.executorClass = executorClass; - } - - FMLOldPacket make() - { - try - { - return this.packetType.newInstance(); - } - catch (Exception e) - { - Throwables.propagateIfPossible(e); - FMLLog.log(Level.SEVERE, e, "A bizarre critical error occured during packet encoding"); - throw new FMLNetworkException(e); - } - } - - boolean isMultipart() - { - return isMultipart; - } - - private FMLOldPacket findCurrentPart(NetworkManager network) - { - if (partTracker == null) - { - partTracker = new MapMaker().weakKeys().weakValues().makeMap(); - } - if (!partTracker.containsKey(network)) - { - partTracker.put(network, make()); - } - return partTracker.get(network); - } - } - - public static byte[][] makePacketSet(Type type, Object... data) - { - if (!type.isMultipart()) - { - return new byte[0][]; - } - byte[] packetData = type.make().generatePacketData(data); - - byte[][] chunks = new byte[packetData.length / 32000 + 1][]; - for (int i = 0; i < packetData.length / 32000 + 1; i++) - { - int len = Math.min(32000, packetData.length - i* 32000); - chunks[i] = Bytes.concat(new byte[] { UnsignedBytes.checkedCast(type.ordinal()), UnsignedBytes.checkedCast(i), UnsignedBytes.checkedCast(chunks.length)}, Ints.toByteArray(len), Arrays.copyOfRange(packetData, i * 32000, len + i * 32000)); - } - return chunks; - } - static byte[] makePacket(Type type, Object... data) - { - byte[] packetData = type.make().generatePacketData(data); - return Bytes.concat(new byte[] { UnsignedBytes.checkedCast(type.ordinal()) }, packetData ); - } - - abstract byte[] generatePacketData(Object... data); - - abstract FMLOldPacket consumePacketData(byte[] data); -} diff --git a/fml/src/main/java/cpw/mods/fml/common/registry/EntityRegistry.java b/fml/src/main/java/cpw/mods/fml/common/registry/EntityRegistry.java index 83fd9aa8e..a19631c11 100644 --- a/fml/src/main/java/cpw/mods/fml/common/registry/EntityRegistry.java +++ b/fml/src/main/java/cpw/mods/fml/common/registry/EntityRegistry.java @@ -38,7 +38,7 @@ import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.FMLLog; import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.ModContainer; -import cpw.mods.fml.common.network.FMLMessage.EntitySpawnMessage; +import cpw.mods.fml.common.network.internal.FMLMessage.EntitySpawnMessage; public class EntityRegistry { diff --git a/fml/src/main/java/cpw/mods/fml/server/FMLServerHandler.java b/fml/src/main/java/cpw/mods/fml/server/FMLServerHandler.java index 7a6972b93..3a01bcd7a 100644 --- a/fml/src/main/java/cpw/mods/fml/server/FMLServerHandler.java +++ b/fml/src/main/java/cpw/mods/fml/server/FMLServerHandler.java @@ -22,7 +22,6 @@ import java.util.regex.Pattern; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; -import net.minecraft.entity.Entity; import net.minecraft.network.NetworkManager; import net.minecraft.server.MinecraftServer; import net.minecraft.util.StringTranslate; @@ -34,9 +33,6 @@ import cpw.mods.fml.common.FMLLog; import cpw.mods.fml.common.IFMLSidedHandler; import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.ModContainer; -import cpw.mods.fml.common.network.packet.EntitySpawnAdjustmentPacket; -import cpw.mods.fml.common.network.packet.EntitySpawnPacket; -import cpw.mods.fml.common.registry.EntityRegistry.EntityRegistration; import cpw.mods.fml.common.registry.LanguageRegistry; import cpw.mods.fml.relauncher.Side; @@ -141,12 +137,6 @@ public class FMLServerHandler implements IFMLSidedHandler { } - - @Override - public void adjustEntityLocationOnClient(EntitySpawnAdjustmentPacket entitySpawnAdjustmentPacket) - { - // NOOP - } @Override public boolean shouldServerShouldBeKilledQuietly() {