diff --git a/patches/server/Entity-Activation-Range-2.0.patch b/patches/server/Entity-Activation-Range-2.0.patch index 347e88421e..8123729e09 100644 --- a/patches/server/Entity-Activation-Range-2.0.patch +++ b/patches/server/Entity-Activation-Range-2.0.patch @@ -32,14 +32,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - } + }*/ // Paper - comment out EAR 2 // Spigot end -+ final boolean isActive = org.spigotmc.ActivationRange.checkIfActive(entity); // Paper - EAR 2 entity.setOldPosAndRot(); ProfilerFiller gameprofilerfiller = Profiler.get(); - @@ -0,0 +0,0 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe return BuiltInRegistries.ENTITY_TYPE.getKey(entity.getType()).toString(); }); gameprofilerfiller.incrementCounter("tickNonPassenger"); ++ final boolean isActive = org.spigotmc.ActivationRange.checkIfActive(entity); // Paper - EAR 2 + if (isActive) { // Paper - EAR 2 entity.tick(); entity.postTick(); // CraftBukkit @@ -651,11 +650,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper start + if (entity instanceof Mob && ((Mob) entity).targetSelector.hasTasks() ) { + return 0; -+ } + } + if (entity instanceof Pillager) { + Pillager pillager = (Pillager) entity; + // TODO:? - } ++ } + // Paper end } // SPIGOT-6644: Otherwise the target refresh tick will be missed @@ -706,14 +705,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } + // Paper end isActive = true; -+ - } - // Add a little performance juice to active entities. Skip 1/4 if not immune. -- } else if ( !entity.defaultActivationState && (entity.tickCount + entity.getId()) % 4 == 0 && !ActivationRange.checkEntityImmunities( entity ) ) // Paper - Ensure checking item movement is offset from Spigot's entity activation range check -+ } else if ( (entity.tickCount + entity.getId()) % 4 == 0 && ActivationRange.checkEntityImmunities( entity ) < 0 ) // Paper - { - isActive = false; - } + } else if (entity instanceof net.minecraft.world.entity.item.ItemEntity && (entity.tickCount + entity.getId()) % 4 == 0) { // Paper - Needed for item gravity, see ItemEntity tick + isActive = true; diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/spigotmc/SpigotWorldConfig.java diff --git a/patches/server/Fix-items-not-falling-correctly.patch b/patches/server/Fix-item-EAR-ticks.patch similarity index 60% rename from patches/server/Fix-items-not-falling-correctly.patch rename to patches/server/Fix-item-EAR-ticks.patch index 9258c412ba..78dedc7604 100644 --- a/patches/server/Fix-items-not-falling-correctly.patch +++ b/patches/server/Fix-item-EAR-ticks.patch @@ -1,18 +1,11 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: AJMFactsheets -Date: Fri, 17 Jan 2020 17:17:54 -0600 -Subject: [PATCH] Fix items not falling correctly +From: Nassim Jahnke +Date: Wed, 30 Oct 2024 13:51:54 +0100 +Subject: [PATCH] Fix item EAR ticks -Since 1.14, Mojang has added an optimization which skips checking if -an item should fall every fourth tick. - -However, Spigot's entity activation range class also has an -optimization which skips ticking active entities every fourth tick. -This can result in a state where an item will never properly fall -due to its move method never being called. - -This patch resolves the conflict by offsetting checking Spigot's entity -activation range check from an item's move method. +Item entities only have their gravity ticked every 4 ticks when on ground. +Fix that and also remove Spigot's arbitrary tick skipping. It's a terribly +cheap way of getting extra performance that doesn't really work at all. diff --git a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 @@ -23,7 +16,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } - if (!this.onGround() || this.getDeltaMovement().horizontalDistanceSqr() > 9.999999747378752E-6D || (this.tickCount + this.getId()) % 4 == 0) { -+ if (!this.onGround() || this.getDeltaMovement().horizontalDistanceSqr() > 9.999999747378752E-6D || (this.tickCount + this.getId()) % 4 == 0) { // Paper - Diff on change ++ if (!this.onGround() || this.getDeltaMovement().horizontalDistanceSqr() > 9.999999747378752E-6D || (this.tickCount + this.getId()) % 4 == 0) { // Paper - Diff on change; ActivationRange immunity this.move(MoverType.SELF, this.getDeltaMovement()); this.applyEffectsFromBlocks(); float f = 0.98F; @@ -32,11 +25,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/spigotmc/ActivationRange.java +++ b/src/main/java/org/spigotmc/ActivationRange.java @@ -0,0 +0,0 @@ public class ActivationRange + entity.activatedTick = MinecraftServer.currentTick + 20; + } isActive = true; ++ } else if (entity instanceof net.minecraft.world.entity.item.ItemEntity && (entity.tickCount + entity.getId()) % 4 == 0) { // Paper - Needed for item gravity, see ItemEntity tick ++ isActive = true; } - // Add a little performance juice to active entities. Skip 1/4 if not immune. +- // Add a little performance juice to active entities. Skip 1/4 if not immune. - } else if ( !entity.defaultActivationState && entity.tickCount % 4 == 0 && !ActivationRange.checkEntityImmunities( entity ) ) -+ } else if ( !entity.defaultActivationState && (entity.tickCount + entity.getId()) % 4 == 0 && !ActivationRange.checkEntityImmunities( entity ) ) // Paper - Ensure checking item movement is offset from Spigot's entity activation range check - { - isActive = false; +- { +- isActive = false; } ++ // Paper - remove dumb tick skipping for active entities + return isActive; + } + }