SpawnAdjustment packet. Clean up stuffs. No more compile errors.

This commit is contained in:
Christian 2013-12-11 19:07:59 -05:00
parent 5086f22370
commit 5e57ce519e
38 changed files with 111 additions and 538 deletions

View file

@ -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();
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -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<Side, EmbeddedChannel> channelPair;
public FMLContainer()
{
super(new ModMetadata());

View file

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

View file

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

View file

@ -12,7 +12,6 @@
package cpw.mods.fml.common;
import java.util.Collection;
import java.util.List;
import java.util.Set;

View file

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

View file

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

View file

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

View file

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

View file

@ -1,9 +0,0 @@
package cpw.mods.fml.common.network;
import io.netty.buffer.ByteBuf;
public interface IFMLMessage {
IMessageHandler<? extends IFMLMessage> handler();
void fromBytes(ByteBuf source);
void toBytes(ByteBuf target);
}

View file

@ -1,14 +0,0 @@
package cpw.mods.fml.common.network;
import cpw.mods.fml.common.network.handshake.NetworkDispatcher;
public interface IMessageHandler<M extends IFMLMessage> {
/**
* Unsigned byte for the discriminator
* @return an unsigned byte
*/
short discriminator();
Class<? extends M> messageType(short discriminator);
void receiveMessage(M message, NetworkDispatcher dispatcher);
}

View file

@ -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<ModContainer,NetworkModHolder> registry()
public Map<ModContainer,NetworkModHolder> registry()
{
return registry;
return ImmutableMap.copyOf(registry);
}
public Set<String> channelNamesFor(Side side)

View file

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

View file

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

View file

@ -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<String> channels)

View file

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

View file

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

View file

@ -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<Packet> implements ChannelOutboundHandler {

View file

@ -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<FMLMessage.EntityMessage> {
@Override
@ -29,14 +31,33 @@ public class EntitySpawnHandler extends SimpleChannelInboundHandler<FMLMessage.E
{
if (msg.getClass().equals(FMLMessage.EntitySpawnMessage.class))
{
spawnEntity(msg);
spawnEntity((FMLMessage.EntitySpawnMessage)msg);
}
else if (msg.getClass().equals(FMLMessage.EntityAdjustMessage.class))
{
adjustEntity((FMLMessage.EntityAdjustMessage)msg);
}
}
private void spawnEntity(EntityMessage msg)
private void adjustEntity(EntityAdjustMessage msg)
{
Entity ent = FMLClientHandler.instance().getWorldClient().func_73045_a(msg.entityId);
if (ent != null)
{
ent.field_70118_ct = msg.serverX;
ent.field_70117_cu = msg.serverY;
ent.field_70116_cv = msg.serverZ;
}
else
{
FMLLog.fine("Attempted to adjust the position of entity %d which is not present on the client", msg.entityId);
}
}
private void spawnEntity(FMLMessage.EntitySpawnMessage spawnMsg)
{
System.out.println("Spawning entity on client");
FMLMessage.EntitySpawnMessage spawnMsg = (EntitySpawnMessage) msg;
ModContainer mc = Loader.instance().getIndexedModList().get(spawnMsg.modId);
EntityRegistration er = EntityRegistry.instance().lookupModSpawn(mc, spawnMsg.modEntityTypeId);
WorldClient wc = FMLClientHandler.instance().getWorldClient();

View file

@ -1,4 +1,4 @@
package cpw.mods.fml.common.network;
package cpw.mods.fml.common.network.internal;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
@ -12,6 +12,7 @@ import net.minecraft.entity.EntityLivingBase;
import net.minecraft.network.PacketBuffer;
import net.minecraft.util.MathHelper;
import cpw.mods.fml.common.ModContainer;
import cpw.mods.fml.common.network.ByteBufUtils;
import cpw.mods.fml.common.registry.EntityRegistry.EntityRegistration;
import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData;
import cpw.mods.fml.common.registry.IThrowableEntity;
@ -71,6 +72,38 @@ public abstract class FMLMessage {
}
}
public static class EntityAdjustMessage extends EntityMessage {
int serverX;
int serverY;
int serverZ;
public EntityAdjustMessage() {}
public EntityAdjustMessage(Entity entity, int serverX, int serverY, int serverZ)
{
super(entity);
this.serverX = serverX;
this.serverY = serverY;
this.serverZ = serverZ;
}
@Override
void toBytes(ByteBuf buf)
{
super.toBytes(buf);
buf.writeInt(serverX);
buf.writeInt(serverY);
buf.writeInt(serverZ);
}
@Override
void fromBytes(ByteBuf buf)
{
super.fromBytes(buf);
serverX = buf.readInt();
serverY = buf.readInt();
serverZ = buf.readInt();
}
}
public static class EntitySpawnMessage extends EntityMessage {
String modId;
int modEntityTypeId;

View file

@ -10,7 +10,7 @@
* cpw - implementation
*/
package cpw.mods.fml.common.network;
package cpw.mods.fml.common.network.internal;
import io.netty.channel.embedded.EmbeddedChannel;
@ -34,6 +34,8 @@ import com.google.common.collect.Lists;
import cpw.mods.fml.common.FMLContainer;
import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.common.ModContainer;
import cpw.mods.fml.common.network.FMLOutboundHandler;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.network.FMLOutboundHandler.OutboundTarget;
import cpw.mods.fml.common.network.handshake.FMLHandshakeMessage;
import cpw.mods.fml.common.network.handshake.NetworkDispatcher;
@ -448,10 +450,12 @@ public class FMLNetworkHandler
}
public static void makeEntitySpawnAdjustment(int func_145782_y, EntityPlayerMP p_73117_1_, int field_73128_d, int field_73129_e, int field_73126_f)
public static void makeEntitySpawnAdjustment(Entity entity, EntityPlayerMP player, int serverX, int serverY, int serverZ)
{
// TODO Auto-generated method stub
EmbeddedChannel embeddedChannel = channelPair.get(Side.SERVER);
embeddedChannel.attr(FMLOutboundHandler.FML_MESSAGETARGET).set(OutboundTarget.PLAYER);
embeddedChannel.attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(player);
embeddedChannel.writeOutbound(new FMLMessage.EntityAdjustMessage(entity, serverX, serverY, serverZ));
}
public static Packet getEntitySpawningPacket(Entity entity)
@ -467,6 +471,7 @@ public class FMLNetworkHandler
}
EmbeddedChannel embeddedChannel = channelPair.get(Side.SERVER);
embeddedChannel.attr(FMLOutboundHandler.FML_MESSAGETARGET).set(OutboundTarget.NOWHERE);
embeddedChannel.writeOutbound(new FMLMessage.EntitySpawnMessage(er, entity, er.getContainer()));
FMLProxyPacket result = (FMLProxyPacket) embeddedChannel.outboundMessages().poll();
return result;

View file

@ -1,4 +1,4 @@
package cpw.mods.fml.common.network;
package cpw.mods.fml.common.network.internal;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
@ -11,6 +11,7 @@ import net.minecraft.network.Packet;
import net.minecraft.network.PacketBuffer;
import net.minecraft.network.play.client.C17PacketCustomPayload;
import net.minecraft.network.play.server.S3FPacketCustomPayload;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.relauncher.Side;
public class FMLProxyPacket extends Packet {

View file

@ -1,5 +1,6 @@
package cpw.mods.fml.common.network;
package cpw.mods.fml.common.network.internal;
import cpw.mods.fml.common.network.FMLIndexedMessageToMessageCodec;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
@ -8,6 +9,7 @@ public class FMLRuntimeCodec extends FMLIndexedMessageToMessageCodec<FMLMessage>
{
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

View file

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

View file

@ -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<FMLMessage.OpenGui> {
@Override

View file

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

View file

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

View file

@ -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<? extends FMLOldPacket> packetType;
private boolean isMultipart;
private String executorClass;
private ConcurrentMap<INetworkManager, FMLOldPacket> partTracker;
private Type(Class<? extends FMLOldPacket> 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);
}

View file

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

View file

@ -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()
{