Compare commits

...

5 Commits

Author SHA1 Message Date
kugge
31c6a8e270 Stashes 2023-06-25 12:51:46 +02:00
kugge
6657b9cb08 Fixes 2023-06-22 20:55:02 +02:00
kugge
3176184ca6 Cache scaledRange on highly repetitive calls 2023-06-22 18:29:11 +02:00
kugge
bc3e578199 Move optimizeHoppers & tickWhenEmpty to the optimization section 2023-06-22 15:44:40 +02:00
kugge
8ead6a39e8 Typo 2023-06-22 01:08:14 +02:00
14 changed files with 511 additions and 74 deletions

View File

@@ -29,7 +29,7 @@ optimization:
disable-vanish-api: false
disable-player-stats: false
disable-arm-swing-event: false
disable-ensure-tick-thread-check: false
disable-ensure-tick-thread-checks: false
gameplay:
server-mod-name: Kaiiju
shared-random-for-players: true

View File

@@ -6,20 +6,21 @@ Subject: [PATCH] Toggle optimize hoppers
Paper optimize hoppers patch break a lot of technical redstone farms because of piston updates. (Example: twiti888 wood farm)
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
index 95ed6cb7b94797187d1011cab344e187b39d9193..72bcf8e35593bb54079b6cbd9238acdcd43c3e46 100644
index 95ed6cb7b94797187d1011cab344e187b39d9193..6d7356cc07da58b1cef8d8963e790251d765de2c 100644
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
@@ -153,8 +153,10 @@ public class KaiijuWorldConfig {
@@ -147,9 +147,11 @@ public class KaiijuWorldConfig {
}
public boolean shulkerBoxDropContentsWhenDestroyed = true;
+ public boolean optimizeHoppers = true;
private void optimizationSettings() {
shulkerBoxDropContentsWhenDestroyed = getBoolean("optimization.shulker-box-drop-contents-when-destroyed", shulkerBoxDropContentsWhenDestroyed);
+ optimizeHoppers = getBoolean("optimization.optimize-hoppers", optimizeHoppers);
}
public boolean fixVoidTrading = true;
+ public boolean optimizeHoppers = true;
private void gameplaySettings() {
fixVoidTrading = getBoolean("gameplay.fix-void-trading", fixVoidTrading);
+ optimizeHoppers = getBoolean("gameplay.optimize-hoppers", optimizeHoppers);
}
}
diff --git a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
index 4825a74ce4893dafdb70ae1badf3d2e1930d01a1..762b763f271c3208b4f8a7e346897207ec5beb6c 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java

View File

@@ -5,21 +5,22 @@ Subject: [PATCH] Toggle tick level when empty
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
index 72bcf8e35593bb54079b6cbd9238acdcd43c3e46..9802039d34eb1717b712c9041fd9f602fccae236 100644
index 6d7356cc07da58b1cef8d8963e790251d765de2c..601b9867d839f4928ba993ee8f00df9c330a0fe3 100644
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
@@ -154,9 +154,11 @@ public class KaiijuWorldConfig {
@@ -148,10 +148,12 @@ public class KaiijuWorldConfig {
public boolean fixVoidTrading = true;
public boolean shulkerBoxDropContentsWhenDestroyed = true;
public boolean optimizeHoppers = true;
+ public boolean tickWhenEmpty = true;
private void gameplaySettings() {
fixVoidTrading = getBoolean("gameplay.fix-void-trading", fixVoidTrading);
optimizeHoppers = getBoolean("gameplay.optimize-hoppers", optimizeHoppers);
+ tickWhenEmpty = getBoolean("gameplay.tick-when-empty", tickWhenEmpty);
}
private void optimizationSettings() {
shulkerBoxDropContentsWhenDestroyed = getBoolean("optimization.shulker-box-drop-contents-when-destroyed", shulkerBoxDropContentsWhenDestroyed);
optimizeHoppers = getBoolean("optimization.optimize-hoppers", optimizeHoppers);
+ tickWhenEmpty = getBoolean("optimization.tick-when-empty", tickWhenEmpty);
}
public boolean fixVoidTrading = true;
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index 7f39e36037d55278d15399196459e51b885c5d1e..66509fa23bfcde70abd3917eb774cf48d5d6da93 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java

View File

@@ -6,19 +6,17 @@ Subject: [PATCH] Toggle break redstone on top of trap doors early
That patch break vanilla mechanics such as portal slicing.
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
index 9802039d34eb1717b712c9041fd9f602fccae236..3355935bbf8059d8a539dcefb84e3c0785314ce2 100644
index 601b9867d839f4928ba993ee8f00df9c330a0fe3..e7ee85b09aa4438868e068551280b13e84cdfdb8 100644
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
@@ -155,10 +155,12 @@ public class KaiijuWorldConfig {
@@ -157,8 +157,10 @@ public class KaiijuWorldConfig {
}
public boolean fixVoidTrading = true;
public boolean optimizeHoppers = true;
public boolean tickWhenEmpty = true;
+ public boolean breakRedstoneOnTopOfTrapDoorsEarly = true;
private void gameplaySettings() {
fixVoidTrading = getBoolean("gameplay.fix-void-trading", fixVoidTrading);
optimizeHoppers = getBoolean("gameplay.optimize-hoppers", optimizeHoppers);
tickWhenEmpty = getBoolean("gameplay.tick-when-empty", tickWhenEmpty);
+ breakRedstoneOnTopOfTrapDoorsEarly = getBoolean("gameplay.break-redstone-on-top-of-trap-doors-early", breakRedstoneOnTopOfTrapDoorsEarly);
}
}

View File

@@ -6,19 +6,17 @@ Subject: [PATCH] Toggle fix TripWire state inconsistency
This allow string duplication
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
index 3355935bbf8059d8a539dcefb84e3c0785314ce2..5c87df0fd68e4971201836b6301d526378271af5 100644
index e7ee85b09aa4438868e068551280b13e84cdfdb8..8d7821d8b1a3615eaef1073d9dab690559b85f81 100644
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
@@ -156,11 +156,13 @@ public class KaiijuWorldConfig {
public boolean optimizeHoppers = true;
public boolean tickWhenEmpty = true;
@@ -158,9 +158,11 @@ public class KaiijuWorldConfig {
public boolean fixVoidTrading = true;
public boolean breakRedstoneOnTopOfTrapDoorsEarly = true;
+ public boolean fixTripWireStateInconsistency = true;
private void gameplaySettings() {
fixVoidTrading = getBoolean("gameplay.fix-void-trading", fixVoidTrading);
optimizeHoppers = getBoolean("gameplay.optimize-hoppers", optimizeHoppers);
tickWhenEmpty = getBoolean("gameplay.tick-when-empty", tickWhenEmpty);
breakRedstoneOnTopOfTrapDoorsEarly = getBoolean("gameplay.break-redstone-on-top-of-trap-doors-early", breakRedstoneOnTopOfTrapDoorsEarly);
+ fixTripWireStateInconsistency = getBoolean("gameplay.fix-tripwire-state-inconsistency", fixTripWireStateInconsistency);
}

View File

@@ -18,7 +18,7 @@ index 1615346024037f2abe0fcfcfc5ea7713505bebca..d24f5fdc6a8c34774933a5cd8bfed857
implementation("net.minecrell:terminalconsoleappender:1.3.0")
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuEntityLimits.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuEntityLimits.java
new file mode 100644
index 0000000000000000000000000000000000000000..887ea85ca2a03796bfa5bf62f27d1a7abd7fbc29
index 0000000000000000000000000000000000000000..9fc0823faa2a27a470adb24d688b2f9e60f628eb
--- /dev/null
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuEntityLimits.java
@@ -0,0 +1,139 @@
@@ -86,16 +86,16 @@ index 0000000000000000000000000000000000000000..887ea85ca2a03796bfa5bf62f27d1a7a
+ try {
+ entityLimitsConfig.load(ENTITY_LIMITS_FILE);
+ } catch (InvalidConfigurationException ex) {
+ Bukkit.getLogger().log(Level.SEVERE, "Could not load kaiiju_entity_limits.yml, please correct your syntax errors", ex);
+ Bukkit.getLogger().log(Level.SEVERE, "Could not load kaiiju-entity-limits.yml, please correct your syntax errors", ex);
+ throw Throwables.propagate(ex);
+ } catch (IOException ignore) {}
+ } else {
+ if (setup) {
+ entityLimitsConfig.options().header(HEADER);
+ entityLimitsConfig.options().copyDefaults(true);
+ entityLimitsConfig.set("Wither.limit", 1000);
+ entityLimitsConfig.set("Wither.tick-throttle", 1000);
+ entityLimitsConfig.set("Wither.removal", 5000);
+ entityLimitsConfig.set("Axolotl.limit", 1000);
+ entityLimitsConfig.set("Axolotl.tick-throttle", 1000);
+ entityLimitsConfig.set("Axolotl.removal", 5000);
+ try {
+ entityLimitsConfig.save(ENTITY_LIMITS_FILE);
@@ -121,19 +121,19 @@ index 0000000000000000000000000000000000000000..887ea85ca2a03796bfa5bf62f27d1a7a
+ LOGGER.error("Unknown entity '" + key + "' in kaiiju-entity-limits.yml, skipping");
+ continue;
+ }
+ int limit = entityLimitsConfig.getInt(key + ".limit");
+ int tickThrottle = entityLimitsConfig.getInt(key + ".tick-throttle");
+ int removal = entityLimitsConfig.getInt(key + ".removal");
+
+ if (limit < 1) {
+ LOGGER.error(key + " has a limit less than the minimum of 1, ignoring");
+ if (tickThrottle < 1) {
+ LOGGER.error(key + " has a tick-throttle less than the minimum of 1, ignoring");
+ continue;
+ }
+ if (removal <= limit && removal != -1) {
+ if (removal <= tickThrottle && removal != -1) {
+ LOGGER.error(key + " has a removal limit that is less than or equal to its limit, setting removal to limit * 10");
+ removal = limit * 10;
+ removal = tickThrottle * 10;
+ }
+
+ entityLimits.put((Class<? extends Entity>) Class.forName(entityClasses.get(key).getName()), new EntityLimit(limit, removal));
+ entityLimits.put((Class<? extends Entity>) Class.forName(entityClasses.get(key).getName()), new EntityLimit(tickThrottle, removal));
+ }
+ } catch (ClassNotFoundException e) {
+ e.printStackTrace();
@@ -154,10 +154,10 @@ index 0000000000000000000000000000000000000000..887ea85ca2a03796bfa5bf62f27d1a7a
+ }
+ }
+
+ public record EntityLimit(int limit, int removal) {
+ public record EntityLimit(int tickThrottle, int removal) {
+ @Override
+ public String toString() {
+ return "EntityLimit{limit=" + limit + ", removal=" + removal + "}";
+ return "EntityLimit{tickThrottle=" + tickThrottle + ", removal=" + removal + "}";
+ }
+ }
+}
@@ -252,17 +252,19 @@ index 0000000000000000000000000000000000000000..eb690efacf083e4ff3e321578b12c534
+ }
+}
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
index 5c87df0fd68e4971201836b6301d526378271af5..ecae04b0cc317b154b29ca80a7246dc19e5d67ba 100644
index 8d7821d8b1a3615eaef1073d9dab690559b85f81..816db23fa64aab69e3034484c00645ebd0479978 100644
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
@@ -147,9 +147,11 @@ public class KaiijuWorldConfig {
}
@@ -149,11 +149,13 @@ public class KaiijuWorldConfig {
public boolean shulkerBoxDropContentsWhenDestroyed = true;
public boolean optimizeHoppers = true;
public boolean tickWhenEmpty = true;
+ public boolean enableEntityThrottling = false;
private void optimizationSettings() {
shulkerBoxDropContentsWhenDestroyed = getBoolean("optimization.shulker-box-drop-contents-when-destroyed", shulkerBoxDropContentsWhenDestroyed);
optimizeHoppers = getBoolean("optimization.optimize-hoppers", optimizeHoppers);
tickWhenEmpty = getBoolean("optimization.tick-when-empty", tickWhenEmpty);
+ enableEntityThrottling = getBoolean("optimization.enable-entity-throttling", enableEntityThrottling);
}

View File

@@ -5,19 +5,17 @@ Subject: [PATCH] Toggle safe teleportation
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
index ecae04b0cc317b154b29ca80a7246dc19e5d67ba..68074cc41c1e4cd06f2562d44947b63722d5af50 100644
index 816db23fa64aab69e3034484c00645ebd0479978..7c6c74f95c2534624a928ccf6b0a4b9d2a5486ad 100644
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
@@ -159,6 +159,7 @@ public class KaiijuWorldConfig {
public boolean tickWhenEmpty = true;
@@ -161,10 +161,12 @@ public class KaiijuWorldConfig {
public boolean fixVoidTrading = true;
public boolean breakRedstoneOnTopOfTrapDoorsEarly = true;
public boolean fixTripWireStateInconsistency = true;
+ public boolean safeTeleporting = true;
private void gameplaySettings() {
fixVoidTrading = getBoolean("gameplay.fix-void-trading", fixVoidTrading);
@@ -166,5 +167,6 @@ public class KaiijuWorldConfig {
tickWhenEmpty = getBoolean("gameplay.tick-when-empty", tickWhenEmpty);
breakRedstoneOnTopOfTrapDoorsEarly = getBoolean("gameplay.break-redstone-on-top-of-trap-doors-early", breakRedstoneOnTopOfTrapDoorsEarly);
fixTripWireStateInconsistency = getBoolean("gameplay.fix-tripwire-state-inconsistency", fixTripWireStateInconsistency);
+ safeTeleporting = getBoolean("gameplay.safe-teleportation", safeTeleporting);

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Toggle sand duplication
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
index 68074cc41c1e4cd06f2562d44947b63722d5af50..be32a516c1ee0f95790b8a96c465045ca4355c76 100644
index 7c6c74f95c2534624a928ccf6b0a4b9d2a5486ad..9f0095f2196133a8bcffd5306aa9ac0b99b2f8d7 100644
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
@@ -160,6 +160,7 @@ public class KaiijuWorldConfig {
@@ -162,11 +162,13 @@ public class KaiijuWorldConfig {
public boolean breakRedstoneOnTopOfTrapDoorsEarly = true;
public boolean fixTripWireStateInconsistency = true;
public boolean safeTeleporting = true;
@@ -16,7 +16,6 @@ index 68074cc41c1e4cd06f2562d44947b63722d5af50..be32a516c1ee0f95790b8a96c465045c
private void gameplaySettings() {
fixVoidTrading = getBoolean("gameplay.fix-void-trading", fixVoidTrading);
@@ -168,5 +169,6 @@ public class KaiijuWorldConfig {
breakRedstoneOnTopOfTrapDoorsEarly = getBoolean("gameplay.break-redstone-on-top-of-trap-doors-early", breakRedstoneOnTopOfTrapDoorsEarly);
fixTripWireStateInconsistency = getBoolean("gameplay.fix-tripwire-state-inconsistency", fixTripWireStateInconsistency);
safeTeleporting = getBoolean("gameplay.safe-teleportation", safeTeleporting);

View File

@@ -5,17 +5,19 @@ Subject: [PATCH] Option to disable achievements
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
index be32a516c1ee0f95790b8a96c465045ca4355c76..27a0f1d81161adb86339f4b829c3628c1022271b 100644
index 9f0095f2196133a8bcffd5306aa9ac0b99b2f8d7..31d66bb2fcf4bb7262df2d8006e307fee92660ea 100644
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
@@ -148,10 +148,12 @@ public class KaiijuWorldConfig {
public boolean shulkerBoxDropContentsWhenDestroyed = true;
@@ -150,12 +150,14 @@ public class KaiijuWorldConfig {
public boolean optimizeHoppers = true;
public boolean tickWhenEmpty = true;
public boolean enableEntityThrottling = false;
+ public boolean disableAchievements = false;
private void optimizationSettings() {
shulkerBoxDropContentsWhenDestroyed = getBoolean("optimization.shulker-box-drop-contents-when-destroyed", shulkerBoxDropContentsWhenDestroyed);
optimizeHoppers = getBoolean("optimization.optimize-hoppers", optimizeHoppers);
tickWhenEmpty = getBoolean("optimization.tick-when-empty", tickWhenEmpty);
enableEntityThrottling = getBoolean("optimization.enable-entity-throttling", enableEntityThrottling);
+ disableAchievements = getBoolean("optimization.disable-achievements", disableAchievements);
}

View File

@@ -5,17 +5,19 @@ Subject: [PATCH] Option to disable creatures spawn events
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
index 27a0f1d81161adb86339f4b829c3628c1022271b..58b0725fea8d2216242a949b9ed2b3d9e93ef1f3 100644
index 31d66bb2fcf4bb7262df2d8006e307fee92660ea..c9830912019079369268bfbf2c95de18ad598f52 100644
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
@@ -149,11 +149,13 @@ public class KaiijuWorldConfig {
public boolean shulkerBoxDropContentsWhenDestroyed = true;
@@ -151,6 +151,7 @@ public class KaiijuWorldConfig {
public boolean tickWhenEmpty = true;
public boolean enableEntityThrottling = false;
public boolean disableAchievements = false;
+ public boolean disableCreaturesSpawnEvents = false;
private void optimizationSettings() {
shulkerBoxDropContentsWhenDestroyed = getBoolean("optimization.shulker-box-drop-contents-when-destroyed", shulkerBoxDropContentsWhenDestroyed);
@@ -158,6 +159,7 @@ public class KaiijuWorldConfig {
tickWhenEmpty = getBoolean("optimization.tick-when-empty", tickWhenEmpty);
enableEntityThrottling = getBoolean("optimization.enable-entity-throttling", enableEntityThrottling);
disableAchievements = getBoolean("optimization.disable-achievements", disableAchievements);
+ disableCreaturesSpawnEvents = getBoolean("optimization.disable-creatures-spawn-events", disableCreaturesSpawnEvents);

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Option to disable dolphin swim to treasure
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
index 58b0725fea8d2216242a949b9ed2b3d9e93ef1f3..87887a6d266767fd46f4d65d89dfb9d853089db4 100644
index c9830912019079369268bfbf2c95de18ad598f52..e2fb7d7a7b3126d386b46442c115085d1974ac4e 100644
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
@@ -150,12 +150,14 @@ public class KaiijuWorldConfig {
@@ -152,6 +152,7 @@ public class KaiijuWorldConfig {
public boolean enableEntityThrottling = false;
public boolean disableAchievements = false;
public boolean disableCreaturesSpawnEvents = false;
@@ -16,6 +16,7 @@ index 58b0725fea8d2216242a949b9ed2b3d9e93ef1f3..87887a6d266767fd46f4d65d89dfb9d8
private void optimizationSettings() {
shulkerBoxDropContentsWhenDestroyed = getBoolean("optimization.shulker-box-drop-contents-when-destroyed", shulkerBoxDropContentsWhenDestroyed);
@@ -160,6 +161,7 @@ public class KaiijuWorldConfig {
enableEntityThrottling = getBoolean("optimization.enable-entity-throttling", enableEntityThrottling);
disableAchievements = getBoolean("optimization.disable-achievements", disableAchievements);
disableCreaturesSpawnEvents = getBoolean("optimization.disable-creatures-spawn-events", disableCreaturesSpawnEvents);

View File

@@ -5,32 +5,32 @@ Subject: [PATCH] Option to disable ensure tick thread checks
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
index ec71f3f52cb8f7931aabd94619d2e7a24491d7ad..900d319f4ddb17af2275c1a20824648b41d39aac 100644
index ec71f3f52cb8f7931aabd94619d2e7a24491d7ad..fa2a763e5784e7dae02c94a13751cbf746b6eee8 100644
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuConfig.java
@@ -210,11 +210,13 @@ public class KaiijuConfig {
public static boolean disableVanishApi = false;
public static boolean disablePlayerStats = false;
public static boolean disableArmSwingEvent = false;
+ public static boolean disableEnsureTickThreadCheck = false;
+ public static boolean disableEnsureTickThreadChecks = false;
private static void optimizationSettings() {
disableVanishApi = getBoolean("optimization.disable-vanish-api", disableVanishApi);
disablePlayerStats = getBoolean("optimization.disable-player-stats", disablePlayerStats);
disableArmSwingEvent = getBoolean("optimization.disable-arm-swing-event", disableArmSwingEvent);
+ disableEnsureTickThreadCheck = getBoolean("optimization.disable-ensure-tick-thread-check", disableEnsureTickThreadCheck);
+ disableEnsureTickThreadChecks = getBoolean("optimization.disable-ensure-tick-thread-checks", disableEnsureTickThreadChecks);
}
public static String serverModName = "Kaiiju";
diff --git a/src/main/java/io/papermc/paper/util/TickThread.java b/src/main/java/io/papermc/paper/util/TickThread.java
index cb453dd110fc37fae75257a4576512126207763e..6d0c5aa38b6980c80c2021933c4758e2dabed9fd 100644
index cb453dd110fc37fae75257a4576512126207763e..492e6a512343001d3d772d2d8b427d2d84e89da5 100644
--- a/src/main/java/io/papermc/paper/util/TickThread.java
+++ b/src/main/java/io/papermc/paper/util/TickThread.java
@@ -46,6 +46,7 @@ public class TickThread extends Thread {
*/
@Deprecated
public static void ensureTickThread(final String reason) {
+ if (dev.kaiijumc.kaiiju.KaiijuConfig.disableEnsureTickThreadCheck) return; // Kaiiju
+ if (dev.kaiijumc.kaiiju.KaiijuConfig.disableEnsureTickThreadChecks) return; // Kaiiju
if (!isTickThread()) {
MinecraftServer.LOGGER.error("Thread " + Thread.currentThread().getName() + " failed main thread check: " + reason, new Throwable());
throw new IllegalStateException(reason);
@@ -38,7 +38,7 @@ index cb453dd110fc37fae75257a4576512126207763e..6d0c5aa38b6980c80c2021933c4758e2
}
public static void ensureTickThread(final ServerLevel world, final BlockPos pos, final String reason) {
+ if (dev.kaiijumc.kaiiju.KaiijuConfig.disableEnsureTickThreadCheck) return; // Kaiiju
+ if (dev.kaiijumc.kaiiju.KaiijuConfig.disableEnsureTickThreadChecks) return; // Kaiiju
if (!isTickThreadFor(world, pos)) {
MinecraftServer.LOGGER.error("Thread " + Thread.currentThread().getName() + " failed main thread check: " + reason, new Throwable());
throw new IllegalStateException(reason);
@@ -46,7 +46,7 @@ index cb453dd110fc37fae75257a4576512126207763e..6d0c5aa38b6980c80c2021933c4758e2
}
public static void ensureTickThread(final ServerLevel world, final ChunkPos pos, final String reason) {
+ if (dev.kaiijumc.kaiiju.KaiijuConfig.disableEnsureTickThreadCheck) return; // Kaiiju
+ if (dev.kaiijumc.kaiiju.KaiijuConfig.disableEnsureTickThreadChecks) return; // Kaiiju
if (!isTickThreadFor(world, pos)) {
MinecraftServer.LOGGER.error("Thread " + Thread.currentThread().getName() + " failed main thread check: " + reason, new Throwable());
throw new IllegalStateException(reason);
@@ -54,7 +54,7 @@ index cb453dd110fc37fae75257a4576512126207763e..6d0c5aa38b6980c80c2021933c4758e2
}
public static void ensureTickThread(final ServerLevel world, final int chunkX, final int chunkZ, final String reason) {
+ if (dev.kaiijumc.kaiiju.KaiijuConfig.disableEnsureTickThreadCheck) return; // Kaiiju
+ if (dev.kaiijumc.kaiiju.KaiijuConfig.disableEnsureTickThreadChecks) return; // Kaiiju
if (!isTickThreadFor(world, chunkX, chunkZ)) {
MinecraftServer.LOGGER.error("Thread " + Thread.currentThread().getName() + " failed main thread check: " + reason, new Throwable());
throw new IllegalStateException(reason);
@@ -62,7 +62,7 @@ index cb453dd110fc37fae75257a4576512126207763e..6d0c5aa38b6980c80c2021933c4758e2
}
public static void ensureTickThread(final Entity entity, final String reason) {
+ if (dev.kaiijumc.kaiiju.KaiijuConfig.disableEnsureTickThreadCheck) return; // Kaiiju
+ if (dev.kaiijumc.kaiiju.KaiijuConfig.disableEnsureTickThreadChecks) return; // Kaiiju
if (!isTickThreadFor(entity)) {
MinecraftServer.LOGGER.error("Thread " + Thread.currentThread().getName() + " failed main thread check: " + reason, new Throwable());
throw new IllegalStateException(reason);
@@ -70,7 +70,7 @@ index cb453dd110fc37fae75257a4576512126207763e..6d0c5aa38b6980c80c2021933c4758e2
}
public static void ensureTickThread(final ServerLevel world, final AABB aabb, final String reason) {
+ if (dev.kaiijumc.kaiiju.KaiijuConfig.disableEnsureTickThreadCheck) return; // Kaiiju
+ if (dev.kaiijumc.kaiiju.KaiijuConfig.disableEnsureTickThreadChecks) return; // Kaiiju
if (!isTickThreadFor(world, aabb)) {
MinecraftServer.LOGGER.error("Thread " + Thread.currentThread().getName() + " failed main thread check: " + reason, new Throwable());
throw new IllegalStateException(reason);
@@ -78,7 +78,7 @@ index cb453dd110fc37fae75257a4576512126207763e..6d0c5aa38b6980c80c2021933c4758e2
}
public static void ensureTickThread(final ServerLevel world, final double blockX, final double blockZ, final String reason) {
+ if (dev.kaiijumc.kaiiju.KaiijuConfig.disableEnsureTickThreadCheck) return; // Kaiiju
+ if (dev.kaiijumc.kaiiju.KaiijuConfig.disableEnsureTickThreadChecks) return; // Kaiiju
if (!isTickThreadFor(world, blockX, blockZ)) {
MinecraftServer.LOGGER.error("Thread " + Thread.currentThread().getName() + " failed main thread check: " + reason, new Throwable());
throw new IllegalStateException(reason);

View File

@@ -0,0 +1,19 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: kugge <sofiane.djerbi38@gmail.com>
Date: Thu, 22 Jun 2023 20:32:58 +0200
Subject: [PATCH] Fix teleportAsync rotation API
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
index 76bcfda336e9cfa039d80ea3ccbebbc3d2b13f7f..24617b3994c0f148f1c17928e18aa1e1a784e6f5 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
@@ -1329,7 +1329,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
boolean success = nmsEntity.teleportAsync(
((CraftWorld)locationClone.getWorld()).getHandle(),
new net.minecraft.world.phys.Vec3(locationClone.getX(), locationClone.getY(), locationClone.getZ()),
- null, null, net.minecraft.world.phys.Vec3.ZERO,
+ locationClone.getYaw(), locationClone.getPitch(), net.minecraft.world.phys.Vec3.ZERO, // Kaiiju - fix teleportAsync() rotation
cause == null ? TeleportCause.UNKNOWN : cause,
Entity.TELEPORT_FLAG_LOAD_CHUNK | Entity.TELEPORT_FLAG_UNMOUNT, // preserve behavior with old API: dismount the entity so it can teleport
(Entity entityTp) -> {

View File

@@ -0,0 +1,416 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: kugge <sofiane.djerbi38@gmail.com>
Date: Sun, 25 Jun 2023 12:51:07 +0200
Subject: [PATCH] Stashes
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuEntityLimits.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuEntityLimits.java
index 9fc0823faa2a27a470adb24d688b2f9e60f628eb..a6dd123915434f9fea22e95adab5c805ce069dee 100644
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuEntityLimits.java
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuEntityLimits.java
@@ -2,11 +2,10 @@ package dev.kaiijumc.kaiiju;
import java.io.File;
import java.io.IOException;
-import java.util.Map;
+import java.util.Arrays;import java.util.List;import java.util.Map;
import java.util.HashMap;
import java.util.logging.Level;
-import com.google.common.base.Throwables;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import io.github.classgraph.ClassGraph;
import io.github.classgraph.ClassInfo;
@@ -23,11 +22,11 @@ import org.bukkit.configuration.file.YamlConfiguration;
public class KaiijuEntityLimits {
private static final Logger LOGGER = LogUtils.getLogger();
- protected static final String HEADER =
- "Per region entity limits for Kaiiju.\n"
- + "If there are more of particular entity type in a region than limit, entity ticking will be throttled.\n"
- + "Example: for Wither limit 100 & 300 Withers in a region -> 100 Withers tick every tick & every Wither ticks every 3 ticks.\n"
- + "Available entities: GlowSquid, Ambient, Bat, Animal, Bee, Cat, Chicken, Cod, Cow, Dolphin, Fish, FishSchool, Fox, Golem, IronGolem, "
+ protected static final List<String> HEADER = Arrays.asList(
+ "Per region entity limits for Kaiiju.",
+ "If there are more of particular entity type in a region than limit, entity ticking will be throttled.",
+ "Example: for Wither limit 100 & 300 Withers in a region -> 100 Withers tick every tick & every Wither ticks every 3 ticks.",
+ "Available entities: GlowSquid, Ambient, Bat, Animal, Bee, Cat, Chicken, Cod, Cow, Dolphin, Fish, FishSchool, Fox, Golem, IronGolem,"
+ "MushroomCow, Ocelot, Panda, Parrot, Perchable, Pig, PolarBear, PufferFish, Rabbit, Salmon, Sheep, Snowman, Squid, TropicalFish, Turtle, "
+ "WaterAnimal, Wolf, Allay, Axolotl, Camel, Frog, Tadpole, Goat, Horse, HorseAbstract, HorseChestedAbstract, HorseDonkey, HorseMule, "
+ "HorseSkeleton, HorseZombie, Llama, LlamaTrader, Sniffer, EnderCrystal, EnderDragon, Wither, ArmorStand, Hanging, ItemFrame, Leash, "
@@ -38,8 +37,7 @@ public class KaiijuEntityLimits {
+ "VillagerTrader, Arrow, DragonFireball, Egg, EnderPearl, EnderSignal, EvokerFangs, Fireball, FireballFireball, Fireworks, FishingHook, "
+ "LargeFireball, LlamaSpit, Potion, Projectile, ProjectileThrowable, ShulkerBullet, SmallFireball, Snowball, SpectralArrow, ThrownExpBottle, "
+ "ThrownTrident, TippedArrow, WitherSkull, Raider, ChestBoat, Boat, MinecartAbstract, MinecartChest, MinecartCommandBlock, MinecartContainer, "
- + "MinecartFurnace, MinecartHopper, MinecartMobSpawner, MinecartRideable, MinecartTNT\n";
- protected static File ENTITY_LIMITS_FILE;
+ + "MinecartFurnace, MinecartHopper, MinecartMobSpawner, MinecartRideable, MinecartTNT");
public static YamlConfiguration entityLimitsConfig;
protected static Map<Class<? extends Entity>, EntityLimit> entityLimits;
@@ -54,36 +52,37 @@ public class KaiijuEntityLimits {
init(entityLimitsFile, false);
}
- private static void init(File entityLimitsFile, boolean setup) {
- ENTITY_LIMITS_FILE = entityLimitsFile;
- entityLimitsConfig = new YamlConfiguration();
+ private static void setDefaultEntityLimits(YamlConfiguration config) {
+ config.options().setHeader(HEADER);
+ config.options().copyDefaults(true);
+ config.set("Wither.brain-throttle", 50);
+ config.set("Wither.tick-throttle", 100);
+ config.set("Wither.removal", 500);
+ config.set("Axolotl.brain-throttle", 100);
+ config.set("Axolotl.tick-throttle", 200);
+ config.set("Axolotl.removal", 1000);
+ }
- if (entityLimitsFile.exists()) {
- try {
- entityLimitsConfig.load(ENTITY_LIMITS_FILE);
- } catch (InvalidConfigurationException ex) {
- Bukkit.getLogger().log(Level.SEVERE, "Could not load kaiiju-entity-limits.yml, please correct your syntax errors", ex);
- throw Throwables.propagate(ex);
- } catch (IOException ignore) {}
- } else {
- if (setup) {
- entityLimitsConfig.options().header(HEADER);
- entityLimitsConfig.options().copyDefaults(true);
- entityLimitsConfig.set("Wither.tick-throttle", 1000);
- entityLimitsConfig.set("Wither.removal", 5000);
- entityLimitsConfig.set("Axolotl.tick-throttle", 1000);
- entityLimitsConfig.set("Axolotl.removal", 5000);
- try {
- entityLimitsConfig.save(ENTITY_LIMITS_FILE);
- } catch (IOException ex) {
- Bukkit.getLogger().log(Level.SEVERE, "Could not save " + ENTITY_LIMITS_FILE, ex);
- }
- }
+ private static void saveEntityLimitsConfig(File entityLimitsFile) {
+ try {
+ entityLimitsConfig.save(entityLimitsFile);
+ } catch (IOException ex) {
+ Bukkit.getLogger().log(Level.SEVERE, "Could not save " + entityLimitsFile, ex);
}
+ }
- entityLimits = new Object2ObjectOpenHashMap<>();
+ private static void loadEntityLimitsConfig(File entityLimitsFile) {
+ try {
+ entityLimitsConfig.load(entityLimitsFile);
+ } catch (InvalidConfigurationException ex) {
+ Bukkit.getLogger().log(Level.SEVERE, "Could not load kaiiju-entity-limits.yml, please correct your syntax errors", ex);
+ throw new RuntimeException(ex);
+ } catch (IOException ignore) {}
+ }
+
+ private static Map<String, ClassInfo> scanEntityClasses() {
+ Map<String, ClassInfo> entityClasses = new HashMap<>();
try (ScanResult scanResult = new ClassGraph().enableAllInfo().acceptPackages("net.minecraft.world.entity").scan()) {
- Map<String, ClassInfo> entityClasses = new HashMap<>();
for (ClassInfo classInfo : scanResult.getAllClasses()) {
Class<?> entityClass = Class.forName(classInfo.getName());
if (Entity.class.isAssignableFrom(entityClass)) {
@@ -91,28 +90,42 @@ public class KaiijuEntityLimits {
entityClasses.put(entityName, classInfo);
}
}
+ } catch (ClassNotFoundException e) {
+ e.printStackTrace();
+ }
+ return entityClasses;
+ }
- for (String key : entityLimitsConfig.getKeys(false)) {
- if (!entityClasses.containsKey(key)) {
- LOGGER.error("Unknown entity '" + key + "' in kaiiju-entity-limits.yml, skipping");
- continue;
- }
- int tickThrottle = entityLimitsConfig.getInt(key + ".tick-throttle");
- int removal = entityLimitsConfig.getInt(key + ".removal");
+ private static void init(File entityLimitsFile, boolean setup) {
+ entityLimitsConfig = new YamlConfiguration();
+
+ if (entityLimitsFile.exists()) {
+ loadEntityLimitsConfig(entityLimitsFile);
+ } else if (setup) {
+ setDefaultEntityLimits(entityLimitsConfig);
+ saveEntityLimitsConfig(entityLimitsFile);
+ }
+
+ entityLimits = new Object2ObjectOpenHashMap<>();
+ Map<String, ClassInfo> entityClasses = scanEntityClasses();
- if (tickThrottle < 1) {
- LOGGER.error(key + " has a tick-throttle less than the minimum of 1, ignoring");
- continue;
- }
- if (removal <= tickThrottle && removal != -1) {
- LOGGER.error(key + " has a removal limit that is less than or equal to its limit, setting removal to limit * 10");
- removal = tickThrottle * 10;
- }
- entityLimits.put((Class<? extends Entity>) Class.forName(entityClasses.get(key).getName()), new EntityLimit(tickThrottle, removal));
+ for (String key : entityLimitsConfig.getKeys(false)) {
+ if (!entityClasses.containsKey(key)) {
+ LOGGER.error("Unknown entity '" + key + "' in kaiiju-entity-limits.yml, skipping");
+ continue;
+ }
+
+ int brainThrottle = entityLimitsConfig.getInt(key + ".brain-throttle");
+ int tickThrottle = entityLimitsConfig.getInt(key + ".tick-throttle");
+ int removal = entityLimitsConfig.getInt(key + ".removal");
+
+ try {
+ entityLimits.put((Class<? extends Entity>) Class.forName(entityClasses.get(key).getName()),
+ new EntityLimit(brainThrottle, tickThrottle, removal));
+ } catch (ClassNotFoundException e) {
+ e.printStackTrace();
}
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
}
}
@@ -130,10 +143,12 @@ public class KaiijuEntityLimits {
}
}
- public record EntityLimit(int tickThrottle, int removal) {
+ public record EntityLimit(int brainThrottle, int tickThrottle, int removal) {
@Override
public String toString() {
- return "EntityLimit{tickThrottle=" + tickThrottle + ", removal=" + removal + "}";
+ return "EntityLimit{brainThrottle=" + brainThrottle
+ + ", tickThrottle=" + tickThrottle
+ + ", removal=" + removal + "}";
}
}
}
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuEntityThrottler.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuEntityThrottler.java
index eb690efacf083e4ff3e321578b12c534e6a40196..a89a421db9cd06bb165afd1ec28fac9b02e9b5a5 100644
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuEntityThrottler.java
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuEntityThrottler.java
@@ -1,79 +1,84 @@
package dev.kaiijumc.kaiiju;
+import io.papermc.paper.threadedregions.RegionizedWorldData;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import net.minecraft.world.entity.Entity;
-import io.papermc.paper.threadedregions.RegionizedWorldData;
+import java.util.Map;
public class KaiijuEntityThrottler {
private static class TickInfo {
int currentTick;
int continueFrom;
+ int continueFromBrain;
int toTick;
+ int toTickBrain;
int toRemove;
}
- public static class EntityThrottlerReturn {
- public boolean skip;
- public boolean remove;
+ public record EntityThrottlerReturn(boolean skipBrain, boolean skipTick, boolean remove) {
+ public EntityThrottlerReturn() {
+ this(false, false, false);
+ }
}
- private final Object2ObjectOpenHashMap<KaiijuEntityLimits.EntityLimit, TickInfo> entityLimitTickInfoMap = new Object2ObjectOpenHashMap<>();
+ private final Map<KaiijuEntityLimits.EntityLimit, TickInfo> entityLimitTickInfoMap = new Object2ObjectOpenHashMap<>();
+ private final Map<KaiijuEntityLimits.EntityLimit, EntityThrottlerReturn> entityLimitReturnMap = new Object2ObjectOpenHashMap<>();
public void tickLimiterStart() {
- for (TickInfo tickInfo : entityLimitTickInfoMap.values()) {
- tickInfo.currentTick = 0;
- }
+ entityLimitTickInfoMap.values().forEach(tickInfo -> tickInfo.currentTick = 0);
}
- public EntityThrottlerReturn tickLimiterShouldSkip(Entity entity) {
- EntityThrottlerReturn retVal = new EntityThrottlerReturn();
- if (entity.isRemoved()) return retVal;
+ public EntityThrottlerReturn tickLimiterShouldSkip(Entity entity, boolean compute) {
+ if (entity.isRemoved()) return new EntityThrottlerReturn(true, true, true);
KaiijuEntityLimits.EntityLimit entityLimit = KaiijuEntityLimits.getEntityLimit(entity);
- if (entityLimit != null) {
- TickInfo tickInfo = entityLimitTickInfoMap.computeIfAbsent(entityLimit, el -> {
- TickInfo newTickInfo = new TickInfo();
- newTickInfo.toTick = entityLimit.limit();
- return newTickInfo;
- });
+ if (entityLimit == null) return new EntityThrottlerReturn();
- tickInfo.currentTick++;
- if (tickInfo.currentTick <= tickInfo.toRemove && entityLimit.removal() > 0) {
- retVal.skip = false;
- retVal.remove = true;
- return retVal;
- }
+ TickInfo tickInfo = entityLimitTickInfoMap.computeIfAbsent(entityLimit, el -> {
+ TickInfo newTickInfo = new TickInfo();
+ newTickInfo.toTick = entityLimit.tickThrottle();
+ return newTickInfo;
+ });
- if (tickInfo.currentTick < tickInfo.continueFrom) {
- retVal.skip = true;
- return retVal;
- }
- if (tickInfo.currentTick - tickInfo.continueFrom < tickInfo.toTick) {
- retVal.skip = false;
- return retVal;
- }
- retVal.skip = true;
- return retVal;
- } else {
- retVal.skip = false;
- return retVal;
+ if (compute) {
+ tickInfo.currentTick++;
+ entityLimitReturnMap.put(entityLimit, processTickInfo(tickInfo, entityLimit));
}
+
+ return entityLimitReturnMap.get(entityLimit);
+ }
+
+ public EntityThrottlerReturn processTickInfo(TickInfo tickInfo, KaiijuEntityLimits.EntityLimit entityLimit) {
+ if (tickInfo.currentTick <= tickInfo.toRemove && entityLimit.removal() > 0) // Remove
+ return new EntityThrottlerReturn(false, false, true);
+
+ if (tickInfo.currentTick < tickInfo.continueFrom) // Skip tick
+ return new EntityThrottlerReturn(false, true, false);
+
+ if (tickInfo.currentTick - tickInfo.continueFrom < tickInfo.toTick) // Don't skip
+ return new EntityThrottlerReturn();
+
+ return new EntityThrottlerReturn(false, true, false);
}
- public void tickLimiterFinish(RegionizedWorldData regionizedWorldData) {
+ public void tickLimiterFinish() {
for (var entry : entityLimitTickInfoMap.entrySet()) {
KaiijuEntityLimits.EntityLimit entityLimit = entry.getKey();
TickInfo tickInfo = entry.getValue();
- int additionals = 0;
+ int additionalsTick = 0;
+ int additionalsBrain = 0;
int nextContinueFrom = tickInfo.continueFrom + tickInfo.toTick;
+
if (nextContinueFrom >= tickInfo.currentTick) {
- additionals = entityLimit.limit() - (tickInfo.currentTick - tickInfo.continueFrom);
+ additionalsTick = entityLimit.tickThrottle() - (tickInfo.currentTick - tickInfo.continueFrom);
+ additionalsBrain = entityLimit.brainThrottle() - (tickInfo.currentTick - tickInfo.continueFrom);
nextContinueFrom = 0;
}
- tickInfo.continueFrom = nextContinueFrom;
- tickInfo.toTick = entityLimit.limit() + additionals;
+ tickInfo.continueFrom = nextContinueFrom;
+ tickInfo.toTick = entityLimit.tickThrottle() + additionalsTick;
+ tickInfo.toTickBrain = entityLimit.brainThrottle() + additionalsBrain;
if (tickInfo.toRemove == 0 && tickInfo.currentTick > entityLimit.removal()) {
tickInfo.toRemove = tickInfo.currentTick - entityLimit.removal();
} else if (tickInfo.toRemove != 0) {
@@ -81,4 +86,30 @@ public class KaiijuEntityThrottler {
}
}
}
+ public void tickLimiterFinish() {
+ for (var entry : entityLimitTickInfoMap.entrySet()) {
+ KaiijuEntityLimits.EntityLimit entityLimit = entry.getKey();
+ TickInfo tickInfo = entry.getValue();
+
+ int additionalsTick = 0;
+ int additionalsBrain = 0;
+ int nextContinueFromTick = tickInfo.continueFrom + tickInfo.toTick;
+ int nextContinueFromBrain = tickInfo.continueFromBrain + tickInfo.toTickBrain;
+
+ if (nextContinueFromTick >= tickInfo.currentTick) {
+ additionalsTick = entityLimit.tickThrottle() - tickDiff;
+ nextContinueFromTick = 0;
+ }
+ if (nextContinueFromBrain >= tickInfo.currentTick) {
+ additionalsBrain = entityLimit.brainThrottle() - tickDiff;
+ int tickDiff = tickInfo.currentTick - tickInfo.continueFrom;
+ }
+
+ tickInfo.continueFrom = nextContinueFromTick;
+ tickInfo.toTick = entityLimit.tickThrottle() + additionalsTick;
+ tickInfo.toTickBrain = entityLimit.brainThrottle() + additionalsBrain;
+ tickInfo.toRemove = (tickInfo.toRemove == 0 && tickInfo.currentTick > entityLimit.removal()) ? tickInfo.currentTick - entityLimit.removal() : 0;
+ }
+ }
+
}
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index 8fd9e3cee5a671ef8425311371cde57449ef1d8e..7d29574850329205c7f989094f4e762197ccffd0 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -14,7 +14,6 @@ import it.unimi.dsi.fastutil.objects.Object2IntMap.Entry;
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import it.unimi.dsi.fastutil.objects.ObjectIterator;
-import it.unimi.dsi.fastutil.objects.ObjectLinkedOpenHashSet;
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
import java.io.BufferedWriter;
import java.io.IOException;
@@ -132,12 +131,9 @@ import net.minecraft.world.level.chunk.storage.EntityStorage;
import net.minecraft.world.level.dimension.BuiltinDimensionTypes;
import net.minecraft.world.level.dimension.LevelStem;
import net.minecraft.world.level.dimension.end.EndDragonFight;
-import net.minecraft.world.level.entity.EntityPersistentStorage;
-import net.minecraft.world.level.entity.EntityTickList;
import net.minecraft.world.level.entity.EntityTypeTest;
import net.minecraft.world.level.entity.LevelCallback;
import net.minecraft.world.level.entity.LevelEntityGetter;
-import net.minecraft.world.level.entity.PersistentEntitySectionManager;
import net.minecraft.world.level.gameevent.DynamicGameEventListener;
import net.minecraft.world.level.gameevent.GameEvent;
import net.minecraft.world.level.gameevent.GameEventDispatcher;
@@ -168,15 +164,13 @@ import org.bukkit.Location;
import org.bukkit.WeatherType;
import org.bukkit.craftbukkit.event.CraftEventFactory;
import org.bukkit.craftbukkit.generator.CustomWorldChunkManager;
-import org.bukkit.craftbukkit.util.CraftNamespacedKey;
import org.bukkit.craftbukkit.util.WorldUUID;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.server.MapInitializeEvent;
import org.bukkit.event.weather.LightningStrikeEvent;
-import org.bukkit.event.world.GenericGameEvent;
import org.bukkit.event.world.TimeSkipEvent;
// CraftBukkit end
-import it.unimi.dsi.fastutil.ints.IntArrayList; // Paper
+
public class ServerLevel extends Level implements WorldGenLevel {
@@ -848,8 +842,11 @@ public class ServerLevel extends Level implements WorldGenLevel {
// Kaiiju start
if (kaiijuConfig.enableEntityThrottling) {
dev.kaiijumc.kaiiju.KaiijuEntityThrottler.EntityThrottlerReturn throttle = regionizedWorldData.entityThrottler.tickLimiterShouldSkip(entity);
- if (throttle.remove) entity.remove(Entity.RemovalReason.DISCARDED);
- if (throttle.skip) return;
+ if (throttle.remove) {
+ entity.remove(Entity.RemovalReason.DISCARDED);
+ return;
+ }
+ if (throttle.skipTick) return;
}
// Kaiiju end
gameprofilerfiller.push("tick");
@@ -859,7 +856,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
}
}
});
- if (kaiijuConfig.enableEntityThrottling) regionizedWorldData.entityThrottler.tickLimiterFinish(regionizedWorldData); // Kaiiju
+ if (kaiijuConfig.enableEntityThrottling) regionizedWorldData.entityThrottler.tickLimiterFinish(); // Kaiiju
timings.entityTick.stopTiming(); // Spigot
timings.tickEntities.stopTiming(); // Spigot
gameprofilerfiller.pop();