Need to load the dimension from disk - do it without filling out the player so that the normal player loading (including events)
works properly
This commit is contained in:
parent
613c5edc7d
commit
f4972b7611
3 changed files with 81 additions and 13 deletions
|
@ -9,7 +9,15 @@
|
|||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import java.io.File;
|
||||
@@ -98,7 +100,7 @@
|
||||
@@ -58,6 +60,7 @@
|
||||
import net.minecraft.world.WorldSettings;
|
||||
import net.minecraft.world.demo.DemoWorldManager;
|
||||
import net.minecraft.world.storage.IPlayerFileData;
|
||||
+import net.minecraft.world.storage.SaveHandler;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
@@ -98,7 +101,7 @@
|
||||
this.field_72405_c = 8;
|
||||
}
|
||||
|
||||
|
@ -18,7 +26,7 @@
|
|||
{
|
||||
GameProfile gameprofile = p_72355_2_.func_146103_bH();
|
||||
PlayerProfileCache playerprofilecache = this.field_72400_f.func_152358_ax();
|
||||
@@ -119,7 +121,7 @@
|
||||
@@ -119,7 +122,7 @@
|
||||
WorldServer worldserver = this.field_72400_f.func_71218_a(p_72355_2_.field_71093_bK);
|
||||
ChunkCoordinates chunkcoordinates = worldserver.func_72861_E();
|
||||
this.func_72381_a(p_72355_2_, (EntityPlayerMP)null, worldserver);
|
||||
|
@ -27,7 +35,7 @@
|
|||
nethandlerplayserver.func_147359_a(new S01PacketJoinGame(p_72355_2_.func_145782_y(), p_72355_2_.field_71134_c.func_73081_b(), worldserver.func_72912_H().func_76093_s(), worldserver.field_73011_w.field_76574_g, worldserver.field_73013_u, this.func_72352_l(), worldserver.func_72912_H().func_76067_t()));
|
||||
nethandlerplayserver.func_147359_a(new S3FPacketCustomPayload("MC|Brand", this.func_72365_p().getServerModName().getBytes(Charsets.UTF_8)));
|
||||
nethandlerplayserver.func_147359_a(new S05PacketSpawnPosition(chunkcoordinates.field_71574_a, chunkcoordinates.field_71572_b, chunkcoordinates.field_71573_c));
|
||||
@@ -161,6 +163,7 @@
|
||||
@@ -161,6 +164,7 @@
|
||||
|
||||
p_72355_2_.func_71116_b();
|
||||
|
||||
|
@ -35,8 +43,23 @@
|
|||
if (nbttagcompound != null && nbttagcompound.func_150297_b("Riding", 10))
|
||||
{
|
||||
Entity entity = EntityList.func_75615_a(nbttagcompound.func_74775_l("Riding"), worldserver);
|
||||
@@ -250,6 +253,8 @@
|
||||
@@ -248,8 +252,23 @@
|
||||
return nbttagcompound1;
|
||||
}
|
||||
|
||||
+ public NBTTagCompound getPlayerNBT(EntityPlayerMP player)
|
||||
+ {
|
||||
+ // Hacky method to allow loading the NBT for a player prior to login
|
||||
+ NBTTagCompound nbttagcompound = this.field_72400_f.field_71305_c[0].func_72912_H().func_76072_h();
|
||||
+ if (player.func_70005_c_().equals(this.field_72400_f.func_71214_G()) && nbttagcompound != null)
|
||||
+ {
|
||||
+ return nbttagcompound;
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ return ((SaveHandler)this.field_72412_k).getPlayerNBT(player);
|
||||
+ }
|
||||
+ }
|
||||
protected void func_72391_b(EntityPlayerMP p_72391_1_)
|
||||
{
|
||||
+ if (p_72391_1_.field_71135_a == null) return;
|
||||
|
@ -44,7 +67,7 @@
|
|||
this.field_72412_k.func_75753_a(p_72391_1_);
|
||||
StatisticsFile statisticsfile = (StatisticsFile)this.field_148547_k.get(p_72391_1_.func_110124_au());
|
||||
|
||||
@@ -281,6 +286,7 @@
|
||||
@@ -281,6 +300,7 @@
|
||||
|
||||
public void func_72367_e(EntityPlayerMP p_72367_1_)
|
||||
{
|
||||
|
@ -52,7 +75,7 @@
|
|||
p_72367_1_.func_71029_a(StatList.field_75947_j);
|
||||
this.func_72391_b(p_72367_1_);
|
||||
WorldServer worldserver = p_72367_1_.func_71121_q();
|
||||
@@ -436,6 +442,7 @@
|
||||
@@ -436,6 +456,7 @@
|
||||
this.field_72404_b.add(entityplayermp1);
|
||||
entityplayermp1.func_71116_b();
|
||||
entityplayermp1.func_70606_j(entityplayermp1.func_110143_aJ());
|
||||
|
@ -60,7 +83,7 @@
|
|||
return entityplayermp1;
|
||||
}
|
||||
|
||||
@@ -461,6 +468,7 @@
|
||||
@@ -461,6 +482,7 @@
|
||||
PotionEffect potioneffect = (PotionEffect)iterator.next();
|
||||
p_72356_1_.field_71135_a.func_147359_a(new S1DPacketEntityEffect(p_72356_1_.func_145782_y(), potioneffect));
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
--- ../src-base/minecraft/net/minecraft/world/storage/SaveHandler.java
|
||||
+++ ../src-work/minecraft/net/minecraft/world/storage/SaveHandler.java
|
||||
@@ -6,6 +6,9 @@
|
||||
@@ -6,13 +6,18 @@
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
|
@ -8,9 +8,18 @@
|
|||
+import cpw.mods.fml.common.FMLCommonHandler;
|
||||
+import cpw.mods.fml.common.StartupQuery;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
+import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.CompressedStreamTools;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -107,20 +110,29 @@
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.world.MinecraftException;
|
||||
import net.minecraft.world.WorldProvider;
|
||||
import net.minecraft.world.chunk.storage.IChunkLoader;
|
||||
+
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
@@ -107,20 +112,29 @@
|
||||
NBTTagCompound nbttagcompound;
|
||||
NBTTagCompound nbttagcompound1;
|
||||
|
||||
|
@ -41,7 +50,7 @@
|
|||
file1 = new File(this.field_75770_b, "level.dat_old");
|
||||
|
||||
if (file1.exists())
|
||||
@@ -129,8 +141,14 @@
|
||||
@@ -129,8 +143,14 @@
|
||||
{
|
||||
nbttagcompound = CompressedStreamTools.func_74796_a(new FileInputStream(file1));
|
||||
nbttagcompound1 = nbttagcompound.func_74775_l("Data");
|
||||
|
@ -57,7 +66,7 @@
|
|||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
@@ -146,6 +164,8 @@
|
||||
@@ -146,6 +166,8 @@
|
||||
NBTTagCompound nbttagcompound2 = new NBTTagCompound();
|
||||
nbttagcompound2.func_74782_a("Data", nbttagcompound1);
|
||||
|
||||
|
@ -66,7 +75,7 @@
|
|||
try
|
||||
{
|
||||
File file1 = new File(this.field_75770_b, "level.dat_new");
|
||||
@@ -184,6 +204,8 @@
|
||||
@@ -184,6 +206,8 @@
|
||||
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
|
||||
nbttagcompound1.func_74782_a("Data", nbttagcompound);
|
||||
|
||||
|
@ -75,3 +84,26 @@
|
|||
try
|
||||
{
|
||||
File file1 = new File(this.field_75770_b, "level.dat_new");
|
||||
@@ -296,4 +320,22 @@
|
||||
{
|
||||
return this.field_75767_f;
|
||||
}
|
||||
+
|
||||
+ public NBTTagCompound getPlayerNBT(EntityPlayerMP player)
|
||||
+ {
|
||||
+ try
|
||||
+ {
|
||||
+ File file1 = new File(this.field_75771_c, player.func_110124_au().toString() + ".dat");
|
||||
+
|
||||
+ if (file1.exists() && file1.isFile())
|
||||
+ {
|
||||
+ return CompressedStreamTools.func_74796_a(new FileInputStream(file1));
|
||||
+ }
|
||||
+ }
|
||||
+ catch (Exception exception)
|
||||
+ {
|
||||
+ field_151478_a.warn("Failed to load player data for " + player.func_70005_c_());
|
||||
+ }
|
||||
+ return null;
|
||||
+ }
|
||||
}
|
||||
|
|
|
@ -10,14 +10,18 @@ import io.netty.util.AttributeKey;
|
|||
import io.netty.util.concurrent.Future;
|
||||
import io.netty.util.concurrent.GenericFutureListener;
|
||||
import io.netty.util.concurrent.ScheduledFuture;
|
||||
|
||||
import java.net.SocketAddress;
|
||||
import java.nio.channels.ClosedChannelException;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.EnumConnectionState;
|
||||
import net.minecraft.network.INetHandler;
|
||||
import net.minecraft.network.NetHandlerPlayServer;
|
||||
|
@ -149,7 +153,16 @@ public class NetworkDispatcher extends SimpleChannelInboundHandler<Packet> imple
|
|||
this.manager.setConnectionState(EnumConnectionState.PLAY);
|
||||
|
||||
// Return the dimension the player is in, so it can be pre-sent to the client in the ServerHello v2 packet
|
||||
return player.dimension;
|
||||
// Requires some hackery to the serverconfigmanager and stuff for this to work
|
||||
NBTTagCompound playerNBT = scm.getPlayerNBT(player);
|
||||
if (playerNBT!=null)
|
||||
{
|
||||
return playerNBT.getInteger("Dimension");
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void clientListenForServerHandshake()
|
||||
|
|
Loading…
Reference in a new issue