1
0
Fork 0
mirror of https://github.com/PaperMC/Paper.git synced 2025-02-17 18:47:40 +01:00

Properly remove Entities from current chunk

We store a reference to the chunk the entity is currently in, so use it
to more accurately unregister it in chunkCheck

Should maybe fix some entity loss issues.
This commit is contained in:
Aikar 2020-05-10 05:52:31 -04:00
parent a26aabf9d0
commit b74f95d9f9

View file

@ -23,8 +23,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/server/WorldServer.java
+++ b/src/main/java/net/minecraft/server/WorldServer.java
@@ -0,0 +0,0 @@ public class WorldServer extends World {
this.getChunkAt(entity.chunkX, entity.chunkZ).a(entity, entity.chunkY);
int k = MathHelper.floor(entity.locZ() / 16.0D);
if (!entity.inChunk || entity.chunkX != i || entity.chunkY != j || entity.chunkZ != k) {
- if (entity.inChunk && this.isChunkLoaded(entity.chunkX, entity.chunkZ)) {
- this.getChunkAt(entity.chunkX, entity.chunkZ).a(entity, entity.chunkY);
+ // Paper start - remove entity if its in a chunk more correctly.
+ Chunk currentChunk = entity.getCurrentChunk();
+ if (currentChunk != null) {
+ currentChunk.removeEntity(entity);
}
+ // Paper end
- if (!entity.cc() && !this.isChunkLoaded(i, k)) {
+ if (!entity.valid && !entity.cc() && !this.isChunkLoaded(i, k)) { // Paper - always load chunks to register valid entities location