mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-22 17:07:34 +01:00
re-add distance map patch
This commit is contained in:
parent
47aeab84ad
commit
81c5901c67
@ -6,10 +6,10 @@ Subject: [PATCH] Use distance map to optimise entity tracker
|
||||
Use the distance map to find candidate players for tracking.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
index dadf403ac91887f0fae87889170deb6d5732cbc1..52d9d0f2366f292c56eee9fe241cb43bc2900b23 100644
|
||||
index 463a82f08b7848a4b8a4eb89b201a6e8424c6831..e2b4567a8abc5a6217f4926733c6749edd83029d 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
@@ -157,6 +157,23 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
@@ -148,6 +148,23 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
|
||||
// Paper start - distance maps
|
||||
private final com.destroystokyo.paper.util.misc.PooledLinkedHashSets<ServerPlayer> pooledLinkedPlayerHashSets = new com.destroystokyo.paper.util.misc.PooledLinkedHashSets<>();
|
||||
@ -33,7 +33,7 @@ index dadf403ac91887f0fae87889170deb6d5732cbc1..52d9d0f2366f292c56eee9fe241cb43b
|
||||
|
||||
void addPlayerToDistanceMaps(ServerPlayer player) {
|
||||
this.level.playerChunkLoader.addPlayer(player); // Paper - replace chunk loader
|
||||
@@ -168,6 +185,14 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
@@ -159,6 +176,14 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
this.playerMobDistanceMap.add(player, chunkX, chunkZ, io.papermc.paper.chunk.system.ChunkSystem.getTickViewDistance(player));
|
||||
}
|
||||
// Paper end - per player mob spawning
|
||||
@ -48,7 +48,7 @@ index dadf403ac91887f0fae87889170deb6d5732cbc1..52d9d0f2366f292c56eee9fe241cb43b
|
||||
}
|
||||
|
||||
void removePlayerFromDistanceMaps(ServerPlayer player) {
|
||||
@@ -178,6 +203,11 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
@@ -169,6 +194,11 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
this.playerMobDistanceMap.remove(player);
|
||||
}
|
||||
// Paper end - per player mob spawning
|
||||
@ -60,7 +60,7 @@ index dadf403ac91887f0fae87889170deb6d5732cbc1..52d9d0f2366f292c56eee9fe241cb43b
|
||||
}
|
||||
|
||||
void updateMaps(ServerPlayer player) {
|
||||
@@ -190,6 +220,14 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
@@ -182,6 +212,14 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
this.playerMobDistanceMap.update(player, chunkX, chunkZ, io.papermc.paper.chunk.system.ChunkSystem.getTickViewDistance(player));
|
||||
}
|
||||
// Paper end - per player mob spawning
|
||||
@ -75,7 +75,7 @@ index dadf403ac91887f0fae87889170deb6d5732cbc1..52d9d0f2366f292c56eee9fe241cb43b
|
||||
}
|
||||
// Paper end
|
||||
// Paper start
|
||||
@@ -276,6 +314,48 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
@@ -268,6 +306,48 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
this.regionManagers.add(this.dataRegionManager);
|
||||
// Paper end
|
||||
this.playerMobDistanceMap = this.level.paperConfig().entities.spawning.perPlayerMobSpawns ? new com.destroystokyo.paper.util.misc.PlayerAreaMap(this.pooledLinkedPlayerHashSets) : null; // Paper
|
||||
@ -124,7 +124,7 @@ index dadf403ac91887f0fae87889170deb6d5732cbc1..52d9d0f2366f292c56eee9fe241cb43b
|
||||
}
|
||||
|
||||
protected ChunkGenerator generator() {
|
||||
@@ -960,17 +1040,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
@@ -936,17 +1016,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
}
|
||||
|
||||
public void move(ServerPlayer player) {
|
||||
@ -141,9 +141,9 @@ index dadf403ac91887f0fae87889170deb6d5732cbc1..52d9d0f2366f292c56eee9fe241cb43b
|
||||
- }
|
||||
+ // Paper - delay this logic for the entity tracker tick, no need to duplicate it
|
||||
|
||||
int i = SectionPos.blockToSectionCoord(player.getBlockX());
|
||||
int j = SectionPos.blockToSectionCoord(player.getBlockZ());
|
||||
@@ -1054,7 +1124,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
SectionPos sectionposition = player.getLastSectionPos();
|
||||
SectionPos sectionposition1 = SectionPos.of((EntityAccess) player);
|
||||
@@ -1023,7 +1093,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
|
||||
entity.tracker = playerchunkmap_entitytracker; // Paper - Fast access to tracker
|
||||
this.entityMap.put(entity.getId(), playerchunkmap_entitytracker);
|
||||
@ -152,7 +152,7 @@ index dadf403ac91887f0fae87889170deb6d5732cbc1..52d9d0f2366f292c56eee9fe241cb43b
|
||||
if (entity instanceof ServerPlayer) {
|
||||
ServerPlayer entityplayer = (ServerPlayer) entity;
|
||||
|
||||
@@ -1098,7 +1168,37 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
@@ -1067,7 +1137,37 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
entity.tracker = null; // Paper - We're no longer tracked
|
||||
}
|
||||
|
||||
@ -187,58 +187,10 @@ index dadf403ac91887f0fae87889170deb6d5732cbc1..52d9d0f2366f292c56eee9fe241cb43b
|
||||
+ return;
|
||||
+ }
|
||||
+ // Paper end - optimized tracker
|
||||
// Paper - replaced by PlayerChunkLoader
|
||||
|
||||
List<ServerPlayer> list = Lists.newArrayList();
|
||||
List<ServerPlayer> list1 = this.level.players();
|
||||
ObjectIterator objectiterator = this.entityMap.values().iterator();
|
||||
@@ -1205,46 +1305,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
}));
|
||||
// Paper end
|
||||
DebugPackets.sendPoiPacketsForChunk(this.level, chunk.getPos());
|
||||
- List<Entity> list = Lists.newArrayList();
|
||||
- List<Entity> list1 = Lists.newArrayList();
|
||||
- ObjectIterator objectiterator = this.entityMap.values().iterator();
|
||||
-
|
||||
- while (objectiterator.hasNext()) {
|
||||
- ChunkMap.TrackedEntity playerchunkmap_entitytracker = (ChunkMap.TrackedEntity) objectiterator.next();
|
||||
- Entity entity = playerchunkmap_entitytracker.entity;
|
||||
-
|
||||
- if (entity != player && entity.chunkPosition().equals(chunk.getPos())) {
|
||||
- playerchunkmap_entitytracker.updatePlayer(player);
|
||||
- if (entity instanceof Mob && ((Mob) entity).getLeashHolder() != null) {
|
||||
- list.add(entity);
|
||||
- }
|
||||
-
|
||||
- if (!entity.getPassengers().isEmpty()) {
|
||||
- list1.add(entity);
|
||||
- }
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- Iterator iterator;
|
||||
- Entity entity1;
|
||||
-
|
||||
- if (!list.isEmpty()) {
|
||||
- iterator = list.iterator();
|
||||
-
|
||||
- while (iterator.hasNext()) {
|
||||
- entity1 = (Entity) iterator.next();
|
||||
- player.connection.send(new ClientboundSetEntityLinkPacket(entity1, ((Mob) entity1).getLeashHolder()));
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- if (!list1.isEmpty()) {
|
||||
- iterator = list1.iterator();
|
||||
-
|
||||
- while (iterator.hasNext()) {
|
||||
- entity1 = (Entity) iterator.next();
|
||||
- player.connection.send(new ClientboundSetPassengersPacket(entity1));
|
||||
- }
|
||||
- }
|
||||
+ // Paper - no longer needed - this was used to account for clients bugging out since they needed a chunk to store entities, but they no longer need a chunk
|
||||
|
||||
}
|
||||
|
||||
@@ -1299,6 +1360,42 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
@@ -1219,6 +1319,42 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
this.lastSectionPos = SectionPos.of((EntityAccess) entity);
|
||||
}
|
||||
|
||||
@ -282,10 +234,10 @@ index dadf403ac91887f0fae87889170deb6d5732cbc1..52d9d0f2366f292c56eee9fe241cb43b
|
||||
return object instanceof ChunkMap.TrackedEntity ? ((ChunkMap.TrackedEntity) object).entity.getId() == this.entity.getId() : false;
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index ce4b2ec2ad6138b754ced976521d1c73eb4193a8..c99d24008792b07d5e2984261215de944482006b 100644
|
||||
index 1d2dd9b8ae43f22d875cb530130118df247b87dc..b80e8f05a8f99cc912904470c31092faad0717da 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -57,6 +57,7 @@ import net.minecraft.network.syncher.EntityDataSerializers;
|
||||
@@ -56,6 +56,7 @@ import net.minecraft.network.syncher.EntityDataSerializers;
|
||||
import net.minecraft.network.syncher.SynchedEntityData;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
@ -5,10 +5,10 @@ Subject: [PATCH] Ensure Entity AABB's are never invalid
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index 1d2dd9b8ae43f22d875cb530130118df247b87dc..d4d151fd8b500e32ca5c0f866bd28d3b5cf68633 100644
|
||||
index b80e8f05a8f99cc912904470c31092faad0717da..f2faddf78b5ea591f66d92d9e0f2b7984a3c2124 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -688,8 +688,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
@@ -721,8 +721,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
}
|
||||
|
||||
public void setPos(double x, double y, double z) {
|
||||
@ -19,7 +19,7 @@ index 1d2dd9b8ae43f22d875cb530130118df247b87dc..d4d151fd8b500e32ca5c0f866bd28d3b
|
||||
}
|
||||
|
||||
protected AABB makeBoundingBox() {
|
||||
@@ -4190,6 +4190,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
@@ -4223,6 +4223,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
}
|
||||
|
||||
public final void setPosRaw(double x, double y, double z) {
|
||||
@ -31,7 +31,7 @@ index 1d2dd9b8ae43f22d875cb530130118df247b87dc..d4d151fd8b500e32ca5c0f866bd28d3b
|
||||
// Paper start - rewrite chunk system
|
||||
if (this.updatingSectionStatus) {
|
||||
LOGGER.error("Refusing to update position for entity " + this + " to position " + new Vec3(x, y, z) + " since it is processing a section status update", new Throwable());
|
||||
@@ -4213,6 +4218,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
@@ -4246,6 +4251,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
this.levelCallback.onMove();
|
||||
}
|
||||
|
@ -31,10 +31,10 @@ index 1cf17df6cad66c4b27e1636f365024c9e1e080f1..e7d584a4a5618c8d70ed7b74bc94b6c2
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index d4d151fd8b500e32ca5c0f866bd28d3b5cf68633..b0a73ddd7438b9ecd4462638f9f784d796c62c6c 100644
|
||||
index f2faddf78b5ea591f66d92d9e0f2b7984a3c2124..2d416d0d657667d857794bafa315c720dee9762a 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -158,6 +158,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
@@ -159,6 +159,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
|
||||
// CraftBukkit start
|
||||
private static final int CURRENT_LEVEL = 2;
|
||||
@ -42,7 +42,7 @@ index d4d151fd8b500e32ca5c0f866bd28d3b5cf68633..b0a73ddd7438b9ecd4462638f9f784d7
|
||||
static boolean isLevelAtLeast(CompoundTag tag, int level) {
|
||||
return tag.contains("Bukkit.updateLevel") && tag.getInt("Bukkit.updateLevel") >= level;
|
||||
}
|
||||
@@ -1831,6 +1832,13 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
@@ -1864,6 +1865,13 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
}
|
||||
|
||||
public void moveTo(double x, double y, double z, float yaw, float pitch) {
|
@ -6,10 +6,10 @@ Subject: [PATCH] Expose the Entity Counter to allow plugins to use valid and
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index b0a73ddd7438b9ecd4462638f9f784d796c62c6c..71dc4112cb932c6b1305f0f22e99f069517cac08 100644
|
||||
index 2d416d0d657667d857794bafa315c720dee9762a..c78df4fc62a347455f8d7b3aa186344863915ab3 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -4439,4 +4439,10 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
@@ -4472,4 +4472,10 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
|
||||
void accept(Entity entity, double x, double y, double z);
|
||||
}
|
@ -5,10 +5,10 @@ Subject: [PATCH] Entity#isTicking
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index 71dc4112cb932c6b1305f0f22e99f069517cac08..cfdc8c37d41473300ca9a8c251e27cb2a07ca4c7 100644
|
||||
index c78df4fc62a347455f8d7b3aa186344863915ab3..658e47bf5aff1e56462cc3f0a87eeb7349654176 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -4444,5 +4444,9 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
@@ -4477,5 +4477,9 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
public static int nextEntityId() {
|
||||
return ENTITY_COUNTER.incrementAndGet();
|
||||
}
|
@ -5,10 +5,10 @@ Subject: [PATCH] Climbing should not bypass cramming gamerule
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index cfdc8c37d41473300ca9a8c251e27cb2a07ca4c7..5705dd4c89c2e57540a2eaec0568e45e1947d8c6 100644
|
||||
index 658e47bf5aff1e56462cc3f0a87eeb7349654176..c35d22e4d54abcb16b7ec932729d2f177fd4a14b 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -2024,6 +2024,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
@@ -2057,6 +2057,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
}
|
||||
|
||||
public boolean isPushable() {
|
@ -28,10 +28,10 @@ index 05ac41e136da43284fb24a6b698ebd36318278fb..33d9131e9c75ef23cd637f5d6c39a270
|
||||
|
||||
public Vec3 decode(long x, long y, long z) {
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index 5705dd4c89c2e57540a2eaec0568e45e1947d8c6..0d96f40ca4d08197f101a31cca7e334525542565 100644
|
||||
index c35d22e4d54abcb16b7ec932729d2f177fd4a14b..3acaa05743373b818ba70a0229c6afe63bfd1a97 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -4215,6 +4215,16 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
@@ -4248,6 +4248,16 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
return;
|
||||
}
|
||||
// Paper end - rewrite chunk system
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user