mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-21 18:15:54 +01:00
Fix item gravity on inactive items, remove dumb active skipping
This commit is contained in:
parent
fe2f3d4693
commit
9f1fa0b4f8
@ -1,21 +1,14 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: AJMFactsheets <AJMFactsheets@gmail.com>
|
||||
Date: Fri, 17 Jan 2020 17:17:54 -0600
|
||||
Subject: [PATCH] Fix items not falling correctly
|
||||
From: Nassim Jahnke <nassim@njahnke.dev>
|
||||
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 75ebf09777e19645eee296a9edabac39c858ffb9..c390d8b3a706d0177b9f3105a7b9a84265688ece 100644
|
||||
index 75ebf09777e19645eee296a9edabac39c858ffb9..c21fa55c62d97d9511e41a1e313e904330a6eee6 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
||||
@@ -175,7 +175,7 @@ public class ItemEntity extends Entity implements TraceableEntity {
|
||||
@ -23,20 +16,27 @@ index 75ebf09777e19645eee296a9edabac39c858ffb9..c390d8b3a706d0177b9f3105a7b9a842
|
||||
}
|
||||
|
||||
- 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;
|
||||
diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java
|
||||
index dd1c5bc7522a4710cbfdd4764f6431e1e28d63cc..f8387277d915460d755bdd35198d2547d1a49bde 100644
|
||||
index dd1c5bc7522a4710cbfdd4764f6431e1e28d63cc..05ad15fc40ccb7feed5c51ad0ad0a98bd0d02af6 100644
|
||||
--- a/src/main/java/org/spigotmc/ActivationRange.java
|
||||
+++ b/src/main/java/org/spigotmc/ActivationRange.java
|
||||
@@ -253,7 +253,7 @@ public class ActivationRange
|
||||
@@ -251,12 +251,11 @@ 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;
|
||||
}
|
||||
}
|
@ -6,7 +6,7 @@ Subject: [PATCH] Alternative item-despawn-rate
|
||||
Co-authored-by: Noah van der Aa <ndvdaa@gmail.com>
|
||||
|
||||
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 c390d8b3a706d0177b9f3105a7b9a84265688ece..65deb4568a80577f67f39de3af9fb568975a649d 100644
|
||||
index c21fa55c62d97d9511e41a1e313e904330a6eee6..9974aec00935a1c3068eceee6d7042f14f15ac56 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
||||
@@ -62,6 +62,7 @@ public class ItemEntity extends Entity implements TraceableEntity {
|
||||
|
@ -5,7 +5,7 @@ Subject: [PATCH] Add option to fix items merging through walls
|
||||
|
||||
|
||||
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 65deb4568a80577f67f39de3af9fb568975a649d..6b19689a19465554b943470fc6f959e48169ac5b 100644
|
||||
index 9974aec00935a1c3068eceee6d7042f14f15ac56..586257fe5c9f5cddd0ed164254f46777c6e71d66 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
||||
@@ -285,6 +285,14 @@ public class ItemEntity extends Entity implements TraceableEntity {
|
||||
|
@ -9,7 +9,7 @@ should be supported. Some entities (for whatever
|
||||
reason) use the level's random in some places.
|
||||
|
||||
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 6b19689a19465554b943470fc6f959e48169ac5b..aa41c4cf8d3ae291c4147118c96190ff0bb807b2 100644
|
||||
index 586257fe5c9f5cddd0ed164254f46777c6e71d66..d555fd0b200c012f30ed0c0ec09a37b25a737b76 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
||||
@@ -72,7 +72,12 @@ public class ItemEntity extends Entity implements TraceableEntity {
|
||||
|
@ -55,7 +55,7 @@ index 5330f6315cecfa6afd04b711a5b8656717cb5ede..8b0a764984f886b711cb337a7f706081
|
||||
this.getAttributes().load(nbt.getList("attributes", 10));
|
||||
}
|
||||
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 aa41c4cf8d3ae291c4147118c96190ff0bb807b2..e83a705f54063a17fc69a22683333aacad5a43ce 100644
|
||||
index d555fd0b200c012f30ed0c0ec09a37b25a737b76..7a6d51020d9c6be33b4c34c0d608559589d5b390 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
||||
@@ -63,6 +63,7 @@ public class ItemEntity extends Entity implements TraceableEntity {
|
||||
|
@ -17,10 +17,10 @@ Adds villagers as separate config
|
||||
public net.minecraft.world.entity.Entity isInsidePortal
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
index ce148cf5930cdcf0163c7f6416cbbd89e4d22720..75c388a5c9de26f0053015619e6c19bcff219478 100644
|
||||
index ce148cf5930cdcf0163c7f6416cbbd89e4d22720..cd00b534e4c527e0b4a5ad78cde87c22c49b4c33 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -962,12 +962,13 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
||||
@@ -962,11 +962,11 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
||||
|
||||
public void tickNonPassenger(Entity entity) {
|
||||
// Spigot start
|
||||
@ -32,14 +32,13 @@ index ce148cf5930cdcf0163c7f6416cbbd89e4d22720..75c388a5c9de26f0053015619e6c19bc
|
||||
- }
|
||||
+ }*/ // Paper - comment out EAR 2
|
||||
// Spigot end
|
||||
+ final boolean isActive = org.spigotmc.ActivationRange.checkIfActive(entity); // Paper - EAR 2
|
||||
entity.setOldPosAndRot();
|
||||
ProfilerFiller gameprofilerfiller = Profiler.get();
|
||||
|
||||
@@ -976,20 +977,22 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
||||
@@ -976,20 +976,23 @@ 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
|
||||
@ -350,7 +349,7 @@ index 46afba838cf12eeb1bbccaa260131a76f090364b..e1c9a961064887070b29207efd7af478
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java
|
||||
index f8387277d915460d755bdd35198d2547d1a49bde..6ffe86aa887ebf96f21114a468e16376c2449911 100644
|
||||
index 05ad15fc40ccb7feed5c51ad0ad0a98bd0d02af6..133bcf639a45bd7fa1a2d02410ea3e8568265007 100644
|
||||
--- a/src/main/java/org/spigotmc/ActivationRange.java
|
||||
+++ b/src/main/java/org/spigotmc/ActivationRange.java
|
||||
@@ -1,26 +1,35 @@
|
||||
@ -651,11 +650,11 @@ index f8387277d915460d755bdd35198d2547d1a49bde..6ffe86aa887ebf96f21114a468e16376
|
||||
+ // 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
|
||||
@ -689,7 +688,7 @@ index f8387277d915460d755bdd35198d2547d1a49bde..6ffe86aa887ebf96f21114a468e16376
|
||||
|
||||
// Should this entity tick?
|
||||
if ( !isActive )
|
||||
@@ -245,15 +399,19 @@ public class ActivationRange
|
||||
@@ -245,11 +399,14 @@ public class ActivationRange
|
||||
if ( ( MinecraftServer.currentTick - entity.activatedTick - 1 ) % 20 == 0 )
|
||||
{
|
||||
// Check immunities every 20 ticks.
|
||||
@ -706,14 +705,8 @@ index f8387277d915460d755bdd35198d2547d1a49bde..6ffe86aa887ebf96f21114a468e16376
|
||||
}
|
||||
+ // 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 2b263246135c85aa225120519e9702a628773935..2c408fa4abcbe1171c58aee8799c8cf7867d0f0a 100644
|
||||
--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
||||
|
@ -1104,7 +1104,7 @@ index 183b2191fa1c1b27adedf39593e1b5a223fb1279..8ead66c134688b11dca15f6509147e72
|
||||
|
||||
private ClientboundLevelChunkWithLightPacket(RegistryFriendlyByteBuf buf) {
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
index 75c388a5c9de26f0053015619e6c19bcff219478..c0de354ac03a62f159540f25940dc3700cc0c575 100644
|
||||
index cd00b534e4c527e0b4a5ad78cde87c22c49b4c33..32f8186b1502b481c1100f7fdba0339ae3dd34fa 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -343,7 +343,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
||||
|
@ -14,7 +14,7 @@ This allows us to have both the reduced number of item entities a high item-merg
|
||||
without most of the visual artifacts caused by items merging vertically.
|
||||
|
||||
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 e83a705f54063a17fc69a22683333aacad5a43ce..246b5649883e4f305afa5a887b9df0f3735f7593 100644
|
||||
index 7a6d51020d9c6be33b4c34c0d608559589d5b390..4ce041726661dbbd19f36a516f2fd7f5e3307ef0 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
||||
@@ -285,7 +285,7 @@ public class ItemEntity extends Entity implements TraceableEntity {
|
||||
|
@ -30,7 +30,7 @@ completely unnecessary, which also rids paper of the previous described
|
||||
incompatibility with non-ticking chunks.
|
||||
|
||||
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 246b5649883e4f305afa5a887b9df0f3735f7593..5d8885bca55503bf7e1a2a4e1bb9b3bd86d55391 100644
|
||||
index 4ce041726661dbbd19f36a516f2fd7f5e3307ef0..0f086af57a5ff08c264dcbf89a8c3931ec73a609 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
||||
@@ -60,7 +60,7 @@ public class ItemEntity extends Entity implements TraceableEntity {
|
||||
|
@ -26779,7 +26779,7 @@ index b2fd3e936559c8fcb8b02ae3ef63c4f3bd0edb08..5bbc7ceaafc163f12344e5d5d355ad2f
|
||||
|
||||
if (!list.equals(this.lastPassengers)) {
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
index c0de354ac03a62f159540f25940dc3700cc0c575..9af879115a24145ec290ac200565004e49ee7b0b 100644
|
||||
index 32f8186b1502b481c1100f7fdba0339ae3dd34fa..70efc63102b3d3727be376d42f1bef70174468a3 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -185,7 +185,7 @@ import org.bukkit.event.weather.LightningStrikeEvent;
|
||||
|
@ -76,7 +76,7 @@ index f7197f1347251a37dd0f6d9ffa2f09bc3a4e1233..1f7f68aad97ee73763c042837f239bdc
|
||||
});
|
||||
throw RunningOnDifferentThreadException.RUNNING_ON_DIFFERENT_THREAD;
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
index 9af879115a24145ec290ac200565004e49ee7b0b..c9d7ea8fbaf8858564282b42f6f6dda3d6927f8e 100644
|
||||
index 70efc63102b3d3727be376d42f1bef70174468a3..7b936a01888d71fe305863054471b6b4a3aa95b8 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -1247,7 +1247,26 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
||||
|
@ -50,7 +50,7 @@ index 8a45960de3fd890991a1c75a103fec1adb03c0cb..c1e8d2679083516040e9d1768d79f5e4
|
||||
ProfilerFiller gameprofilerfiller = Profiler.get();
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
index c9d7ea8fbaf8858564282b42f6f6dda3d6927f8e..2519a886317362db4ac0aeadb3655624f175cd99 100644
|
||||
index 7b936a01888d71fe305863054471b6b4a3aa95b8..c09c718c1b1c9f27fdf1e4160b2df6887cf1d1a2 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -1347,6 +1347,30 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
||||
|
@ -28,7 +28,7 @@ index c1e8d2679083516040e9d1768d79f5e4d71bf0a6..af7c6f56444c0e495fd39da872f80301
|
||||
gameprofilerfiller.push(() -> {
|
||||
String s = String.valueOf(worldserver);
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
index 2519a886317362db4ac0aeadb3655624f175cd99..e65cfb1132f5f0c9e1fa5ae4a46a8abed0c56be1 100644
|
||||
index c09c718c1b1c9f27fdf1e4160b2df6887cf1d1a2..21c78bc96c39f6261adaad2e7c225948b6f1606f 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -576,6 +576,17 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
||||
|
Loading…
Reference in New Issue
Block a user