Rewrote the login code to delay full login untill forge fnishes negotiating network IDs. Should fix entities not having proper ID mapings.
This commit is contained in:
parent
f27a85c511
commit
4e575f353f
5 changed files with 98 additions and 31 deletions
|
@ -2,6 +2,7 @@ package net.minecraft.src;
|
||||||
|
|
||||||
import net.minecraft.src.forge.ForgeHooks;
|
import net.minecraft.src.forge.ForgeHooks;
|
||||||
import net.minecraft.src.forge.MinecraftForge;
|
import net.minecraft.src.forge.MinecraftForge;
|
||||||
|
import net.minecraft.src.forge.MinecraftForgeClient;
|
||||||
import net.minecraft.src.forge.NetworkMod;
|
import net.minecraft.src.forge.NetworkMod;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -21,6 +22,7 @@ public class mod_MinecraftForge extends NetworkMod
|
||||||
public void load()
|
public void load()
|
||||||
{
|
{
|
||||||
MinecraftForge.getDungeonLootTries(); //Random thing to make things Initialize
|
MinecraftForge.getDungeonLootTries(); //Random thing to make things Initialize
|
||||||
|
MinecraftForgeClient.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
package net.minecraft.src.forge;
|
package net.minecraft.src.forge;
|
||||||
|
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import net.minecraft.src.*;
|
import net.minecraft.src.*;
|
||||||
|
import net.minecraft.src.forge.packets.ForgePacket;
|
||||||
import net.minecraft.src.forge.packets.PacketModList;
|
import net.minecraft.src.forge.packets.PacketModList;
|
||||||
|
|
||||||
public class ForgeHooksServer
|
public class ForgeHooksServer
|
||||||
|
@ -42,6 +44,38 @@ public class ForgeHooksServer
|
||||||
System.out.println("S->C: " + pkt.toString(true));
|
System.out.println("S->C: " + pkt.toString(true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void handleLoginPacket(Packet1Login pktLogin, NetServerHandler net, NetworkManager manager)
|
||||||
|
{
|
||||||
|
init();
|
||||||
|
if (pktLogin.serverMode == ForgePacket.FORGE_ID)
|
||||||
|
{
|
||||||
|
ForgeHooks.onLogin(manager, pktLogin);
|
||||||
|
|
||||||
|
String[] channels = MessageManager.getInstance().getRegisteredChannels(manager);
|
||||||
|
StringBuilder tmp = new StringBuilder();
|
||||||
|
tmp.append("Forge");
|
||||||
|
for(String channel : channels)
|
||||||
|
{
|
||||||
|
tmp.append("\0");
|
||||||
|
tmp.append(channel);
|
||||||
|
}
|
||||||
|
Packet250CustomPayload pkt = new Packet250CustomPayload();
|
||||||
|
pkt.channel = "REGISTER";
|
||||||
|
try {
|
||||||
|
pkt.data = tmp.toString().getBytes("UTF8");
|
||||||
|
} catch (UnsupportedEncodingException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
pkt.length = pkt.data.length;
|
||||||
|
net.sendPacket(pkt);
|
||||||
|
ForgeHooksServer.sendModListRequest(manager);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
net.kickPlayer("This server requires you to have Minecraft Forge installed.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private static boolean hasInit = false;
|
private static boolean hasInit = false;
|
||||||
|
|
|
@ -91,6 +91,10 @@ public class PacketHandlerServer implements IPacketHandler
|
||||||
{
|
{
|
||||||
doMissingMods(net, missing);
|
doMissingMods(net, missing);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
finishLogin(net);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -127,4 +131,32 @@ public class PacketHandlerServer implements IPacketHandler
|
||||||
mc.configManager.playerLoggedOut(net.getPlayerEntity());
|
mc.configManager.playerLoggedOut(net.getPlayerEntity());
|
||||||
net.connectionClosed = true;
|
net.connectionClosed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void finishLogin(NetServerHandler net)
|
||||||
|
{
|
||||||
|
EntityPlayerMP player = net.getPlayerEntity();
|
||||||
|
WorldServer world = net.mcServer.getWorldManager(player.dimension);
|
||||||
|
ChunkCoordinates spawn = world.getSpawnPoint();
|
||||||
|
|
||||||
|
net.sendPacket(new Packet1Login("", player.entityId, world.getWorldInfo().getTerrainType(),
|
||||||
|
player.itemInWorldManager.getGameType(), world.worldProvider.worldType,
|
||||||
|
(byte)world.difficultySetting, (byte)world.getHeight(),
|
||||||
|
(byte)net.mcServer.configManager.getMaxPlayers()));
|
||||||
|
|
||||||
|
net.sendPacket(new Packet6SpawnPosition(spawn.posX, spawn.posY, spawn.posZ));
|
||||||
|
net.sendPacket(new Packet202PlayerAbilities(player.capabilities));
|
||||||
|
net.mcServer.configManager.updateTimeAndWeather(player, world);
|
||||||
|
net.mcServer.configManager.sendPacketToAllPlayers(new Packet3Chat("\u00a7e" + player.username + " joined the game."));
|
||||||
|
net.mcServer.configManager.playerLoggedIn(player);
|
||||||
|
|
||||||
|
net.teleportTo(player.posX, player.posY, player.posZ, player.rotationYaw, player.rotationPitch);
|
||||||
|
net.sendPacket(new Packet4UpdateTime(world.getWorldTime()));
|
||||||
|
|
||||||
|
for (Object efx : player.getActivePotionEffects())
|
||||||
|
{
|
||||||
|
net.sendPacket(new Packet41EntityEffect(player.entityId, (PotionEffect)efx));
|
||||||
|
}
|
||||||
|
|
||||||
|
player.func_20057_k();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,40 +18,30 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -164,6 +168,36 @@
|
@@ -146,6 +150,7 @@
|
||||||
|
ChunkCoordinates var4 = var3.getSpawnPoint();
|
||||||
|
var2.itemInWorldManager.func_35695_b(var3.getWorldInfo().getGameType());
|
||||||
|
NetServerHandler var5 = new NetServerHandler(this.mcServer, this.netManager, var2);
|
||||||
|
+ /*
|
||||||
|
var5.sendPacket(new Packet1Login("", var2.entityId, var3.getWorldInfo().getTerrainType(), var2.itemInWorldManager.getGameType(), var3.worldProvider.worldType, (byte)var3.difficultySetting, (byte)var3.getHeight(), (byte)this.mcServer.configManager.getMaxPlayers()));
|
||||||
|
var5.sendPacket(new Packet6SpawnPosition(var4.posX, var4.posY, var4.posZ));
|
||||||
|
var5.sendPacket(new Packet202PlayerAbilities(var2.capabilities));
|
||||||
|
@@ -153,7 +158,9 @@
|
||||||
|
this.mcServer.configManager.sendPacketToAllPlayers(new Packet3Chat("\u00a7e" + var2.username + " joined the game."));
|
||||||
|
this.mcServer.configManager.playerLoggedIn(var2);
|
||||||
|
var5.teleportTo(var2.posX, var2.posY, var2.posZ, var2.rotationYaw, var2.rotationPitch);
|
||||||
|
+ */
|
||||||
|
this.mcServer.networkServer.addPlayer(var5);
|
||||||
|
+ /*
|
||||||
|
var5.sendPacket(new Packet4UpdateTime(var3.getWorldTime()));
|
||||||
|
Iterator var6 = var2.getActivePotionEffects().iterator();
|
||||||
|
|
||||||
|
@@ -164,6 +171,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
var2.func_20057_k();
|
var2.func_20057_k();
|
||||||
+ if (par1Packet1Login.serverMode == ForgePacket.FORGE_ID)
|
+ */
|
||||||
+ {
|
+ ForgeHooksServer.handleLoginPacket(par1Packet1Login, var5, netManager);
|
||||||
+ //Pretty hackish place to put it, but it needs to go somewhere
|
|
||||||
+ ForgeHooksServer.init();
|
|
||||||
+ //pkt.mapSeed = ForgeHooks.buildVersion;
|
|
||||||
+ ForgeHooks.onLogin(netManager, par1Packet1Login);
|
|
||||||
+
|
|
||||||
+ String[] channels = MessageManager.getInstance().getRegisteredChannels(netManager);
|
|
||||||
+ StringBuilder tmp = new StringBuilder();
|
|
||||||
+ tmp.append("Forge");
|
|
||||||
+ for(String channel : channels)
|
|
||||||
+ {
|
|
||||||
+ tmp.append("\0");
|
|
||||||
+ tmp.append(channel);
|
|
||||||
+ }
|
|
||||||
+ Packet250CustomPayload pkt = new Packet250CustomPayload();
|
|
||||||
+ pkt.channel = "REGISTER";
|
|
||||||
+ try {
|
|
||||||
+ pkt.data = tmp.toString().getBytes("UTF8");
|
|
||||||
+ } catch (UnsupportedEncodingException e) {
|
|
||||||
+ e.printStackTrace();
|
|
||||||
+ }
|
|
||||||
+ pkt.length = pkt.data.length;
|
|
||||||
+ var5.sendPacket(pkt);
|
|
||||||
+ ForgeHooksServer.sendModListRequest(netManager);
|
|
||||||
+ }
|
|
||||||
+ else
|
|
||||||
+ {
|
|
||||||
+ var5.kickPlayer("This server requires you to have Minecraft Forge installed.");
|
|
||||||
+ }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.finishedProcessing = true;
|
this.finishedProcessing = true;
|
||||||
|
|
|
@ -10,6 +10,15 @@
|
||||||
|
|
||||||
public class NetServerHandler extends NetHandler implements ICommandListener
|
public class NetServerHandler extends NetHandler implements ICommandListener
|
||||||
{
|
{
|
||||||
|
@@ -19,7 +22,7 @@
|
||||||
|
public boolean connectionClosed = false;
|
||||||
|
|
||||||
|
/** Reference to the MinecraftServer object. */
|
||||||
|
- private MinecraftServer mcServer;
|
||||||
|
+ public MinecraftServer mcServer;
|
||||||
|
|
||||||
|
/** Reference to the EntityPlayerMP object. */
|
||||||
|
private EntityPlayerMP playerEntity;
|
||||||
@@ -374,8 +377,11 @@
|
@@ -374,8 +377,11 @@
|
||||||
double var10 = this.playerEntity.posY - ((double)var6 + 0.5D) + 1.5D;
|
double var10 = this.playerEntity.posY - ((double)var6 + 0.5D) + 1.5D;
|
||||||
double var12 = this.playerEntity.posZ - ((double)var7 + 0.5D);
|
double var12 = this.playerEntity.posZ - ((double)var7 + 0.5D);
|
||||||
|
|
Loading…
Reference in a new issue