mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-25 00:30:25 +01:00
1358d1e914
Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: 881e06e5 PR-725: Add Item Unlimited Lifetime APIs CraftBukkit Changes: 74c08312 SPIGOT-6962: Call EntityChangeBlockEvent when when FallingBlockEntity starts to fall 64db5126 SPIGOT-6959: Make /loot command ignore empty items for spawn 2d760831 Increase outdated build delay 9ed7e4fb SPIGOT-6138, SPIGOT-6415: Don't call CreatureSpawnEvent after cross-dimensional travel fc4ad813 SPIGOT-6895: Trees grown with applyBoneMeal() don't fire the StructureGrowthEvent 59733a2e SPIGOT-6961: Actually return a copy of the ItemMeta Spigot Changes: ffceeae3 SPIGOT-6956: Drop unload queue patch as attempt at fixing stop issue e19ddabd PR-1011: Add Item Unlimited Lifetime APIs 34d40b0e SPIGOT-2942: give command fires PlayerDropItemEvent, cancelling it causes Item Duplication
69 lines
3.8 KiB
Diff
69 lines
3.8 KiB
Diff
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 5c5f9cf3539aeba4911d27111b0580d99a61f577..42d7802e787d1e2722bf94487f9bf8383aeef660 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
@@ -2169,19 +2169,22 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
|
}
|
|
|
|
private boolean isPositionTickingWithEntitiesLoaded(long chunkPos) {
|
|
- return this.areEntitiesLoaded(chunkPos) && this.chunkSource.isPositionTicking(chunkPos);
|
|
+ // Paper start - optimize is ticking ready type functions
|
|
+ ChunkHolder chunkHolder = this.chunkSource.chunkMap.getVisibleChunkIfPresent(chunkPos);
|
|
+ return chunkHolder != null && this.chunkSource.isPositionTicking(chunkPos) && chunkHolder.isTickingReady() && this.areEntitiesLoaded(chunkPos);
|
|
+ // Paper end
|
|
}
|
|
|
|
public boolean isPositionEntityTicking(BlockPos pos) {
|
|
- return this.entityManager.canPositionTick(pos) && this.chunkSource.chunkMap.getDistanceManager().inEntityTickingRange(ChunkPos.asLong(pos));
|
|
+ return this.entityManager.canPositionTick(ChunkPos.asLong(pos)) && this.chunkSource.chunkMap.getDistanceManager().inEntityTickingRange(ChunkPos.asLong(pos)); // Paper
|
|
}
|
|
|
|
public boolean isNaturalSpawningAllowed(BlockPos pos) {
|
|
- return this.entityManager.canPositionTick(pos);
|
|
+ return this.entityManager.canPositionTick(ChunkPos.asLong(pos)); // Paper
|
|
}
|
|
|
|
public boolean isNaturalSpawningAllowed(ChunkPos pos) {
|
|
- return this.entityManager.canPositionTick(pos);
|
|
+ return this.entityManager.canPositionTick(pos.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 4c5f8a103b550a681178926096d5f758654c61a7..d2952a1a84ae7326e2d4a1f19497db8f978e4688 100644
|
|
--- a/src/main/java/net/minecraft/world/level/ChunkPos.java
|
|
+++ b/src/main/java/net/minecraft/world/level/ChunkPos.java
|
|
@@ -50,7 +50,7 @@ public class ChunkPos {
|
|
}
|
|
|
|
public static long asLong(BlockPos pos) {
|
|
- return asLong(SectionPos.blockToSectionCoord(pos.getX()), SectionPos.blockToSectionCoord(pos.getZ()));
|
|
+ return (((long)pos.getX() >> 4) & 4294967295L) | ((((long)pos.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 1407f30d467fa78bc207a91da0e6395c0a9ba83d..2110cb437807f99994838b57653caefe2f01a9c5 100644
|
|
--- a/src/main/java/net/minecraft/world/level/entity/PersistentEntitySectionManager.java
|
|
+++ b/src/main/java/net/minecraft/world/level/entity/PersistentEntitySectionManager.java
|
|
@@ -383,6 +383,11 @@ public class PersistentEntitySectionManager<T extends EntityAccess> implements A
|
|
public LevelEntityGetter<T> getEntityGetter() {
|
|
return this.entityGetter;
|
|
}
|
|
+ // Paper start
|
|
+ public final boolean canPositionTick(long position) {
|
|
+ return this.chunkVisibility.get(position).isTicking();
|
|
+ }
|
|
+ // Paper end
|
|
|
|
public boolean canPositionTick(BlockPos pos) {
|
|
return ((Visibility) this.chunkVisibility.get(ChunkPos.asLong(pos))).isTicking();
|