mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-12 08:17:35 +00:00
Attempt to build some protocol negotiation, and fix packet1login so that the dimension is a short, matching packet9respawn
This commit is contained in:
1 parent
16fe495d18
commit
ecd4e46a45
7 files changed
+109
-19
No files matched your search
@@ -411,8 +411,16 @@ public class FMLClientHandler implements IFMLSidedHandler
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCompatibilityLevel(NetHandler netHandler, byte compatibilityLevel)
|
||||
public void setClientCompatibilityLevel(byte compatibilityLevel)
|
||||
{
|
||||
((NetClientHandler)netHandler).setConnectionCompatibilityLevel(compatibilityLevel);
|
||||
NetClientHandler.setConnectionCompatibilityLevel(compatibilityLevel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getClientCompatibilityLevel()
|
||||
{
|
||||
System.out.printf("Client Compatibility %d\n", NetClientHandler.getConnectionCompatibilityLevel());
|
||||
Thread.dumpStack();
|
||||
return NetClientHandler.getConnectionCompatibilityLevel();
|
||||
}
|
||||
}
|
||||
@@ -38,5 +38,7 @@ public interface IFMLSidedHandler
|
||||
|
||||
void handleTinyPacket(NetHandler handler, Packet131MapData mapData);
|
||||
|
||||
void setCompatibilityLevel(NetHandler netHandler, byte compatibilityLevel);
|
||||
void setClientCompatibilityLevel(byte compatibilityLevel);
|
||||
|
||||
byte getClientCompatibilityLevel();
|
||||
}
|
||||
@@ -218,6 +218,8 @@ public class FMLNetworkHandler
|
||||
|
||||
public static Packet1Login getFMLFakeLoginPacket()
|
||||
{
|
||||
// Always reset compat to zero before sending our fake packet
|
||||
FMLCommonHandler.instance().getSidedDelegate().setClientCompatibilityLevel((byte) 0);
|
||||
Packet1Login fake = new Packet1Login();
|
||||
// Hash FML using a simple function
|
||||
fake.field_73561_a = FML_HASH;
|
||||
@@ -412,4 +414,9 @@ public class FMLNetworkHandler
|
||||
{
|
||||
return PROTOCOL_VERSION;
|
||||
}
|
||||
|
||||
public static boolean vanillaLoginPacketCompatibility()
|
||||
{
|
||||
return FMLCommonHandler.instance().getSidedDelegate().getClientCompatibilityLevel() == 0;
|
||||
}
|
||||
}
|
||||
@@ -61,7 +61,7 @@ public class ModListRequestPacket extends FMLPacket
|
||||
{
|
||||
compatibilityLevel = in.readByte();
|
||||
}
|
||||
catch (IllegalArgumentException e)
|
||||
catch (IllegalStateException e)
|
||||
{
|
||||
FMLLog.fine("No compatibility byte found - the server is too old");
|
||||
}
|
||||
@@ -110,16 +110,9 @@ public class ModListRequestPacket extends FMLPacket
|
||||
}
|
||||
}
|
||||
|
||||
if (compatibilityLevel != 0)
|
||||
{
|
||||
FMLLog.fine("The server has compatibility level %d", compatibilityLevel);
|
||||
FMLCommonHandler.instance().getSidedDelegate().setCompatibilityLevel(netHandler, compatibilityLevel);
|
||||
}
|
||||
Packet250CustomPayload pkt = new Packet250CustomPayload();
|
||||
pkt.field_73630_a = "FML";
|
||||
pkt.field_73629_c = FMLPacket.makePacket(MOD_LIST_RESPONSE, modVersions, missingMods);
|
||||
pkt.field_73628_b = pkt.field_73629_c.length;
|
||||
FMLLog.fine("The server has compatibility level %d", compatibilityLevel);
|
||||
FMLCommonHandler.instance().getSidedDelegate().setClientCompatibilityLevel(compatibilityLevel);
|
||||
|
||||
mgr.func_74429_a(pkt);
|
||||
mgr.func_74429_a(PacketDispatcher.getPacket("FML", FMLPacket.makePacket(MOD_LIST_RESPONSE, modVersions, missingMods)));
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@ import java.util.List;
|
||||
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.src.Entity;
|
||||
import net.minecraft.src.NetClientHandler;
|
||||
import net.minecraft.src.NetHandler;
|
||||
import net.minecraft.src.Packet;
|
||||
import net.minecraft.src.Packet131MapData;
|
||||
@@ -164,8 +165,15 @@ public class FMLServerHandler implements IFMLSidedHandler
|
||||
// NOOP on server
|
||||
}
|
||||
@Override
|
||||
public void setCompatibilityLevel(NetHandler netHandler, byte compatibilityLevel)
|
||||
public void setClientCompatibilityLevel(byte compatibilityLevel)
|
||||
{
|
||||
// NOOP on server
|
||||
}
|
||||
@Override
|
||||
public byte getClientCompatibilityLevel()
|
||||
{
|
||||
System.out.printf("Server Compatibility %d\n", 0);
|
||||
Thread.dumpStack();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
--- ../src-base/common/net/minecraft/src/Packet1Login.java
|
||||
+++ ../src-work/common/net/minecraft/src/Packet1Login.java
|
||||
@@ -3,6 +3,8 @@
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
+
|
||||
+import cpw.mods.fml.common.network.FMLNetworkHandler;
|
||||
|
||||
public class Packet1Login extends Packet
|
||||
{
|
||||
@@ -15,7 +17,11 @@
|
||||
public byte field_73556_g;
|
||||
public byte field_73562_h;
|
||||
|
||||
- public Packet1Login() {}
|
||||
+ private boolean vanillaCompatible;
|
||||
+
|
||||
+ public Packet1Login() {
|
||||
+ this.vanillaCompatible = FMLNetworkHandler.vanillaLoginPacketCompatibility();
|
||||
+ }
|
||||
|
||||
public Packet1Login(int p_i3327_1_, WorldType p_i3327_2_, EnumGameType p_i3327_3_, boolean p_i3327_4_, int p_i3327_5_, int p_i3327_6_, int p_i3327_7_, int p_i3327_8_)
|
||||
{
|
||||
@@ -27,6 +33,7 @@
|
||||
this.field_73556_g = (byte)p_i3327_7_;
|
||||
this.field_73562_h = (byte)p_i3327_8_;
|
||||
this.field_73560_c = p_i3327_4_;
|
||||
+ this.vanillaCompatible = false;
|
||||
}
|
||||
|
||||
public void func_73267_a(DataInputStream p_73267_1_) throws IOException
|
||||
@@ -44,7 +51,14 @@
|
||||
this.field_73560_c = (var3 & 8) == 8;
|
||||
int var4 = var3 & -9;
|
||||
this.field_73557_d = EnumGameType.func_77146_a(var4);
|
||||
- this.field_73558_e = p_73267_1_.readByte();
|
||||
+ if (vanillaCompatible)
|
||||
+ {
|
||||
+ this.field_73558_e = p_73267_1_.readByte();
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ this.field_73558_e = p_73267_1_.readShort();
|
||||
+ }
|
||||
this.field_73555_f = p_73267_1_.readByte();
|
||||
this.field_73556_g = p_73267_1_.readByte();
|
||||
this.field_73562_h = p_73267_1_.readByte();
|
||||
@@ -62,7 +76,14 @@
|
||||
}
|
||||
|
||||
p_73273_1_.writeByte(var2);
|
||||
- p_73273_1_.writeByte(this.field_73558_e);
|
||||
+ if (vanillaCompatible)
|
||||
+ {
|
||||
+ p_73273_1_.writeByte(this.field_73558_e);
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ p_73273_1_.writeShort(this.field_73558_e);
|
||||
+ }
|
||||
p_73273_1_.writeByte(this.field_73555_f);
|
||||
p_73273_1_.writeByte(this.field_73556_g);
|
||||
p_73273_1_.writeByte(this.field_73562_h);
|
||||
@@ -82,6 +103,6 @@
|
||||
var1 = this.field_73559_b.func_77127_a().length();
|
||||
}
|
||||
|
||||
- return 6 + 2 * var1 + 4 + 4 + 1 + 1 + 1;
|
||||
+ return 6 + 2 * var1 + 4 + 4 + 1 + 1 + 1 + (vanillaCompatible ? 0 : 1);
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@
|
||||
public int field_72556_d = 20;
|
||||
Random field_72557_e = new Random();
|
||||
|
||||
+ public int connectionCompatibilityLevel;
|
||||
+ private static byte connectionCompatibilityLevel;
|
||||
+
|
||||
public NetClientHandler(Minecraft p_i3103_1_, String p_i3103_2_, int p_i3103_3_) throws IOException
|
||||
{
|
||||
@@ -91,12 +91,12 @@
|
||||
+ return field_72563_h.field_71439_g;
|
||||
+ }
|
||||
+
|
||||
+ public void setConnectionCompatibilityLevel(int connectionCompatibilityLevel)
|
||||
+ public static void setConnectionCompatibilityLevel(byte connectionCompatibilityLevel)
|
||||
+ {
|
||||
+ this.connectionCompatibilityLevel = connectionCompatibilityLevel;
|
||||
+ NetClientHandler.connectionCompatibilityLevel = connectionCompatibilityLevel;
|
||||
+ }
|
||||
+
|
||||
+ public int getConnectionCompatibilityLevel()
|
||||
+ public static byte getConnectionCompatibilityLevel()
|
||||
+ {
|
||||
+ return connectionCompatibilityLevel;
|
||||
+ }
|
||||
|
||||
Reference in new issue
Block a user