mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-30 16:19:03 +01:00
add back optimizing ServerLevel chunk checking methods
This commit is contained in:
parent
7606788417
commit
91e39ea5ac
1 changed files with 64 additions and 0 deletions
|
@ -0,0 +1,64 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
|
||||
Date: Thu, 16 Apr 2020 16:13:59 -0700
|
||||
Subject: [PATCH] Optimize ServerLevels chunk level checking methods
|
||||
|
||||
These can be hot functions (i.e entity ticking and block ticking),
|
||||
so inline where possible, and avoid the abstraction of the
|
||||
Either class.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -0,0 +0,0 @@ public class ServerLevel extends net.minecraft.world.level.Level implements Worl
|
||||
public boolean isPositionTickingWithEntitiesLoaded(BlockPos blockposition) {
|
||||
long i = ChunkPos.asLong(blockposition);
|
||||
|
||||
- return this.chunkSource.isPositionTicking(i) && this.areEntitiesLoaded(i);
|
||||
+ // Paper start - optimize is ticking ready type functions
|
||||
+ ChunkHolder chunkHolder = this.chunkSource.chunkMap.getVisibleChunkIfPresent(i);
|
||||
+ return chunkHolder != null && chunkHolder.isTickingReady() && this.areEntitiesLoaded(i);
|
||||
+ // Paper end
|
||||
}
|
||||
|
||||
public boolean isPositionEntityTicking(BlockPos blockposition) {
|
||||
- return this.entityManager.isPositionTicking(blockposition);
|
||||
+ return this.entityManager.isPositionTicking(ChunkPos.asLong(blockposition)); // Paper
|
||||
}
|
||||
|
||||
public boolean isPositionEntityTicking(ChunkPos chunkcoordintpair) {
|
||||
- return this.entityManager.isPositionTicking(chunkcoordintpair);
|
||||
+ return this.entityManager.isPositionTicking(chunkcoordintpair.toLong()); // Paper
|
||||
}
|
||||
|
||||
private final class EntityCallbacks implements LevelCallback<Entity> {
|
||||
diff --git a/src/main/java/net/minecraft/world/level/ChunkPos.java b/src/main/java/net/minecraft/world/level/ChunkPos.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/ChunkPos.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/ChunkPos.java
|
||||
@@ -0,0 +0,0 @@ public class ChunkPos {
|
||||
}
|
||||
|
||||
public static long asLong(BlockPos blockPos) {
|
||||
- return asLong(SectionPos.blockToSectionCoord(blockPos.getX()), SectionPos.blockToSectionCoord(blockPos.getZ()));
|
||||
+ return (((long)blockPos.getX() >> 4) & 4294967295L) | ((((long)blockPos.getZ() >> 4) & 4294967295L) << 32); // Paper - inline
|
||||
}
|
||||
|
||||
public static int getX(long pos) {
|
||||
diff --git a/src/main/java/net/minecraft/world/level/entity/PersistentEntitySectionManager.java b/src/main/java/net/minecraft/world/level/entity/PersistentEntitySectionManager.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/entity/PersistentEntitySectionManager.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/entity/PersistentEntitySectionManager.java
|
||||
@@ -0,0 +0,0 @@ public class PersistentEntitySectionManager<T extends EntityAccess> implements A
|
||||
public LevelEntityGetter<T> getEntityGetter() {
|
||||
return this.entityGetter;
|
||||
}
|
||||
+ // Paper start
|
||||
+ public final boolean isPositionTicking(long position) {
|
||||
+ return this.chunkVisibility.get(position).isTicking();
|
||||
+ }
|
||||
+ // Paper end
|
||||
|
||||
public boolean isPositionTicking(BlockPos blockPos) {
|
||||
return this.chunkVisibility.get(ChunkPos.asLong(blockPos)).isTicking();
|
Loading…
Reference in a new issue