fix render distance cycling, but partially break new players appearing when doing so
This commit is contained in:
parent
05379987aa
commit
73668289cf
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
|
@ -816,9 +816,13 @@ public class EntityPlayerMP extends EntityPlayer implements ICrafting {
|
|||
var2 = (var2 >> 5) + 2;
|
||||
|
||||
if (var2 > 3 && var2 < 15) {
|
||||
if (this.mcServer.getServerOwner().equals(this.username)) {
|
||||
this.renderDistance = var2;
|
||||
} else {
|
||||
EntityPlayerMP fard = this.mcServer.getConfigurationManager().getPlayerEntity(this.mcServer.getServerOwner());
|
||||
int maxRenderDistance = fard == null ? 10 : (fard.renderDistance > 10 ? 10 : fard.renderDistance);
|
||||
this.renderDistance = var2 > maxRenderDistance ? maxRenderDistance : var2;
|
||||
}
|
||||
if(this.lastRenderDistance != this.renderDistance) {
|
||||
if(this.mcServer.isSinglePlayer() && this.mcServer.getServerOwner().equals(this.username)) {
|
||||
for(int i = 0; i < this.mcServer.worldServers.length; ++i) {
|
||||
|
|
|
@ -136,11 +136,15 @@ public class NetLoginHandler extends NetHandler {
|
|||
if (var1 != null) {
|
||||
this.kickUser(var1);
|
||||
} else {
|
||||
EntityPlayerMP fard = this.mcServer.getConfigurationManager().getPlayerEntity(this.mcServer.getServerOwner());
|
||||
int maxRenderDistance = fard == null ? 10 : (fard.renderDistance > 10 ? 10 : fard.renderDistance);
|
||||
EntityPlayerMP var2 = this.mcServer.getConfigurationManager().createPlayerForUser(this.clientUsername);
|
||||
if (var2 != null) {
|
||||
var2.renderDistance = var2.lastRenderDistance = (this.viewDistance > maxRenderDistance && !this.mcServer.getServerOwner().equals(this.clientUsername)) ? maxRenderDistance : this.viewDistance;
|
||||
if (this.mcServer.getServerOwner().equals(this.clientUsername)) {
|
||||
var2.renderDistance = this.viewDistance;
|
||||
} else {
|
||||
EntityPlayerMP fard = this.mcServer.getConfigurationManager().getPlayerEntity(this.mcServer.getServerOwner());
|
||||
int maxRenderDistance = fard == null ? 10 : (fard.renderDistance > 10 ? 10 : fard.renderDistance);
|
||||
var2.renderDistance = this.viewDistance > maxRenderDistance ? maxRenderDistance : this.viewDistance;
|
||||
}
|
||||
this.mcServer.getConfigurationManager().initializeConnectionToPlayer(this.myTCPConnection, var2);
|
||||
}else {
|
||||
this.kickUser("Could not construct EntityPlayerMP for '" + var1 + "'");
|
||||
|
|
|
@ -86,37 +86,31 @@ public class PlayerManager {
|
|||
}
|
||||
}
|
||||
|
||||
public EntityPlayerMP cycleRenderDistance(EntityPlayerMP player) {
|
||||
if(player.mcServer.getServerOwner().equals(player.username)) {
|
||||
player = cycleAllRenderDistance(player);
|
||||
}else {
|
||||
public void cycleRenderDistance(EntityPlayerMP player) {
|
||||
if(player.lastRenderDistance != player.renderDistance) {
|
||||
player.lastRenderDistance = player.renderDistance;
|
||||
player.playerNetServerHandler.playerEntity = player.mcServer.getConfigurationManager().recreatePlayerEntity(player, player.dimension, true, false);
|
||||
player = player.playerNetServerHandler.playerEntity;
|
||||
player.mcServer.getConfigurationManager().updateOnRenderDistanceChange(player);
|
||||
}
|
||||
if(player.mcServer.getServerOwner().equals(player.username)) {
|
||||
cycleAllRenderDistance(player);
|
||||
}
|
||||
return player;
|
||||
}
|
||||
|
||||
public EntityPlayerMP cycleAllRenderDistance(EntityPlayerMP player) {
|
||||
if(player.lastRenderDistance != player.renderDistance) {
|
||||
public void cycleAllRenderDistance(EntityPlayerMP player) {
|
||||
player.mcServer.getConfigurationManager().viewDistance = player.renderDistance;
|
||||
// player.lastRenderDistance = player.renderDistance;
|
||||
player.lastRenderDistance = player.renderDistance;
|
||||
List curList = new ArrayList();
|
||||
curList.addAll(players);
|
||||
curList.remove(player);
|
||||
int limited = player.renderDistance > 10 ? 10 : player.renderDistance;
|
||||
for(int i = 0, l = curList.size(); i < l; ++i) {
|
||||
EntityPlayerMP playerReload = (EntityPlayerMP)curList.get(i);
|
||||
boolean returnThisOne = playerReload.equals(player);
|
||||
if (playerReload.lastRenderDistance != player.renderDistance) {
|
||||
playerReload.lastRenderDistance = playerReload.renderDistance = player.renderDistance;
|
||||
playerReload.playerNetServerHandler.playerEntity = playerReload.mcServer.getConfigurationManager().recreatePlayerEntity(playerReload, playerReload.dimension, true, false);
|
||||
playerReload = playerReload.playerNetServerHandler.playerEntity;
|
||||
}
|
||||
if (returnThisOne) player = playerReload;
|
||||
int targetRenderDist = player.renderDistance > limited ? limited : player.renderDistance;
|
||||
if (playerReload.renderDistance != targetRenderDist) {
|
||||
playerReload.lastRenderDistance = playerReload.renderDistance = targetRenderDist;
|
||||
playerReload.mcServer.getConfigurationManager().updateOnRenderDistanceChange(playerReload);
|
||||
}
|
||||
}
|
||||
return player;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -150,7 +144,7 @@ public class PlayerManager {
|
|||
*/
|
||||
public EntityPlayerMP filterChunkLoadQueue(EntityPlayerMP par1EntityPlayerMP) {
|
||||
if(par1EntityPlayerMP.lastRenderDistance != par1EntityPlayerMP.renderDistance) {
|
||||
par1EntityPlayerMP = cycleRenderDistance(par1EntityPlayerMP);
|
||||
cycleRenderDistance(par1EntityPlayerMP);
|
||||
}
|
||||
ArrayList var2 = new ArrayList(par1EntityPlayerMP.loadedChunks);
|
||||
int var3 = 0;
|
||||
|
@ -233,7 +227,7 @@ public class PlayerManager {
|
|||
*/
|
||||
public EntityPlayerMP updateMountedMovingPlayer(EntityPlayerMP par1EntityPlayerMP) {
|
||||
if(par1EntityPlayerMP.renderDistance != par1EntityPlayerMP.lastRenderDistance) {
|
||||
par1EntityPlayerMP = cycleRenderDistance(par1EntityPlayerMP);
|
||||
cycleRenderDistance(par1EntityPlayerMP);
|
||||
}
|
||||
int var2 = (int) par1EntityPlayerMP.posX >> 4;
|
||||
int var3 = (int) par1EntityPlayerMP.posZ >> 4;
|
||||
|
|
|
@ -282,6 +282,19 @@ public class ServerConfigurationManager {
|
|||
return new EntityPlayerMP(this.mcServer, this.mcServer.worldServerForDimension(0), par1Str, (ItemInWorldManager) var6);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called on render distance change
|
||||
*/
|
||||
public void updateOnRenderDistanceChange(EntityPlayerMP par1EntityPlayerMP) {
|
||||
par1EntityPlayerMP.getServerForPlayer().getEntityTracker().removePlayerFromTrackers(par1EntityPlayerMP);
|
||||
par1EntityPlayerMP.getServerForPlayer().getPlayerManager().removePlayer(par1EntityPlayerMP);
|
||||
par1EntityPlayerMP.getServerForPlayer().getPlayerManager().addPlayer(par1EntityPlayerMP);
|
||||
for (Object loadedChunk : par1EntityPlayerMP.loadedChunks) {
|
||||
Chunk chunk = (Chunk) loadedChunk;
|
||||
par1EntityPlayerMP.getServerForPlayer().getEntityTracker().func_85172_a(par1EntityPlayerMP, chunk);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called on respawn
|
||||
*/
|
||||
|
@ -307,6 +320,9 @@ public class ServerConfigurationManager {
|
|||
var7.playerNetServerHandler = par1EntityPlayerMP.playerNetServerHandler;
|
||||
var7.clonePlayer(par1EntityPlayerMP, par3);
|
||||
var7.entityId = par1EntityPlayerMP.entityId;
|
||||
if (!teleport) {
|
||||
var7.capabilities = par1EntityPlayerMP.capabilities;
|
||||
}
|
||||
WorldServer var8 = this.mcServer.worldServerForDimension(par1EntityPlayerMP.dimension);
|
||||
this.func_72381_a(var7, par1EntityPlayerMP, var8);
|
||||
ChunkCoordinates var9;
|
||||
|
@ -334,9 +350,11 @@ public class ServerConfigurationManager {
|
|||
|
||||
var8.theChunkProviderServer.loadChunk((int) var7.posX >> 4, (int) var7.posZ >> 4);
|
||||
|
||||
if (teleport) {
|
||||
while (!var8.getCollidingBoundingBoxes(var7, var7.boundingBox).isEmpty()) {
|
||||
var7.setPosition(var7.posX, var7.posY + 1.0D, var7.posZ);
|
||||
}
|
||||
}
|
||||
|
||||
if (startDim != par2) {
|
||||
// see https://wiki.vg/index.php?title=Protocol&oldid=1092
|
||||
|
|
Loading…
Reference in New Issue
Block a user