mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-22 02:25:28 +01:00
Optimize checkIfActive to only check if chunks are loaded if entity is active
This will cut down on the call to areChunksLoaded drastically, which is pretty slow
This commit is contained in:
parent
adc47e13e1
commit
577140d9ab
@ -1,4 +1,4 @@
|
||||
From a4fdbca267e36d8b233d2922a0104b208c3af50d Mon Sep 17 00:00:00 2001
|
||||
From 9ee2b803e738023d85d05bfaf16e61aedf600d0e Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Sun, 3 Feb 2013 05:10:21 -0500
|
||||
Subject: [PATCH] Entity Activation Range
|
||||
@ -13,10 +13,10 @@ This change can have dramatic impact on gameplay if configured too low. Balance
|
||||
src/main/java/net/minecraft/server/EntityItem.java | 5 +-
|
||||
src/main/java/net/minecraft/server/World.java | 14 +-
|
||||
.../java/org/bukkit/craftbukkit/CraftWorld.java | 15 +-
|
||||
src/main/java/org/bukkit/craftbukkit/Spigot.java | 219 +++++++++++++++++++++
|
||||
src/main/java/org/bukkit/craftbukkit/Spigot.java | 218 +++++++++++++++++++++
|
||||
.../java/org/bukkit/craftbukkit/SpigotTimings.java | 3 +
|
||||
src/main/resources/configurations/bukkit.yml | 3 +
|
||||
8 files changed, 259 insertions(+), 11 deletions(-)
|
||||
8 files changed, 258 insertions(+), 11 deletions(-)
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
|
||||
index bf9108a..807b4d1 100644
|
||||
@ -173,7 +173,7 @@ index 21bd64a..33df602 100644
|
||||
|
||||
public Block getBlockAt(int x, int y, int z) {
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/Spigot.java b/src/main/java/org/bukkit/craftbukkit/Spigot.java
|
||||
index ad65bca..572527f 100644
|
||||
index ad65bca..32954fa 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/Spigot.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/Spigot.java
|
||||
@@ -1,9 +1,16 @@
|
||||
@ -193,7 +193,7 @@ index ad65bca..572527f 100644
|
||||
|
||||
public static void initialize(CraftServer server, SimpleCommandMap commandMap, YamlConfiguration configuration) {
|
||||
commandMap.register("bukkit", new org.bukkit.craftbukkit.command.TicksPerSecondCommand("tps"));
|
||||
@@ -26,5 +33,217 @@ public class Spigot {
|
||||
@@ -26,5 +33,216 @@ public class Spigot {
|
||||
if (server.chunkGCPeriod == 0) {
|
||||
server.getLogger().severe("[Spigot] You should not disable chunk-gc, unexpected behaviour may occur!");
|
||||
}
|
||||
@ -384,13 +384,6 @@ index ad65bca..572527f 100644
|
||||
+ */
|
||||
+ public static boolean checkIfActive(Entity entity) {
|
||||
+ SpigotTimings.checkIfActiveTimer.startTiming();
|
||||
+ int x = MathHelper.floor(entity.locX);
|
||||
+ int z = MathHelper.floor(entity.locZ);
|
||||
+ // Make sure not on edge of unloaded chunk
|
||||
+ if (!entity.world.areChunksLoaded(x, 0, z, 16)) {
|
||||
+ SpigotTimings.checkIfActiveTimer.stopTiming();
|
||||
+ return false;
|
||||
+ }
|
||||
+ boolean isActive = entity.activatedTick >= MinecraftServer.currentTick || entity.defaultActivationState;
|
||||
+
|
||||
+ // Should this entity tick?
|
||||
@ -407,12 +400,18 @@ index ad65bca..572527f 100644
|
||||
+ } else if (!entity.defaultActivationState && entity.ticksLived % 4 == 0 && !checkEntityImmunities(entity)) {
|
||||
+ isActive = false;
|
||||
+ }
|
||||
+ int x = MathHelper.floor(entity.locX);
|
||||
+ int z = MathHelper.floor(entity.locZ);
|
||||
+ // Make sure not on edge of unloaded chunk
|
||||
+ if (isActive && !entity.world.areChunksLoaded(x, 0, z, 16)) {
|
||||
+ isActive = false;
|
||||
+ }
|
||||
+ SpigotTimings.checkIfActiveTimer.stopTiming();
|
||||
+ return isActive;
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/SpigotTimings.java b/src/main/java/org/bukkit/craftbukkit/SpigotTimings.java
|
||||
index df837a3..9a1bcc5 100644
|
||||
index dec3110..c4e7dda 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/SpigotTimings.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/SpigotTimings.java
|
||||
@@ -30,6 +30,9 @@ public class SpigotTimings {
|
||||
|
@ -1,4 +1,4 @@
|
||||
From b0378ebbdbfe2bb1462cf2c3c44562b9ac731408 Mon Sep 17 00:00:00 2001
|
||||
From 51ae704ad3290541373ec51570d48c9e66743f5c Mon Sep 17 00:00:00 2001
|
||||
From: md_5 <md_5@live.com.au>
|
||||
Date: Sat, 23 Feb 2013 12:33:20 +1100
|
||||
Subject: [PATCH] Watchdog Thread.
|
||||
@ -34,7 +34,7 @@ index aa6a14a..6005fac 100644
|
||||
this.isStopped = true;
|
||||
} catch (Throwable throwable1) {
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/Spigot.java b/src/main/java/org/bukkit/craftbukkit/Spigot.java
|
||||
index 3171411..c0335fa 100644
|
||||
index 83018b0..931f6fd 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/Spigot.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/Spigot.java
|
||||
@@ -1,5 +1,6 @@
|
||||
@ -90,7 +90,7 @@ index 3171411..c0335fa 100644
|
||||
}
|
||||
|
||||
if (server.chunkGCPeriod == 0) {
|
||||
@@ -265,4 +280,63 @@ public class Spigot {
|
||||
@@ -264,4 +279,63 @@ public class Spigot {
|
||||
SpigotTimings.checkIfActiveTimer.stopTiming();
|
||||
return isActive;
|
||||
}
|
||||
@ -297,5 +297,5 @@ index e568bf6..7c18391 100644
|
||||
default:
|
||||
growth-chunks-per-tick: 650
|
||||
--
|
||||
1.8.1-rc2
|
||||
1.8.1.1
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user