Skip to content

Commit c904da6

Browse files
authored
Offset spigot item optimizations instead of Mojang's (#6290)
1 parent 4533821 commit c904da6

25 files changed

+52
-39
lines changed

patches/server/0352-Fix-items-not-falling-correctly.patch

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,32 @@ optimization which skips ticking active entities every fourth tick.
1111
This can result in a state where an item will never properly fall
1212
due to its move method never being called.
1313

14-
This patch resolves the conflict by offsetting checking an item's
15-
move method from Spigot's entity activation range check.
14+
This patch resolves the conflict by offsetting checking Spigot's entity
15+
activation range check from an item's move method.
1616

1717
diff --git a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
18-
index 1da634eacccff884d50b7f1298bc8e44b0b8b6f2..abe72b940b21376571e6a0598e847e3e9ed0f061 100644
18+
index 1da634eacccff884d50b7f1298bc8e44b0b8b6f2..b73198444747e6f8865ad9694c0b11ee95746dae 100644
1919
--- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
2020
+++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
2121
@@ -134,7 +134,7 @@ public class ItemEntity extends Entity {
2222
}
2323
}
2424

2525
- if (!this.onGround || this.getDeltaMovement().horizontalDistanceSqr() > 9.999999747378752E-6D || (this.tickCount + this.getId()) % 4 == 0) {
26-
+ if (!this.onGround || this.getDeltaMovement().horizontalDistanceSqr() > 9.999999747378752E-6D || this.tickCount % 4 == 0) { // Paper - Ensure checking item movement is always offset from Spigot's entity activation range check
26+
+ if (!this.onGround || this.getDeltaMovement().horizontalDistanceSqr() > 9.999999747378752E-6D || (this.tickCount + this.getId()) % 4 == 0) { // Paper - Diff on change
2727
this.move(MoverType.SELF, this.getDeltaMovement());
2828
float f1 = 0.98F;
2929

30+
diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java
31+
index 07e5ece37af6b02210920ce6cc31738274d447a9..7bae24598218dcf0012dd21e619e6f5f984bd6f0 100644
32+
--- a/src/main/java/org/spigotmc/ActivationRange.java
33+
+++ b/src/main/java/org/spigotmc/ActivationRange.java
34+
@@ -251,7 +251,7 @@ public class ActivationRange
35+
isActive = true;
36+
}
37+
// Add a little performance juice to active entities. Skip 1/4 if not immune.
38+
- } else if ( !entity.defaultActivationState && entity.tickCount % 4 == 0 && !ActivationRange.checkEntityImmunities( entity ) )
39+
+ } else if ( !entity.defaultActivationState && entity.tickCount + entity.getId() + 1 % 4 == 0 && !ActivationRange.checkEntityImmunities( entity ) ) // Paper - Ensure checking item movement is offset from Spigot's entity activation range check
40+
{
41+
isActive = false;
42+
}

patches/server/0357-Entity-Activation-Range-2.0.patch

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ index 367e074dd5f85f824b7c4f5506d0ccac60580c1b..83c5b111b98e52f52b7e4cf607aac07b
108108
} else {
109109
passenger.stopRiding();
110110
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
111-
index aa5fdc74a3b06b8d8b82b86fb4f1469ddd4c629e..ae454b12a0671f6698ff2b889988348e3a518b36 100644
111+
index 71de08f60b9d9d0f132e2d3c60cd7b70e9ec3759..8b1e6961e2a60e17aa12ec949e3166e461d4fed7 100644
112112
--- a/src/main/java/net/minecraft/world/entity/Entity.java
113113
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
114114
@@ -313,6 +313,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, i
@@ -335,7 +335,7 @@ index 6b29f66aec8a82b367a979b5b04857416b697c14..78d252b829e5c1f19532656a72862085
335335
}
336336
}
337337
diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java
338-
index 07e5ece37af6b02210920ce6cc31738274d447a9..84880151abd193be5f02b5e9abb3fa78f2aa2cac 100644
338+
index 7bae24598218dcf0012dd21e619e6f5f984bd6f0..88c3022abc5edde312573de4fe499f1f5ee9eeae 100644
339339
--- a/src/main/java/org/spigotmc/ActivationRange.java
340340
+++ b/src/main/java/org/spigotmc/ActivationRange.java
341341
@@ -1,39 +1,52 @@
@@ -681,8 +681,8 @@ index 07e5ece37af6b02210920ce6cc31738274d447a9..84880151abd193be5f02b5e9abb3fa78
681681
+
682682
}
683683
// Add a little performance juice to active entities. Skip 1/4 if not immune.
684-
- } else if ( !entity.defaultActivationState && entity.tickCount % 4 == 0 && !ActivationRange.checkEntityImmunities( entity ) )
685-
+ } else if ( entity.tickCount % 4 == 0 && ActivationRange.checkEntityImmunities( entity ) < 0 ) // Paper
684+
- } else if ( !entity.defaultActivationState && entity.tickCount + entity.getId() + 1 % 4 == 0 && !ActivationRange.checkEntityImmunities( entity ) ) // Paper - Ensure checking item movement is offset from Spigot's entity activation range check
685+
+ } else if ( entity.tickCount + entity.getId() + 1 % 4 == 0 && ActivationRange.checkEntityImmunities( entity ) < 0 ) // Paper
686686
{
687687
isActive = false;
688688
}

patches/server/0360-Anti-Xray.patch

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Subject: [PATCH] Anti-Xray
55

66

77
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
8-
index 723adafaf82a664b8bfff9d7d11e43e3eafafa6e..1cdfba84abcee02c0ac49367c97544bc4758715b 100644
8+
index d9c59ea6faa7155d415c89228c22da3311855c9d..a17bf0ebe4d60effc72ea71ba4a7eba001875e19 100644
99
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
1010
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
1111
@@ -1,11 +1,13 @@
@@ -1126,7 +1126,7 @@ index 7825d6f0fdcfda6212cff8033ec55fb7db236154..2072aa8710f6e285f7c8f76c63b7bcf8
11261126

11271127
public ClientboundLevelChunkWithLightPacket(FriendlyByteBuf buf) {
11281128
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
1129-
index cb050e658c5c99feb4586c1fba9a57ee3c0d6052..1112ffdaa13c6f0ca41b32127c3fed69f828d6fe 100644
1129+
index 66c9cbf383e1b6333e46162b8a97e0a9cc05f419..882a960c97b5f298049ea38ef1208b437e2e02a8 100644
11301130
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
11311131
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
11321132
@@ -938,7 +938,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -1179,7 +1179,7 @@ index cb050e658c5c99feb4586c1fba9a57ee3c0d6052..1112ffdaa13c6f0ca41b32127c3fed69
11791179
List<Entity> list = Lists.newArrayList();
11801180
List<Entity> list1 = Lists.newArrayList();
11811181
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
1182-
index daeb483b7aa0356447381aec8d92f5dfa500d5b1..6a0eb9313ae62549f2e9220ca00a7ef27d3b2fca 100644
1182+
index 83c5b111b98e52f52b7e4cf607aac07be7043709..be75691d91b3559788365da2b813ea3c010b6637 100644
11831183
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
11841184
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
11851185
@@ -394,7 +394,7 @@ public class ServerLevel extends Level implements WorldGenLevel {

patches/server/0361-Implement-alternative-item-despawn-rate.patch

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Subject: [PATCH] Implement alternative item-despawn-rate
55

66

77
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
8-
index 1cdfba84abcee02c0ac49367c97544bc4758715b..619f5c11ae8e21b060b52b60d681db6dd9cb5816 100644
8+
index a17bf0ebe4d60effc72ea71ba4a7eba001875e19..68ae6664541d1dbc611520e7e8612b4f5162c696 100644
99
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
1010
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
1111
@@ -565,5 +565,52 @@ public class PaperWorldConfig {
@@ -63,7 +63,7 @@ index 1cdfba84abcee02c0ac49367c97544bc4758715b..619f5c11ae8e21b060b52b60d681db6d
6363
+ }
6464
+}
6565
diff --git a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
66-
index abe72b940b21376571e6a0598e847e3e9ed0f061..37d9788c1d4eb40ccdc0ec946bfd648822e486a0 100644
66+
index b73198444747e6f8865ad9694c0b11ee95746dae..995172d8f271520ffa09e919f2a4890a4a1ccd89 100644
6767
--- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
6868
+++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
6969
@@ -174,7 +174,7 @@ public class ItemEntity extends Entity {

patches/server/0364-implement-optional-per-player-mob-spawns.patch

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Subject: [PATCH] implement optional per player mob spawns
55

66

77
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
8-
index 619f5c11ae8e21b060b52b60d681db6dd9cb5816..88d140a03b6f28070b2f78588ee5ce4d5ac3cf0f 100644
8+
index 68ae6664541d1dbc611520e7e8612b4f5162c696..6b0391743cd9e249c66796e7fe7a4da8c6b81b2e 100644
99
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
1010
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
1111
@@ -613,4 +613,12 @@ public class PaperWorldConfig {
@@ -269,7 +269,7 @@ index 0000000000000000000000000000000000000000..11de56afaf059b00fa5bec293516bcdc
269269
+ }
270270
+}
271271
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
272-
index 0c82b270c7095c7e4666a8078ecc7142503795c4..2d7f0eb7df62d1c26ccf19cf61595227e19aa562 100644
272+
index 75381712377c1b77289a6b5877a657af8eb39a41..056e35b00bd840d8c62c4dc978cbbe5bb8c37887 100644
273273
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
274274
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
275275
@@ -151,6 +151,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider

patches/server/0378-Configurable-chance-of-villager-zombie-infection.patch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ This allows you to solve an issue in vanilla behavior where:
88
* On normal difficulty they will have a 50% of getting infected or dying.
99

1010
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
11-
index e0ebea2f62db5d0723aa353db49cdc3854aa5dd7..5fee3bdea651fcdd7ea01df4cfb8288a231f9236 100644
11+
index 4c49a7a686ad1ff386999c21fa25acd30a615abf..c9d9461695d95e227f41b894b42b8be8d9d198cd 100644
1212
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
1313
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
1414
@@ -536,6 +536,11 @@ public class PaperWorldConfig {

patches/server/0409-Add-phantom-creative-and-insomniac-controls.patch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Subject: [PATCH] Add phantom creative and insomniac controls
55

66

77
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
8-
index 7f09e1178b73b3c436aea9059162628bfa8a6911..1ea83baba79254e11fc770a6a1c7fb740ac43d82 100644
8+
index e2b71ffd6057dcc84e4e0910fddd24c50ef9d38d..e7cbdc75d7fd1252024c450ff0ec3b1ebdd17b93 100644
99
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
1010
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
1111
@@ -646,4 +646,11 @@ public class PaperWorldConfig {

patches/server/0420-Option-for-maximum-exp-value-when-merging-orbs.patch

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Subject: [PATCH] Option for maximum exp value when merging orbs
55

66

77
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
8-
index 1ea83baba79254e11fc770a6a1c7fb740ac43d82..65fcdbc5c1f637f809d3033b83e5b1c807472911 100644
8+
index e7cbdc75d7fd1252024c450ff0ec3b1ebdd17b93..bc880a78381b9c30e4ec92bdf17c9eca1ded41f2 100644
99
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
1010
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
1111
@@ -653,4 +653,10 @@ public class PaperWorldConfig {
@@ -20,7 +20,7 @@ index 1ea83baba79254e11fc770a6a1c7fb740ac43d82..65fcdbc5c1f637f809d3033b83e5b1c8
2020
+ }
2121
}
2222
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
23-
index d74db5ac46314683b8c8713b8e6f6450ef7eb1b1..d62b1f22ee5679b0f223320db0db9c53b2120c91 100644
23+
index de5f5856875fc4bfb051c7535344f18ded360ad3..618be6243225c82c3f7e039a00c43cf3c2ef1dbf 100644
2424
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
2525
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
2626
@@ -630,16 +630,30 @@ public class CraftEventFactory {

patches/server/0435-Delay-Chunk-Unloads-based-on-Player-Movement.patch

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ This allows servers with smaller worlds who do less long distance exploring to s
1717
wasting cpu cycles on saving/unloading/reloading chunks repeatedly.
1818

1919
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
20-
index 65fcdbc5c1f637f809d3033b83e5b1c807472911..d6d549df6e8920c936dd0d1b7ba828dbebc60b32 100644
20+
index bc880a78381b9c30e4ec92bdf17c9eca1ded41f2..eae27a641ee69f3383f1200f8c8ab8dd7a4105a4 100644
2121
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
2222
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
2323
@@ -659,4 +659,13 @@ public class PaperWorldConfig {
@@ -35,7 +35,7 @@ index 65fcdbc5c1f637f809d3033b83e5b1c807472911..d6d549df6e8920c936dd0d1b7ba828db
3535
+ }
3636
}
3737
diff --git a/src/main/java/net/minecraft/server/level/DistanceManager.java b/src/main/java/net/minecraft/server/level/DistanceManager.java
38-
index 95f195980e28bb59f43e5ca1d5e79ebe8c3ddaea..84dc1e94b4f7b8315d8422634dd49b1f85044d18 100644
38+
index 3865146697051e01a778414064425ea0e5162b8d..cd81e7844c985d7d0f0930faa96478af6a7f6cd4 100644
3939
--- a/src/main/java/net/minecraft/server/level/DistanceManager.java
4040
+++ b/src/main/java/net/minecraft/server/level/DistanceManager.java
4141
@@ -197,6 +197,27 @@ public abstract class DistanceManager {

patches/server/0568-Added-world-settings-for-mobs-picking-up-loot.patch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Subject: [PATCH] Added world settings for mobs picking up loot
55

66

77
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
8-
index 8df810594156944a2cb149af35863caf10edbb83..63d0971379f96e000ab9e7939f626c216cb6d12c 100644
8+
index f61e0c14db835a6b79f7c4b1f68a1005d5b3e913..ab52e655d16dc565cfb890ec8fdb07ce7f68e4cf 100644
99
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
1010
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
1111
@@ -720,6 +720,14 @@ public class PaperWorldConfig {

0 commit comments

Comments
 (0)