mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-12 16:27:47 +00:00
Fix potential issues with the Minecraft FakePlayer lingering around after world unloads.
This commit is contained in:
1 parent
dd27209565
commit
a5f29570a3
2 files changed
+12
No files matched your search
@@ -19,6 +19,8 @@
|
||||
|
||||
package net.minecraftforge.common.util;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
@@ -26,6 +28,7 @@ import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.network.play.client.CPacketClientSettings;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.management.PlayerInteractionManager;
|
||||
import net.minecraft.stats.StatBase;
|
||||
import net.minecraft.util.DamageSource;
|
||||
@@ -54,4 +57,5 @@ public class FakePlayer extends EntityPlayerMP
|
||||
@Override public void onUpdate(){ return; }
|
||||
@Override public Entity changeDimension(int dim, ITeleporter teleporter){ return this; }
|
||||
@Override public void handleClientSettings(CPacketClientSettings pkt){ return; }
|
||||
@Override @Nullable public MinecraftServer getServer() { return FMLCommonHandler.instance().getMinecraftServerInstance(); }
|
||||
}
|
||||
@@ -68,5 +68,13 @@ public class FakePlayerFactory
|
||||
public static void unloadWorld(WorldServer world)
|
||||
{
|
||||
fakePlayers.entrySet().removeIf(entry -> entry.getValue().world == world);
|
||||
if (MINECRAFT_PLAYER != null && MINECRAFT_PLAYER.get() != null && MINECRAFT_PLAYER.get().world == world) // This shouldn't be strictly necessary, but lets be aggressive.
|
||||
{
|
||||
FakePlayer mc = MINECRAFT_PLAYER.get();
|
||||
if (mc != null && mc.world == world)
|
||||
{
|
||||
MINECRAFT_PLAYER = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user