mirror of
https://github.com/Minestom/Minestom.git
synced 2024-09-28 14:37:31 +02:00
Fixed chunk being asked two times
This commit is contained in:
parent
234ac6daf4
commit
500fc2e903
@ -698,7 +698,7 @@ public class Player extends LivingEntity implements CommandSender {
|
||||
// true if the chunks need to be sent to the client, can be false if the instances share the same chunks (eg SharedInstance)
|
||||
final boolean needWorldRefresh = !InstanceUtils.areLinked(this.instance, instance);
|
||||
|
||||
if (needWorldRefresh) {
|
||||
if (needWorldRefresh && !firstSpawn) {
|
||||
// Remove all previous viewable chunks (from the previous instance)
|
||||
for (Chunk viewableChunk : viewableChunks) {
|
||||
viewableChunk.removeViewer(this);
|
||||
@ -729,7 +729,7 @@ public class Player extends LivingEntity implements CommandSender {
|
||||
final boolean isLast = counter.get() == length - 1;
|
||||
if (isLast) {
|
||||
// This is the last chunk to be loaded , spawn player
|
||||
spawnPlayer(instance, firstSpawn);
|
||||
spawnPlayer(instance, false);
|
||||
} else {
|
||||
// Increment the counter of current loaded chunks
|
||||
counter.incrementAndGet();
|
||||
@ -739,8 +739,13 @@ public class Player extends LivingEntity implements CommandSender {
|
||||
// WARNING: if auto load is disabled and no chunks are loaded beforehand, player will be stuck.
|
||||
instance.loadOptionalChunk(chunkX, chunkZ, callback);
|
||||
}
|
||||
} else if (firstSpawn) {
|
||||
// The player always believe that his position is 0;0 so this is a pretty hacky fix
|
||||
instance.loadOptionalChunk(0, 0, chunk -> spawnPlayer(instance, true));
|
||||
} else {
|
||||
spawnPlayer(instance, firstSpawn);
|
||||
// The player already has the good version of all the chunks.
|
||||
// We just need to refresh his entity viewing list and add him to the instance
|
||||
spawnPlayer(instance, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ public class TemporaryCache<T> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the time an object will be kept without being retrieved
|
||||
* Gets the time an object will be kept without being retrieved.
|
||||
*
|
||||
* @return the keep time in milliseconds
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user