From b46708d56562893f14d06bf217a839ded7977206 Mon Sep 17 00:00:00 2001 From: Cody Date: Sun, 2 Apr 2023 13:21:13 -0500 Subject: [PATCH] Added a config option for ticking markers (#9034) --- patches/server/Don-t-tick-markers.patch | 14 ++++++++------ patches/server/Paper-config-files.patch | 6 ++++++ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/patches/server/Don-t-tick-markers.patch b/patches/server/Don-t-tick-markers.patch index a66804f613..babdbaa9c2 100644 --- a/patches/server/Don-t-tick-markers.patch +++ b/patches/server/Don-t-tick-markers.patch @@ -3,10 +3,11 @@ From: Noah van der Aa Date: Fri, 7 Jan 2022 11:58:26 +0100 Subject: [PATCH] Don't tick markers -Fixes https://github.com/PaperMC/Paper/issues/7276 by not adding markers to the entity -tick list at all and ignoring them in Spigot's activation range checks. The entity tick +Fixes https://github.com/PaperMC/Paper/issues/7276 and https://github.com/PaperMC/Paper/issues/8118 +by using a config option that, when set to false, does not add markers to the entity +tick list at all and ignores them in Spigot's activation range checks. The entity tick list is only used in the tick and tickPassenger methods, so we can safely not add the -markers to it. +markers to it. When the config option is set to true, markers are ticked as normal. diff --git a/src/main/java/io/papermc/paper/command/subcommands/EntityCommand.java b/src/main/java/io/papermc/paper/command/subcommands/EntityCommand.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 @@ -17,7 +18,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 info.left++; info.right.put(chunk, info.right.getOrDefault(chunk, 0) + 1); - if (!chunkProviderServer.isPositionTicking(e)) { -+ if (!chunkProviderServer.isPositionTicking(e) || e instanceof net.minecraft.world.entity.Marker) { // Markers aren't ticked. ++ if (!chunkProviderServer.isPositionTicking(e) || (e instanceof net.minecraft.world.entity.Marker && !world.paperConfig().entities.markers.tick)) { // Configurable marker ticking nonEntityTicking.merge(key, 1, Integer::sum); } }); @@ -29,7 +30,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } public void onTickingStart(Entity entity) { -+ if (entity instanceof net.minecraft.world.entity.Marker) return; // Paper - Don't tick markers ++ if (entity instanceof net.minecraft.world.entity.Marker && !paperConfig().entities.markers.tick) return; // Paper - Configurable marker ticking ServerLevel.this.entityTickList.add(entity); } @@ -42,7 +43,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 // Paper start - java.util.List entities = world.getEntities((Entity)null, maxBB, null); -+ java.util.List entities = world.getEntities((Entity)null, maxBB, (e) -> !(e instanceof net.minecraft.world.entity.Marker)); // Don't tick markers ++ java.util.function.Predicate entityPredicate = world.paperConfig().entities.markers.tick ? null : (e) -> !(e instanceof net.minecraft.world.entity.Marker); // Configurable marker ticking ++ java.util.List entities = world.getEntities((Entity)null, maxBB, entityPredicate); for (int i = 0; i < entities.size(); i++) { Entity entity = entities.get(i); ActivationRange.activateEntity(entity); diff --git a/patches/server/Paper-config-files.patch b/patches/server/Paper-config-files.patch index 8ab68e3f74..c4e6368483 100644 --- a/patches/server/Paper-config-files.patch +++ b/patches/server/Paper-config-files.patch @@ -1574,6 +1574,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + public boolean tick = true; + } + ++ public Markers markers; ++ ++ public class Markers extends ConfigurationPart { ++ public boolean tick = true; ++ } ++ + public Spawning spawning; + + public class Spawning extends ConfigurationPart {