|
@@ -5,30 +5,33 @@ import com.mojang.authlib.GameProfile;
|
|
import io.netty.buffer.Unpooled;
|
|
import io.netty.buffer.Unpooled;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
+import java.util.Optional;
|
|
import java.util.UUID;
|
|
import java.util.UUID;
|
|
import me.km.KajetansMod;
|
|
import me.km.KajetansMod;
|
|
import me.km.networking.ModPacketHandler;
|
|
import me.km.networking.ModPacketHandler;
|
|
import me.km.utils.ReflectionUtils;
|
|
import me.km.utils.ReflectionUtils;
|
|
import net.minecraft.entity.Entity;
|
|
import net.minecraft.entity.Entity;
|
|
-import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
-import net.minecraft.entity.player.EntityPlayerMP;
|
|
|
|
-import net.minecraft.nbt.NBTTagCompound;
|
|
|
|
-import net.minecraft.network.NetHandlerPlayServer;
|
|
|
|
|
|
+import net.minecraft.entity.EntityType;
|
|
|
|
+import net.minecraft.entity.player.PlayerEntity;
|
|
|
|
+import net.minecraft.entity.player.ServerPlayerEntity;
|
|
|
|
+import net.minecraft.nbt.CompoundNBT;
|
|
import net.minecraft.network.NetworkManager;
|
|
import net.minecraft.network.NetworkManager;
|
|
import net.minecraft.network.PacketBuffer;
|
|
import net.minecraft.network.PacketBuffer;
|
|
-import net.minecraft.network.play.server.SPacketChangeGameState;
|
|
|
|
-import net.minecraft.network.play.server.SPacketCustomPayload;
|
|
|
|
-import net.minecraft.network.play.server.SPacketEntityEffect;
|
|
|
|
-import net.minecraft.network.play.server.SPacketHeldItemChange;
|
|
|
|
-import net.minecraft.network.play.server.SPacketJoinGame;
|
|
|
|
-import net.minecraft.network.play.server.SPacketPlayerAbilities;
|
|
|
|
-import net.minecraft.network.play.server.SPacketRespawn;
|
|
|
|
-import net.minecraft.network.play.server.SPacketServerDifficulty;
|
|
|
|
-import net.minecraft.network.play.server.SPacketSetExperience;
|
|
|
|
-import net.minecraft.network.play.server.SPacketSpawnPosition;
|
|
|
|
-import net.minecraft.network.play.server.SPacketTagsList;
|
|
|
|
-import net.minecraft.network.play.server.SPacketUpdateRecipes;
|
|
|
|
-import net.minecraft.potion.PotionEffect;
|
|
|
|
|
|
+import net.minecraft.network.play.ServerPlayNetHandler;
|
|
|
|
+import net.minecraft.network.play.server.SChangeGameStatePacket;
|
|
|
|
+import net.minecraft.network.play.server.SCustomPayloadPlayPacket;
|
|
|
|
+import net.minecraft.network.play.server.SHeldItemChangePacket;
|
|
|
|
+import net.minecraft.network.play.server.SJoinGamePacket;
|
|
|
|
+import net.minecraft.network.play.server.SPlayEntityEffectPacket;
|
|
|
|
+import net.minecraft.network.play.server.SPlayerAbilitiesPacket;
|
|
|
|
+import net.minecraft.network.play.server.SPlayerListItemPacket;
|
|
|
|
+import net.minecraft.network.play.server.SRespawnPacket;
|
|
|
|
+import net.minecraft.network.play.server.SServerDifficultyPacket;
|
|
|
|
+import net.minecraft.network.play.server.SSetExperiencePacket;
|
|
|
|
+import net.minecraft.network.play.server.SSpawnPositionPacket;
|
|
|
|
+import net.minecraft.network.play.server.STagsListPacket;
|
|
|
|
+import net.minecraft.network.play.server.SUpdateRecipesPacket;
|
|
|
|
+import net.minecraft.potion.EffectInstance;
|
|
import net.minecraft.server.dedicated.DedicatedPlayerList;
|
|
import net.minecraft.server.dedicated.DedicatedPlayerList;
|
|
import net.minecraft.server.dedicated.DedicatedServer;
|
|
import net.minecraft.server.dedicated.DedicatedServer;
|
|
import net.minecraft.server.management.DemoPlayerInteractionManager;
|
|
import net.minecraft.server.management.DemoPlayerInteractionManager;
|
|
@@ -36,10 +39,10 @@ import net.minecraft.server.management.PlayerInteractionManager;
|
|
import net.minecraft.server.management.PlayerList;
|
|
import net.minecraft.server.management.PlayerList;
|
|
import net.minecraft.server.management.PlayerProfileCache;
|
|
import net.minecraft.server.management.PlayerProfileCache;
|
|
import net.minecraft.util.math.BlockPos;
|
|
import net.minecraft.util.math.BlockPos;
|
|
-import net.minecraft.util.text.TextComponentTranslation;
|
|
|
|
|
|
+import net.minecraft.util.math.Vec3d;
|
|
|
|
+import net.minecraft.util.text.TranslationTextComponent;
|
|
import net.minecraft.world.IWorld;
|
|
import net.minecraft.world.IWorld;
|
|
-import net.minecraft.world.WorldServer;
|
|
|
|
-import net.minecraft.world.chunk.storage.AnvilChunkLoader;
|
|
|
|
|
|
+import net.minecraft.world.ServerWorld;
|
|
import net.minecraft.world.dimension.DimensionType;
|
|
import net.minecraft.world.dimension.DimensionType;
|
|
import net.minecraft.world.storage.WorldInfo;
|
|
import net.minecraft.world.storage.WorldInfo;
|
|
import org.apache.logging.log4j.LogManager;
|
|
import org.apache.logging.log4j.LogManager;
|
|
@@ -47,9 +50,9 @@ import org.apache.logging.log4j.LogManager;
|
|
public class ModPlayerList extends DedicatedPlayerList
|
|
public class ModPlayerList extends DedicatedPlayerList
|
|
{
|
|
{
|
|
private final DedicatedServer server;
|
|
private final DedicatedServer server;
|
|
- private final List<EntityPlayerMP> players;
|
|
|
|
- private final Map<UUID, EntityPlayerMP> uuidToPlayerMap;
|
|
|
|
-
|
|
|
|
|
|
+ private final List<ServerPlayerEntity> players;
|
|
|
|
+ private final Map<UUID, ServerPlayerEntity> uuidToPlayerMap;
|
|
|
|
+
|
|
public ModPlayerList(DedicatedServer server)
|
|
public ModPlayerList(DedicatedServer server)
|
|
{
|
|
{
|
|
super(server);
|
|
super(server);
|
|
@@ -57,23 +60,23 @@ public class ModPlayerList extends DedicatedPlayerList
|
|
this.players = getPlayers();
|
|
this.players = getPlayers();
|
|
this.uuidToPlayerMap = ReflectionUtils.getFieldValue(Map.class, PlayerList.class, this, "field_177454_f");
|
|
this.uuidToPlayerMap = ReflectionUtils.getFieldValue(Map.class, PlayerList.class, this, "field_177454_f");
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
- public void initializeConnectionToPlayer(NetworkManager netManager, EntityPlayerMP p)
|
|
|
|
|
|
+ public void initializeConnectionToPlayer(NetworkManager netManager, ServerPlayerEntity p)
|
|
{
|
|
{
|
|
GameProfile profile = p.getGameProfile();
|
|
GameProfile profile = p.getGameProfile();
|
|
PlayerProfileCache cache = this.server.getPlayerProfileCache();
|
|
PlayerProfileCache cache = this.server.getPlayerProfileCache();
|
|
GameProfile cachedProfile = cache.getProfileByUUID(profile.getId());
|
|
GameProfile cachedProfile = cache.getProfileByUUID(profile.getId());
|
|
String s = cachedProfile == null ? profile.getName() : cachedProfile.getName();
|
|
String s = cachedProfile == null ? profile.getName() : cachedProfile.getName();
|
|
cache.addEntry(profile);
|
|
cache.addEntry(profile);
|
|
- NBTTagCompound tag = this.readPlayerDataFromFile(p);
|
|
|
|
|
|
+ CompoundNBT compoundnbt = this.readPlayerDataFromFile(p);
|
|
|
|
|
|
//Forge: Make sure the dimension hasn't been deleted, if so stick them in the overworld.
|
|
//Forge: Make sure the dimension hasn't been deleted, if so stick them in the overworld.
|
|
DimensionType type = p.dimension;
|
|
DimensionType type = p.dimension;
|
|
boolean noSchedule = true;
|
|
boolean noSchedule = true;
|
|
if(type == null || !type.isVanilla())
|
|
if(type == null || !type.isVanilla())
|
|
{
|
|
{
|
|
- WorldServer overWorld = this.server.getWorld(DimensionType.OVERWORLD);
|
|
|
|
|
|
+ ServerWorld overWorld = this.server.getWorld(DimensionType.OVERWORLD);
|
|
p.dimension = DimensionType.OVERWORLD;
|
|
p.dimension = DimensionType.OVERWORLD;
|
|
if(type != null && this.server.getWorld(type) != null)
|
|
if(type != null && this.server.getWorld(type) != null)
|
|
{
|
|
{
|
|
@@ -85,7 +88,7 @@ public class ModPlayerList extends DedicatedPlayerList
|
|
noSchedule = false;
|
|
noSchedule = false;
|
|
KajetansMod.scheduler.scheduleTask(() ->
|
|
KajetansMod.scheduler.scheduleTask(() ->
|
|
{
|
|
{
|
|
- WorldServer ws = server.getWorld(type);
|
|
|
|
|
|
+ ServerWorld ws = server.getWorld(type);
|
|
if(ws != null)
|
|
if(ws != null)
|
|
{
|
|
{
|
|
p.teleport(ws, x, y, z, yaw, pitch);
|
|
p.teleport(ws, x, y, z, yaw, pitch);
|
|
@@ -96,10 +99,10 @@ public class ModPlayerList extends DedicatedPlayerList
|
|
WorldInfo wi = overWorld.getWorldInfo();
|
|
WorldInfo wi = overWorld.getWorldInfo();
|
|
p.setPosition(wi.getSpawnX(), wi.getSpawnY(), wi.getSpawnZ());
|
|
p.setPosition(wi.getSpawnX(), wi.getSpawnY(), wi.getSpawnZ());
|
|
}
|
|
}
|
|
-
|
|
|
|
- WorldServer ws = this.server.getWorld(p.dimension);
|
|
|
|
- p.setWorld(ws);
|
|
|
|
- p.interactionManager.setWorld((WorldServer) p.world);
|
|
|
|
|
|
+
|
|
|
|
+ ServerWorld sw = this.server.getWorld(p.dimension);
|
|
|
|
+ p.setWorld(sw);
|
|
|
|
+ p.interactionManager.setWorld((ServerWorld) p.world);
|
|
String s1 = "local";
|
|
String s1 = "local";
|
|
if(netManager.getRemoteAddress() != null)
|
|
if(netManager.getRemoteAddress() != null)
|
|
{
|
|
{
|
|
@@ -107,43 +110,57 @@ public class ModPlayerList extends DedicatedPlayerList
|
|
}
|
|
}
|
|
|
|
|
|
LogManager.getLogger().info("{}[{}] logged in with entity id {} at ({}, {}, {})", p.getName().getString(), s1, p.getEntityId(), p.posX, p.posY, p.posZ);
|
|
LogManager.getLogger().info("{}[{}] logged in with entity id {} at ({}, {}, {})", p.getName().getString(), s1, p.getEntityId(), p.posX, p.posY, p.posZ);
|
|
- WorldInfo wi = ws.getWorldInfo();
|
|
|
|
- this.setPlayerGameTypeBasedOnOther(p, null, ws);
|
|
|
|
- NetHandlerPlayServer nhps = new NetHandlerPlayServer(this.server, netManager, p);
|
|
|
|
|
|
+ WorldInfo wi = sw.getWorldInfo();
|
|
|
|
+ setPlayerGameTypeBasedOnOther(p, null, sw);
|
|
|
|
+ ServerPlayNetHandler spnh = new ServerPlayNetHandler(this.server, netManager, p);
|
|
ModPacketHandler.syncDimensions(p);
|
|
ModPacketHandler.syncDimensions(p);
|
|
- nhps.sendPacket(new SPacketJoinGame(p.getEntityId(), p.interactionManager.getGameType(), wi.isHardcore(), ws.dimension.getType(), ws.getDifficulty(), this.getMaxPlayers(), wi.getTerrainType(), ws.getGameRules().getBoolean("reducedDebugInfo")));
|
|
|
|
- nhps.sendPacket(new SPacketCustomPayload(SPacketCustomPayload.BRAND, (new PacketBuffer(Unpooled.buffer())).writeString(this.getServer().getServerModName())));
|
|
|
|
- nhps.sendPacket(new SPacketServerDifficulty(wi.getDifficulty(), wi.isDifficultyLocked()));
|
|
|
|
- nhps.sendPacket(new SPacketPlayerAbilities(p.abilities));
|
|
|
|
- nhps.sendPacket(new SPacketHeldItemChange(p.inventory.currentItem));
|
|
|
|
- nhps.sendPacket(new SPacketUpdateRecipes(this.server.getRecipeManager().getRecipes()));
|
|
|
|
- nhps.sendPacket(new SPacketTagsList(this.server.getNetworkTagManager()));
|
|
|
|
|
|
+ spnh.sendPacket(new SJoinGamePacket(p.getEntityId(), p.interactionManager.getGameType(), wi.isHardcore(), sw.dimension.getType(), this.getMaxPlayers(), wi.getGenerator(), getViewDistance(), sw.getGameRules().getBoolean("reducedDebugInfo")));
|
|
|
|
+ spnh.sendPacket(new SCustomPayloadPlayPacket(SCustomPayloadPlayPacket.BRAND, (new PacketBuffer(Unpooled.buffer())).writeString(this.getServer().getServerModName())));
|
|
|
|
+ spnh.sendPacket(new SServerDifficultyPacket(wi.getDifficulty(), wi.isDifficultyLocked()));
|
|
|
|
+ spnh.sendPacket(new SPlayerAbilitiesPacket(p.abilities));
|
|
|
|
+ spnh.sendPacket(new SHeldItemChangePacket(p.inventory.currentItem));
|
|
|
|
+ spnh.sendPacket(new SUpdateRecipesPacket(this.server.getRecipeManager().getRecipes()));
|
|
|
|
+ spnh.sendPacket(new STagsListPacket(this.server.getNetworkTagManager()));
|
|
this.updatePermissionLevel(p);
|
|
this.updatePermissionLevel(p);
|
|
p.getStats().markAllDirty();
|
|
p.getStats().markAllDirty();
|
|
p.getRecipeBook().init(p);
|
|
p.getRecipeBook().init(p);
|
|
- this.sendScoreboard(ws.getScoreboard(), p);
|
|
|
|
|
|
+ this.sendScoreboard(sw.getScoreboard(), p);
|
|
this.server.refreshStatusNextTick();
|
|
this.server.refreshStatusNextTick();
|
|
|
|
|
|
- this.playerLoggedIn(p);
|
|
|
|
- nhps.setPlayerLocation(p.posX, p.posY, p.posZ, p.rotationYaw, p.rotationPitch);
|
|
|
|
- this.sendWorldInfo(p, ws);
|
|
|
|
|
|
+ spnh.setPlayerLocation(p.posX, p.posY, p.posZ, p.rotationYaw, p.rotationPitch);
|
|
|
|
+ this.players.add(p);
|
|
|
|
+ this.uuidToPlayerMap.put(p.getUniqueID(), p);
|
|
|
|
+ this.sendPacketToAllPlayers(new SPlayerListItemPacket(SPlayerListItemPacket.Action.ADD_PLAYER, p));
|
|
|
|
+
|
|
|
|
+ for(int i = 0; i < this.players.size(); ++i)
|
|
|
|
+ {
|
|
|
|
+ p.connection.sendPacket(new SPlayerListItemPacket(SPlayerListItemPacket.Action.ADD_PLAYER, this.players.get(i)));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ sw.addNewPlayer(p);
|
|
|
|
+ this.server.getCustomBossEvents().onPlayerLogin(p);
|
|
|
|
+ this.sendWorldInfo(p, sw);
|
|
if(!this.server.getResourcePackUrl().isEmpty())
|
|
if(!this.server.getResourcePackUrl().isEmpty())
|
|
{
|
|
{
|
|
p.loadResourcePack(this.server.getResourcePackUrl(), this.server.getResourcePackHash());
|
|
p.loadResourcePack(this.server.getResourcePackUrl(), this.server.getResourcePackHash());
|
|
}
|
|
}
|
|
|
|
|
|
- for(PotionEffect potioneffect : p.getActivePotionEffects())
|
|
|
|
|
|
+ for(EffectInstance effectinstance : p.getActivePotionEffects())
|
|
{
|
|
{
|
|
- nhps.sendPacket(new SPacketEntityEffect(p.getEntityId(), potioneffect));
|
|
|
|
|
|
+ spnh.sendPacket(new SPlayEntityEffectPacket(p.getEntityId(), effectinstance));
|
|
}
|
|
}
|
|
|
|
|
|
- if(tag != null && tag.contains("RootVehicle", 10))
|
|
|
|
|
|
+ if(compoundnbt != null && compoundnbt.contains("RootVehicle", 10))
|
|
{
|
|
{
|
|
- NBTTagCompound nbttagcompound1 = tag.getCompound("RootVehicle");
|
|
|
|
- Entity entity1 = AnvilChunkLoader.readWorldEntity(nbttagcompound1.getCompound("Entity"), ws, true);
|
|
|
|
|
|
+ CompoundNBT compoundnbt1 = compoundnbt.getCompound("RootVehicle");
|
|
|
|
+ final ServerWorld worldf = sw;
|
|
|
|
+ Entity entity1 = EntityType.func_220335_a(compoundnbt1.getCompound("Entity"), sw, (p_217885_1_) ->
|
|
|
|
+ {
|
|
|
|
+ return !worldf.summonEntity(p_217885_1_) ? null : p_217885_1_;
|
|
|
|
+ });
|
|
if(entity1 != null)
|
|
if(entity1 != null)
|
|
{
|
|
{
|
|
- UUID uuid = nbttagcompound1.getUniqueId("Attach");
|
|
|
|
|
|
+ UUID uuid = compoundnbt1.getUniqueId("Attach");
|
|
if(entity1.getUniqueID().equals(uuid))
|
|
if(entity1.getUniqueID().equals(uuid))
|
|
{
|
|
{
|
|
p.startRiding(entity1, true);
|
|
p.startRiding(entity1, true);
|
|
@@ -163,11 +180,11 @@ public class ModPlayerList extends DedicatedPlayerList
|
|
if(!p.isPassenger())
|
|
if(!p.isPassenger())
|
|
{
|
|
{
|
|
LogManager.getLogger().warn("Couldn't reattach entity to player");
|
|
LogManager.getLogger().warn("Couldn't reattach entity to player");
|
|
- ws.removeEntityDangerously(entity1);
|
|
|
|
|
|
+ sw.removeEntity(entity1);
|
|
|
|
|
|
for(Entity entity2 : entity1.getRecursivePassengers())
|
|
for(Entity entity2 : entity1.getRecursivePassengers())
|
|
{
|
|
{
|
|
- ws.removeEntityDangerously(entity2);
|
|
|
|
|
|
+ sw.removeEntity(entity2);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -181,29 +198,29 @@ public class ModPlayerList extends DedicatedPlayerList
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public EntityPlayerMP createPlayerForUser(GameProfile profile)
|
|
|
|
|
|
+ public ServerPlayerEntity createPlayerForUser(GameProfile profile)
|
|
{
|
|
{
|
|
- UUID uuid = EntityPlayer.getUUID(profile);
|
|
|
|
- List<EntityPlayerMP> list = Lists.newArrayList();
|
|
|
|
|
|
+ UUID uuid = PlayerEntity.getUUID(profile);
|
|
|
|
+ List<ServerPlayerEntity> list = Lists.newArrayList();
|
|
|
|
|
|
for(int i = 0; i < this.players.size(); ++i)
|
|
for(int i = 0; i < this.players.size(); ++i)
|
|
{
|
|
{
|
|
- EntityPlayerMP entityplayermp = this.players.get(i);
|
|
|
|
- if(entityplayermp.getUniqueID().equals(uuid))
|
|
|
|
|
|
+ ServerPlayerEntity serverplayerentity = this.players.get(i);
|
|
|
|
+ if(serverplayerentity.getUniqueID().equals(uuid))
|
|
{
|
|
{
|
|
- list.add(entityplayermp);
|
|
|
|
|
|
+ list.add(serverplayerentity);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- EntityPlayerMP entityplayermp2 = this.uuidToPlayerMap.get(profile.getId());
|
|
|
|
- if(entityplayermp2 != null && !list.contains(entityplayermp2))
|
|
|
|
|
|
+ ServerPlayerEntity serverplayerentity2 = this.uuidToPlayerMap.get(profile.getId());
|
|
|
|
+ if(serverplayerentity2 != null && !list.contains(serverplayerentity2))
|
|
{
|
|
{
|
|
- list.add(entityplayermp2);
|
|
|
|
|
|
+ list.add(serverplayerentity2);
|
|
}
|
|
}
|
|
|
|
|
|
- for(EntityPlayerMP entityplayermp1 : list)
|
|
|
|
|
|
+ for(ServerPlayerEntity serverplayerentity1 : list)
|
|
{
|
|
{
|
|
- entityplayermp1.connection.disconnect(new TextComponentTranslation("multiplayer.disconnect.duplicate_login"));
|
|
|
|
|
|
+ serverplayerentity1.connection.disconnect(new TranslationTextComponent("multiplayer.disconnect.duplicate_login"));
|
|
}
|
|
}
|
|
|
|
|
|
PlayerInteractionManager playerinteractionmanager;
|
|
PlayerInteractionManager playerinteractionmanager;
|
|
@@ -218,11 +235,11 @@ public class ModPlayerList extends DedicatedPlayerList
|
|
|
|
|
|
return new ModEntityPlayerMP(this.server, this.server.getWorld(DimensionType.OVERWORLD), profile, playerinteractionmanager);
|
|
return new ModEntityPlayerMP(this.server, this.server.getWorld(DimensionType.OVERWORLD), profile, playerinteractionmanager);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
- public EntityPlayerMP recreatePlayerEntity(EntityPlayerMP pIn, DimensionType dim, boolean conqueredEnd)
|
|
|
|
|
|
+ public ServerPlayerEntity recreatePlayerEntity(ServerPlayerEntity pIn, DimensionType dim, boolean conqueredEnd)
|
|
{
|
|
{
|
|
- WorldServer world = server.getWorld(dim);
|
|
|
|
|
|
+ ServerWorld world = server.getWorld(dim);
|
|
if(world == null)
|
|
if(world == null)
|
|
{
|
|
{
|
|
dim = pIn.getSpawnDimension();
|
|
dim = pIn.getSpawnDimension();
|
|
@@ -236,11 +253,8 @@ public class ModPlayerList extends DedicatedPlayerList
|
|
dim = DimensionType.OVERWORLD;
|
|
dim = DimensionType.OVERWORLD;
|
|
}
|
|
}
|
|
|
|
|
|
- pIn.getServerWorld().getEntityTracker().removePlayerFromTrackers(pIn);
|
|
|
|
- pIn.getServerWorld().getEntityTracker().untrack(pIn);
|
|
|
|
- pIn.getServerWorld().getPlayerChunkMap().removePlayer(pIn);
|
|
|
|
this.players.remove(pIn);
|
|
this.players.remove(pIn);
|
|
- this.server.getWorld(pIn.dimension).removeEntityDangerously(pIn, true); // Forge: keep data until copyFrom called
|
|
|
|
|
|
+ pIn.getServerWorld().removePlayer(pIn, true); // Forge: keep data until copyFrom called
|
|
BlockPos blockpos = pIn.getBedLocation(dim);
|
|
BlockPos blockpos = pIn.getBedLocation(dim);
|
|
boolean flag = pIn.isSpawnForced(dim);
|
|
boolean flag = pIn.isSpawnForced(dim);
|
|
pIn.dimension = dim;
|
|
pIn.dimension = dim;
|
|
@@ -254,7 +268,7 @@ public class ModPlayerList extends DedicatedPlayerList
|
|
playerinteractionmanager = new PlayerInteractionManager(this.server.getWorld(pIn.dimension));
|
|
playerinteractionmanager = new PlayerInteractionManager(this.server.getWorld(pIn.dimension));
|
|
}
|
|
}
|
|
|
|
|
|
- EntityPlayerMP p = new ModEntityPlayerMP(this.server, this.server.getWorld(pIn.dimension), pIn.getGameProfile(), playerinteractionmanager);
|
|
|
|
|
|
+ ServerPlayerEntity p = new ModEntityPlayerMP(this.server, this.server.getWorld(pIn.dimension), pIn.getGameProfile(), playerinteractionmanager);
|
|
p.connection = pIn.connection;
|
|
p.connection = pIn.connection;
|
|
p.copyFrom(pIn, conqueredEnd);
|
|
p.copyFrom(pIn, conqueredEnd);
|
|
pIn.remove(false); // Forge: clone event had a chance to see old data, now discard it
|
|
pIn.remove(false); // Forge: clone event had a chance to see old data, now discard it
|
|
@@ -267,38 +281,38 @@ public class ModPlayerList extends DedicatedPlayerList
|
|
p.addTag(s);
|
|
p.addTag(s);
|
|
}
|
|
}
|
|
|
|
|
|
- WorldServer worldserver = this.server.getWorld(pIn.dimension);
|
|
|
|
- this.setPlayerGameTypeBasedOnOther(p, pIn, worldserver);
|
|
|
|
|
|
+ ServerWorld serverworld = this.server.getWorld(pIn.dimension);
|
|
|
|
+ this.setPlayerGameTypeBasedOnOther(p, pIn, serverworld);
|
|
if(blockpos != null)
|
|
if(blockpos != null)
|
|
{
|
|
{
|
|
- BlockPos blockpos1 = EntityPlayer.getBedSpawnLocation(this.server.getWorld(pIn.dimension), blockpos, flag);
|
|
|
|
- if(blockpos1 != null)
|
|
|
|
|
|
+ Optional<Vec3d> optional = PlayerEntity.func_213822_a(this.server.getWorld(pIn.dimension), blockpos, flag);
|
|
|
|
+ if(optional.isPresent())
|
|
{
|
|
{
|
|
- p.setLocationAndAngles((double) ((float) blockpos1.getX() + 0.5F), (double) ((float) blockpos1.getY() + 0.1F), (double) ((float) blockpos1.getZ() + 0.5F), 0.0F, 0.0F);
|
|
|
|
- p.setSpawnPoint(blockpos, flag, pIn.dimension);
|
|
|
|
|
|
+ Vec3d vec3d = optional.get();
|
|
|
|
+ p.setLocationAndAngles(vec3d.x, vec3d.y, vec3d.z, 0.0F, 0.0F);
|
|
|
|
+ p.setSpawnPoint(blockpos, flag, dim);
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- p.connection.sendPacket(new SPacketChangeGameState(0, 0.0F));
|
|
|
|
|
|
+ p.connection.sendPacket(new SChangeGameStatePacket(0, 0.0F));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- worldserver.getChunkProvider().provideChunk((int) p.posX >> 4, (int) p.posZ >> 4, true, true);
|
|
|
|
-
|
|
|
|
- while(!worldserver.isCollisionBoxesEmpty(p, p.getBoundingBox()) && p.posY < 256.0D)
|
|
|
|
|
|
+ while(!serverworld.areCollisionShapesEmpty(p) && p.posY < 256.0D)
|
|
{
|
|
{
|
|
p.setPosition(p.posX, p.posY + 1.0D, p.posZ);
|
|
p.setPosition(p.posX, p.posY + 1.0D, p.posZ);
|
|
}
|
|
}
|
|
|
|
|
|
- p.connection.sendPacket(new SPacketRespawn(p.dimension, world.getDifficulty(), world.getWorldInfo().getTerrainType(), p.interactionManager.getGameType())); // Forge: Use new dimensions information
|
|
|
|
- BlockPos blockpos2 = worldserver.getSpawnPoint();
|
|
|
|
|
|
+ WorldInfo wi = p.world.getWorldInfo();
|
|
|
|
+ p.connection.sendPacket(new SRespawnPacket(p.dimension, wi.getGenerator(), p.interactionManager.getGameType()));
|
|
|
|
+ BlockPos pos = serverworld.getSpawnPoint();
|
|
p.connection.setPlayerLocation(p.posX, p.posY, p.posZ, p.rotationYaw, p.rotationPitch);
|
|
p.connection.setPlayerLocation(p.posX, p.posY, p.posZ, p.rotationYaw, p.rotationPitch);
|
|
- p.connection.sendPacket(new SPacketSpawnPosition(blockpos2));
|
|
|
|
- p.connection.sendPacket(new SPacketSetExperience(p.experience, p.experienceTotal, p.experienceLevel));
|
|
|
|
- this.sendWorldInfo(p, worldserver);
|
|
|
|
|
|
+ p.connection.sendPacket(new SSpawnPositionPacket(pos));
|
|
|
|
+ p.connection.sendPacket(new SServerDifficultyPacket(wi.getDifficulty(), wi.isDifficultyLocked()));
|
|
|
|
+ p.connection.sendPacket(new SSetExperiencePacket(p.experience, p.experienceTotal, p.experienceLevel));
|
|
|
|
+ this.sendWorldInfo(p, serverworld);
|
|
this.updatePermissionLevel(p);
|
|
this.updatePermissionLevel(p);
|
|
- worldserver.getPlayerChunkMap().addPlayer(p);
|
|
|
|
- worldserver.spawnEntity(p);
|
|
|
|
|
|
+ serverworld.addRespawnedPlayer(p);
|
|
this.players.add(p);
|
|
this.players.add(p);
|
|
this.uuidToPlayerMap.put(p.getUniqueID(), p);
|
|
this.uuidToPlayerMap.put(p.getUniqueID(), p);
|
|
p.addSelfToInternalCraftingInventory();
|
|
p.addSelfToInternalCraftingInventory();
|
|
@@ -306,8 +320,8 @@ public class ModPlayerList extends DedicatedPlayerList
|
|
net.minecraftforge.fml.hooks.BasicEventHooks.firePlayerRespawnEvent(p, conqueredEnd);
|
|
net.minecraftforge.fml.hooks.BasicEventHooks.firePlayerRespawnEvent(p, conqueredEnd);
|
|
return p;
|
|
return p;
|
|
}
|
|
}
|
|
-
|
|
|
|
- private void setPlayerGameTypeBasedOnOther(EntityPlayerMP target, EntityPlayerMP source, IWorld w)
|
|
|
|
|
|
+
|
|
|
|
+ private void setPlayerGameTypeBasedOnOther(ServerPlayerEntity target, ServerPlayerEntity source, IWorld w)
|
|
{
|
|
{
|
|
ReflectionUtils.setPlayerGameTypeBasedOnOther(this, target, source, w);
|
|
ReflectionUtils.setPlayerGameTypeBasedOnOther(this, target, source, w);
|
|
}
|
|
}
|