diff --git a/Paper-MojangAPI/pom.xml b/Paper-MojangAPI/pom.xml
index d0da7daf4..4c7c62c78 100644
--- a/Paper-MojangAPI/pom.xml
+++ b/Paper-MojangAPI/pom.xml
@@ -10,7 +10,7 @@
com.destroystokyo.paper
paper-mojangapi
- 1.15.2-R0.1-SNAPSHOT
+ 1.16.1-R0.1-SNAPSHOT
jar
Paper-MojangAPI
diff --git a/Spigot-Server-Patches/0001-POM-Changes.patch b/Spigot-Server-Patches/0001-POM-Changes.patch
index ec0dbc3a7..88617b94b 100644
--- a/Spigot-Server-Patches/0001-POM-Changes.patch
+++ b/Spigot-Server-Patches/0001-POM-Changes.patch
@@ -190,7 +190,7 @@ index 0466cd48f5ccd1479f2909c70654d884dc1e8f24..7bc5bf271e435e1e0d85af133f1352f3
diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java
-index 4ac80c20ba970a2078fe62c452e7fdfb8ad0b46e..a5c4b7f28f13f0aad4712912f60ba5fc6785539a 100644
+index b75bed0890ce76c7a015998f199851374de6983c..9ff914194ca72c2d0d4c63a12fa4441aee93429d 100644
--- a/src/main/java/org/bukkit/craftbukkit/Main.java
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
@@ -186,7 +186,7 @@ public class Main {
@@ -201,7 +201,7 @@ index 4ac80c20ba970a2078fe62c452e7fdfb8ad0b46e..a5c4b7f28f13f0aad4712912f60ba5fc
+ Date buildDate = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'").parse(Main.class.getPackage().getImplementationVendor()); // Paper
Calendar deadline = Calendar.getInstance();
- deadline.add(Calendar.DAY_OF_YEAR, -3);
+ deadline.add(Calendar.DAY_OF_YEAR, -1);
diff --git a/src/main/java/org/bukkit/craftbukkit/util/Versioning.java b/src/main/java/org/bukkit/craftbukkit/util/Versioning.java
index 93046379d0cefd5d3236fc59e698809acdc18f80..674096cab190d62622f9947853b056f57d43a2a5 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/Versioning.java
diff --git a/Spigot-Server-Patches/0002-Paper-config-files.patch b/Spigot-Server-Patches/0002-Paper-config-files.patch
index edc9aad0d..51ac0e671 100644
--- a/Spigot-Server-Patches/0002-Paper-config-files.patch
+++ b/Spigot-Server-Patches/0002-Paper-config-files.patch
@@ -574,10 +574,10 @@ index 27e6872c675647d7e61040b76183dac4e347a40c..1964130ae411ff7d5e1b456a23629804
this.setPVP(dedicatedserverproperties.pvp);
this.setAllowFlight(dedicatedserverproperties.allowFlight);
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
-index 390dafff979ebdd99b98db312035d665ab1eabda..2f81613099f3fa8828ce0a20c2cc26d431f208e5 100644
+index ede38b7b5fe4acc29ae9c12298a73a3a745983ac..781eaaa4544dfa6e2c523d4d3d99929e7ab46ac7 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
-@@ -136,9 +136,9 @@ public abstract class Entity implements INamableTileEntity, ICommandListener {
+@@ -135,9 +135,9 @@ public abstract class Entity implements INamableTileEntity, ICommandListener {
private static final DataWatcherObject aA = DataWatcher.a(Entity.class, DataWatcherRegistry.i);
protected static final DataWatcherObject POSE = DataWatcher.a(Entity.class, DataWatcherRegistry.s);
public boolean inChunk;
@@ -699,7 +699,7 @@ index 9aa648bb5ec42730f6ce85902b91a079084e7f8e..d9dda69118a5319da28cf3011fe5d8a6
+ // Paper end
}
diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java
-index a5c4b7f28f13f0aad4712912f60ba5fc6785539a..3d15661eb1f15f74213ecb7e8eceb1f231ad2c1c 100644
+index 9ff914194ca72c2d0d4c63a12fa4441aee93429d..5d8a9361151985f8a8215797592f7998a186152d 100644
--- a/src/main/java/org/bukkit/craftbukkit/Main.java
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
@@ -129,6 +129,14 @@ public class Main {
diff --git a/Spigot-Server-Patches/0004-MC-Utils.patch b/Spigot-Server-Patches/0004-MC-Utils.patch
index 0bd0c2f86..b569c8356 100644
--- a/Spigot-Server-Patches/0004-MC-Utils.patch
+++ b/Spigot-Server-Patches/0004-MC-Utils.patch
@@ -3053,10 +3053,10 @@ index 8856981da86219bdb036aa6246152f382ff8a818..4c6979903d287f7f37d9029f6ce25517
this.a();
packetdataserializer.writeByte(this.i);
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
-index 2f81613099f3fa8828ce0a20c2cc26d431f208e5..1512b23034b0ec95e2c72b9dd1c7b0a80d611e15 100644
+index 781eaaa4544dfa6e2c523d4d3d99929e7ab46ac7..0622f0d8d765c1249fd97f27c3c83af519f01c00 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
-@@ -984,8 +984,9 @@ public abstract class Entity implements INamableTileEntity, ICommandListener {
+@@ -983,8 +983,9 @@ public abstract class Entity implements INamableTileEntity, ICommandListener {
}
@@ -3068,7 +3068,7 @@ index 2f81613099f3fa8828ce0a20c2cc26d431f208e5..1512b23034b0ec95e2c72b9dd1c7b0a8
return null;
}
-@@ -1775,6 +1776,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener {
+@@ -1774,6 +1775,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener {
return EnumInteractionResult.PASS;
}
@@ -3126,7 +3126,7 @@ index fb0f281261455c9f127abd8d3b336135ad84fc27..ebdd990829edb8e423f482fa4352fe2d
super(entitytypes, world);
this.f = 5;
diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
-index 3f4453bbfbad4d4171c2981fd625e80aec6bea6c..2f3fe374070a3743931ac0c68c949cded4da085a 100644
+index a356e3258a69e059fd752212d3c5f13078ed62ab..183346d37e36be70348ecf0f2f26a0e0ef35eab8 100644
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
@@ -91,6 +91,8 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
@@ -3807,7 +3807,7 @@ index 0000000000000000000000000000000000000000..da7a325d070e194cd1664ed20dcb3a76
+ }
+}
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
-index 3cb0957d8b57c930d74fc25aa5e1a0eaaf33e747..0aed429bfa996b1b01dbe2c876c6ad489ab7fa4a 100644
+index a5f26a51ba612bc62d406cbefa858af75bd062da..67120e3e4a2cd77394fd7e77543223afa2d6a22e 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -767,6 +767,9 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant> info = list.computeIfAbsent(key, k -> MutablePair.of(0, Maps.newHashMap()));
ChunkCoordIntPair chunk = new ChunkCoordIntPair(e.getChunkX(), e.getChunkZ());
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
-index 1512b23034b0ec95e2c72b9dd1c7b0a80d611e15..06165a668c96d25f3a863f5c98eae93240fd56fc 100644
+index 0622f0d8d765c1249fd97f27c3c83af519f01c00..3e679f66cd922cf0b47a84cdd1a83f311ddf6d0b 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
-@@ -50,7 +50,7 @@ import org.bukkit.event.player.PlayerTeleportEvent;
+@@ -49,7 +49,7 @@ import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.plugin.PluginManager;
// CraftBukkit end
@@ -31,7 +31,7 @@ index 1512b23034b0ec95e2c72b9dd1c7b0a80d611e15..06165a668c96d25f3a863f5c98eae932
// CraftBukkit start
private static final int CURRENT_LEVEL = 2;
-@@ -1671,12 +1671,31 @@ public abstract class Entity implements INamableTileEntity, ICommandListener {
+@@ -1670,12 +1670,31 @@ public abstract class Entity implements INamableTileEntity, ICommandListener {
return true;
}
diff --git a/Spigot-Server-Patches/0007-Store-reference-to-current-Chunk-for-Entity-and-Bloc.patch b/Spigot-Server-Patches/0007-Store-reference-to-current-Chunk-for-Entity-and-Bloc.patch
index 704accb54..725775fd2 100644
--- a/Spigot-Server-Patches/0007-Store-reference-to-current-Chunk-for-Entity-and-Bloc.patch
+++ b/Spigot-Server-Patches/0007-Store-reference-to-current-Chunk-for-Entity-and-Bloc.patch
@@ -80,10 +80,10 @@ index 7c7826cf3adb19814984ab627e4c4726d8933244..bd92ed2e6d4766f4f16ec3002c41b36b
}
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
-index 06165a668c96d25f3a863f5c98eae93240fd56fc..62814197d32f9daf4e6b6aad26920589589efd75 100644
+index 3e679f66cd922cf0b47a84cdd1a83f311ddf6d0b..f51325612fa14c1428679d6955a6d92322da7c84 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
-@@ -179,7 +179,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
+@@ -178,7 +178,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
}
public boolean isChunkLoaded() {
@@ -92,7 +92,7 @@ index 06165a668c96d25f3a863f5c98eae93240fd56fc..62814197d32f9daf4e6b6aad26920589
}
// CraftBukkit end
-@@ -1672,6 +1672,23 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
+@@ -1671,6 +1671,23 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
}
// Paper start
diff --git a/Spigot-Server-Patches/0009-Timings-v2.patch b/Spigot-Server-Patches/0009-Timings-v2.patch
index 7c3b44e41..2ae0e78da 100644
--- a/Spigot-Server-Patches/0009-Timings-v2.patch
+++ b/Spigot-Server-Patches/0009-Timings-v2.patch
@@ -1001,10 +1001,10 @@ index 1964130ae411ff7d5e1b456a23629804d294a5d0..4cf4ef11ce295aec3b7d0bf07b64a1ec
}
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
-index 62814197d32f9daf4e6b6aad26920589589efd75..a25e9ce6d536c8c276750bfd56ac73a2dbaf7202 100644
+index f51325612fa14c1428679d6955a6d92322da7c84..81f2c91f9e27e2ad2855b64a7849efa18505e952 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
-@@ -30,7 +30,8 @@ import org.bukkit.command.CommandSender;
+@@ -29,7 +29,8 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Hanging;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Vehicle;
@@ -1014,7 +1014,7 @@ index 62814197d32f9daf4e6b6aad26920589589efd75..a25e9ce6d536c8c276750bfd56ac73a2
import org.bukkit.event.entity.EntityCombustByEntityEvent;
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
import org.bukkit.event.vehicle.VehicleBlockCollisionEvent;
-@@ -166,7 +167,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
+@@ -165,7 +166,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
public boolean valid;
public org.bukkit.projectiles.ProjectileSource projectileSource; // For projectiles only
public boolean forceExplosionKnockback; // SPIGOT-949
@@ -1023,7 +1023,7 @@ index 62814197d32f9daf4e6b6aad26920589589efd75..a25e9ce6d536c8c276750bfd56ac73a2
// Spigot start
public final org.spigotmc.ActivationRange.ActivationType activationType = org.spigotmc.ActivationRange.initializeEntityActivationType(this);
public final boolean defaultActivationState;
-@@ -527,7 +528,6 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
+@@ -526,7 +527,6 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
}
public void move(EnumMoveType enummovetype, Vec3D vec3d) {
@@ -1031,7 +1031,7 @@ index 62814197d32f9daf4e6b6aad26920589589efd75..a25e9ce6d536c8c276750bfd56ac73a2
if (this.noclip) {
this.a(this.getBoundingBox().c(vec3d));
this.recalcPosition();
-@@ -664,7 +664,6 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
+@@ -663,7 +663,6 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
this.world.getMethodProfiler().exit();
}
@@ -1116,7 +1116,7 @@ index dccb315440f7429fe881bd0d12af8f1ae8e35c3d..96a95413f74592ef0a8e9367fd3ed81f
if (!this.world.isClientSide && this.dN() && this.aC()) {
this.damageEntity(DamageSource.DROWN, 1.0F);
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
-index 0aed429bfa996b1b01dbe2c876c6ad489ab7fa4a..76ee1196df1d9a0f4c9dfb7b590ee95cc9871aae 100644
+index 67120e3e4a2cd77394fd7e77543223afa2d6a22e..a5284ca66043150c7132f6bee29a952fb6601007 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -65,7 +65,7 @@ import org.bukkit.craftbukkit.CraftServer;
diff --git a/Spigot-Server-Patches/0013-Allow-nerfed-mobs-to-jump-and-take-water-damage.patch b/Spigot-Server-Patches/0013-Allow-nerfed-mobs-to-jump-and-take-water-damage.patch
index 10b2a01af..ecb06718c 100644
--- a/Spigot-Server-Patches/0013-Allow-nerfed-mobs-to-jump-and-take-water-damage.patch
+++ b/Spigot-Server-Patches/0013-Allow-nerfed-mobs-to-jump-and-take-water-damage.patch
@@ -31,10 +31,10 @@ index 2e869004c8c6b8bfbb002fb4eda04519d50390c8..8a6856e0fd7b9b515d98f45aaabefbc3
this.b.setJumping(this.a);
this.a = false;
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
-index a25e9ce6d536c8c276750bfd56ac73a2dbaf7202..748193697235755ba778126dd693526ece0bf46d 100644
+index 81f2c91f9e27e2ad2855b64a7849efa18505e952..f8a85f1c96729ad97aa5f21ac0468c92f243f079 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
-@@ -1025,6 +1025,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
+@@ -1024,6 +1024,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
return this.isInWater() || this.isInRain();
}
diff --git a/Spigot-Server-Patches/0016-Drop-falling-block-and-tnt-entities-at-the-specified.patch b/Spigot-Server-Patches/0016-Drop-falling-block-and-tnt-entities-at-the-specified.patch
index 63ab83a6a..6066138b6 100644
--- a/Spigot-Server-Patches/0016-Drop-falling-block-and-tnt-entities-at-the-specified.patch
+++ b/Spigot-Server-Patches/0016-Drop-falling-block-and-tnt-entities-at-the-specified.patch
@@ -24,10 +24,10 @@ index 8ee2b9bb1bce698fce50ac1b3fc477fcafd0542c..d59b82b7bb1f6d1b231f4e394e0a67a3
+ }
}
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
-index 748193697235755ba778126dd693526ece0bf46d..0f40d8505edda1bb01b5212e2d2fdf07fbfa302b 100644
+index f8a85f1c96729ad97aa5f21ac0468c92f243f079..80f1c4930d6dd602210b07a50b10c45e9f80ae8a 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
-@@ -1762,6 +1762,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
+@@ -1761,6 +1761,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
return this.a(itemstack, 0.0F);
}
diff --git a/Spigot-Server-Patches/0017-Show-Paper-in-client-crashes-server-lists-and-Mojang.patch b/Spigot-Server-Patches/0017-Show-Paper-in-client-crashes-server-lists-and-Mojang.patch
index 1381f0383..be4ce0fe6 100644
--- a/Spigot-Server-Patches/0017-Show-Paper-in-client-crashes-server-lists-and-Mojang.patch
+++ b/Spigot-Server-Patches/0017-Show-Paper-in-client-crashes-server-lists-and-Mojang.patch
@@ -19,7 +19,7 @@ index aab33df7a36eb69300fedfce733985d6c239ca01..550232cb3819138b3bae0fa1c5142948
throwable = throwable1;
throw throwable1;
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
-index 76ee1196df1d9a0f4c9dfb7b590ee95cc9871aae..f4d2ecac55d8ec6272fcb9488c8d4488119b991d 100644
+index a5284ca66043150c7132f6bee29a952fb6601007..77746c19bdeb81b0b2da86cf0aad39207e1b16d1 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1225,7 +1225,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant 0);
-@@ -433,6 +440,17 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
+@@ -432,6 +439,17 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
this.world.getMethodProfiler().exit();
}
@@ -67,7 +67,7 @@ index 15a7c8c01ad27ad25eec8cb59c20e9fe4e0f0ba6..71f2234fd430ee219da6b3d10b8e679a
protected void E() {
if (this.portalCooldown > 0) {
--this.portalCooldown;
-@@ -508,6 +526,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
+@@ -507,6 +525,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
this.setFireTicks(0);
}
diff --git a/Spigot-Server-Patches/0030-Configurable-end-credits.patch b/Spigot-Server-Patches/0030-Configurable-end-credits.patch
index 8680df6f7..509463869 100644
--- a/Spigot-Server-Patches/0030-Configurable-end-credits.patch
+++ b/Spigot-Server-Patches/0030-Configurable-end-credits.patch
@@ -20,7 +20,7 @@ index f7a0a33e49cadf9b2bd43f118c106937760da762..50dec5cb5e924301842300e8fc80cb67
+ }
}
diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
-index 2f3fe374070a3743931ac0c68c949cded4da085a..f768c6450f5224507fd6b2251de14cc59227d1a9 100644
+index 183346d37e36be70348ecf0f2f26a0e0ef35eab8..c3fc8de59042e97560785997fdb3f7bbdc6234e6 100644
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
@@ -60,7 +60,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
diff --git a/Spigot-Server-Patches/0032-Optimize-explosions.patch b/Spigot-Server-Patches/0032-Optimize-explosions.patch
index 0942164ba..d79c31b57 100644
--- a/Spigot-Server-Patches/0032-Optimize-explosions.patch
+++ b/Spigot-Server-Patches/0032-Optimize-explosions.patch
@@ -123,7 +123,7 @@ index bf156897acfe25c16a1b09a83a00ba3ab647a2dd..842563f2030382659a62a3a63d9af9d5
+ // Paper end
}
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
-index 401e528b0812f4917fe782a16ce3831e4427ac6b..fe47aa345b93105547e216f683491943866ccd3f 100644
+index 9555c26c889ceb19b2546967ad60979c8f4868f4..63c2953d6eb6f3c034be97e0cb2dd5e991c75fdd 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1209,6 +1209,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant {
diff --git a/Spigot-Server-Patches/0056-Disable-Scoreboards-for-non-players-by-default.patch b/Spigot-Server-Patches/0056-Disable-Scoreboards-for-non-players-by-default.patch
index cb3b72b34..202a44a84 100644
--- a/Spigot-Server-Patches/0056-Disable-Scoreboards-for-non-players-by-default.patch
+++ b/Spigot-Server-Patches/0056-Disable-Scoreboards-for-non-players-by-default.patch
@@ -25,10 +25,10 @@ index abbf59bb91021821876a8960e8f77fac24457ec4..04430aae52205ee167662004e45c145b
+ }
}
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
-index bfdb57ff56df5d025a7bba9558682089a557c7c9..936919c357865b8933dc1395fffa844940099138 100644
+index 833234254a93b0aee421f7cdb91f85f269040b91..c2ea0e74b72976131976f875934042cf65ba8263 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
-@@ -2196,6 +2196,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
+@@ -2195,6 +2195,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
@Nullable
public ScoreboardTeamBase getScoreboardTeam() {
diff --git a/Spigot-Server-Patches/0064-Handle-Item-Meta-Inconsistencies.patch b/Spigot-Server-Patches/0064-Handle-Item-Meta-Inconsistencies.patch
index dd8b0ecd9..f36e44a5d 100644
--- a/Spigot-Server-Patches/0064-Handle-Item-Meta-Inconsistencies.patch
+++ b/Spigot-Server-Patches/0064-Handle-Item-Meta-Inconsistencies.patch
@@ -79,7 +79,7 @@ index 76091ab3f149decc0d3c848b79edd24e20cf181d..a360711ea14983e8df34caa5edda80a0
public boolean hasEnchantments() {
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
-index c59da5b36c158a25ab861b1aaee497b4119feb3e..bbee99c13e66b50401489fa4ea497980b1e50b18 100644
+index 2097ea9b2683bf4063fbcb601720e8d297fb3b13..52fbc33dab7090075146e04388262f91ae027f2d 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
@@ -178,28 +178,11 @@ public final class CraftItemStack extends ItemStack {
@@ -194,7 +194,7 @@ index c59da5b36c158a25ab861b1aaee497b4119feb3e..bbee99c13e66b50401489fa4ea497980
static Map getEnchantments(net.minecraft.server.ItemStack item) {
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
-index dac0bf9c482cdad7a4e94e41a70cd0765e3c5f18..c1a42d04429a4e9587a4907c29f6b917951e659c 100644
+index e5f029c6ccb2d9258e173ded90ab345426343faf..5d14fff8050f43f5bd9036d5e8b8c7544abf44ee 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
@@ -6,6 +6,7 @@ import com.google.common.collect.ImmutableList;
diff --git a/Spigot-Server-Patches/0070-Use-a-Shared-Random-for-Entities.patch b/Spigot-Server-Patches/0070-Use-a-Shared-Random-for-Entities.patch
index 332923832..100be84da 100644
--- a/Spigot-Server-Patches/0070-Use-a-Shared-Random-for-Entities.patch
+++ b/Spigot-Server-Patches/0070-Use-a-Shared-Random-for-Entities.patch
@@ -6,10 +6,10 @@ Subject: [PATCH] Use a Shared Random for Entities
Reduces memory usage and provides ensures more randomness, Especially since a lot of garbage entity objects get created.
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
-index 936919c357865b8933dc1395fffa844940099138..d4e673a70f28b9d29b3d1b16eaa06562b7a5d7bc 100644
+index c2ea0e74b72976131976f875934042cf65ba8263..9e750c0ff42fa1189f20f10495e1ca1d74c6d51b 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
-@@ -59,6 +59,21 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
+@@ -58,6 +58,21 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
return tag.hasKey("Bukkit.updateLevel") && tag.getInt("Bukkit.updateLevel") >= level;
}
@@ -31,7 +31,7 @@ index 936919c357865b8933dc1395fffa844940099138..d4e673a70f28b9d29b3d1b16eaa06562
private CraftEntity bukkitEntity;
public CraftEntity getBukkitEntity() {
-@@ -193,7 +208,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
+@@ -192,7 +207,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
this.x = Vec3D.a;
this.at = 1.0F;
this.au = 1.0F;
diff --git a/Spigot-Server-Patches/0073-Only-process-BlockPhysicsEvent-if-a-plugin-has-a-lis.patch b/Spigot-Server-Patches/0073-Only-process-BlockPhysicsEvent-if-a-plugin-has-a-lis.patch
index b369db116..cf5dd4463 100644
--- a/Spigot-Server-Patches/0073-Only-process-BlockPhysicsEvent-if-a-plugin-has-a-lis.patch
+++ b/Spigot-Server-Patches/0073-Only-process-BlockPhysicsEvent-if-a-plugin-has-a-lis.patch
@@ -32,7 +32,7 @@ index f87fc631255aa5948459f0726b188ebbbae13c5f..446a2ffcd95fd631750b74fd31b4c410
}
// CraftBukkit end
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
-index fe47aa345b93105547e216f683491943866ccd3f..2455bbee53b4fe3084a785471fde7c4a3354dd4b 100644
+index 63c2953d6eb6f3c034be97e0cb2dd5e991c75fdd..777a553fe3abfdc5db3616352ac11de7969f737c 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1175,6 +1175,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant 0) {
diff --git a/Spigot-Server-Patches/0139-Cap-Entity-Collisions.patch b/Spigot-Server-Patches/0139-Cap-Entity-Collisions.patch
index f6a174508..f71a66395 100644
--- a/Spigot-Server-Patches/0139-Cap-Entity-Collisions.patch
+++ b/Spigot-Server-Patches/0139-Cap-Entity-Collisions.patch
@@ -27,10 +27,10 @@ index f164844f339793860e773c499443ce160d0a6830..751551f173338217f6682532a9a5e1a2
+ }
}
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
-index 8bac1e7d8ad004fc7d248ed21382ca9042dfa9b7..400e6d5784d1d92678bf26fa3dbffbe2e0424a65 100644
+index e1c592c57e54c0c0882978b25286e06d6aaef570..6c60cf4ff4e7d5716c0487767b7632a59607ce23 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
-@@ -189,6 +189,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
+@@ -188,6 +188,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
public final org.spigotmc.ActivationRange.ActivationType activationType = org.spigotmc.ActivationRange.initializeEntityActivationType(this);
public final boolean defaultActivationState;
public long activatedTick = Integer.MIN_VALUE;
diff --git a/Spigot-Server-Patches/0141-Make-targetSize-more-aggressive-in-the-chunk-unload-.patch b/Spigot-Server-Patches/0141-Make-targetSize-more-aggressive-in-the-chunk-unload-.patch
index b2d49c6fc..293fd16f1 100644
--- a/Spigot-Server-Patches/0141-Make-targetSize-more-aggressive-in-the-chunk-unload-.patch
+++ b/Spigot-Server-Patches/0141-Make-targetSize-more-aggressive-in-the-chunk-unload-.patch
@@ -5,7 +5,7 @@ Subject: [PATCH] Make targetSize more aggressive in the chunk unload queue
diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java
-index 9816b64c0760f334e508194ccb3f6b3ab54f7695..cec1baadf5e8e0459837522ca434327491005e8c 100644
+index 2b4033cb2b3d42b776afb9c219d2f64b6c6b1e79..465beba397f05a31dcda9840375a0e9b97153e78 100644
--- a/src/main/java/net/minecraft/server/PlayerChunkMap.java
+++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java
@@ -75,7 +75,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
diff --git a/Spigot-Server-Patches/0143-Properly-handle-async-calls-to-restart-the-server.patch b/Spigot-Server-Patches/0143-Properly-handle-async-calls-to-restart-the-server.patch
index cfbf5f476..9cbb7bc52 100644
--- a/Spigot-Server-Patches/0143-Properly-handle-async-calls-to-restart-the-server.patch
+++ b/Spigot-Server-Patches/0143-Properly-handle-async-calls-to-restart-the-server.patch
@@ -30,7 +30,7 @@ will have plugins and worlds saving to the disk has a high potential to result
in corruption/dataloss.
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
-index 56c9e7e2fd3b454f20fe6f440915bbb770d9a0c9..bb08e1ed62e50549bcef036218f9ed9ed8124a97 100644
+index 9c9dc07a3b6dbfc5c4e0abc9a094de7230c34452..d710082d0aefa0d4a3dccbf5839969bc4d056e7b 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -91,6 +91,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant 0) {
diff --git a/Spigot-Server-Patches/0181-API-to-get-a-BlockState-without-a-snapshot.patch b/Spigot-Server-Patches/0181-API-to-get-a-BlockState-without-a-snapshot.patch
index 0df5427f9..321d2d840 100644
--- a/Spigot-Server-Patches/0181-API-to-get-a-BlockState-without-a-snapshot.patch
+++ b/Spigot-Server-Patches/0181-API-to-get-a-BlockState-without-a-snapshot.patch
@@ -39,7 +39,7 @@ index 967aec7ce9a7fbbb42b51d1ed281db005e107c2c..54285237ed5a096b2e46cabd78f7dcd5
return null;
}
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
-index 562d9daa34540c0e3d99b799dd6f01bf87329006..5ce381ad88daf5f95b19871356ab5852097c5956 100644
+index 1d75200e73f3eaccca4040853a14cfa35a09a2ea..20a294723869756495b4bd5c23846be4049d52a6 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
@@ -308,6 +308,20 @@ public class CraftBlock implements Block {
diff --git a/Spigot-Server-Patches/0185-ExperienceOrbMergeEvent.patch b/Spigot-Server-Patches/0185-ExperienceOrbMergeEvent.patch
index 769320160..deef60597 100644
--- a/Spigot-Server-Patches/0185-ExperienceOrbMergeEvent.patch
+++ b/Spigot-Server-Patches/0185-ExperienceOrbMergeEvent.patch
@@ -8,10 +8,10 @@ Plugins can cancel this if they want to ensure experience orbs do not lose impor
metadata such as spawn reason, or conditionally move data from source to target.
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
-index ee7f71c0fe2cf075ab2e821391cd94f920dc494b..8551d3c9ba808bb9a77897a9866249bc0845c3b2 100644
+index ffad80b0c08274a0a24bfad731a299ae153b6bd9..1529a42197380bd7570abc085a7ad77e9a58894c 100644
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
-@@ -558,7 +558,7 @@ public class CraftEventFactory {
+@@ -572,7 +572,7 @@ public class CraftEventFactory {
if (e instanceof EntityExperienceOrb) {
EntityExperienceOrb loopItem = (EntityExperienceOrb) e;
// Paper start
diff --git a/Spigot-Server-Patches/0189-PlayerNaturallySpawnCreaturesEvent.patch b/Spigot-Server-Patches/0189-PlayerNaturallySpawnCreaturesEvent.patch
index cf0949b6b..b6a7714d4 100644
--- a/Spigot-Server-Patches/0189-PlayerNaturallySpawnCreaturesEvent.patch
+++ b/Spigot-Server-Patches/0189-PlayerNaturallySpawnCreaturesEvent.patch
@@ -29,7 +29,7 @@ index 7abd3683f9cc21b90dc74739954de2decddf6478..6921def2dc8dd7f2b8ba9d46ab697a9f
Optional optional = ((Either) playerchunk.a().getNow(PlayerChunk.UNLOADED_CHUNK)).left();
diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
-index f4275e2ba2659d3087395105da9446225d3a904c..00b19cce68abf405117c5e2d55ba86fc10e7db34 100644
+index 2fa8c3e2491ff5947a99374c0678694d833bf659..253dac9aff57f4311f8c3134caad760992bd340b 100644
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
@@ -1,5 +1,6 @@
@@ -48,7 +48,7 @@ index f4275e2ba2659d3087395105da9446225d3a904c..00b19cce68abf405117c5e2d55ba86fc
public final com.destroystokyo.paper.util.misc.PooledLinkedHashSets.PooledObjectLinkedOpenHashSet cachedSingleHashSet; // Paper
diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java
-index cec1baadf5e8e0459837522ca434327491005e8c..ebe18750e19030b7e7eceb8190fc8d78dc0c3a90 100644
+index 465beba397f05a31dcda9840375a0e9b97153e78..4ae3e91677ecf9c2104a229b4e8b229d18b87aa4 100644
--- a/src/main/java/net/minecraft/server/PlayerChunkMap.java
+++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java
@@ -912,12 +912,23 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
diff --git a/Spigot-Server-Patches/0193-Add-ArmorStand-Item-Meta.patch b/Spigot-Server-Patches/0193-Add-ArmorStand-Item-Meta.patch
index c9871a8cb..0c370ab22 100644
--- a/Spigot-Server-Patches/0193-Add-ArmorStand-Item-Meta.patch
+++ b/Spigot-Server-Patches/0193-Add-ArmorStand-Item-Meta.patch
@@ -267,7 +267,7 @@ index f700522840ee0dfd90871b1b0c8973d7d62a9353..3723faccac00afe19e59d71008ba1604
+ // Paper end
}
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
-index c1a42d04429a4e9587a4907c29f6b917951e659c..e5a2779a0460500c7d58f97c605549a366b5f0ce 100644
+index 5d14fff8050f43f5bd9036d5e8b8c7544abf44ee..153f4c31584e6968978ce4befd7db294cc44c16b 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
@@ -1427,7 +1427,15 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
diff --git a/Spigot-Server-Patches/0200-Implement-extended-PaperServerListPingEvent.patch b/Spigot-Server-Patches/0200-Implement-extended-PaperServerListPingEvent.patch
index 8d678debf..7b693c305 100644
--- a/Spigot-Server-Patches/0200-Implement-extended-PaperServerListPingEvent.patch
+++ b/Spigot-Server-Patches/0200-Implement-extended-PaperServerListPingEvent.patch
@@ -177,7 +177,7 @@ index 0000000000000000000000000000000000000000..a85466bc7e0a8aa54b9eff14077fe6c9
+
+}
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
-index c8a82a6b4b29dcee0f7996b7fd9f01fd73ec2659..f5fa425308e4253d961f8f2bac5b961616dd8521 100644
+index 12aaacc19006f99ccd59f98b55dbab8b4134c654..790d7df8691537a976086b5507db4f97054706de 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -2,6 +2,9 @@ package net.minecraft.server;
diff --git a/Spigot-Server-Patches/0210-Add-method-to-open-already-placed-sign.patch b/Spigot-Server-Patches/0210-Add-method-to-open-already-placed-sign.patch
index 4d1123236..abc0e8ae0 100644
--- a/Spigot-Server-Patches/0210-Add-method-to-open-already-placed-sign.patch
+++ b/Spigot-Server-Patches/0210-Add-method-to-open-already-placed-sign.patch
@@ -5,10 +5,10 @@ Subject: [PATCH] Add method to open already placed sign
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
-index d67fd3bf1048afae0bb78a95724ddf53337d9a2f..42bc39381c4fc5ff81bdd312afd1644dcc5d40c2 100644
+index 30ba0a6aa2fd8c281f1129ad3098ee1033c32f8c..27b2ee740a705238995dd3bcea62b4bf74ec82dc 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
-@@ -584,4 +584,17 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
+@@ -585,4 +585,17 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
entity.remove();
}
}
diff --git a/Spigot-Server-Patches/0216-Expand-World.spawnParticle-API-and-add-Builder.patch b/Spigot-Server-Patches/0216-Expand-World.spawnParticle-API-and-add-Builder.patch
index 73173219f..b5d2d74d2 100644
--- a/Spigot-Server-Patches/0216-Expand-World.spawnParticle-API-and-add-Builder.patch
+++ b/Spigot-Server-Patches/0216-Expand-World.spawnParticle-API-and-add-Builder.patch
@@ -43,7 +43,7 @@ index 6d5bb1c5183c0e7fc83e197f3a6840b2dcb1ad02..7a71e6dfea35addb7d3d33d8ce187cc2
if (this.a(entityplayer, force, d0, d1, d2, packetplayoutworldparticles)) { // CraftBukkit
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
-index 876a62a456c8ff938cca4944b0b40a135dd6ac1c..aa497699fc0fab80b3da1ff4dd08840260cb22d3 100644
+index 7c4514ad1969f7f79bb474606df0f2c3c5888b1a..81546c69e375ffdd46634a5826fd0d016e9e9218 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -2295,11 +2295,17 @@ public class CraftWorld implements World {
diff --git a/Spigot-Server-Patches/0220-Allow-spawning-Item-entities-with-World.spawnEntity.patch b/Spigot-Server-Patches/0220-Allow-spawning-Item-entities-with-World.spawnEntity.patch
index 1826d7235..4a3a2eaec 100644
--- a/Spigot-Server-Patches/0220-Allow-spawning-Item-entities-with-World.spawnEntity.patch
+++ b/Spigot-Server-Patches/0220-Allow-spawning-Item-entities-with-World.spawnEntity.patch
@@ -8,7 +8,7 @@ This API has more capabilities than .dropItem with the Consumer function
Item can be set inside of the Consumer pre spawn function.
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
-index aa497699fc0fab80b3da1ff4dd08840260cb22d3..61780597747e67581531ae436249ddd1c32bae82 100644
+index 81546c69e375ffdd46634a5826fd0d016e9e9218..2aea66553dceadc504abcf5701f8c82b24d1bda7 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -1489,6 +1489,10 @@ public class CraftWorld implements World {
diff --git a/Spigot-Server-Patches/0222-ItemStack-getMaxItemUseDuration.patch b/Spigot-Server-Patches/0222-ItemStack-getMaxItemUseDuration.patch
index fed6fc5c0..cfa748824 100644
--- a/Spigot-Server-Patches/0222-ItemStack-getMaxItemUseDuration.patch
+++ b/Spigot-Server-Patches/0222-ItemStack-getMaxItemUseDuration.patch
@@ -18,7 +18,7 @@ index c4d034c6a6ff176bc954c00c328512bdf67455a6..7b2010ec4955fb5788c60178c6e306ea
return this.getItem().e_(this);
}
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
-index bbee99c13e66b50401489fa4ea497980b1e50b18..4f72b8874f9575c5fc7949c39b4d489809bba097 100644
+index 52fbc33dab7090075146e04388262f91ae027f2d..2146d1354c48b9a76b24bca321b578d401e1a0a8 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
@@ -174,6 +174,13 @@ public final class CraftItemStack extends ItemStack {
diff --git a/Spigot-Server-Patches/0229-EntityShootBowEvent-consumeArrow-and-getArrowItem-AP.patch b/Spigot-Server-Patches/0229-EntityShootBowEvent-consumeArrow-and-getArrowItem-AP.patch
index 474f9e78d..3d70fca47 100644
--- a/Spigot-Server-Patches/0229-EntityShootBowEvent-consumeArrow-and-getArrowItem-AP.patch
+++ b/Spigot-Server-Patches/0229-EntityShootBowEvent-consumeArrow-and-getArrowItem-AP.patch
@@ -72,18 +72,10 @@ index 1592e94c78611a4b968bfb24daf68570e778fadd..31c80bb0a2e403c34fb9cd4b3ee4e903
event.getProjectile().remove();
return;
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
-index 8551d3c9ba808bb9a77897a9866249bc0845c3b2..bd820d9661616c1b294fff0a7af7581a84ada25f 100644
+index 1529a42197380bd7570abc085a7ad77e9a58894c..78475dd2c0f6cca94586536f12323d8080e05623 100644
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
-@@ -50,6 +50,7 @@ import net.minecraft.server.GeneratorAccess;
- import net.minecraft.server.IBlockData;
- import net.minecraft.server.IChatBaseComponent;
- import net.minecraft.server.IInventory;
-+import net.minecraft.server.IProjectile;
- import net.minecraft.server.ItemActionContext;
- import net.minecraft.server.ItemStack;
- import net.minecraft.server.Items;
-@@ -476,16 +477,16 @@ public class CraftEventFactory {
+@@ -490,16 +490,16 @@ public class CraftEventFactory {
/**
* EntityShootBowEvent
*/
diff --git a/Spigot-Server-Patches/0238-InventoryCloseEvent-Reason-API.patch b/Spigot-Server-Patches/0238-InventoryCloseEvent-Reason-API.patch
index 7c795f740..90a0c9674 100644
--- a/Spigot-Server-Patches/0238-InventoryCloseEvent-Reason-API.patch
+++ b/Spigot-Server-Patches/0238-InventoryCloseEvent-Reason-API.patch
@@ -34,7 +34,7 @@ index 4893daca7ea64504731cfab455e09b0a11c65857..1f3e5c384a66bb0767cc18bdbe99b942
this.activeContainer = this.defaultContainer;
}
diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
-index 00b19cce68abf405117c5e2d55ba86fc10e7db34..dc99c7730e72e1a52219fbe0b3b039899899f49d 100644
+index 253dac9aff57f4311f8c3134caad760992bd340b..e050f21fb74ff28e1f18894dc5c9452e2c280c45 100644
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
@@ -411,7 +411,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
@@ -55,7 +55,7 @@ index 00b19cce68abf405117c5e2d55ba86fc10e7db34..dc99c7730e72e1a52219fbe0b3b03989
}
String deathMessage = event.getDeathMessage();
-@@ -1164,7 +1164,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
+@@ -1165,7 +1165,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
return OptionalInt.empty();
} else {
if (this.activeContainer != this.defaultContainer) {
@@ -64,7 +64,7 @@ index 00b19cce68abf405117c5e2d55ba86fc10e7db34..dc99c7730e72e1a52219fbe0b3b03989
}
this.nextContainerCounter();
-@@ -1224,7 +1224,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
+@@ -1225,7 +1225,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
}
// CraftBukkit end
if (this.activeContainer != this.defaultContainer) {
@@ -73,7 +73,7 @@ index 00b19cce68abf405117c5e2d55ba86fc10e7db34..dc99c7730e72e1a52219fbe0b3b03989
}
// this.nextContainerCounter(); // CraftBukkit - moved up
-@@ -1288,7 +1288,12 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
+@@ -1289,7 +1289,12 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
@Override
public void closeInventory() {
@@ -136,10 +136,10 @@ index 7a71e6dfea35addb7d3d33d8ce187cc2c6943de6..dbc7db5c52752c52b3e84b370bbf3877
}
// Spigot End
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
-index 42bc39381c4fc5ff81bdd312afd1644dcc5d40c2..1eac3798acfc8a6859f102250bc8e49ed29d6e21 100644
+index 27b2ee740a705238995dd3bcea62b4bf74ec82dc..f6209e9c0b9e0ab99693025d23847bc62a06225d 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
-@@ -434,8 +434,13 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
+@@ -435,8 +435,13 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
@Override
public void closeInventory() {
@@ -168,10 +168,10 @@ index ec0cb22d53733bed33019b257ac06ca9dc80d19e..5575c44d6f427661de1fec2c69932b44
// Check if the fromWorld and toWorld are the same.
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
-index bd820d9661616c1b294fff0a7af7581a84ada25f..3757a30e7b0ae1ec61211b2250bab47f70c776d4 100644
+index 78475dd2c0f6cca94586536f12323d8080e05623..ec079f7d04f17cc82bd65aec5abfe269bbfb6922 100644
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
-@@ -1299,12 +1299,22 @@ public class CraftEventFactory {
+@@ -1319,12 +1319,22 @@ public class CraftEventFactory {
return event;
}
diff --git a/Spigot-Server-Patches/0246-add-more-information-to-Entity.toString.patch b/Spigot-Server-Patches/0246-add-more-information-to-Entity.toString.patch
index 561df855c..d82bdcfc2 100644
--- a/Spigot-Server-Patches/0246-add-more-information-to-Entity.toString.patch
+++ b/Spigot-Server-Patches/0246-add-more-information-to-Entity.toString.patch
@@ -6,10 +6,10 @@ Subject: [PATCH] add more information to Entity.toString()
UUID, ticks lived, valid, dead
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
-index 3e5b6c2a0ce6df2620d5f6505fcd25e6ea622744..3cb157cf4d1aa90b23f24b5090071d71c6bd2754 100644
+index 357d9293b66eee667f49e566f6f7b5449666986e..09567fe1628f9d2393e7902782e3cdc91531bb18 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
-@@ -2430,7 +2430,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
+@@ -2429,7 +2429,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
}
public String toString() {
diff --git a/Spigot-Server-Patches/0247-Add-Debug-Entities-option-to-debug-dupe-uuid-issues.patch b/Spigot-Server-Patches/0247-Add-Debug-Entities-option-to-debug-dupe-uuid-issues.patch
index dba29626a..f4b8a2c0b 100644
--- a/Spigot-Server-Patches/0247-Add-Debug-Entities-option-to-debug-dupe-uuid-issues.patch
+++ b/Spigot-Server-Patches/0247-Add-Debug-Entities-option-to-debug-dupe-uuid-issues.patch
@@ -6,10 +6,10 @@ Subject: [PATCH] Add Debug Entities option to debug dupe uuid issues
Add -Ddebug.entities=true to your JVM flags to gain more information
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
-index 3cb157cf4d1aa90b23f24b5090071d71c6bd2754..814c885313967f007584f6832111ec5b445e4088 100644
+index 09567fe1628f9d2393e7902782e3cdc91531bb18..c84bf924c9d1c98b469f279302d8595cece71960 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
-@@ -77,6 +77,8 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
+@@ -76,6 +76,8 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
public com.destroystokyo.paper.loottable.PaperLootableInventoryData lootableData; // Paper
private CraftEntity bukkitEntity;
diff --git a/Spigot-Server-Patches/0253-Vanished-players-don-t-have-rights.patch b/Spigot-Server-Patches/0253-Vanished-players-don-t-have-rights.patch
index 9871c118f..bf5699bc0 100644
--- a/Spigot-Server-Patches/0253-Vanished-players-don-t-have-rights.patch
+++ b/Spigot-Server-Patches/0253-Vanished-players-don-t-have-rights.patch
@@ -17,10 +17,10 @@ index 47324feca49786b49563d3d0e854e74ad27c190b..16a8ee36ba2b23207cb8630623d542ac
return this.getBlock().c(this.p(), iblockaccess, blockposition, voxelshapecollision);
}
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
-index 814c885313967f007584f6832111ec5b445e4088..e281ab94a1a69059db653789532735e8c5fd272a 100644
+index c84bf924c9d1c98b469f279302d8595cece71960..3b718673e250a1f9e12ce58481ed533151ad3754 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
-@@ -99,7 +99,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
+@@ -98,7 +98,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
private static double e = 1.0D;
private final EntityTypes> f;
private int id;
@@ -159,10 +159,10 @@ index 66ce6afd46be67a131091d16b6a1221bbff333b5..f6cb503b8eb329cb6bfaa960f812da3c
public boolean s_() {
return this.isClientSide;
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
-index 3757a30e7b0ae1ec61211b2250bab47f70c776d4..a349ce7f04d6f2b29a0de534a3f7616778026666 100644
+index ec079f7d04f17cc82bd65aec5abfe269bbfb6922..1a74690daa05c46c3c0be02a762951efbe945e65 100644
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
-@@ -1177,6 +1177,14 @@ public class CraftEventFactory {
+@@ -1190,6 +1190,14 @@ public class CraftEventFactory {
Projectile projectile = (Projectile) entity.getBukkitEntity();
org.bukkit.entity.Entity collided = position.getEntity().getBukkitEntity();
com.destroystokyo.paper.event.entity.ProjectileCollideEvent event = new com.destroystokyo.paper.event.entity.ProjectileCollideEvent(projectile, collided);
diff --git a/Spigot-Server-Patches/0255-Add-some-Debug-to-Chunk-Entity-slices.patch b/Spigot-Server-Patches/0255-Add-some-Debug-to-Chunk-Entity-slices.patch
index 79423f7b9..31cd188c1 100644
--- a/Spigot-Server-Patches/0255-Add-some-Debug-to-Chunk-Entity-slices.patch
+++ b/Spigot-Server-Patches/0255-Add-some-Debug-to-Chunk-Entity-slices.patch
@@ -58,10 +58,10 @@ index a27f91e6c3d1f5dd0adf8a3b48a640cc63676114..3ba19f75d24a1539c94f4fed9b8f90ae
return;
}
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
-index e281ab94a1a69059db653789532735e8c5fd272a..6012891971265323603cb05ae444cca1bb058c89 100644
+index 3b718673e250a1f9e12ce58481ed533151ad3754..c9905e99e61ffd4f1f0a000bf18daa403a7ea7d1 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
-@@ -72,6 +72,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
+@@ -71,6 +71,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
}
}
};
diff --git a/Spigot-Server-Patches/0260-Ignore-Dead-Entities-in-entityList-iteration.patch b/Spigot-Server-Patches/0260-Ignore-Dead-Entities-in-entityList-iteration.patch
index fc445de04..f019e41cd 100644
--- a/Spigot-Server-Patches/0260-Ignore-Dead-Entities-in-entityList-iteration.patch
+++ b/Spigot-Server-Patches/0260-Ignore-Dead-Entities-in-entityList-iteration.patch
@@ -51,10 +51,10 @@ index 3ba19f75d24a1539c94f4fed9b8f90aecc918cdc..f7be161c8557ae3848227b1a61e27374
if (oclass.isInstance(t0) && t0.getBoundingBox().c(axisalignedbb) && (predicate == null || predicate.test(t0))) { // Spigot - instance check
list.add(t0);
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
-index 6012891971265323603cb05ae444cca1bb058c89..9163916e6f600f2efa3e05f3df1d07ef9b60cd3a 100644
+index c9905e99e61ffd4f1f0a000bf18daa403a7ea7d1..7ccaaa9f2fe2a663674d2cd8a2bd759faec3f603 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
-@@ -196,6 +196,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
+@@ -195,6 +195,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
protected int numCollisions = 0; // Paper
public void inactiveTick() { }
// Spigot end
diff --git a/Spigot-Server-Patches/0265-Add-hand-to-bucket-events.patch b/Spigot-Server-Patches/0265-Add-hand-to-bucket-events.patch
index 1ee7ba868..db1e261dd 100644
--- a/Spigot-Server-Patches/0265-Add-hand-to-bucket-events.patch
+++ b/Spigot-Server-Patches/0265-Add-hand-to-bucket-events.patch
@@ -117,10 +117,10 @@ index ba0bb12dd5c5068d31c8a925e31804ddf2cec5da..14ec04c6503cca58f64fc2a82a9fd715
public LongSet getForceLoadedChunks() {
ForcedChunk forcedchunk = (ForcedChunk) this.getWorldPersistentData().b(ForcedChunk::new, "chunks");
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
-index a349ce7f04d6f2b29a0de534a3f7616778026666..46889e7b462673f5d03e6efc1114074da3165d47 100644
+index 1a74690daa05c46c3c0be02a762951efbe945e65..26a7463a536df9aa8558aba68a2a45464eb2dcfb 100644
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
-@@ -220,7 +220,7 @@ public class CraftEventFactory {
+@@ -224,7 +224,7 @@ public class CraftEventFactory {
public static Entity entityDamage; // For use in EntityDamageByEntityEvent
// helper methods
@@ -129,7 +129,7 @@ index a349ce7f04d6f2b29a0de534a3f7616778026666..46889e7b462673f5d03e6efc1114074d
int spawnSize = Bukkit.getServer().getSpawnRadius();
if (world.getDimensionKey() != World.OVERWORLD) return true;
-@@ -379,6 +379,20 @@ public class CraftEventFactory {
+@@ -392,6 +392,20 @@ public class CraftEventFactory {
}
private static PlayerEvent getPlayerBucketEvent(boolean isFilling, WorldServer world, EntityHuman who, BlockPosition changed, BlockPosition clicked, EnumDirection clickedFace, ItemStack itemstack, net.minecraft.server.Item item) {
@@ -150,7 +150,7 @@ index a349ce7f04d6f2b29a0de534a3f7616778026666..46889e7b462673f5d03e6efc1114074d
Player player = (Player) who.getBukkitEntity();
CraftItemStack itemInHand = CraftItemStack.asNewCraftStack(item);
Material bucket = CraftMagicNumbers.getMaterial(itemstack.getItem());
-@@ -391,10 +405,10 @@ public class CraftEventFactory {
+@@ -404,10 +418,10 @@ public class CraftEventFactory {
PlayerEvent event;
if (isFilling) {
diff --git a/Spigot-Server-Patches/0268-Add-Early-Warning-Feature-to-WatchDog.patch b/Spigot-Server-Patches/0268-Add-Early-Warning-Feature-to-WatchDog.patch
index 09a508e23..850f23006 100644
--- a/Spigot-Server-Patches/0268-Add-Early-Warning-Feature-to-WatchDog.patch
+++ b/Spigot-Server-Patches/0268-Add-Early-Warning-Feature-to-WatchDog.patch
@@ -36,7 +36,7 @@ index adef07d4d521b4aaa6f3389b04aa27e29bec0229..214b577b326bc794fa3721deb6171228
public static int tabSpamLimit = 500;
private static void tabSpamLimiters() {
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
-index f5fa425308e4253d961f8f2bac5b961616dd8521..6a42e480940c4081622050c07961a2c56cfaa542 100644
+index 790d7df8691537a976086b5507db4f97054706de..a7be2875faa968d2e3939974f62c977ca03e9c5b 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -900,6 +900,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant collection, boolean force) {
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
-index 46889e7b462673f5d03e6efc1114074da3165d47..3ba376b077bde759ac62ca1641962598637edd59 100644
+index 26a7463a536df9aa8558aba68a2a45464eb2dcfb..49b39ab97f4ef32a0ea35a0832dca289da14bbde 100644
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
-@@ -755,9 +755,16 @@ public class CraftEventFactory {
+@@ -768,9 +768,16 @@ public class CraftEventFactory {
public static EntityDeathEvent callEntityDeathEvent(EntityLiving victim, List drops) {
CraftLivingEntity entity = (CraftLivingEntity) victim.getBukkitEntity();
EntityDeathEvent event = new EntityDeathEvent(entity, drops, victim.getExpReward());
@@ -398,7 +398,7 @@ index 46889e7b462673f5d03e6efc1114074da3165d47..3ba376b077bde759ac62ca1641962598
victim.expToDrop = event.getDroppedExp();
for (org.bukkit.inventory.ItemStack stack : event.getDrops()) {
-@@ -773,8 +780,15 @@ public class CraftEventFactory {
+@@ -786,8 +793,15 @@ public class CraftEventFactory {
CraftPlayer entity = victim.getBukkitEntity();
PlayerDeathEvent event = new PlayerDeathEvent(entity, drops, victim.getExpReward(), 0, deathMessage);
event.setKeepInventory(keepInventory);
@@ -414,7 +414,7 @@ index 46889e7b462673f5d03e6efc1114074da3165d47..3ba376b077bde759ac62ca1641962598
victim.keepLevel = event.getKeepLevel();
victim.newLevel = event.getNewLevel();
-@@ -791,6 +805,31 @@ public class CraftEventFactory {
+@@ -804,6 +818,31 @@ public class CraftEventFactory {
return event;
}
diff --git a/Spigot-Server-Patches/0290-Implement-an-API-for-CanPlaceOn-and-CanDestroy-NBT-v.patch b/Spigot-Server-Patches/0290-Implement-an-API-for-CanPlaceOn-and-CanDestroy-NBT-v.patch
index badd4ad96..d65836253 100644
--- a/Spigot-Server-Patches/0290-Implement-an-API-for-CanPlaceOn-and-CanDestroy-NBT-v.patch
+++ b/Spigot-Server-Patches/0290-Implement-an-API-for-CanPlaceOn-and-CanDestroy-NBT-v.patch
@@ -32,7 +32,7 @@ index b986a8e318733bdae766202bef93d4d25f18b58d..1f74602ff13a9f89c8dc40170353a79a
this.s = this::l;
if (this.i.canRead() && this.i.peek() == '#') {
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
-index e5a2779a0460500c7d58f97c605549a366b5f0ce..7e0cdc3a1dde2c2e9cf5a9a80bc42010c6695f9e 100644
+index 153f4c31584e6968978ce4befd7db294cc44c16b..79d8d60ea2c64d728297756d2fe9fc1d8f2063ca 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
@@ -85,6 +85,12 @@ import org.bukkit.persistence.PersistentDataContainer;
diff --git a/Spigot-Server-Patches/0295-Optimize-Server-World-Map.patch b/Spigot-Server-Patches/0295-Optimize-Server-World-Map.patch
index 8c39dc1f9..cdcdcc4d1 100644
--- a/Spigot-Server-Patches/0295-Optimize-Server-World-Map.patch
+++ b/Spigot-Server-Patches/0295-Optimize-Server-World-Map.patch
@@ -219,7 +219,7 @@ index 0000000000000000000000000000000000000000..0f0c5330c364909c85cc8cf58fb5c478
+ }
+}
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
-index 6a42e480940c4081622050c07961a2c56cfaa542..16a8300a202e0b33b6de472a72ebf74653bafc20 100644
+index a7be2875faa968d2e3939974f62c977ca03e9c5b..1d4ec1412db104a6437b57afe192063188fabd10 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -91,7 +91,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant
diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
-index 7a0391dc2861d604f1f3acc53eb9e1134c33c64f..9972ee33433914ef9abc5075f274e58d46a9192f 100644
+index 8719381d942789bf80f4b0394cec12e7394ce871..f64a83a6a9f8aaa0c1bbd6c2e3d0af28c06cbbd6 100644
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
-@@ -1694,15 +1694,59 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
+@@ -1696,15 +1696,59 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
return (Entity) (this.spectatedEntity == null ? this : this.spectatedEntity);
}
diff --git a/Spigot-Server-Patches/0309-Reset-players-airTicks-on-respawn.patch b/Spigot-Server-Patches/0309-Reset-players-airTicks-on-respawn.patch
index b61fa994c..92ecb5f73 100644
--- a/Spigot-Server-Patches/0309-Reset-players-airTicks-on-respawn.patch
+++ b/Spigot-Server-Patches/0309-Reset-players-airTicks-on-respawn.patch
@@ -5,10 +5,10 @@ Subject: [PATCH] Reset players airTicks on respawn
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
-index 698619c25714d6bb296084298de4f2e39f8f9c63..28714c10c2bf30fc51c591060bec87c330fc62c1 100644
+index 4e3ea0a00b903b09e2f4d62a330f9faf5ff15f67..58ecc49ba91cdb9c100ce3319434f2110b9a5892 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
-@@ -2257,6 +2257,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
+@@ -2256,6 +2256,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
}
@@ -17,10 +17,10 @@ index 698619c25714d6bb296084298de4f2e39f8f9c63..28714c10c2bf30fc51c591060bec87c3
return 300;
}
diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
-index 9972ee33433914ef9abc5075f274e58d46a9192f..8de15e4856217fb4fc4fc44d9460437e0c8c65ee 100644
+index f64a83a6a9f8aaa0c1bbd6c2e3d0af28c06cbbd6..6bdbe8081689c55a61e133c7b4d3d06d0c507d50 100644
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
-@@ -2025,6 +2025,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
+@@ -2027,6 +2027,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
}
this.setHealth(this.getMaxHealth());
diff --git a/Spigot-Server-Patches/0311-Improve-Server-Thread-Pool-and-Thread-Priorities.patch b/Spigot-Server-Patches/0311-Improve-Server-Thread-Pool-and-Thread-Priorities.patch
index 84edc4750..dd6bcdf54 100644
--- a/Spigot-Server-Patches/0311-Improve-Server-Thread-Pool-and-Thread-Priorities.patch
+++ b/Spigot-Server-Patches/0311-Improve-Server-Thread-Pool-and-Thread-Priorities.patch
@@ -12,7 +12,7 @@ server threads
Allow usage of a single thread executor by not using ForkJoin so single core CPU's.
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
-index 16a8300a202e0b33b6de472a72ebf74653bafc20..ba9b0a7b8b34919eb67c611c11dacbd1805bb226 100644
+index 1d4ec1412db104a6437b57afe192063188fabd10..e4f033d5ad66da5a38e5bfee861e9ea3399f30fe 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -176,6 +176,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant entitySlice = null;
@@ -21,7 +21,7 @@ index 84aa003d90b64c0a37e155f38041c7908860b7f9..8144433d6c309d49b624e88623a3dd37
// Paper end
public com.destroystokyo.paper.loottable.PaperLootableInventoryData lootableData; // Paper
-@@ -1590,6 +1591,9 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
+@@ -1589,6 +1590,9 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
if (this.origin != null) {
nbttagcompound.set("Paper.Origin", this.createList(origin.getX(), origin.getY(), origin.getZ()));
}
@@ -31,7 +31,7 @@ index 84aa003d90b64c0a37e155f38041c7908860b7f9..8144433d6c309d49b624e88623a3dd37
// Save entity's from mob spawner status
if (spawnedViaMobSpawner) {
nbttagcompound.setBoolean("Paper.FromMobSpawner", true);
-@@ -1718,6 +1722,26 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
+@@ -1717,6 +1721,26 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
}
spawnedViaMobSpawner = nbttagcompound.getBoolean("Paper.FromMobSpawner"); // Restore entity's from mob spawner status
diff --git a/Spigot-Server-Patches/0348-Server-Tick-Events.patch b/Spigot-Server-Patches/0348-Server-Tick-Events.patch
index e3877e97e..0217e2a92 100644
--- a/Spigot-Server-Patches/0348-Server-Tick-Events.patch
+++ b/Spigot-Server-Patches/0348-Server-Tick-Events.patch
@@ -6,7 +6,7 @@ Subject: [PATCH] Server Tick Events
Fires event at start and end of a server tick
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
-index f1098b1b62fd568579fd0e1fda63478f58036c8c..5d62daec9afe60cfb0069b6ed867d1d2530389a8 100644
+index 4c610db03f4d8bae0e310d6a0680cefb7bc74872..b6e103bf140d04e9f3bda4112252da5d5fedcf6d 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1120,6 +1120,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant windowType = CraftContainer.getNotchInventoryType(inventory.getTopInventory());
String title = inventory.getTitle();
-- player.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, windowType, new ChatComponentText(title)));
-+ if (!player.isFrozen()) player.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, windowType, new ChatComponentText(title))); // Paper
+- player.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, windowType, CraftChatMessage.fromString(title)[0]));
++ if (!player.isFrozen()) player.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, windowType, CraftChatMessage.fromString(title)[0])); // Paper
player.activeContainer = container;
player.activeContainer.addSlotListener(player);
}
diff --git a/Spigot-Server-Patches/0454-Optimise-entity-hard-collision-checking.patch b/Spigot-Server-Patches/0454-Optimise-entity-hard-collision-checking.patch
index c426f1829..4026e5242 100644
--- a/Spigot-Server-Patches/0454-Optimise-entity-hard-collision-checking.patch
+++ b/Spigot-Server-Patches/0454-Optimise-entity-hard-collision-checking.patch
@@ -88,10 +88,10 @@ index cb24f27bc443880b18ffc36236f6ec7174c9d493..b65ae2d6919a67498d0646c552273508
}
if (entity instanceof EntityItem) {
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
-index 8b7f59577416468a89a99954e2a00b3704ffbd40..bf01f4ef7831491ecb29b86f6d459d1e3a767554 100644
+index a64e21964ed6131d2fc62345e04a30885e1d9a74..83f248b2a045a55ddffd8988f4d176992de26148 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
-@@ -212,6 +212,40 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
+@@ -211,6 +211,40 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
}
// CraftBukkit end
diff --git a/Spigot-Server-Patches/0457-Implement-Player-Client-Options-API.patch b/Spigot-Server-Patches/0457-Implement-Player-Client-Options-API.patch
index b9c0b9581..9d74d6d5c 100644
--- a/Spigot-Server-Patches/0457-Implement-Player-Client-Options-API.patch
+++ b/Spigot-Server-Patches/0457-Implement-Player-Client-Options-API.patch
@@ -98,7 +98,7 @@ index 0bf9de73e800cbbe0553bf491cb1546bb1677b63..e6bf2b5268c03edfb3205f13a963ec1d
protected static final DataWatcherObject br = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.p);
protected static final DataWatcherObject bs = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.p);
diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
-index 97f03d09d8e7f38b00f407b1268e30a0729d1811..0683e163fa6081d4382b3f4635bc52b646b9dd54 100644
+index bfce9d46816cb80272b1825d322231a941b11b58..ef35e07fd8b27a66710140c1422f88ad512e774f 100644
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
@@ -2,6 +2,7 @@ package net.minecraft.server;
@@ -118,7 +118,7 @@ index 97f03d09d8e7f38b00f407b1268e30a0729d1811..0683e163fa6081d4382b3f4635bc52b6
private long ch = SystemUtils.getMonotonicMillis();
private Entity spectatedEntity;
public boolean worldChangeInvuln;
-@@ -1681,6 +1682,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
+@@ -1682,6 +1683,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
public String locale = null; // CraftBukkit - lowercase // Paper - default to null
public void a(PacketPlayInSettings packetplayinsettings) {
diff --git a/Spigot-Server-Patches/0461-Fix-Longstanding-Broken-behavior-of-PlayerJoinEvent.patch b/Spigot-Server-Patches/0461-Fix-Longstanding-Broken-behavior-of-PlayerJoinEvent.patch
index 96ee28841..0b03e2d32 100644
--- a/Spigot-Server-Patches/0461-Fix-Longstanding-Broken-behavior-of-PlayerJoinEvent.patch
+++ b/Spigot-Server-Patches/0461-Fix-Longstanding-Broken-behavior-of-PlayerJoinEvent.patch
@@ -28,7 +28,7 @@ receives a deterministic result, and should no longer require 1 tick
delays anymore.
diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
-index 0683e163fa6081d4382b3f4635bc52b646b9dd54..b3429f001397ed7cbcdfeb12c8f47e5face209a3 100644
+index ef35e07fd8b27a66710140c1422f88ad512e774f..56cf64709ae520287f6687fe7c2f55040cc769a1 100644
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
@@ -104,6 +104,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
diff --git a/Spigot-Server-Patches/0462-Load-Chunks-for-Login-Asynchronously.patch b/Spigot-Server-Patches/0462-Load-Chunks-for-Login-Asynchronously.patch
index ed6b8944c..c18d76c30 100644
--- a/Spigot-Server-Patches/0462-Load-Chunks-for-Login-Asynchronously.patch
+++ b/Spigot-Server-Patches/0462-Load-Chunks-for-Login-Asynchronously.patch
@@ -18,10 +18,10 @@ index 0080a0cbe58d1a81c434ef97659428c8bf1ec290..eebd4c50a7324250d3ebe7060739a71a
boolean flag1 = this.playerChunkMap.b();
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
-index bf01f4ef7831491ecb29b86f6d459d1e3a767554..26cfb843fd54de475190b793d9a206d798d54268 100644
+index 83f248b2a045a55ddffd8988f4d176992de26148..3bcd6c5a32515b96bb7424bcafd5cd0a04954b7b 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
-@@ -1327,7 +1327,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
+@@ -1326,7 +1326,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
this.pitch = MathHelper.a(f1, -90.0F, 90.0F) % 360.0F;
this.lastYaw = this.yaw;
this.lastPitch = this.pitch;
@@ -31,7 +31,7 @@ index bf01f4ef7831491ecb29b86f6d459d1e3a767554..26cfb843fd54de475190b793d9a206d7
public void c(Vec3D vec3d) {
diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
-index b3429f001397ed7cbcdfeb12c8f47e5face209a3..c26236ff4ab56506c51d4e215cfe4fb76bed26ed 100644
+index 56cf64709ae520287f6687fe7c2f55040cc769a1..0a5f784e851414f84e5a94b53f5616531f533109 100644
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
@@ -43,6 +43,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
diff --git a/Spigot-Server-Patches/0463-Move-player-to-spawn-point-if-spawn-in-unloaded-worl.patch b/Spigot-Server-Patches/0463-Move-player-to-spawn-point-if-spawn-in-unloaded-worl.patch
index 5addc24da..b2f572fd5 100644
--- a/Spigot-Server-Patches/0463-Move-player-to-spawn-point-if-spawn-in-unloaded-worl.patch
+++ b/Spigot-Server-Patches/0463-Move-player-to-spawn-point-if-spawn-in-unloaded-worl.patch
@@ -7,10 +7,10 @@ The code following this has better support for null worlds to move
them back to the world spawn.
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
-index 26cfb843fd54de475190b793d9a206d798d54268..7aa95b968af810a7bb4d7dedfacc83219f491e05 100644
+index 3bcd6c5a32515b96bb7424bcafd5cd0a04954b7b..66adeb5e986e721a7e98d57cf5414cdb82cdc071 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
-@@ -1755,9 +1755,11 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
+@@ -1754,9 +1754,11 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
bworld = server.getWorld(worldName);
}
diff --git a/Spigot-Server-Patches/0468-Fix-numerous-item-duplication-issues-and-teleport-is.patch b/Spigot-Server-Patches/0468-Fix-numerous-item-duplication-issues-and-teleport-is.patch
index f17424f1b..539ad92f8 100644
--- a/Spigot-Server-Patches/0468-Fix-numerous-item-duplication-issues-and-teleport-is.patch
+++ b/Spigot-Server-Patches/0468-Fix-numerous-item-duplication-issues-and-teleport-is.patch
@@ -16,10 +16,10 @@ So even if something NEW comes up, it would be impossible to drop the
same item twice because the source was destroyed.
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
-index 7aa95b968af810a7bb4d7dedfacc83219f491e05..b400b04fcb733110150de800927c602180771cec 100644
+index 66adeb5e986e721a7e98d57cf5414cdb82cdc071..f6bd3f458e340c7b19921c135415acdfc3f54802 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
-@@ -1911,11 +1911,12 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
+@@ -1910,11 +1910,12 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
} else {
// CraftBukkit start - Capture drops for death event
if (this instanceof EntityLiving && !((EntityLiving) this).forceDrops) {
@@ -34,7 +34,7 @@ index 7aa95b968af810a7bb4d7dedfacc83219f491e05..b400b04fcb733110150de800927c6021
entityitem.defaultPickupDelay();
// CraftBukkit start
-@@ -2560,6 +2561,12 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
+@@ -2559,6 +2560,12 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
@Nullable
public Entity teleportTo(WorldServer worldserver, BlockPosition location) {
// CraftBukkit end
@@ -47,7 +47,7 @@ index 7aa95b968af810a7bb4d7dedfacc83219f491e05..b400b04fcb733110150de800927c6021
if (this.world instanceof WorldServer && !this.dead) {
this.world.getMethodProfiler().enter("changeDimension");
// CraftBukkit start
-@@ -2663,7 +2670,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
+@@ -2662,7 +2669,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
entity.bukkitEntity = this.getBukkitEntity();
if (this instanceof EntityInsentient) {
@@ -56,7 +56,7 @@ index 7aa95b968af810a7bb4d7dedfacc83219f491e05..b400b04fcb733110150de800927c6021
}
// CraftBukkit end
}
-@@ -2684,7 +2691,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
+@@ -2683,7 +2690,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
}
public boolean canPortal() {
@@ -88,10 +88,10 @@ index 51e9f4a6e09474a7489d2872a800308ee3f02e46..250bccee4a27801b41c50d59e93396c6
}
}
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
-index d82b57f4078802acd6b4a45e1f46f7ac9c8ba1d6..3c73d81d143ade511a88d2ab46417c7aa09719d8 100644
+index 4b8ea4e56efb4c8bfe969c9c1628b5d69aa0c4d9..d4b77d70bfc91339346689ad58f585856633007b 100644
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
-@@ -775,7 +775,8 @@ public class CraftEventFactory {
+@@ -788,7 +788,8 @@ public class CraftEventFactory {
for (org.bukkit.inventory.ItemStack stack : event.getDrops()) {
if (stack == null || stack.getType() == Material.AIR || stack.getAmount() == 0) continue;
diff --git a/Spigot-Server-Patches/0475-Set-cap-on-JDK-per-thread-native-byte-buffer-cache.patch b/Spigot-Server-Patches/0475-Set-cap-on-JDK-per-thread-native-byte-buffer-cache.patch
index c19c1ace7..c070fa456 100644
--- a/Spigot-Server-Patches/0475-Set-cap-on-JDK-per-thread-native-byte-buffer-cache.patch
+++ b/Spigot-Server-Patches/0475-Set-cap-on-JDK-per-thread-native-byte-buffer-cache.patch
@@ -17,7 +17,7 @@ keeping long lived large direct buffers in cache.
Set system properly at server startup if not set already to help protect from this.
diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java
-index 429ae482f30eeeab84cc009a9143245e086ce469..a61e6561c10b62cc97aab1b4d8befe893c5da09f 100644
+index ff2b21305e4a46a8cafa247a0d4e786a6b7cb627..feb45475bb3c0785a8d8198615fbf4b3cd99acbe 100644
--- a/src/main/java/org/bukkit/craftbukkit/Main.java
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
@@ -20,6 +20,7 @@ public class Main {
diff --git a/Spigot-Server-Patches/0477-Use-distance-map-to-optimise-entity-tracker.patch b/Spigot-Server-Patches/0477-Use-distance-map-to-optimise-entity-tracker.patch
index d931923a4..284637ce1 100644
--- a/Spigot-Server-Patches/0477-Use-distance-map-to-optimise-entity-tracker.patch
+++ b/Spigot-Server-Patches/0477-Use-distance-map-to-optimise-entity-tracker.patch
@@ -6,10 +6,10 @@ Subject: [PATCH] Use distance map to optimise entity tracker
Use the distance map to find candidate players for tracking.
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
-index b400b04fcb733110150de800927c602180771cec..d1b5e421e80ed79fec94cbf181d4e6f5515b94e8 100644
+index f6bd3f458e340c7b19921c135415acdfc3f54802..fa15abb838aa4560acaaca1bd1d982b9b8073674 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
-@@ -246,6 +246,21 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
+@@ -245,6 +245,21 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
}
// Paper end
@@ -44,7 +44,7 @@ index 9b89c0c8a3f1dada4e9b2aaeed0b92e56229b7ca..0c46297e6ff229538d77b2f481e4ab13
List list = this.tracker.getPassengers();
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
-index cf05c44865b5d3210b50d11ac7413865cc57f1ff..14a208b3b36f492285c432c591000df1573d31b1 100644
+index e4e946c0b3c6b73f02567fffaaabf06312cbea91..45715f50deb7c3c31a1d2f9795ad026e4938dc47 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1531,6 +1531,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant {
diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
-index 6c8c697367b2c8504d0467cd58f576afbd3e775f..55351ee29a724e7680e5ec98afea2c0f365bc6c4 100644
+index fb2b64628b974758cace770ce6debe5e88318ae8..0e3ceb60e503c74fc65b1d08371645ffbb26ef5c 100644
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
@@ -115,6 +115,8 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
diff --git a/Spigot-Server-Patches/0504-Add-villager-reputation-API.patch b/Spigot-Server-Patches/0481-Add-villager-reputation-API.patch
similarity index 93%
rename from Spigot-Server-Patches/0504-Add-villager-reputation-API.patch
rename to Spigot-Server-Patches/0481-Add-villager-reputation-API.patch
index ab2742c64..ada8c81cd 100644
--- a/Spigot-Server-Patches/0504-Add-villager-reputation-API.patch
+++ b/Spigot-Server-Patches/0481-Add-villager-reputation-API.patch
@@ -20,19 +20,19 @@ index 0000000000000000000000000000000000000000..0f10c333d88f2e1c56a6c7f22d421084
+ }
+}
diff --git a/src/main/java/net/minecraft/server/EntityVillager.java b/src/main/java/net/minecraft/server/EntityVillager.java
-index eeb76bc0298711ac3ea24440a172e812925f875e..7da267d287eb338d32a8cace82bacc4ce2c47182 100644
+index 86b75e31ea1ed9deecae9756c6f838c302dd8df6..91c19ee2926957c530b3ebc7680eeea451464e24 100644
--- a/src/main/java/net/minecraft/server/EntityVillager.java
+++ b/src/main/java/net/minecraft/server/EntityVillager.java
-@@ -960,6 +960,7 @@ public class EntityVillager extends EntityVillagerAbstract implements Reputation
- this.bL = 0;
+@@ -959,6 +959,7 @@ public class EntityVillager extends EntityVillagerAbstract implements Reputation
+ this.bK = 0;
}
-+ public Reputation getReputation() { return this.eN(); } // Paper - OBFHELPER
- public Reputation eN() {
- return this.bG;
++ public Reputation getReputation() { return this.fj(); } // Paper - OBFHELPER
+ public Reputation fj() {
+ return this.bF;
}
diff --git a/src/main/java/net/minecraft/server/Reputation.java b/src/main/java/net/minecraft/server/Reputation.java
-index 0b6f91ac1206089654a6745bccb038fba8c13d98..4ae31599664ee8478ca1acf68f7253eb02eb45ed 100644
+index 3c6d6be4485cad4f2e9a395425b5837590853eee..28c9f9ed2d532a1eb14b74c2e9723a2cf1b3c6fa 100644
--- a/src/main/java/net/minecraft/server/Reputation.java
+++ b/src/main/java/net/minecraft/server/Reputation.java
@@ -25,7 +25,7 @@ import java.util.stream.Stream;
@@ -44,7 +44,7 @@ index 0b6f91ac1206089654a6745bccb038fba8c13d98..4ae31599664ee8478ca1acf68f7253eb
public Reputation() {}
-@@ -138,11 +138,11 @@ public class Reputation {
+@@ -140,11 +140,11 @@ public class Reputation {
return k > reputationtype.h ? Math.max(reputationtype.h, i) : k;
}
@@ -58,7 +58,7 @@ index 0b6f91ac1206089654a6745bccb038fba8c13d98..4ae31599664ee8478ca1acf68f7253eb
this.a = new Object2IntOpenHashMap();
}
-@@ -196,6 +196,27 @@ public class Reputation {
+@@ -198,6 +198,27 @@ public class Reputation {
public void b(ReputationType reputationtype) {
this.a.removeInt(reputationtype);
}
diff --git a/Spigot-Server-Patches/0505-Fix-Light-Command.patch b/Spigot-Server-Patches/0482-Fix-Light-Command.patch
similarity index 94%
rename from Spigot-Server-Patches/0505-Fix-Light-Command.patch
rename to Spigot-Server-Patches/0482-Fix-Light-Command.patch
index a6cb9a1c7..a4d507695 100644
--- a/Spigot-Server-Patches/0505-Fix-Light-Command.patch
+++ b/Spigot-Server-Patches/0482-Fix-Light-Command.patch
@@ -122,10 +122,10 @@ index 182b440ba4802d199b8e44f7779b3401ace495d5..10b72083322b7f8e3e14525b3e834f53
if (!SyncLoadFinder.ENABLED) {
sender.sendMessage(ChatColor.RED + "This command requires the server startup flag '-Dpaper.debug-sync-loads=true' to be set.");
diff --git a/src/main/java/net/minecraft/server/PlayerChunk.java b/src/main/java/net/minecraft/server/PlayerChunk.java
-index 03fb688fe4bdc19b4bc36b1f1d5b40c61e7bef9b..aeca6b2b9d5d73aeb6dc639b5cad2f2533a2de44 100644
+index 40347212ad1bcf857d5b8ddb0ee6a698e2568201..e5751adde516544722b95016f64b2a46c16e77ce 100644
--- a/src/main/java/net/minecraft/server/PlayerChunk.java
+++ b/src/main/java/net/minecraft/server/PlayerChunk.java
-@@ -327,6 +327,7 @@ public class PlayerChunk {
+@@ -314,6 +314,7 @@ public class PlayerChunk {
}
@@ -134,10 +134,10 @@ index 03fb688fe4bdc19b4bc36b1f1d5b40c61e7bef9b..aeca6b2b9d5d73aeb6dc639b5cad2f25
// Paper start - per player view distance
// there can be potential desync with player's last mapped section and the view distance map, so use the
diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java
-index f832e7cdfc6741a932787f02754f145202ff7887..f361939b9ae451bdccf7922e9cca09344c6152b5 100644
+index 6cde6d684f6a3ced1eb2aa554559672e7b0d4947..31f122aeef8df2eae5e8aab12f0b3316a67daa3b 100644
--- a/src/main/java/net/minecraft/server/PlayerChunkMap.java
+++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java
-@@ -95,6 +95,12 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
+@@ -96,6 +96,12 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
private final ChunkTaskQueueSorter p;
private final Mailbox> mailboxWorldGen;
final Mailbox> mailboxMain; // Paper - private -> package private
@@ -150,7 +150,7 @@ index f832e7cdfc6741a932787f02754f145202ff7887..f361939b9ae451bdccf7922e9cca0934
public final WorldLoadListener worldLoadListener;
public final PlayerChunkMap.a chunkDistanceManager; public final PlayerChunkMap.a getChunkMapDistanceManager() { return this.chunkDistanceManager; } // Paper - OBFHELPER
private final AtomicInteger u;
-@@ -282,11 +288,12 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
+@@ -287,11 +293,12 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
Mailbox mailbox = Mailbox.a("main", iasynctaskhandler::a);
this.worldLoadListener = worldloadlistener;
@@ -161,6 +161,6 @@ index f832e7cdfc6741a932787f02754f145202ff7887..f361939b9ae451bdccf7922e9cca0934
this.mailboxWorldGen = this.p.a(threadedmailbox, false);
this.mailboxMain = this.p.a(mailbox, false);
+ this.mailboxLight = this.p.a(lightthreaded, false);// Paper
- this.lightEngine = new LightEngineThreaded(ilightaccess, this, this.world.getWorldProvider().f(), threadedmailbox1, this.p.a(threadedmailbox1, false));
+ this.lightEngine = new LightEngineThreaded(ilightaccess, this, this.world.getDimensionManager().hasSkyLight(), threadedmailbox1, this.p.a(threadedmailbox1, false));
this.chunkDistanceManager = new PlayerChunkMap.a(executor, iasynctaskhandler); this.chunkDistanceManager.chunkMap = this; // Paper
this.l = supplier;
diff --git a/Spigot-Server-Patches/0507-Fix-PotionEffect-ignores-icon-flag.patch b/Spigot-Server-Patches/0483-Fix-PotionEffect-ignores-icon-flag.patch
similarity index 87%
rename from Spigot-Server-Patches/0507-Fix-PotionEffect-ignores-icon-flag.patch
rename to Spigot-Server-Patches/0483-Fix-PotionEffect-ignores-icon-flag.patch
index 9c6ba39af..43fcc1a79 100644
--- a/Spigot-Server-Patches/0507-Fix-PotionEffect-ignores-icon-flag.patch
+++ b/Spigot-Server-Patches/0483-Fix-PotionEffect-ignores-icon-flag.patch
@@ -5,10 +5,10 @@ Subject: [PATCH] Fix PotionEffect ignores icon flag
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
-index 245bd116d143af120127a9d25dcb7a0c43ad47a0..a461ac36144361b712e015b722e68bdb0b43dfb2 100644
+index b3ec32b20751fbea2f6df14fc5e9f84682493bfd..3777aba5f32f58f4620d4fe496af4e641ff8c858 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
-@@ -384,7 +384,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
+@@ -387,7 +387,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
@Override
public boolean addPotionEffect(PotionEffect effect, boolean force) {
diff --git a/Spigot-Server-Patches/0508-Optimize-brigadier-child-sorting-performance.patch b/Spigot-Server-Patches/0484-Optimize-brigadier-child-sorting-performance.patch
similarity index 100%
rename from Spigot-Server-Patches/0508-Optimize-brigadier-child-sorting-performance.patch
rename to Spigot-Server-Patches/0484-Optimize-brigadier-child-sorting-performance.patch
diff --git a/Spigot-Server-Patches/0510-Don-t-toString-block-unless-actually-showing-the-mes.patch b/Spigot-Server-Patches/0485-Don-t-toString-block-unless-actually-showing-the-mes.patch
similarity index 92%
rename from Spigot-Server-Patches/0510-Don-t-toString-block-unless-actually-showing-the-mes.patch
rename to Spigot-Server-Patches/0485-Don-t-toString-block-unless-actually-showing-the-mes.patch
index f81d312f6..11c031b70 100644
--- a/Spigot-Server-Patches/0510-Don-t-toString-block-unless-actually-showing-the-mes.patch
+++ b/Spigot-Server-Patches/0485-Don-t-toString-block-unless-actually-showing-the-mes.patch
@@ -7,7 +7,7 @@ This is causing MASSIVE performance issues with hoppers and block states
in general.
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java
-index 3e22d558ea09a6554e1bc71f8ca10277ec480705..3da34ebcb96040ef4b399e348d1cff2f000aefa2 100644
+index 6e9eff2c29528b857cf758e9e45606c8a1c1cc8d..dc0e6e49e9eb5004e53d24304bce095bcef8f4c2 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java
@@ -26,7 +26,7 @@ public class CraftBlockEntityState extends CraftBlockState
diff --git a/Spigot-Server-Patches/0514-Potential-bed-API.patch b/Spigot-Server-Patches/0486-Potential-bed-API.patch
similarity index 57%
rename from Spigot-Server-Patches/0514-Potential-bed-API.patch
rename to Spigot-Server-Patches/0486-Potential-bed-API.patch
index 2dd156300..3e0e6af76 100644
--- a/Spigot-Server-Patches/0514-Potential-bed-API.patch
+++ b/Spigot-Server-Patches/0486-Potential-bed-API.patch
@@ -8,24 +8,29 @@ Adds a new method to fetch the location of a player's bed without generating any
getPotentialBedLocation - Gets the last known location of a player's bed. This does not preform any check if the bed is still valid and does not load any chunks.
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
-index a5e9fc90ffae794b9b14468337ce7b091fd0dc35..a2815073bc04dd831fa22da47162031d360683dd 100644
+index 1c271ee568a02f1ab9c8722b840444f5cf5d657f..7c22a24d0b50f0a8f4ccfef87f7f77028c3188c6 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
-@@ -143,6 +143,17 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
- return null;
+@@ -126,6 +126,22 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
+ return getHandle().sleepTicks;
}
+ // Paper start - Potential bed api
+ @Override
+ public Location getPotentialBedLocation() {
-+ BlockPosition bed = getHandle().getBed();
++ EntityPlayer handle = (EntityPlayer) getHandle();
++ BlockPosition bed = handle.getSpawn();
+ if (bed == null) {
+ return null;
+ }
-+ return new Location(getServer().getWorld(getHandle().spawnWorld), bed.getX(), bed.getY(), bed.getZ());
++
++ net.minecraft.server.WorldServer worldServer = handle.server.getWorldServer(handle.getSpawnDimension());
++ if (worldServer == null) {
++ return null;
++ }
++ return new Location(worldServer.getWorld(), bed.getX(), bed.getY(), bed.getZ());
+ }
+ // Paper end
-+
@Override
- public void setBedSpawnLocation(Location location) {
- setBedSpawnLocation(location, false);
+ public boolean sleep(Location location, boolean force) {
+ Preconditions.checkArgument(location != null, "Location cannot be null");
diff --git a/Spigot-Server-Patches/0515-Wait-for-Async-Tasks-during-shutdown.patch b/Spigot-Server-Patches/0487-Wait-for-Async-Tasks-during-shutdown.patch
similarity index 87%
rename from Spigot-Server-Patches/0515-Wait-for-Async-Tasks-during-shutdown.patch
rename to Spigot-Server-Patches/0487-Wait-for-Async-Tasks-during-shutdown.patch
index b7b12e779..c04562f74 100644
--- a/Spigot-Server-Patches/0515-Wait-for-Async-Tasks-during-shutdown.patch
+++ b/Spigot-Server-Patches/0487-Wait-for-Async-Tasks-during-shutdown.patch
@@ -10,10 +10,10 @@ Adds a 5 second grace period for any async tasks to finish and warns
if any are still running after that delay just as reload does.
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
-index 2c9ae5c46a39639fd9f842df23993a47b31c8585..4ab6579032043f570c20befa7fef8931babd2355 100644
+index 45715f50deb7c3c31a1d2f9795ad026e4938dc47..10e6572afa5b5cf65673b65541ef2fafb0b2aaae 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
-@@ -747,6 +747,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant extends PathfinderGoal {
@@ -18,12 +18,11 @@ index c0b7b5f072b0b3777b2042b0b80f3bb22e617b11..ee1fcb11afbc3efa42ce0170b72da3fd
public b(T entityraider) { // CraftBukkit - decompile error
this.b = entityraider;
-@@ -495,6 +495,8 @@ public abstract class EntityRaider extends EntityMonsterPatrolling {
+@@ -496,6 +496,7 @@ public abstract class EntityRaider extends EntityMonsterPatrolling {
@Override
public boolean a() {
+ if (!getRaider().world.getGameRules().getBoolean(GameRules.MOB_GRIEFING) || !getRaider().canPickupLoot()) return false; // Paper - respect game and entity rules for picking up items
-+
- Raid raid = this.b.eE();
+ Raid raid = this.b.fb();
- if (this.b.eF() && !this.b.eE().a() && this.b.es() && !ItemStack.matches(this.b.getEquipment(EnumItemSlot.HEAD), Raid.s())) {
+ if (this.b.fc() && !this.b.fb().a() && this.b.eO() && !ItemStack.matches(this.b.getEquipment(EnumItemSlot.HEAD), Raid.s())) {
diff --git a/Spigot-Server-Patches/0519-Protect-Bedrock-and-End-Portal-Frames-from-being-des.patch b/Spigot-Server-Patches/0489-Protect-Bedrock-and-End-Portal-Frames-from-being-des.patch
similarity index 69%
rename from Spigot-Server-Patches/0519-Protect-Bedrock-and-End-Portal-Frames-from-being-des.patch
rename to Spigot-Server-Patches/0489-Protect-Bedrock-and-End-Portal-Frames-from-being-des.patch
index 6952b8854..74dd00654 100644
--- a/Spigot-Server-Patches/0519-Protect-Bedrock-and-End-Portal-Frames-from-being-des.patch
+++ b/Spigot-Server-Patches/0489-Protect-Bedrock-and-End-Portal-Frames-from-being-des.patch
@@ -13,10 +13,10 @@ A config is provided if you rather let players use these exploits, and let
them destroy the worlds End Portals and get on top of the nether easy.
diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java
-index 3ee7e5671dd2519cec72b81211f1f39176a228ba..cf9b9de8688e3f655631451409096d7ec0471910 100644
+index c31a97c6ae0dd1493039158e67c5f3ba237ad234..e1c9e559b25792296b6b8f6dd1070035d10d82f2 100644
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
-@@ -431,4 +431,10 @@ public class PaperConfig {
+@@ -410,4 +410,10 @@ public class PaperConfig {
private static void midTickChunkTasks() {
midTickChunkTasks = getInt("settings.chunk-tasks-per-tick", midTickChunkTasks);
}
@@ -28,12 +28,12 @@ index 3ee7e5671dd2519cec72b81211f1f39176a228ba..cf9b9de8688e3f655631451409096d7e
+
}
diff --git a/src/main/java/net/minecraft/server/Block.java b/src/main/java/net/minecraft/server/Block.java
-index e40375b67a4a321048c87002a07fde5c5d2395db..d2207a2c95690de586ab2d181b64955a6d2ea70d 100644
+index 4f9c6b25f152b348a00dadf4b8f58ec3adc3476e..81725611d5b8c10c05d561984f92dc67349900ec 100644
--- a/src/main/java/net/minecraft/server/Block.java
+++ b/src/main/java/net/minecraft/server/Block.java
-@@ -32,6 +32,14 @@ public class Block implements IMaterial {
- protected final SoundEffectType stepSound;
- protected final Material material;
+@@ -25,6 +25,14 @@ public class Block extends BlockBase implements IMaterial {
+ protected final BlockStateList blockStateList;
+ private IBlockData blockData;
// Paper start
+ public final boolean isDestroyable() {
+ return com.destroystokyo.paper.PaperConfig.allowBlockPermanentBreakingExploits ||
@@ -46,7 +46,11 @@ index e40375b67a4a321048c87002a07fde5c5d2395db..d2207a2c95690de586ab2d181b64955a
public co.aikar.timings.Timing timing;
public co.aikar.timings.Timing getTiming() {
if (timing == null) {
-@@ -276,7 +284,7 @@ public class Block implements IMaterial {
+diff --git a/src/main/java/net/minecraft/server/BlockBase.java b/src/main/java/net/minecraft/server/BlockBase.java
+index 16a8ee36ba2b23207cb8630623d542ac5943b9df..ea272c5f818a07535851c93ab905bde906a0e61e 100644
+--- a/src/main/java/net/minecraft/server/BlockBase.java
++++ b/src/main/java/net/minecraft/server/BlockBase.java
+@@ -138,7 +138,7 @@ public abstract class BlockBase {
@Deprecated
public boolean a(IBlockData iblockdata, BlockActionContext blockactioncontext) {
@@ -55,20 +59,33 @@ index e40375b67a4a321048c87002a07fde5c5d2395db..d2207a2c95690de586ab2d181b64955a
}
@Deprecated
-@@ -596,7 +604,7 @@ public class Block implements IMaterial {
+@@ -334,7 +334,11 @@ public abstract class BlockBase {
+ public Block getBlock() {
+ return (Block) this.c;
+ }
+-
++ // Paper start
++ public final boolean isDestroyable() {
++ return getBlock().isDestroyable();
++ }
++ // Paper end
+ public Material getMaterial() {
+ return this.g;
+ }
+@@ -424,7 +428,7 @@ public abstract class BlockBase {
+ }
- @Deprecated
- public EnumPistonReaction getPushReaction(IBlockData iblockdata) {
-- return this.material.getPushReaction();
-+ return !blockData.isDestroyable() ? EnumPistonReaction.BLOCK : this.material.getPushReaction(); // Paper
- }
+ public EnumPistonReaction getPushReaction() {
+- return this.getBlock().getPushReaction(this.p());
++ return !isDestroyable() ? EnumPistonReaction.BLOCK : this.getBlock().getPushReaction(this.p()); // Paper
+ }
- public void fallOn(World world, BlockPosition blockposition, Entity entity, float f) {
+ public boolean i(IBlockAccess iblockaccess, BlockPosition blockposition) {
diff --git a/src/main/java/net/minecraft/server/BlockPiston.java b/src/main/java/net/minecraft/server/BlockPiston.java
-index b29525c40dc8e3ae747b8ddf5a3bd79b7cc0b792..39cd8ab5925ceb9494e0ac910c73338c24ecda2c 100644
+index c068a4115e3b82f4886d822d2472e8b522946674..6b1253fe7e8d4bb71d4d19c063d3e84c167c4d7b 100644
--- a/src/main/java/net/minecraft/server/BlockPiston.java
+++ b/src/main/java/net/minecraft/server/BlockPiston.java
-@@ -175,6 +175,12 @@ public class BlockPiston extends BlockDirectional {
+@@ -165,6 +165,12 @@ public class BlockPiston extends BlockDirectional {
@Override
public boolean a(IBlockData iblockdata, World world, BlockPosition blockposition, int i, int j) {
EnumDirection enumdirection = (EnumDirection) iblockdata.get(BlockPiston.FACING);
@@ -81,16 +98,16 @@ index b29525c40dc8e3ae747b8ddf5a3bd79b7cc0b792..39cd8ab5925ceb9494e0ac910c73338c
if (!world.isClientSide) {
boolean flag = this.a(world, blockposition, enumdirection);
-@@ -204,7 +210,7 @@ public class BlockPiston extends BlockDirectional {
- }
+@@ -196,7 +202,7 @@ public class BlockPiston extends BlockDirectional {
+ IBlockData iblockdata1 = (IBlockData) ((IBlockData) Blocks.MOVING_PISTON.getBlockData().set(BlockPistonMoving.a, enumdirection)).set(BlockPistonMoving.b, this.sticky ? BlockPropertyPistonType.STICKY : BlockPropertyPistonType.DEFAULT);
- world.setTypeAndData(blockposition, (IBlockData) ((IBlockData) Blocks.MOVING_PISTON.getBlockData().set(BlockPistonMoving.a, enumdirection)).set(BlockPistonMoving.b, this.sticky ? BlockPropertyPistonType.STICKY : BlockPropertyPistonType.DEFAULT), 3);
+ world.setTypeAndData(blockposition, iblockdata1, 20);
- world.setTileEntity(blockposition, BlockPistonMoving.a((IBlockData) this.getBlockData().set(BlockPiston.FACING, EnumDirection.fromType1(j & 7)), enumdirection, false, true));
-+ world.setTileEntity(blockposition, BlockPistonMoving.a((IBlockData) this.getBlockData().set(BlockPiston.FACING, EnumDirection.fromType1(j & 7)), enumdirection, false, true)); // Paper - diff on change, j is facing direction
++ world.setTileEntity(blockposition, BlockPistonMoving.a((IBlockData) this.getBlockData().set(BlockPiston.FACING, EnumDirection.fromType1(j & 7)), enumdirection, false, true)); // Paper - diff on change, j is facing direction - copy this above
+ world.update(blockposition, iblockdata1.getBlock());
+ iblockdata1.a(world, blockposition, 2);
if (this.sticky) {
- BlockPosition blockposition1 = blockposition.b(enumdirection.getAdjacentX() * 2, enumdirection.getAdjacentY() * 2, enumdirection.getAdjacentZ() * 2);
- IBlockData iblockdata1 = world.getType(blockposition1);
-@@ -232,7 +238,14 @@ public class BlockPiston extends BlockDirectional {
+@@ -225,7 +231,14 @@ public class BlockPiston extends BlockDirectional {
}
}
} else {
@@ -107,18 +124,18 @@ index b29525c40dc8e3ae747b8ddf5a3bd79b7cc0b792..39cd8ab5925ceb9494e0ac910c73338c
world.playSound((EntityHuman) null, blockposition, SoundEffects.BLOCK_PISTON_CONTRACT, SoundCategory.BLOCKS, 0.5F, world.random.nextFloat() * 0.15F + 0.6F);
diff --git a/src/main/java/net/minecraft/server/Explosion.java b/src/main/java/net/minecraft/server/Explosion.java
-index a353f3d5fa5a5f54335f73584589de3f5cb20d3e..2552f860ff7a25f74e9a0600e58cefe064fac484 100644
+index 22a19e761fdec68cc9405988b977021a8b6398eb..e408ec8c645e9ceb278a13a5b0de8ecf57f3929e 100644
--- a/src/main/java/net/minecraft/server/Explosion.java
+++ b/src/main/java/net/minecraft/server/Explosion.java
-@@ -117,6 +117,7 @@ public class Explosion {
+@@ -124,6 +124,7 @@ public class Explosion {
for (float f1 = 0.3F; f > 0.0F; f -= 0.22500001F) {
BlockPosition blockposition = new BlockPosition(d4, d5, d6);
IBlockData iblockdata = this.world.getType(blockposition);
+ if (!iblockdata.isDestroyable()) continue; // Paper
Fluid fluid = iblockdata.getFluid(); // Paper
+ Optional optional = this.k.a(this, this.world, blockposition, iblockdata, fluid);
- if (!iblockdata.isAir() || !fluid.isEmpty()) {
-@@ -282,7 +283,7 @@ public class Explosion {
+@@ -277,7 +278,7 @@ public class Explosion {
IBlockData iblockdata = this.world.getType(blockposition);
Block block = iblockdata.getBlock();
@@ -127,28 +144,12 @@ index a353f3d5fa5a5f54335f73584589de3f5cb20d3e..2552f860ff7a25f74e9a0600e58cefe0
BlockPosition blockposition1 = blockposition.immutableCopy();
this.world.getMethodProfiler().enter("explosion_blocks");
-diff --git a/src/main/java/net/minecraft/server/IBlockData.java b/src/main/java/net/minecraft/server/IBlockData.java
-index b19bbbbc81376177751396a2de9452ce1f84c06b..296b41bf36ee1ace5bd9db2b810bf926b5f5278f 100644
---- a/src/main/java/net/minecraft/server/IBlockData.java
-+++ b/src/main/java/net/minecraft/server/IBlockData.java
-@@ -52,6 +52,11 @@ public class IBlockData extends BlockDataAbstract implements
- return (CraftBlockData) cachedCraftBlockData.clone();
- }
- // Paper end
-+ // Paper start
-+ public final boolean isDestroyable() {
-+ return getBlock().isDestroyable();
-+ }
-+ // Paper end
-
- public Material getMaterial() {
- return this.getBlock().k(this);
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
-index 7bd3f789b6055d73f3a6c0628652cca241147887..032b7acee8c8af70c0283f5551ce2875607f6c98 100644
+index 965b43da38832f37091929d954c2bb7e7fbc7798..bf32f4d81e58f6d7ccf1b6eb9daebe0986169b1c 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
-@@ -342,6 +342,10 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
- public boolean setTypeAndData(BlockPosition blockposition, IBlockData iblockdata, int i) {
+@@ -400,6 +400,10 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
+ public boolean a(BlockPosition blockposition, IBlockData iblockdata, int i, int j) {
// CraftBukkit start - tree generation
if (this.captureTreeGeneration) {
+ // Paper start
diff --git a/Spigot-Server-Patches/0520-Optimize-NibbleArray-to-use-pooled-buffers.patch b/Spigot-Server-Patches/0490-Optimize-NibbleArray-to-use-pooled-buffers.patch
similarity index 92%
rename from Spigot-Server-Patches/0520-Optimize-NibbleArray-to-use-pooled-buffers.patch
rename to Spigot-Server-Patches/0490-Optimize-NibbleArray-to-use-pooled-buffers.patch
index bbd03eef7..8b2082f5e 100644
--- a/Spigot-Server-Patches/0520-Optimize-NibbleArray-to-use-pooled-buffers.patch
+++ b/Spigot-Server-Patches/0490-Optimize-NibbleArray-to-use-pooled-buffers.patch
@@ -9,10 +9,10 @@ an object pool for these.
Uses lots of advanced new capabilities of the Paper codebase :)
diff --git a/src/main/java/net/minecraft/server/ChunkRegionLoader.java b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
-index e625842e524f18e469f7695b27d52d4d04892266..d752e793f13a9caf5d255293f7ce9d562fd50064 100644
+index 5b196201c0e35895a04e2a542ef7c753d0c469e1..4b7c4643f04448aaccc66f26a9dea2323bea420d 100644
--- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java
+++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
-@@ -387,11 +387,11 @@ public class ChunkRegionLoader {
+@@ -386,11 +386,11 @@ public class ChunkRegionLoader {
}
if (nibblearray != null && !nibblearray.c()) {
@@ -27,10 +27,10 @@ index e625842e524f18e469f7695b27d52d4d04892266..d752e793f13a9caf5d255293f7ce9d56
nbttaglist.add(nbttagcompound2);
diff --git a/src/main/java/net/minecraft/server/LightEngineStorage.java b/src/main/java/net/minecraft/server/LightEngineStorage.java
-index 88277d23c36696fdd5363e41a130c9a443fac2c0..b0b7544592981bcff22c8acee7230a211918ef28 100644
+index 6c7c4e75670a7e08ba10c0231a2510bf985dab6b..b8b06c790adfa0246b1a6fb5eab1f63bf5ef8b0b 100644
--- a/src/main/java/net/minecraft/server/LightEngineStorage.java
+++ b/src/main/java/net/minecraft/server/LightEngineStorage.java
-@@ -148,7 +148,7 @@ public abstract class LightEngineStorage> e
+@@ -149,7 +149,7 @@ public abstract class LightEngineStorage> e
protected NibbleArray j(long i) {
NibbleArray nibblearray = (NibbleArray) this.i.get(i);
@@ -39,12 +39,15 @@ index 88277d23c36696fdd5363e41a130c9a443fac2c0..b0b7544592981bcff22c8acee7230a21
}
protected void a(LightEngineLayer, ?> lightenginelayer, long i) {
-@@ -317,9 +317,9 @@ public abstract class LightEngineStorage> e
+@@ -331,12 +331,12 @@ public abstract class LightEngineStorage> e
- protected void a(long i, @Nullable NibbleArray nibblearray) {
+ protected void a(long i, @Nullable NibbleArray nibblearray, boolean flag) {
if (nibblearray != null) {
- this.i.put(i, nibblearray);
+ NibbleArray remove = this.i.put(i, nibblearray); if (remove != null && remove.cleaner != null) remove.cleaner.run(); // Paper - clean up when removed
+ if (!flag) {
+ this.n.add(i);
+ }
} else {
- this.i.remove(i);
+ NibbleArray remove = this.i.remove(i); if (remove != null && remove.cleaner != null) remove.cleaner.run(); // Paper - clean up when removed
@@ -244,12 +247,12 @@ index 67c960292db9d99ac85b5d0dda50ae48ef942c1b..5e3efa1fa6c089df35971ce5c83da384
for (int i = 0; i < 16; ++i) {
System.arraycopy(this.a, 0, abyte, i * 128, 128);
diff --git a/src/main/java/net/minecraft/server/PacketPlayOutLightUpdate.java b/src/main/java/net/minecraft/server/PacketPlayOutLightUpdate.java
-index cd1ad45469aa163b9bc41774ae80adfa617fd97b..27068f73a2b1fd97dc675ceb3f0eb07ac9e59437 100644
+index 6b70df646c6a690ab9437ead96c5ff097e4e12d2..1015a1d80530451be0cbee51e135526d3d3d99a7 100644
--- a/src/main/java/net/minecraft/server/PacketPlayOutLightUpdate.java
+++ b/src/main/java/net/minecraft/server/PacketPlayOutLightUpdate.java
-@@ -16,13 +16,42 @@ public class PacketPlayOutLightUpdate implements Packet {
- private List g;
+@@ -17,14 +17,43 @@ public class PacketPlayOutLightUpdate implements Packet {
private List h;
+ private boolean i;
+ // Paper start
+ java.lang.Runnable cleaner1;
@@ -282,9 +285,10 @@ index cd1ad45469aa163b9bc41774ae80adfa617fd97b..27068f73a2b1fd97dc675ceb3f0eb07a
+ // Paper end
public PacketPlayOutLightUpdate() {}
- public PacketPlayOutLightUpdate(ChunkCoordIntPair chunkcoordintpair, LightEngine lightengine) {
+ public PacketPlayOutLightUpdate(ChunkCoordIntPair chunkcoordintpair, LightEngine lightengine, boolean flag) {
this.a = chunkcoordintpair.x;
this.b = chunkcoordintpair.z;
+ this.i = flag;
- this.g = Lists.newArrayList();
- this.h = Lists.newArrayList();
+ this.g = Lists.newArrayList();cleaner1 = MCUtil.registerListCleaner(this, this.g, NibbleArray::releaseBytes); // Paper
@@ -292,7 +296,7 @@ index cd1ad45469aa163b9bc41774ae80adfa617fd97b..27068f73a2b1fd97dc675ceb3f0eb07a
for (int i = 0; i < 18; ++i) {
NibbleArray nibblearray = lightengine.a(EnumSkyBlock.SKY).a(SectionPosition.a(chunkcoordintpair, -1 + i));
-@@ -33,7 +62,7 @@ public class PacketPlayOutLightUpdate implements Packet {
+@@ -35,7 +64,7 @@ public class PacketPlayOutLightUpdate implements Packet {
this.e |= 1 << i;
} else {
this.c |= 1 << i;
@@ -301,7 +305,7 @@ index cd1ad45469aa163b9bc41774ae80adfa617fd97b..27068f73a2b1fd97dc675ceb3f0eb07a
}
}
-@@ -42,7 +71,7 @@ public class PacketPlayOutLightUpdate implements Packet {
+@@ -44,7 +73,7 @@ public class PacketPlayOutLightUpdate implements Packet {
this.f |= 1 << i;
} else {
this.d |= 1 << i;
@@ -310,8 +314,8 @@ index cd1ad45469aa163b9bc41774ae80adfa617fd97b..27068f73a2b1fd97dc675ceb3f0eb07a
}
}
}
-@@ -54,8 +83,8 @@ public class PacketPlayOutLightUpdate implements Packet {
- this.b = chunkcoordintpair.z;
+@@ -57,8 +86,8 @@ public class PacketPlayOutLightUpdate implements Packet {
+ this.i = flag;
this.c = i;
this.d = j;
- this.g = Lists.newArrayList();
@@ -321,7 +325,7 @@ index cd1ad45469aa163b9bc41774ae80adfa617fd97b..27068f73a2b1fd97dc675ceb3f0eb07a
for (int k = 0; k < 18; ++k) {
NibbleArray nibblearray;
-@@ -63,7 +92,7 @@ public class PacketPlayOutLightUpdate implements Packet {
+@@ -66,7 +95,7 @@ public class PacketPlayOutLightUpdate implements Packet {
if ((this.c & 1 << k) != 0) {
nibblearray = lightengine.a(EnumSkyBlock.SKY).a(SectionPosition.a(chunkcoordintpair, -1 + k));
if (nibblearray != null && !nibblearray.c()) {
@@ -330,7 +334,7 @@ index cd1ad45469aa163b9bc41774ae80adfa617fd97b..27068f73a2b1fd97dc675ceb3f0eb07a
} else {
this.c &= ~(1 << k);
if (nibblearray != null) {
-@@ -75,7 +104,7 @@ public class PacketPlayOutLightUpdate implements Packet {
+@@ -78,7 +107,7 @@ public class PacketPlayOutLightUpdate implements Packet {
if ((this.d & 1 << k) != 0) {
nibblearray = lightengine.a(EnumSkyBlock.BLOCK).a(SectionPosition.a(chunkcoordintpair, -1 + k));
if (nibblearray != null && !nibblearray.c()) {
@@ -340,10 +344,10 @@ index cd1ad45469aa163b9bc41774ae80adfa617fd97b..27068f73a2b1fd97dc675ceb3f0eb07a
this.d &= ~(1 << k);
if (nibblearray != null) {
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java
-index 39ef95cbbb1d1d049354ae1e8991309e918d0462..ec3f560556c3056bdfc11cc6a7eb76420f13abad 100644
+index 01bf7320b5cbc38e278ca907aa324ee3e945805e..06e42b7db5385f9a357183552259e7b4491d9fd0 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java
-@@ -271,14 +271,14 @@ public class CraftChunk implements Chunk {
+@@ -273,14 +273,14 @@ public class CraftChunk implements Chunk {
sectionSkyLights[i] = emptyLight;
} else {
sectionSkyLights[i] = new byte[2048];
diff --git a/Spigot-Server-Patches/0521-Reduce-MutableInt-allocations-from-light-engine.patch b/Spigot-Server-Patches/0491-Reduce-MutableInt-allocations-from-light-engine.patch
similarity index 100%
rename from Spigot-Server-Patches/0521-Reduce-MutableInt-allocations-from-light-engine.patch
rename to Spigot-Server-Patches/0491-Reduce-MutableInt-allocations-from-light-engine.patch
diff --git a/Spigot-Server-Patches/0522-Reduce-allocation-of-Vec3D-by-entity-tracker.patch b/Spigot-Server-Patches/0492-Reduce-allocation-of-Vec3D-by-entity-tracker.patch
similarity index 90%
rename from Spigot-Server-Patches/0522-Reduce-allocation-of-Vec3D-by-entity-tracker.patch
rename to Spigot-Server-Patches/0492-Reduce-allocation-of-Vec3D-by-entity-tracker.patch
index 45ed81a06..ff50f48c9 100644
--- a/Spigot-Server-Patches/0522-Reduce-allocation-of-Vec3D-by-entity-tracker.patch
+++ b/Spigot-Server-Patches/0492-Reduce-allocation-of-Vec3D-by-entity-tracker.patch
@@ -5,10 +5,10 @@ Subject: [PATCH] Reduce allocation of Vec3D by entity tracker
diff --git a/src/main/java/net/minecraft/server/EntityTrackerEntry.java b/src/main/java/net/minecraft/server/EntityTrackerEntry.java
-index 6d3b34ead9cc95dcc1152dffa8c6c4a8c7f1d58b..5cc89c0cf9e9e632212a9653391437cbe9b15031 100644
+index 0c46297e6ff229538d77b2f481e4ab13ea14c48e..f75c09d44a19f84588f21a55ea8f0dd8ccb539b9 100644
--- a/src/main/java/net/minecraft/server/EntityTrackerEntry.java
+++ b/src/main/java/net/minecraft/server/EntityTrackerEntry.java
-@@ -125,8 +125,12 @@ public class EntityTrackerEntry {
+@@ -127,8 +127,12 @@ public class EntityTrackerEntry {
++this.o;
i = MathHelper.d(this.tracker.yaw * 256.0F / 360.0F);
j = MathHelper.d(this.tracker.pitch * 256.0F / 360.0F);
@@ -23,7 +23,7 @@ index 6d3b34ead9cc95dcc1152dffa8c6c4a8c7f1d58b..5cc89c0cf9e9e632212a9653391437cb
Packet> packet1 = null;
boolean flag2 = flag1 || this.tickCounter % 60 == 0;
boolean flag3 = Math.abs(i - this.yRot) >= 1 || Math.abs(j - this.xRot) >= 1;
-@@ -143,9 +147,11 @@ public class EntityTrackerEntry {
+@@ -145,9 +149,11 @@ public class EntityTrackerEntry {
// CraftBukkit end
if (this.tickCounter > 0 || this.tracker instanceof EntityArrow) {
@@ -37,12 +37,12 @@ index 6d3b34ead9cc95dcc1152dffa8c6c4a8c7f1d58b..5cc89c0cf9e9e632212a9653391437cb
+ // Paper end - remove allocation of Vec3D here
boolean flag4 = k < -32768L || k > 32767L || l < -32768L || l > 32767L || i1 < -32768L || i1 > 32767L;
- if (!flag4 && this.o <= 400 && !this.q && this.r == this.tracker.onGround) {
+ if (!flag4 && this.o <= 400 && !this.q && this.r == this.tracker.isOnGround()) {
diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java
-index f361939b9ae451bdccf7922e9cca09344c6152b5..68dd9220bb360c75057919fed0598b415b947e4d 100644
+index 31f122aeef8df2eae5e8aab12f0b3316a67daa3b..435fadebe0c7a56a2a338b09238021fa50665285 100644
--- a/src/main/java/net/minecraft/server/PlayerChunkMap.java
+++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java
-@@ -2096,9 +2096,14 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
+@@ -2130,9 +2130,14 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
public void updatePlayer(EntityPlayer entityplayer) {
org.spigotmc.AsyncCatcher.catchOp("player tracker update"); // Spigot
if (entityplayer != this.tracker) {
diff --git a/Spigot-Server-Patches/0523-Ensure-safe-gateway-teleport.patch b/Spigot-Server-Patches/0493-Ensure-safe-gateway-teleport.patch
similarity index 64%
rename from Spigot-Server-Patches/0523-Ensure-safe-gateway-teleport.patch
rename to Spigot-Server-Patches/0493-Ensure-safe-gateway-teleport.patch
index 3e35b9bdc..39235c452 100644
--- a/Spigot-Server-Patches/0523-Ensure-safe-gateway-teleport.patch
+++ b/Spigot-Server-Patches/0493-Ensure-safe-gateway-teleport.patch
@@ -5,7 +5,7 @@ Subject: [PATCH] Ensure safe gateway teleport
diff --git a/src/main/java/net/minecraft/server/TileEntityEndGateway.java b/src/main/java/net/minecraft/server/TileEntityEndGateway.java
-index c71f76004ed934e9e921efc4cb637f2e77af92d2..87aef515c65c8bd815667b1a77f453fee76b192d 100644
+index ea61a473d8e47428ed5cd4541a5855f0e2c50815..aebb6b6b2b869231310567b030fe32f34cc268f5 100644
--- a/src/main/java/net/minecraft/server/TileEntityEndGateway.java
+++ b/src/main/java/net/minecraft/server/TileEntityEndGateway.java
@@ -62,10 +62,14 @@ public class TileEntityEndGateway extends TileEntityEnderPortal implements ITick
@@ -14,16 +14,15 @@ index c71f76004ed934e9e921efc4cb637f2e77af92d2..87aef515c65c8bd815667b1a77f453fe
List list = this.world.a(Entity.class, new AxisAlignedBB(this.getPosition()));
-
- if (!list.isEmpty()) {
-- this.a(((Entity) list.get(0)).getRootVehicle());
-- }
-+ // Paper start
-+ for (Entity entity : list) {
-+ if (!entity.isPassenger() && !entity.isVehicle() && entity.canPortal()) {
-+ this.a(entity);
-+ break;
-+ }
+- this.a((Entity) list.get(this.world.random.nextInt(list.size())));
++ // Paper start
++ for (Entity entity : list) {
++ if (!entity.isPassenger() && !entity.isVehicle() && entity.canPortal()) {
++ this.a(entity);
++ break;
+ }
-+ // Paper end
+ }
++ // Paper end
if (this.age % 2400L == 0L) {
this.h();
diff --git a/Spigot-Server-Patches/0525-Add-option-for-console-having-all-permissions.patch b/Spigot-Server-Patches/0494-Add-option-for-console-having-all-permissions.patch
similarity index 90%
rename from Spigot-Server-Patches/0525-Add-option-for-console-having-all-permissions.patch
rename to Spigot-Server-Patches/0494-Add-option-for-console-having-all-permissions.patch
index f04d491a8..bbfc2ca38 100644
--- a/Spigot-Server-Patches/0525-Add-option-for-console-having-all-permissions.patch
+++ b/Spigot-Server-Patches/0494-Add-option-for-console-having-all-permissions.patch
@@ -5,10 +5,10 @@ Subject: [PATCH] Add option for console having all permissions
diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java
-index cf9b9de8688e3f655631451409096d7ec0471910..f0284e81db3ab7c45018de2b446f2d8296df15c3 100644
+index e1c9e559b25792296b6b8f6dd1070035d10d82f2..08f744ee5e83d317f872f9c48e2037a24327d76f 100644
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
-@@ -437,4 +437,9 @@ public class PaperConfig {
+@@ -416,4 +416,9 @@ public class PaperConfig {
allowBlockPermanentBreakingExploits = getBoolean("allow-perm-block-break-exploits", allowBlockPermanentBreakingExploits);
}
@@ -40,10 +40,10 @@ index bfd21a07280a79d279388c785c78fb8fe731102a..e67da10f9bfbb8125d8fbf34695997ec
+ // Paper end
}
diff --git a/src/main/java/org/bukkit/craftbukkit/command/CraftRemoteConsoleCommandSender.java b/src/main/java/org/bukkit/craftbukkit/command/CraftRemoteConsoleCommandSender.java
-index 228e88a6e2b93ef2c4a5774cc8663b64467fb9eb..4024408815205c12eac9fdb246497ba713295f4b 100644
+index 655bdbc37d0b95622206569229d4f4ea9496c69d..5562a7199f9b73d6af539360d4912d1dbde5d6cf 100644
--- a/src/main/java/org/bukkit/craftbukkit/command/CraftRemoteConsoleCommandSender.java
+++ b/src/main/java/org/bukkit/craftbukkit/command/CraftRemoteConsoleCommandSender.java
-@@ -38,4 +38,16 @@ public class CraftRemoteConsoleCommandSender extends ServerCommandSender impleme
+@@ -39,4 +39,16 @@ public class CraftRemoteConsoleCommandSender extends ServerCommandSender impleme
public void setOp(boolean value) {
throw new UnsupportedOperationException("Cannot change operator status of remote controller.");
}
diff --git a/Spigot-Server-Patches/0526-Workaround-for-Client-Lag-Spikes-MC-162253.patch b/Spigot-Server-Patches/0495-Workaround-for-Client-Lag-Spikes-MC-162253.patch
similarity index 92%
rename from Spigot-Server-Patches/0526-Workaround-for-Client-Lag-Spikes-MC-162253.patch
rename to Spigot-Server-Patches/0495-Workaround-for-Client-Lag-Spikes-MC-162253.patch
index 794ef4675..b433d4d1c 100644
--- a/Spigot-Server-Patches/0526-Workaround-for-Client-Lag-Spikes-MC-162253.patch
+++ b/Spigot-Server-Patches/0495-Workaround-for-Client-Lag-Spikes-MC-162253.patch
@@ -12,10 +12,10 @@ to the client, so that it doesn't attempt to calculate them.
This mitigates the frametime impact to a minimum (but it's still there).
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
-index c80a55ee53eac128c94d74b78c5641854e974750..d7beb47d9e07707e5875c50932dfe4698cb6ad72 100644
+index 7f508b9ef616071b1adeef7c00da7f4565ef4ddd..84dc89d961bde16f96dba5cf7f2ce4b85564215a 100644
--- a/src/main/java/net/minecraft/server/Chunk.java
+++ b/src/main/java/net/minecraft/server/Chunk.java
-@@ -277,7 +277,7 @@ public class Chunk implements IChunkAccess {
+@@ -278,7 +278,7 @@ public class Chunk implements IChunkAccess {
// broadcast
Object[] backingSet = inRange.getBackingSet();
@@ -25,10 +25,10 @@ index c80a55ee53eac128c94d74b78c5641854e974750..d7beb47d9e07707e5875c50932dfe469
Object temp = backingSet[index];
if (!(temp instanceof EntityPlayer)) {
diff --git a/src/main/java/net/minecraft/server/ChunkSection.java b/src/main/java/net/minecraft/server/ChunkSection.java
-index f6df85c6bf27bfa7a16967259a6016c9473201a5..4dcb111c704a495c214827f4ef554fb8e65ca2da 100644
+index 860dc98ab4f84c470b27726314943936d23fcb79..8d45588ecfa33b8c7335df3db58ed6865b8c956c 100644
--- a/src/main/java/net/minecraft/server/ChunkSection.java
+++ b/src/main/java/net/minecraft/server/ChunkSection.java
-@@ -99,6 +99,7 @@ public class ChunkSection {
+@@ -100,6 +100,7 @@ public class ChunkSection {
return this.nonEmptyBlockCount == 0;
}
@@ -37,10 +37,10 @@ index f6df85c6bf27bfa7a16967259a6016c9473201a5..4dcb111c704a495c214827f4ef554fb8
return chunksection == Chunk.a || chunksection.c();
}
diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java
-index 68dd9220bb360c75057919fed0598b415b947e4d..0aa14bfca6e1845eb6e9f5bd4e0e36335fa7f532 100644
+index 435fadebe0c7a56a2a338b09238021fa50665285..45e89468d72adba2cf7c079a12b8f3848f56e807 100644
--- a/src/main/java/net/minecraft/server/PlayerChunkMap.java
+++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java
-@@ -402,7 +402,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
+@@ -408,7 +408,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
player.needsChunkCenterUpdate = false;
player.playerConnection.sendPacket(new PacketPlayOutViewCentre(currPosX, currPosZ));
}
@@ -49,7 +49,7 @@ index 68dd9220bb360c75057919fed0598b415b947e4d..0aa14bfca6e1845eb6e9f5bd4e0e3633
},
(EntityPlayer player, int rangeX, int rangeZ, int currPosX, int currPosZ, int prevPosX, int prevPosZ,
com.destroystokyo.paper.util.misc.PooledLinkedHashSets.PooledObjectLinkedOpenHashSet newState) -> {
-@@ -1921,12 +1921,112 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
+@@ -1955,12 +1955,112 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
}
@@ -102,8 +102,8 @@ index 68dd9220bb360c75057919fed0598b415b947e4d..0aa14bfca6e1845eb6e9f5bd4e0e3633
+ apacket = new Packet[10];
+ }
+ // Paper end
- apacket[0] = new PacketPlayOutMapChunk(chunk, 65535);
- apacket[1] = new PacketPlayOutLightUpdate(chunk.getPos(), this.lightEngine);
+ apacket[0] = new PacketPlayOutMapChunk(chunk, 65535, true);
+ apacket[1] = new PacketPlayOutLightUpdate(chunk.getPos(), this.lightEngine, true);
+
+ // Paper start - Fix MC-162253
+ final int lightMask = getLightMask(chunk);
@@ -127,7 +127,7 @@ index 68dd9220bb360c75057919fed0598b415b947e4d..0aa14bfca6e1845eb6e9f5bd4e0e3633
+ continue;
+ }
+
-+ apacket[i] = new PacketPlayOutLightUpdate(new ChunkCoordIntPair(chunk.getPos().x + x, chunk.getPos().z + z), lightEngine, updateLightMask, 0);
++ apacket[i] = new PacketPlayOutLightUpdate(new ChunkCoordIntPair(chunk.getPos().x + x, chunk.getPos().z + z), lightEngine, updateLightMask, 0, true);
+ }
+ }
+ }
diff --git a/Spigot-Server-Patches/0527-Implement-Chunk-Priority-Urgency-System-for-Chunks.patch b/Spigot-Server-Patches/0496-Implement-Chunk-Priority-Urgency-System-for-Chunks.patch
similarity index 89%
rename from Spigot-Server-Patches/0527-Implement-Chunk-Priority-Urgency-System-for-Chunks.patch
rename to Spigot-Server-Patches/0496-Implement-Chunk-Priority-Urgency-System-for-Chunks.patch
index 519dc60fe..32810a519 100644
--- a/Spigot-Server-Patches/0527-Implement-Chunk-Priority-Urgency-System-for-Chunks.patch
+++ b/Spigot-Server-Patches/0496-Implement-Chunk-Priority-Urgency-System-for-Chunks.patch
@@ -78,19 +78,19 @@ index b5c2e1f4a2b5fdcaa6bb01f4b3b6847cd5b73ae8..6209b33d8497ec56bbde507e523db064
}
diff --git a/src/main/java/net/minecraft/server/ChunkCoordIntPair.java b/src/main/java/net/minecraft/server/ChunkCoordIntPair.java
-index f617636a22167b06ac8073aa25efd8c7099155f0..0f40793f004639822b9d40521cd21ec50391ba3b 100644
+index 35b8a85d1280ba3be757b14b14388954ac1617d4..f47a6e0027de6886991aad5bcb98a04157aeb846 100644
--- a/src/main/java/net/minecraft/server/ChunkCoordIntPair.java
+++ b/src/main/java/net/minecraft/server/ChunkCoordIntPair.java
-@@ -110,6 +110,7 @@ public class ChunkCoordIntPair {
+@@ -108,6 +108,7 @@ public class ChunkCoordIntPair {
return "[" + this.x + ", " + this.z + "]";
}
+ public final BlockPosition asPosition() { return l(); } // Paper - OBFHELPER
public BlockPosition l() {
- return new BlockPosition(this.x << 4, 0, this.z << 4);
+ return new BlockPosition(this.d(), 0, this.e());
}
diff --git a/src/main/java/net/minecraft/server/ChunkMapDistance.java b/src/main/java/net/minecraft/server/ChunkMapDistance.java
-index 7702fbefa598bce7e6a2d287f7ec36b78a62bff8..35a4999b2c34ae62cba042885db25dd1837cb127 100644
+index c072f61e8c88eac8335acd660d8ff0e2f9db819e..4c4108705e9d25912e57a7b3c28b4f1abad58377 100644
--- a/src/main/java/net/minecraft/server/ChunkMapDistance.java
+++ b/src/main/java/net/minecraft/server/ChunkMapDistance.java
@@ -23,6 +23,7 @@ import java.util.concurrent.Executor;
@@ -113,8 +113,8 @@ index 7702fbefa598bce7e6a2d287f7ec36b78a62bff8..35a4999b2c34ae62cba042885db25dd1
@@ -84,6 +85,7 @@ public abstract class ChunkMapDistance {
}
- private static int a(ArraySetSorted> arraysetsorted) {
-+ AsyncCatcher.catchOp("ChunkMapDistance::getHighestTicketLevel"); // Paper
+ private static int getLowestTicketLevel(ArraySetSorted> arraysetsorted) {
++ AsyncCatcher.catchOp("ChunkMapDistance::getLowestTicketLevel"); // Paper
return !arraysetsorted.isEmpty() ? ((Ticket) arraysetsorted.b()).b() : PlayerChunkMap.GOLDEN_TICKET + 1;
}
@@ -122,9 +122,9 @@ index 7702fbefa598bce7e6a2d287f7ec36b78a62bff8..35a4999b2c34ae62cba042885db25dd1
public boolean a(PlayerChunkMap playerchunkmap) {
//this.f.a(); // Paper - no longer used
-+ AsyncCatcher.catchOp("DistanceManagerTick");
++ AsyncCatcher.catchOp("DistanceManagerTick"); // Paper
this.g.a();
- int i = Integer.MAX_VALUE - this.e.a(Integer.MAX_VALUE);
+ int i = Integer.MAX_VALUE - this.ticketLevelTracker.a(Integer.MAX_VALUE);
boolean flag = i != 0;
@@ -107,11 +110,13 @@ public abstract class ChunkMapDistance {
@@ -149,7 +149,7 @@ index 7702fbefa598bce7e6a2d287f7ec36b78a62bff8..35a4999b2c34ae62cba042885db25dd1
private boolean addTicket(long i, Ticket> ticket) { // CraftBukkit - void -> boolean
+ AsyncCatcher.catchOp("ChunkMapDistance::addTicket"); // Paper
ArraySetSorted> arraysetsorted = this.e(i);
- int j = a(arraysetsorted);
+ int j = getLowestTicketLevel(arraysetsorted);
Ticket> ticket1 = (Ticket) arraysetsorted.a(ticket); // CraftBukkit - decompile error
@@ -162,7 +169,9 @@ public abstract class ChunkMapDistance {
}
@@ -157,22 +157,21 @@ index 7702fbefa598bce7e6a2d287f7ec36b78a62bff8..35a4999b2c34ae62cba042885db25dd1
private boolean removeTicket(long i, Ticket> ticket) { // CraftBukkit - void -> boolean
+ AsyncCatcher.catchOp("ChunkMapDistance::removeTicket"); // Paper
ArraySetSorted> arraysetsorted = this.e(i);
-+ int oldLevel = a(arraysetsorted); // Paper
++ int oldLevel = getLowestTicketLevel(arraysetsorted); // Paper
boolean removed = false; // CraftBukkit
if (arraysetsorted.remove(ticket)) {
-@@ -172,8 +181,8 @@ public abstract class ChunkMapDistance {
- if (arraysetsorted.isEmpty()) {
+@@ -173,7 +182,8 @@ public abstract class ChunkMapDistance {
this.tickets.remove(i);
}
--
-- this.e.b(i, a(arraysetsorted), false);
-+ int newLevel = a(arraysetsorted); // Paper
-+ if (newLevel > oldLevel) this.e.b(i, newLevel, false); // Paper
+
+- this.ticketLevelTracker.update(i, getLowestTicketLevel(arraysetsorted), false);
++ int newLevel = getLowestTicketLevel(arraysetsorted); // Paper
++ if (newLevel > oldLevel) this.ticketLevelTracker.update(i, newLevel, false); // Paper
return removed; // CraftBukkit
}
-@@ -182,6 +191,135 @@ public abstract class ChunkMapDistance {
+@@ -182,6 +192,135 @@ public abstract class ChunkMapDistance {
this.addTicketAtLevel(tickettype, chunkcoordintpair, i, t0);
}
@@ -308,7 +307,7 @@ index 7702fbefa598bce7e6a2d287f7ec36b78a62bff8..35a4999b2c34ae62cba042885db25dd1
public boolean addTicketAtLevel(TicketType ticketType, ChunkCoordIntPair chunkcoordintpair, int level, T identifier) {
return this.addTicket(chunkcoordintpair.pair(), new Ticket<>(ticketType, level, identifier));
// CraftBukkit end
-@@ -381,27 +519,51 @@ public abstract class ChunkMapDistance {
+@@ -381,27 +520,50 @@ public abstract class ChunkMapDistance {
private void a(long i, int j, boolean flag, boolean flag1) {
if (flag != flag1) {
@@ -317,6 +316,7 @@ index 7702fbefa598bce7e6a2d287f7ec36b78a62bff8..35a4999b2c34ae62cba042885db25dd1
+ Ticket> ticket = new Ticket<>(TicketType.PLAYER, 33, coords); // Paper - no-tick view distance
if (flag1) {
+- ChunkMapDistance.this.j.a(ChunkTaskQueueSorter.a(() -> {
+ scheduleChunkLoad(i, MinecraftServer.currentTick, j, (priority) -> { // Paper - smarter ticket delay based on frustum and distance
+ // Paper start - recheck its still valid if not cancel
+ if (!isChunkInRange(i)) {
@@ -337,16 +337,16 @@ index 7702fbefa598bce7e6a2d287f7ec36b78a62bff8..35a4999b2c34ae62cba042885db25dd1
+ return;
+ }
+ // Paper end
- ChunkMapDistance.this.j.a(ChunkTaskQueueSorter.a(() -> { // CraftBukkit - decompile error
++ ChunkMapDistance.this.j.a(ChunkTaskQueueSorter.a(() -> { // CraftBukkit - decompile error
ChunkMapDistance.this.m.execute(() -> {
- if (this.c(this.c(i))) {
+ if (isChunkInRange(i)) { if (!hasPlayerTicket(coords, 33)) { // Paper - high priority might of already added it
ChunkMapDistance.this.addTicket(i, ticket);
ChunkMapDistance.this.l.add(i);
- } else {
-+ }
-+ } else { // Paper
- ChunkMapDistance.this.k.a(ChunkTaskQueueSorter.a(() -> { // CraftBukkit - decompile error
+- ChunkMapDistance.this.k.a(ChunkTaskQueueSorter.a(() -> {
++ }} else { // Paper
++ ChunkMapDistance.this.k.a(ChunkTaskQueueSorter.a(() -> { // CraftBukkit - decompile error
}, i, false));
}
@@ -357,7 +357,7 @@ index 7702fbefa598bce7e6a2d287f7ec36b78a62bff8..35a4999b2c34ae62cba042885db25dd1
}));
+ }); // Paper
} else {
- ChunkMapDistance.this.k.a(ChunkTaskQueueSorter.a(() -> { // CraftBukkit - decompile error
+ ChunkMapDistance.this.k.a(ChunkTaskQueueSorter.a(() -> {
ChunkMapDistance.this.m.execute(() -> {
ChunkMapDistance.this.removeTicket(i, ticket);
+ ChunkMapDistance.this.clearPriorityTickets(coords); // Paper
@@ -484,10 +484,10 @@ index 7702fbefa598bce7e6a2d287f7ec36b78a62bff8..35a4999b2c34ae62cba042885db25dd1
protected int c(long i) {
return this.a.get(i);
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
-index 3089d673a029c493cac756124eb0baa21a8bab7f..8efe036be0c74a5ceb6a18e019c4a08a49a28693 100644
+index a6363b73522f9d27534b6e80f4b3789e84316c49..604e7004b659daed2844ba1a76bf09288ec549e5 100644
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
-@@ -442,6 +442,26 @@ public class ChunkProviderServer extends IChunkProvider {
+@@ -443,6 +443,26 @@ public class ChunkProviderServer extends IChunkProvider {
public void removeTicketAtLevel(TicketType ticketType, ChunkCoordIntPair chunkPos, int ticketLevel, T identifier) {
this.chunkMapDistance.removeTicketAtLevel(ticketType, chunkPos, ticketLevel, identifier);
}
@@ -514,7 +514,7 @@ index 3089d673a029c493cac756124eb0baa21a8bab7f..8efe036be0c74a5ceb6a18e019c4a08a
// Paper end
@Nullable
-@@ -480,6 +500,8 @@ public class ChunkProviderServer extends IChunkProvider {
+@@ -481,6 +501,8 @@ public class ChunkProviderServer extends IChunkProvider {
if (!completablefuture.isDone()) { // Paper
// Paper start - async chunk io/loading
@@ -523,7 +523,7 @@ index 3089d673a029c493cac756124eb0baa21a8bab7f..8efe036be0c74a5ceb6a18e019c4a08a
this.world.asyncChunkTaskManager.raisePriority(x, z, com.destroystokyo.paper.io.PrioritizedTaskQueue.HIGHEST_PRIORITY);
com.destroystokyo.paper.io.chunk.ChunkTaskManager.pushChunkWait(this.world, x, z);
// Paper end
-@@ -488,6 +510,8 @@ public class ChunkProviderServer extends IChunkProvider {
+@@ -489,6 +511,8 @@ public class ChunkProviderServer extends IChunkProvider {
this.serverThreadQueue.awaitTasks(completablefuture::isDone);
com.destroystokyo.paper.io.chunk.ChunkTaskManager.popChunkWait(); // Paper - async chunk debug
this.world.timings.syncChunkLoad.stopTiming(); // Paper
@@ -532,7 +532,7 @@ index 3089d673a029c493cac756124eb0baa21a8bab7f..8efe036be0c74a5ceb6a18e019c4a08a
} // Paper
ichunkaccess = (IChunkAccess) ((Either) completablefuture.join()).map((ichunkaccess1) -> {
return ichunkaccess1;
-@@ -540,10 +564,12 @@ public class ChunkProviderServer extends IChunkProvider {
+@@ -541,10 +565,12 @@ public class ChunkProviderServer extends IChunkProvider {
if (flag && !currentlyUnloading) {
// CraftBukkit end
this.chunkMapDistance.a(TicketType.UNKNOWN, chunkcoordintpair, l, chunkcoordintpair);
@@ -545,7 +545,7 @@ index 3089d673a029c493cac756124eb0baa21a8bab7f..8efe036be0c74a5ceb6a18e019c4a08a
this.tickDistanceManager();
playerchunk = this.getChunk(k);
gameprofilerfiller.exit();
-@@ -552,8 +578,13 @@ public class ChunkProviderServer extends IChunkProvider {
+@@ -553,8 +579,13 @@ public class ChunkProviderServer extends IChunkProvider {
}
}
}
@@ -561,18 +561,16 @@ index 3089d673a029c493cac756124eb0baa21a8bab7f..8efe036be0c74a5ceb6a18e019c4a08a
}
private boolean a(@Nullable PlayerChunk playerchunk, int i) {
-@@ -603,7 +634,8 @@ public class ChunkProviderServer extends IChunkProvider {
- return this.serverThreadQueue.executeNext();
+@@ -605,6 +636,7 @@ public class ChunkProviderServer extends IChunkProvider {
}
-- private boolean tickDistanceManager() {
-+ public boolean tickDistanceManager() { // Paper - public
+ public boolean tickDistanceManager() { // Paper - private -> public
+ if (chunkMapDistance.delayDistanceManagerTick) return false; // Paper
boolean flag = this.chunkMapDistance.a(this.playerChunkMap);
boolean flag1 = this.playerChunkMap.b();
diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
-index 07a6fc3d88e7d44bfab7f3d6a0eef7dc132ab422..39072ebdc9e4be2bb762d81a8bd542dbdb8f6371 100644
+index 0e3ceb60e503c74fc65b1d08371645ffbb26ef5c..d5740a25bb487fc186333e908968c6a23a9b5005 100644
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
@@ -55,6 +55,12 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
@@ -588,7 +586,7 @@ index 07a6fc3d88e7d44bfab7f3d6a0eef7dc132ab422..39072ebdc9e4be2bb762d81a8bd542db
private float lastHealthSent = -1.0E8F;
private int lastFoodSent = -99999999;
private boolean lastSentSaturationZero = true;
-@@ -132,6 +138,21 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
+@@ -136,6 +142,21 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
this.maxHealthCache = this.getMaxHealth();
this.cachedSingleMobDistanceMap = new com.destroystokyo.paper.util.PooledHashSets.PooledObjectLinkedOpenHashSet<>(this); // Paper
}
@@ -610,8 +608,8 @@ index 07a6fc3d88e7d44bfab7f3d6a0eef7dc132ab422..39072ebdc9e4be2bb762d81a8bd542db
// Yes, this doesn't match Vanilla, but it's the best we can do for now.
// If this is an issue, PRs are welcome
-@@ -441,6 +462,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
- if (valid && (!this.isSpectator() || this.world.isLoaded(new BlockPosition(this)))) { // Paper - don't tick dead players that are not in the world currently (pending respawn)
+@@ -484,6 +505,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
+ if (valid && !this.isSpectator() || this.world.isLoaded(this.getChunkCoordinates())) { // Paper - don't tick dead players that are not in the world currently (pending respawn)
super.tick();
}
+ if (valid && isAlive() && playerConnection != null) ((WorldServer)world).getChunkProvider().playerChunkMap.checkHighPriorityChunks(this); // Paper
@@ -619,10 +617,10 @@ index 07a6fc3d88e7d44bfab7f3d6a0eef7dc132ab422..39072ebdc9e4be2bb762d81a8bd542db
for (int i = 0; i < this.inventory.getSize(); ++i) {
ItemStack itemstack = this.inventory.getItem(i);
diff --git a/src/main/java/net/minecraft/server/MCUtil.java b/src/main/java/net/minecraft/server/MCUtil.java
-index ce0bf608b71cf492fc31e89a360ecd83fa5c23a6..87d58002116f361d8255d79fc0dbd1200f442168 100644
+index 2f9c014454cf5fe771c6da84ad4af7e7790fdc7d..2e58e58548f0fc7af98b0c6294bf855f54705f9b 100644
--- a/src/main/java/net/minecraft/server/MCUtil.java
+++ b/src/main/java/net/minecraft/server/MCUtil.java
-@@ -666,6 +666,7 @@ public final class MCUtil {
+@@ -654,6 +654,7 @@ public final class MCUtil {
chunkData.addProperty("x", playerChunk.location.x);
chunkData.addProperty("z", playerChunk.location.z);
chunkData.addProperty("ticket-level", playerChunk.getTicketLevel());
@@ -631,7 +629,7 @@ index ce0bf608b71cf492fc31e89a360ecd83fa5c23a6..87d58002116f361d8255d79fc0dbd120
chunkData.addProperty("queued-for-unload", chunkMap.unloadQueue.contains(playerChunk.location.pair()));
chunkData.addProperty("status", status == null ? "unloaded" : status.toString());
diff --git a/src/main/java/net/minecraft/server/PlayerChunk.java b/src/main/java/net/minecraft/server/PlayerChunk.java
-index aeca6b2b9d5d73aeb6dc639b5cad2f2533a2de44..52da9c78c0cc2b21533a1477a25a3dda492700e4 100644
+index e5751adde516544722b95016f64b2a46c16e77ce..04dea2c9fd9337631a6289c7242338e166d6bc1e 100644
--- a/src/main/java/net/minecraft/server/PlayerChunk.java
+++ b/src/main/java/net/minecraft/server/PlayerChunk.java
@@ -26,8 +26,8 @@ public class PlayerChunk {
@@ -645,7 +643,7 @@ index aeca6b2b9d5d73aeb6dc639b5cad2f2533a2de44..52da9c78c0cc2b21533a1477a25a3dda
private final short[] dirtyBlocks;
private int dirtyCount;
private int r;
-@@ -40,6 +40,7 @@ public class PlayerChunk {
+@@ -39,6 +39,7 @@ public class PlayerChunk {
private boolean hasBeenLoaded;
private final PlayerChunkMap chunkMap; // Paper
@@ -653,7 +651,7 @@ index aeca6b2b9d5d73aeb6dc639b5cad2f2533a2de44..52da9c78c0cc2b21533a1477a25a3dda
long lastAutoSaveTime; // Paper - incremental autosave
long inactiveTimeStart; // Paper - incremental autosave
-@@ -67,6 +68,120 @@ public class PlayerChunk {
+@@ -66,6 +67,120 @@ public class PlayerChunk {
return null;
}
// Paper end - no-tick view distance
@@ -774,7 +772,7 @@ index aeca6b2b9d5d73aeb6dc639b5cad2f2533a2de44..52da9c78c0cc2b21533a1477a25a3dda
public PlayerChunk(ChunkCoordIntPair chunkcoordintpair, int i, LightEngine lightengine, PlayerChunk.c playerchunk_c, PlayerChunk.d playerchunk_d) {
this.statusFutures = new AtomicReferenceArray(PlayerChunk.CHUNK_STATUSES.size());
-@@ -165,6 +280,18 @@ public class PlayerChunk {
+@@ -164,6 +279,18 @@ public class PlayerChunk {
}
return null;
}
@@ -793,7 +791,7 @@ index aeca6b2b9d5d73aeb6dc639b5cad2f2533a2de44..52da9c78c0cc2b21533a1477a25a3dda
// Paper end
public CompletableFuture> getStatusFutureUnchecked(ChunkStatus chunkstatus) {
-@@ -418,6 +545,7 @@ public class PlayerChunk {
+@@ -405,6 +532,7 @@ public class PlayerChunk {
return this.n;
}
@@ -801,7 +799,7 @@ index aeca6b2b9d5d73aeb6dc639b5cad2f2533a2de44..52da9c78c0cc2b21533a1477a25a3dda
private void d(int i) {
this.n = i;
}
-@@ -436,7 +564,7 @@ public class PlayerChunk {
+@@ -423,7 +551,7 @@ public class PlayerChunk {
// CraftBukkit start
// ChunkUnloadEvent: Called before the chunk is unloaded: isChunkLoaded is still true and chunk can still be modified by plugins.
if (playerchunk_state.isAtLeast(PlayerChunk.State.BORDER) && !playerchunk_state1.isAtLeast(PlayerChunk.State.BORDER)) {
@@ -810,7 +808,7 @@ index aeca6b2b9d5d73aeb6dc639b5cad2f2533a2de44..52da9c78c0cc2b21533a1477a25a3dda
Chunk chunk = (Chunk)either.left().orElse(null);
if (chunk != null) {
playerchunkmap.callbackExecutor.execute(() -> {
-@@ -501,12 +629,13 @@ public class PlayerChunk {
+@@ -488,12 +616,13 @@ public class PlayerChunk {
if (!flag2 && flag3) {
// Paper start - cache ticking ready status
int expectCreateCount = ++this.fullChunkCreateCount;
@@ -825,7 +823,7 @@ index aeca6b2b9d5d73aeb6dc639b5cad2f2533a2de44..52da9c78c0cc2b21533a1477a25a3dda
}
-@@ -531,7 +660,7 @@ public class PlayerChunk {
+@@ -518,7 +647,7 @@ public class PlayerChunk {
if (!flag4 && flag5) {
// Paper start - cache ticking ready status
@@ -834,7 +832,7 @@ index aeca6b2b9d5d73aeb6dc639b5cad2f2533a2de44..52da9c78c0cc2b21533a1477a25a3dda
if (either.left().isPresent()) {
// note: Here is a very good place to add callbacks to logic waiting on this.
Chunk tickingChunk = either.left().get();
-@@ -562,7 +691,7 @@ public class PlayerChunk {
+@@ -549,7 +678,7 @@ public class PlayerChunk {
}
// Paper start - cache ticking ready status
@@ -843,12 +841,11 @@ index aeca6b2b9d5d73aeb6dc639b5cad2f2533a2de44..52da9c78c0cc2b21533a1477a25a3dda
if (either.left().isPresent()) {
// note: Here is a very good place to add callbacks to logic waiting on this.
Chunk entityTickingChunk = either.left().get();
-@@ -581,13 +710,29 @@ public class PlayerChunk {
- this.entityTickingFuture.complete(PlayerChunk.UNLOADED_CHUNK); this.isEntityTickingReady = false; // Paper - cache chunk ticking stage
+@@ -569,12 +698,29 @@ public class PlayerChunk {
this.entityTickingFuture = PlayerChunk.UNLOADED_CHUNK_FUTURE;
}
--
-- this.w.a(this.location, this::k, this.ticketLevel, this::d);
+
+- this.v.a(this.location, this::k, this.ticketLevel, this::d);
+ // Paper start - raise IO/load priority if priority changes, use our preferred priority
+ priorityBoost = chunkMap.chunkDistanceManager.getChunkPriority(location);
+ int priority = getDemandedPriority();
@@ -862,7 +859,7 @@ index aeca6b2b9d5d73aeb6dc639b5cad2f2533a2de44..52da9c78c0cc2b21533a1477a25a3dda
+ chunkMap.world.asyncChunkTaskManager.raisePriority(location.x, location.z, ioPriority);
+ }
+ if (getCurrentPriority() != priority) {
-+ this.w.a(this.location, this::getCurrentPriority, priority, this::setPriority); // use preferred priority
++ this.v.a(this.location, this::getCurrentPriority, priority, this::setPriority); // use preferred priority
+ int neighborsPriority = getNeighborsPriority();
+ this.neighbors.forEach((neighbor, neighborDesired) -> neighbor.setNeighborPriority(this, neighborsPriority));
+ }
@@ -876,7 +873,7 @@ index aeca6b2b9d5d73aeb6dc639b5cad2f2533a2de44..52da9c78c0cc2b21533a1477a25a3dda
Chunk chunk = (Chunk)either.left().orElse(null);
if (chunk != null) {
playerchunkmap.callbackExecutor.execute(() -> {
-@@ -669,6 +814,7 @@ public class PlayerChunk {
+@@ -656,6 +802,7 @@ public class PlayerChunk {
public interface c {
@@ -885,10 +882,10 @@ index aeca6b2b9d5d73aeb6dc639b5cad2f2533a2de44..52da9c78c0cc2b21533a1477a25a3dda
}
diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java
-index 0aa14bfca6e1845eb6e9f5bd4e0e36335fa7f532..3139d55bb801b6c433de7274be4a1d0c0fd1eef7 100644
+index 45e89468d72adba2cf7c079a12b8f3848f56e807..1eb138f003730f9d1048683beb60426067b2ba89 100644
--- a/src/main/java/net/minecraft/server/PlayerChunkMap.java
+++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java
-@@ -50,6 +50,7 @@ import org.apache.commons.lang3.mutable.MutableBoolean;
+@@ -51,6 +51,7 @@ import org.apache.commons.lang3.mutable.MutableBoolean;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.bukkit.entity.Player; // CraftBukkit
@@ -896,7 +893,15 @@ index 0aa14bfca6e1845eb6e9f5bd4e0e36335fa7f532..3139d55bb801b6c433de7274be4a1d0c
public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
-@@ -123,6 +124,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
+@@ -88,6 +89,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
+ public final WorldServer world;
+ private final LightEngineThreaded lightEngine;
+ private final IAsyncTaskHandler executor;
++ final java.util.concurrent.Executor mainInvokingExecutor; // Paper
+ public final ChunkGenerator chunkGenerator;
+ private final Supplier l; public final Supplier getWorldPersistentDataSupplier() { return this.l; } // Paper - OBFHELPER
+ private final VillagePlace m;
+@@ -125,6 +127,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@Override
public void execute(Runnable runnable) {
@@ -904,7 +909,7 @@ index 0aa14bfca6e1845eb6e9f5bd4e0e36335fa7f532..3139d55bb801b6c433de7274be4a1d0c
if (queued == null) {
queued = new java.util.ArrayDeque<>();
}
-@@ -131,6 +133,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
+@@ -133,6 +136,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@Override
public void run() {
@@ -912,7 +917,23 @@ index 0aa14bfca6e1845eb6e9f5bd4e0e36335fa7f532..3139d55bb801b6c433de7274be4a1d0c
if (queued == null) {
return;
}
-@@ -375,6 +378,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
+@@ -287,6 +291,15 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
+ this.world = worldserver;
+ this.chunkGenerator = chunkgenerator;
+ this.executor = iasynctaskhandler;
++ // Paper start
++ this.mainInvokingExecutor = (run) -> {
++ if (MCUtil.isMainThread()) {
++ run.run();
++ } else {
++ iasynctaskhandler.execute(run);
++ }
++ };
++ // Paper end
+ ThreadedMailbox threadedmailbox = ThreadedMailbox.a(executor, "worldgen");
+
+ iasynctaskhandler.getClass();
+@@ -381,6 +394,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
this.playerViewDistanceTickMap = new com.destroystokyo.paper.util.misc.PlayerAreaMap(this.pooledLinkedPlayerHashSets,
(EntityPlayer player, int rangeX, int rangeZ, int currPosX, int currPosZ, int prevPosX, int prevPosZ,
com.destroystokyo.paper.util.misc.PooledLinkedHashSets.PooledObjectLinkedOpenHashSet newState) -> {
@@ -920,7 +941,7 @@ index 0aa14bfca6e1845eb6e9f5bd4e0e36335fa7f532..3139d55bb801b6c433de7274be4a1d0c
if (newState.size() != 1) {
return;
}
-@@ -393,7 +397,11 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
+@@ -399,7 +413,11 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
}
ChunkCoordIntPair chunkPos = new ChunkCoordIntPair(rangeX, rangeZ);
PlayerChunkMap.this.world.getChunkProvider().removeTicketAtLevel(TicketType.PLAYER, chunkPos, 31, chunkPos); // entity ticking level, TODO check on update
@@ -933,7 +954,7 @@ index 0aa14bfca6e1845eb6e9f5bd4e0e36335fa7f532..3139d55bb801b6c433de7274be4a1d0c
this.playerViewDistanceNoTickMap = new com.destroystokyo.paper.util.misc.PlayerAreaMap(this.pooledLinkedPlayerHashSets);
this.playerViewDistanceBroadcastMap = new com.destroystokyo.paper.util.misc.PlayerAreaMap(this.pooledLinkedPlayerHashSets,
(EntityPlayer player, int rangeX, int rangeZ, int currPosX, int currPosZ, int prevPosX, int prevPosZ,
-@@ -410,6 +418,116 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
+@@ -416,6 +434,116 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
});
// Paper end - no-tick view distance
}
@@ -1050,7 +1071,7 @@ index 0aa14bfca6e1845eb6e9f5bd4e0e36335fa7f532..3139d55bb801b6c433de7274be4a1d0c
public void updatePlayerMobTypeMap(Entity entity) {
if (!this.world.paperConfig.perPlayerMobSpawns) {
-@@ -539,6 +657,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
+@@ -545,6 +673,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
List>> list = Lists.newArrayList();
int j = chunkcoordintpair.x;
int k = chunkcoordintpair.z;
@@ -1058,7 +1079,7 @@ index 0aa14bfca6e1845eb6e9f5bd4e0e36335fa7f532..3139d55bb801b6c433de7274be4a1d0c
for (int l = -i; l <= i; ++l) {
for (int i1 = -i; i1 <= i; ++i1) {
-@@ -557,6 +676,14 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
+@@ -563,6 +692,14 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
ChunkStatus chunkstatus = (ChunkStatus) intfunction.apply(j1);
CompletableFuture> completablefuture = playerchunk.a(chunkstatus, this);
@@ -1073,7 +1094,7 @@ index 0aa14bfca6e1845eb6e9f5bd4e0e36335fa7f532..3139d55bb801b6c433de7274be4a1d0c
list.add(completablefuture);
}
-@@ -1022,14 +1149,22 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
+@@ -1027,14 +1164,22 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
};
CompletableFuture chunkSaveFuture = this.world.asyncChunkTaskManager.getChunkSaveFuture(chunkcoordintpair.x, chunkcoordintpair.z);
@@ -1101,20 +1122,20 @@ index 0aa14bfca6e1845eb6e9f5bd4e0e36335fa7f532..3139d55bb801b6c433de7274be4a1d0c
return ret;
// Paper end
}
-@@ -1158,7 +1293,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
+@@ -1171,7 +1316,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
long i = playerchunk.i().pair();
playerchunk.getClass();
-- mailbox.a(ChunkTaskQueueSorter.a(runnable, i, playerchunk::getTicketLevel)); // CraftBukkit - decompile error
-+ mailbox.a(ChunkTaskQueueSorter.a(runnable, i, () -> 1)); // CraftBukkit - decompile error // Paper - final loads are always urgent!
+- mailbox.a(ChunkTaskQueueSorter.a(runnable, i, playerchunk::getTicketLevel));
++ mailbox.a(ChunkTaskQueueSorter.a(runnable, i, () -> 1)); // Paper - final loads are always urgent!
});
}
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
-index d52fbda79fe1c52d3ddb53c0f1c1f521d7620702..f9cb87a3be35575ecf3362b10dc7fe5ebadb56ec 100644
+index 383a9bdec4d476bbde5a7c63a9915d2ed4c136a4..e34290011bb5d7bcfb677b70fdec1a525a082e0e 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
-@@ -1279,6 +1279,7 @@ public class PlayerConnection implements PacketListenerPlayIn {
+@@ -1301,6 +1301,7 @@ public class PlayerConnection implements PacketListenerPlayIn {
this.A = this.e;
this.player.setLocation(d0, d1, d2, f, f1);
this.syncPosition(); // Paper
@@ -1123,10 +1144,10 @@ index d52fbda79fe1c52d3ddb53c0f1c1f521d7620702..f9cb87a3be35575ecf3362b10dc7fe5e
}
diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java
-index 74571c1befa60e71e93de8052740a56f7b80e920..f0fe864026dc10cd809f06dc9d4e823c21494a8d 100644
+index bdee3540b675f8036c5c6a59d6f53057bbdd6a85..34e218f054eee7d3e2ea064e0758d93f140f270b 100644
--- a/src/main/java/net/minecraft/server/PlayerList.java
+++ b/src/main/java/net/minecraft/server/PlayerList.java
-@@ -174,8 +174,8 @@ public abstract class PlayerList {
+@@ -199,8 +199,8 @@ public abstract class PlayerList {
final ChunkCoordIntPair pos = new ChunkCoordIntPair(chunkX, chunkZ);
PlayerChunkMap playerChunkMap = finalWorldserver.getChunkProvider().playerChunkMap;
playerChunkMap.chunkDistanceManager.addTicketAtLevel(TicketType.LOGIN, pos, 31, pos.pair());
@@ -1137,32 +1158,32 @@ index 74571c1befa60e71e93de8052740a56f7b80e920..f0fe864026dc10cd809f06dc9d4e823c
PlayerChunk updatingChunk = playerChunkMap.getUpdatingChunk(pos.pair());
if (updatingChunk != null) {
return updatingChunk.getEntityTickingFuture();
-@@ -188,7 +188,6 @@ public abstract class PlayerList {
- entityplayer, finalWorldserver, networkmanager, playerconnection,
+@@ -213,7 +213,6 @@ public abstract class PlayerList {
+ entityplayer, finalWorldserver, finalWorldserver1, networkmanager, playerconnection,
nbttagcompound, networkmanager.getSocketAddress().toString(), lastKnownName
);
- //playerChunkMap.chunkDistanceManager.removeTicketAtLevel(TicketType.LOGIN, pos, 31, pos.pair());
};
});
}
-@@ -585,6 +584,7 @@ public abstract class PlayerList {
+@@ -617,6 +616,7 @@ public abstract class PlayerList {
SocketAddress socketaddress = loginlistener.networkManager.getSocketAddress();
- EntityPlayer entity = new EntityPlayer(this.server, this.server.getWorldServer(DimensionManager.OVERWORLD), gameprofile, new PlayerInteractManager(this.server.getWorldServer(DimensionManager.OVERWORLD)));
+ EntityPlayer entity = new EntityPlayer(this.server, this.server.getWorldServer(World.OVERWORLD), gameprofile, new PlayerInteractManager(this.server.getWorldServer(World.OVERWORLD)));
+ entity.isRealPlayer = true; // Paper
Player player = entity.getBukkitEntity();
PlayerLoginEvent event = new PlayerLoginEvent(player, hostname, ((java.net.InetSocketAddress) socketaddress).getAddress(), ((java.net.InetSocketAddress) loginlistener.networkManager.getRawAddress()).getAddress());
-@@ -764,6 +764,7 @@ public abstract class PlayerList {
+@@ -812,6 +812,7 @@ public abstract class PlayerList {
// CraftBukkit end
worldserver.getChunkProvider().addTicket(TicketType.POST_TELEPORT, new ChunkCoordIntPair(location.getBlockX() >> 4, location.getBlockZ() >> 4), 1, entityplayer.getId()); // Paper
+ entityplayer1.forceCheckHighPriority(); // Player
- while (avoidSuffocation && !worldserver.getCubes(entityplayer1) && entityplayer1.locY() < 256.0D) {
+ while (avoidSuffocation && !worldserver1.getCubes(entityplayer1) && entityplayer1.locY() < 256.0D) {
entityplayer1.setPosition(entityplayer1.locX(), entityplayer1.locY() + 1.0D, entityplayer1.locZ());
}
diff --git a/src/main/java/net/minecraft/server/Ticket.java b/src/main/java/net/minecraft/server/Ticket.java
-index 7a8397815a5b7f79f3e3a0348aeedf63fe879f8f..0d6e0f2ddaa85c04e626980591e9a78ac27fb42d 100644
+index 7a8397815a5b7f79f3e3a0348aeedf63fe879f8f..b5030d6f5d917ba33fb3c40903384fa7a56bc5f1 100644
--- a/src/main/java/net/minecraft/server/Ticket.java
+++ b/src/main/java/net/minecraft/server/Ticket.java
@@ -8,6 +8,7 @@ public final class Ticket implements Comparable> {
@@ -1173,6 +1194,14 @@ index 7a8397815a5b7f79f3e3a0348aeedf63fe879f8f..0d6e0f2ddaa85c04e626980591e9a78a
protected Ticket(TicketType tickettype, int i, T t0) {
this.a = tickettype;
+@@ -56,6 +57,7 @@ public final class Ticket implements Comparable> {
+ return this.b;
+ }
+
++ public final void setCurrentTick(long i) { this.a(i); } // Paper - OBFHELPER
+ protected void a(long i) {
+ this.d = i;
+ }
diff --git a/src/main/java/net/minecraft/server/TicketType.java b/src/main/java/net/minecraft/server/TicketType.java
index d7b9d9fd3a3b607278a3d72b0b306b0be2aa30ad..6fd852db6bcfbfbf84ec2acf6d23b08a6051165c 100644
--- a/src/main/java/net/minecraft/server/TicketType.java
@@ -1187,10 +1216,10 @@ index d7b9d9fd3a3b607278a3d72b0b306b0be2aa30ad..6fd852db6bcfbfbf84ec2acf6d23b08a
public static TicketType a(String s, Comparator comparator) {
return new TicketType<>(s, comparator, 0L);
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
-index 36207acffac3620879afd11bb47e06341a3dabb9..5992fdda8a5c66f77dbfca86d6261b98cce2b1e9 100644
+index 745633509d3f948d46529d5439ec14cd01a05563..5ae74d0856f7fb4a7ee35e5d778d78fecaf99730 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
-@@ -2483,6 +2483,10 @@ public class CraftWorld implements World {
+@@ -2486,6 +2486,10 @@ public class CraftWorld implements World {
return future;
}
@@ -1202,10 +1231,10 @@ index 36207acffac3620879afd11bb47e06341a3dabb9..5992fdda8a5c66f77dbfca86d6261b98
net.minecraft.server.Chunk chunk = (net.minecraft.server.Chunk) either.left().orElse(null);
return CompletableFuture.completedFuture(chunk == null ? null : chunk.getBukkitChunk());
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
-index bd4d5184b607db09c8ff2687ceaf47fb94368a28..141003ca718cc6ba113de8e4855b18252b293ef6 100644
+index b28e5abea5d2585d9beff574dd82651e7d20275b..663f9136c4101bb48944ed5ea952f6375e8b2781 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
-@@ -738,6 +738,14 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
+@@ -741,6 +741,14 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
throw new UnsupportedOperationException("Cannot set rotation of players. Consider teleporting instead.");
}
diff --git a/Spigot-Server-Patches/0528-Fix-Non-Full-Status-Chunk-NBT-Memory-Leak.patch b/Spigot-Server-Patches/0497-Fix-Non-Full-Status-Chunk-NBT-Memory-Leak.patch
similarity index 94%
rename from Spigot-Server-Patches/0528-Fix-Non-Full-Status-Chunk-NBT-Memory-Leak.patch
rename to Spigot-Server-Patches/0497-Fix-Non-Full-Status-Chunk-NBT-Memory-Leak.patch
index 29b5e63ec..0888e5d79 100644
--- a/Spigot-Server-Patches/0528-Fix-Non-Full-Status-Chunk-NBT-Memory-Leak.patch
+++ b/Spigot-Server-Patches/0497-Fix-Non-Full-Status-Chunk-NBT-Memory-Leak.patch
@@ -16,10 +16,10 @@ We further improve it by making a copy of the nbt tag with only the memory
it needs, so that we dont have to hold a copy to the entire compound.
diff --git a/src/main/java/net/minecraft/server/ChunkRegionLoader.java b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
-index d752e793f13a9caf5d255293f7ce9d562fd50064..1685237dfd7d6f352c5bab5f65817462de5e6d12 100644
+index 4b7c4643f04448aaccc66f26a9dea2323bea420d..ac58fcb7985ebe0cfdab6e1400deb37c233ff637 100644
--- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java
+++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
-@@ -157,9 +157,9 @@ public class ChunkRegionLoader {
+@@ -156,9 +156,9 @@ public class ChunkRegionLoader {
object2 = protochunkticklist1;
}
@@ -32,7 +32,7 @@ index d752e793f13a9caf5d255293f7ce9d562fd50064..1685237dfd7d6f352c5bab5f65817462
} else {
ProtoChunk protochunk = new ProtoChunk(chunkcoordintpair, chunkconverter, achunksection, protochunkticklist, protochunkticklist1, worldserver); // Paper - Anti-Xray - Add parameter
-@@ -265,6 +265,37 @@ public class ChunkRegionLoader {
+@@ -264,6 +264,37 @@ public class ChunkRegionLoader {
return new InProgressChunkHolder(protochunk1, tasksToExecuteOnMain); // Paper - Async chunk loading
}
}
diff --git a/Spigot-Server-Patches/0498-Optimize-sending-packets-to-nearby-locations-sounds-.patch b/Spigot-Server-Patches/0498-Optimize-sending-packets-to-nearby-locations-sounds-.patch
new file mode 100644
index 000000000..d4b5d55f7
--- /dev/null
+++ b/Spigot-Server-Patches/0498-Optimize-sending-packets-to-nearby-locations-sounds-.patch
@@ -0,0 +1,63 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Aikar
+Date: Sat, 23 May 2020 17:03:41 -0400
+Subject: [PATCH] Optimize sending packets to nearby locations (sounds/effects)
+
+Instead of using the entire world or player list, use the distance
+maps to only iterate players who are even seeing the chunk the packet
+is originating from.
+
+This will drastically cut down on packet sending cost for worlds with
+lots of players in them.
+
+diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java
+index 34e218f054eee7d3e2ea064e0758d93f140f270b..54d5bb4309600ed87a6f7dfc64415fb8854c0f75 100644
+--- a/src/main/java/net/minecraft/server/PlayerList.java
++++ b/src/main/java/net/minecraft/server/PlayerList.java
+@@ -1062,16 +1062,40 @@ public abstract class PlayerList {
+ }
+
+ public void sendPacketNearby(@Nullable EntityHuman entityhuman, double d0, double d1, double d2, double d3, ResourceKey resourcekey, Packet> packet) {
+- for (int i = 0; i < this.players.size(); ++i) {
+- EntityPlayer entityplayer = (EntityPlayer) this.players.get(i);
++ WorldServer world = null;
++ if (entityhuman != null && entityhuman.world instanceof WorldServer) {
++ world = (WorldServer) entityhuman.world;
++ }
+
+- // CraftBukkit start - Test if player receiving packet can see the source of the packet
+- if (entityhuman != null && entityhuman instanceof EntityPlayer && !entityplayer.getBukkitEntity().canSee(((EntityPlayer) entityhuman).getBukkitEntity())) {
+- continue;
++ // Paper start
++ if (world == null) {
++ world = server.getWorldServer(resourcekey);
++ }
++ PlayerChunkMap chunkMap = world != null ? world.getChunkProvider().playerChunkMap : null;
++ Object[] backingSet;
++ if (chunkMap == null) {
++ // Really shouldn't happen...
++ backingSet = world != null ? world.players.toArray() : players.toArray();
++ } else {
++ com.destroystokyo.paper.util.misc.PooledLinkedHashSets.PooledObjectLinkedOpenHashSet nearbyPlayers = chunkMap.playerViewDistanceBroadcastMap.getObjectsInRange(MCUtil.fastFloor(d0) >> 4, MCUtil.fastFloor(d2) >> 4);
++ if (nearbyPlayers == null) {
++ return;
+ }
++ backingSet = nearbyPlayers.getBackingSet();
++ }
++
++ for (Object object : backingSet) {
++ if (!(object instanceof EntityPlayer)) continue;
++ EntityPlayer entityplayer = (EntityPlayer) object;
++ // Paper end
++
++ // CraftBukkit start - Test if player receiving packet can see the source of the packet
++ //if (entityhuman != null && entityhuman instanceof EntityPlayer && !entityplayer.getBukkitEntity().canSee(((EntityPlayer) entityhuman).getBukkitEntity())) { // Paper
++ //continue; // Paper
++ //} // Paper
+ // CraftBukkit end
+
+- if (entityplayer != entityhuman && entityplayer.world.getDimensionKey() == resourcekey) {
++ if (entityplayer != entityhuman && entityplayer.world.getDimensionKey() == resourcekey && entityhuman instanceof EntityPlayer && !entityplayer.getBukkitEntity().canSee(((EntityPlayer) entityhuman).getBukkitEntity())) { // Paper
+ double d4 = d0 - entityplayer.locX();
+ double d5 = d1 - entityplayer.locY();
+ double d6 = d2 - entityplayer.locZ();
diff --git a/Spigot-Server-Patches/0531-Improve-Chunk-Status-Transition-Speed.patch b/Spigot-Server-Patches/0499-Improve-Chunk-Status-Transition-Speed.patch
similarity index 72%
rename from Spigot-Server-Patches/0531-Improve-Chunk-Status-Transition-Speed.patch
rename to Spigot-Server-Patches/0499-Improve-Chunk-Status-Transition-Speed.patch
index 85c0553f6..bbd4ac1ce 100644
--- a/Spigot-Server-Patches/0531-Improve-Chunk-Status-Transition-Speed.patch
+++ b/Spigot-Server-Patches/0499-Improve-Chunk-Status-Transition-Speed.patch
@@ -36,10 +36,10 @@ scenario / path:
Previously would have hopped to SERVER around 12+ times there extra.
diff --git a/src/main/java/net/minecraft/server/PlayerChunk.java b/src/main/java/net/minecraft/server/PlayerChunk.java
-index 52da9c78c0cc2b21533a1477a25a3dda492700e4..69899c100dd86c6c4795013364472336327ce036 100644
+index 04dea2c9fd9337631a6289c7242338e166d6bc1e..446c401b3139f8c6c0e70d883340f0140d94b752 100644
--- a/src/main/java/net/minecraft/server/PlayerChunk.java
+++ b/src/main/java/net/minecraft/server/PlayerChunk.java
-@@ -56,6 +56,13 @@ public class PlayerChunk {
+@@ -55,6 +55,13 @@ public class PlayerChunk {
this.playersInChunkTickRange = this.chunkMap.playerChunkTickRangeMap.getObjectsInRange(key);
}
// Paper end - optimise isOutsideOfRange
@@ -54,34 +54,10 @@ index 52da9c78c0cc2b21533a1477a25a3dda492700e4..69899c100dd86c6c4795013364472336
// Paper start - no-tick view distance
public final Chunk getSendingChunk() {
diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java
-index 3139d55bb801b6c433de7274be4a1d0c0fd1eef7..98adcb6390105a183d66975ed9659906b609ce08 100644
+index 1eb138f003730f9d1048683beb60426067b2ba89..e9703cee3b175b220917b83d80e9904b1af17abe 100644
--- a/src/main/java/net/minecraft/server/PlayerChunkMap.java
+++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java
-@@ -88,6 +88,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
- public final WorldServer world;
- private final LightEngineThreaded lightEngine;
- private final IAsyncTaskHandler executor;
-+ final java.util.concurrent.Executor mainInvokingExecutor; // Paper
- public final ChunkGenerator> chunkGenerator;
- private final Supplier l; public final Supplier getWorldPersistentDataSupplier() { return this.l; } // Paper - OBFHELPER
- private final VillagePlace m;
-@@ -285,6 +286,15 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
- this.world = worldserver;
- this.chunkGenerator = chunkgenerator;
- this.executor = iasynctaskhandler;
-+ // Paper start - optimize chunk status progression without jumping through thread pool
-+ this.mainInvokingExecutor = (run) -> {
-+ if (MCUtil.isMainThread()) {
-+ run.run();
-+ } else {
-+ iasynctaskhandler.execute(run);
-+ }
-+ };
-+ // Paper end
- ThreadedMailbox threadedmailbox = ThreadedMailbox.a(executor, "worldgen");
-
- iasynctaskhandler.getClass();
-@@ -724,7 +734,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
+@@ -740,7 +740,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
return either.mapLeft((list) -> {
return (Chunk) list.get(list.size() / 2);
});
@@ -90,7 +66,7 @@ index 3139d55bb801b6c433de7274be4a1d0c0fd1eef7..98adcb6390105a183d66975ed9659906
}
@Nullable
-@@ -1074,7 +1084,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
+@@ -1090,7 +1090,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
IChunkAccess ichunkaccess = (IChunkAccess) optional.get();
if (ichunkaccess.getChunkStatus().b(chunkstatus)) {
@@ -99,7 +75,7 @@ index 3139d55bb801b6c433de7274be4a1d0c0fd1eef7..98adcb6390105a183d66975ed9659906
if (chunkstatus == ChunkStatus.LIGHT) {
completablefuture1 = this.b(playerchunk, chunkstatus);
-@@ -1090,7 +1100,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
+@@ -1106,7 +1106,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
return this.b(playerchunk, chunkstatus);
}
}
@@ -108,7 +84,7 @@ index 3139d55bb801b6c433de7274be4a1d0c0fd1eef7..98adcb6390105a183d66975ed9659906
}
}
-@@ -1201,6 +1211,12 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
+@@ -1224,6 +1224,12 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
return CompletableFuture.completedFuture(Either.right(playerchunk_failure));
});
}, (runnable) -> {
@@ -118,6 +94,6 @@ index 3139d55bb801b6c433de7274be4a1d0c0fd1eef7..98adcb6390105a183d66975ed9659906
+ return;
+ }
+ // Paper end
- this.mailboxWorldGen.a(ChunkTaskQueueSorter.a(playerchunk, runnable)); // CraftBukkit - decompile error
+ this.mailboxWorldGen.a(ChunkTaskQueueSorter.a(playerchunk, runnable));
});
}
diff --git a/Spigot-Server-Patches/0532-Fix-villager-trading-demand-MC-163962.patch b/Spigot-Server-Patches/0500-Fix-villager-trading-demand-MC-163962.patch
similarity index 89%
rename from Spigot-Server-Patches/0532-Fix-villager-trading-demand-MC-163962.patch
rename to Spigot-Server-Patches/0500-Fix-villager-trading-demand-MC-163962.patch
index daa484429..96152b810 100644
--- a/Spigot-Server-Patches/0532-Fix-villager-trading-demand-MC-163962.patch
+++ b/Spigot-Server-Patches/0500-Fix-villager-trading-demand-MC-163962.patch
@@ -6,7 +6,7 @@ Subject: [PATCH] Fix villager trading demand - MC-163962
Prevent demand from going negative and tending to negative infinity
diff --git a/src/main/java/net/minecraft/server/MerchantRecipe.java b/src/main/java/net/minecraft/server/MerchantRecipe.java
-index f1f49c2ebff93ce3537bd4a58916d4c624a3fe82..7c4dc1143696320c8b8dc21ea4ae0600d5686d62 100644
+index 2865fa7018c3631fbcaaaaa2892219d9cab713d3..e42382a5c385c27b6322b03e87870eb20b21cb22 100644
--- a/src/main/java/net/minecraft/server/MerchantRecipe.java
+++ b/src/main/java/net/minecraft/server/MerchantRecipe.java
@@ -104,7 +104,7 @@ public class MerchantRecipe {
diff --git a/Spigot-Server-Patches/0533-Maps-shouldn-t-load-chunks.patch b/Spigot-Server-Patches/0501-Maps-shouldn-t-load-chunks.patch
similarity index 95%
rename from Spigot-Server-Patches/0533-Maps-shouldn-t-load-chunks.patch
rename to Spigot-Server-Patches/0501-Maps-shouldn-t-load-chunks.patch
index 9b5bf7797..6dd34a1a7 100644
--- a/Spigot-Server-Patches/0533-Maps-shouldn-t-load-chunks.patch
+++ b/Spigot-Server-Patches/0501-Maps-shouldn-t-load-chunks.patch
@@ -15,7 +15,7 @@ Previously maps would load all chunks in a certain radius depending on
five ticks that movement occur in anyways.
diff --git a/src/main/java/net/minecraft/server/ItemWorldMap.java b/src/main/java/net/minecraft/server/ItemWorldMap.java
-index 189e6d753d43b145a5480b10db11bba54fe8fbf3..134468da1a8fad6fdd48f64bf9ea885794e86bdf 100644
+index a65266040dc14d7c679b8eb46188023aa35f83ed..90be8c6091dc590a020721f45c7ff7b137cc806d 100644
--- a/src/main/java/net/minecraft/server/ItemWorldMap.java
+++ b/src/main/java/net/minecraft/server/ItemWorldMap.java
@@ -96,9 +96,9 @@ public class ItemWorldMap extends ItemWorldMapBase {
diff --git a/Spigot-Server-Patches/0534-Use-seed-based-lookup-for-Treasure-Maps-Fixes-lag-fr.patch b/Spigot-Server-Patches/0502-Use-seed-based-lookup-for-Treasure-Maps-Fixes-lag-fr.patch
similarity index 82%
rename from Spigot-Server-Patches/0534-Use-seed-based-lookup-for-Treasure-Maps-Fixes-lag-fr.patch
rename to Spigot-Server-Patches/0502-Use-seed-based-lookup-for-Treasure-Maps-Fixes-lag-fr.patch
index 0a2d3d9c4..96bcd2c18 100644
--- a/Spigot-Server-Patches/0534-Use-seed-based-lookup-for-Treasure-Maps-Fixes-lag-fr.patch
+++ b/Spigot-Server-Patches/0502-Use-seed-based-lookup-for-Treasure-Maps-Fixes-lag-fr.patch
@@ -6,7 +6,7 @@ Subject: [PATCH] Use seed based lookup for Treasure Maps - Fixes lag from
diff --git a/src/main/java/net/minecraft/server/ItemWorldMap.java b/src/main/java/net/minecraft/server/ItemWorldMap.java
-index 134468da1a8fad6fdd48f64bf9ea885794e86bdf..b09de92ee56f491f7b4c526105f8d306b365a275 100644
+index 90be8c6091dc590a020721f45c7ff7b137cc806d..faa556d4358bc9890ae80c18ee10c38a8d46548e 100644
--- a/src/main/java/net/minecraft/server/ItemWorldMap.java
+++ b/src/main/java/net/minecraft/server/ItemWorldMap.java
@@ -229,7 +229,7 @@ public class ItemWorldMap extends ItemWorldMapBase {
@@ -19,16 +19,15 @@ index 134468da1a8fad6fdd48f64bf9ea885794e86bdf..b09de92ee56f491f7b4c526105f8d306
}
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
-index 2c9acffe5a62af43ff4f4ccdb6962929d645e226..49da7352dcee6c352904cabe8b5db0152c427029 100644
+index d0493919e71159ac6b38a64b2411fea722b53306..b79302b83921111d5fa32794babf1fa57b7bbcb1 100644
--- a/src/main/java/net/minecraft/server/WorldServer.java
+++ b/src/main/java/net/minecraft/server/WorldServer.java
-@@ -283,8 +283,9 @@ public class WorldServer extends World {
+@@ -303,8 +303,8 @@ public class WorldServer extends World implements GeneratorAccessSeed {
+ this.worldDataServer.setThundering(flag1);
}
- // CraftBukkit end
- @Override
- public BiomeBase a(int i, int j, int k) {
-+
+ public BiomeBase getBiomeBySeed(int i, int j, int k) { return a(i, j, k); } // Paper - OBFHELPER
+ @Override public BiomeBase a(int i, int j, int k) {
return this.getChunkProvider().getChunkGenerator().getWorldChunkManager().getBiome(i, j, k);
diff --git a/Spigot-Server-Patches/0535-Optimize-Bit-Operations-by-inlining.patch b/Spigot-Server-Patches/0503-Optimize-Bit-Operations-by-inlining.patch
similarity index 69%
rename from Spigot-Server-Patches/0535-Optimize-Bit-Operations-by-inlining.patch
rename to Spigot-Server-Patches/0503-Optimize-Bit-Operations-by-inlining.patch
index 7f9251571..d54739c7e 100644
--- a/Spigot-Server-Patches/0535-Optimize-Bit-Operations-by-inlining.patch
+++ b/Spigot-Server-Patches/0503-Optimize-Bit-Operations-by-inlining.patch
@@ -7,11 +7,11 @@ Inline bit operations and reduce instruction count to make these hot
operations faster
diff --git a/src/main/java/net/minecraft/server/BlockPosition.java b/src/main/java/net/minecraft/server/BlockPosition.java
-index 3bf17ccdaef21322b787db538d569e0bc614ef22..4c64798fbc50f4d8b08502ba865c5fde5c968e62 100644
+index adfeeefbbc307a77738c2cc8d82856cd02c2285e..52b2bff9ee3ccb4cea9549542b2b484685a70bfb 100644
--- a/src/main/java/net/minecraft/server/BlockPosition.java
+++ b/src/main/java/net/minecraft/server/BlockPosition.java
-@@ -75,38 +75,34 @@ public class BlockPosition extends BaseBlockPosition implements MinecraftSeriali
- return dynamicops.createIntList(IntStream.of(new int[]{this.getX(), this.getY(), this.getZ()}));
+@@ -53,28 +53,29 @@ public class BlockPosition extends BaseBlockPosition {
+ this(baseblockposition.getX(), baseblockposition.getY(), baseblockposition.getZ());
}
+ public static long getAdjacent(int baseX, int baseY, int baseZ, EnumDirection enumdirection) { return asLong(baseX + enumdirection.getAdjacentX(), baseY + enumdirection.getAdjacentY(), baseZ + enumdirection.getAdjacentZ()); } // Paper
@@ -25,17 +25,17 @@ index 3bf17ccdaef21322b787db538d569e0bc614ef22..4c64798fbc50f4d8b08502ba865c5fde
}
public static int b(long i) {
-- return (int) (i << 64 - BlockPosition.k - BlockPosition.c >> 64 - BlockPosition.c);
+- return (int) (i << 64 - BlockPosition.m - BlockPosition.f >> 64 - BlockPosition.f);
+ return (int) (i >> 38); // Paper - simplify/inline
}
public static int c(long i) {
-- return (int) (i << 64 - BlockPosition.f >> 64 - BlockPosition.f);
-+ return (int) ((i << 52) >> 52); // Paper - simplify/inline
+- return (int) (i << 64 - BlockPosition.h >> 64 - BlockPosition.h);
++ return (int) ((i << 26) >> 38); // Paper - simplify/inline
}
public static int d(long i) {
-- return (int) (i << 64 - BlockPosition.j - BlockPosition.d >> 64 - BlockPosition.d);
+- return (int) (i << 64 - BlockPosition.l - BlockPosition.g >> 64 - BlockPosition.g);
+ return (int) ((i << 26) >> 38); // Paper - simplify/inline
}
@@ -44,20 +44,23 @@ index 3bf17ccdaef21322b787db538d569e0bc614ef22..4c64798fbc50f4d8b08502ba865c5fde
+ return new BlockPosition((int) (i >> 38), (int) ((i << 52) >> 52), (int) ((i << 26) >> 38)); // Paper - simplify/inline
}
+ public long asLong() {
+@@ -83,12 +84,7 @@ public class BlockPosition extends BaseBlockPosition {
+
public static long asLong(int x, int y, int z) { return a(x, y, z); } // Paper - OBFHELPER
public static long a(int i, int j, int k) {
- long l = 0L;
-
-- l |= ((long) i & BlockPosition.g) << BlockPosition.k;
-- l |= ((long) j & BlockPosition.h) << 0;
-- l |= ((long) k & BlockPosition.i) << BlockPosition.j;
+- l |= ((long) i & BlockPosition.i) << BlockPosition.m;
+- l |= ((long) j & BlockPosition.j) << 0;
+- l |= ((long) k & BlockPosition.k) << BlockPosition.l;
- return l;
+ return (((long) i & (long) 67108863) << 38) | (((long) j & (long) 4095)) | (((long) k & (long) 67108863) << 12); // Paper - inline constants and simplify
}
public static long f(long i) {
diff --git a/src/main/java/net/minecraft/server/SectionPosition.java b/src/main/java/net/minecraft/server/SectionPosition.java
-index ca3f63f5e5e4e926de562b4bfbbf72ad8a6b943f..22bc96f97d22e0748110982e4b1ff85002f924b5 100644
+index 6a8597c585e74ebea2e8bac2f9965f8760e19b67..7806f3c351cba3f0388da11888f900c48004dadf 100644
--- a/src/main/java/net/minecraft/server/SectionPosition.java
+++ b/src/main/java/net/minecraft/server/SectionPosition.java
@@ -16,7 +16,7 @@ public class SectionPosition extends BaseBlockPosition {
@@ -104,75 +107,35 @@ index ca3f63f5e5e4e926de562b4bfbbf72ad8a6b943f..22bc96f97d22e0748110982e4b1ff850
- int k = b(blockposition.getZ());
-
- return (short) (i << 8 | k << 4 | j);
-+ return (short) ((blockposition.x & 15) << 8 | (blockposition.z & 15) << 4 | blockposition.y & 15); // Paper - simplify/inline
++ return (short) ((blockposition.getX() & 15) << 8 | (blockposition.getZ() & 15) << 4 | blockposition.getY() & 15); // Paper - simplify/inline
}
public static int c(int i) {
-@@ -60,7 +64,7 @@ public class SectionPosition extends BaseBlockPosition {
- }
-
- public static int b(long i) {
-- return (int) (i << 0 >> 42);
-+ return (int) (i >> 42); // Paper
- }
-
- public static int c(long i) {
-@@ -71,44 +75,46 @@ public class SectionPosition extends BaseBlockPosition {
- return (int) (i << 22 >> 42);
- }
-
-- public int a() {
-- return this.getX();
-+ public final int a() { // Paper
-+ return x; // Paper
- }
-
-- public int b() {
-- return this.getY();
-+ public final int b() { // Paper
-+ return y; // Paper
- }
-
-- public int c() {
-- return this.getZ();
-+ public final int c() { // Paper
-+ return z; // Paper
+@@ -83,16 +87,16 @@ public class SectionPosition extends BaseBlockPosition {
+ return this.getZ();
}
- public int d() {
- return this.a() << 4;
+ public final int d() { // Paper
-+ return x << 4; // Paper
++ return this.getX() << 4; // Paper
}
- public int e() {
- return this.b() << 4;
+ public final int e() { // Paper
-+ return y << 4; // Paper
++ return this.getY() << 4; // Paper
}
- public int f() {
- return this.c() << 4;
+ public final int f() { // Paper
-+ return z << 4; // Paper
++ return this.getZ() << 4; // Paper
}
-- public int g() {
-- return (this.a() << 4) + 15;
-+ public final int g() { // Paper
-+ return (x << 4) + 15; // Paper
- }
-
-- public int h() {
-- return (this.b() << 4) + 15;
-+ public final int h() { // Paper
-+ return (y << 4) + 15; // Paper
- }
-
-- public int r() {
-- return (this.c() << 4) + 15;
-+ public final int r() { // Paper
-+ return (z << 4) + 15; // Paper
+ public int g() {
+@@ -107,8 +111,10 @@ public class SectionPosition extends BaseBlockPosition {
+ return (this.c() << 4) + 15;
}
+ public static long blockToSection(long i) { return e(i); } // Paper - OBFHELPER
@@ -183,16 +146,7 @@ index ca3f63f5e5e4e926de562b4bfbbf72ad8a6b943f..22bc96f97d22e0748110982e4b1ff850
}
public static long f(long i) {
-@@ -116,7 +122,7 @@ public class SectionPosition extends BaseBlockPosition {
- }
-
- public BlockPosition s() {
-- return new BlockPosition(c(this.a()), c(this.b()), c(this.c()));
-+ return new BlockPosition(x << 4, y << 4, z << 4); // Paper
- }
-
- public BlockPosition t() {
-@@ -129,36 +135,30 @@ public class SectionPosition extends BaseBlockPosition {
+@@ -129,17 +135,18 @@ public class SectionPosition extends BaseBlockPosition {
return new ChunkCoordIntPair(this.a(), this.c());
}
@@ -212,14 +166,13 @@ index ca3f63f5e5e4e926de562b4bfbbf72ad8a6b943f..22bc96f97d22e0748110982e4b1ff850
+ return (((long) i & 4194303L) << 42) | (((long) j & 1048575L)) | (((long) k & 4194303L) << 20); // Paper - Simplify to reduce instruction count
}
- public long v() {
+ public long s() {
- return b(this.a(), this.b(), this.c());
-+ return (((long) x & 4194303L) << 42) | (((long) y & 1048575L)) | (((long) z & 4194303L) << 20); // Paper - Simplify to reduce instruction count
++ return (((long) getX() & 4194303L) << 42) | (((long) getY() & 1048575L)) | (((long) getZ() & 4194303L) << 20); // Paper - Simplify to reduce instruction count
}
- public Stream w() {
-- return BlockPosition.a(this.d(), this.e(), this.f(), this.g(), this.h(), this.r());
-+ return BlockPosition.a(x << 4, y << 4, z << 4, (x << 4) + 15, (y << 4) + 15, (z << 4) + 15); // Paper - simplify/inline
+ public Stream t() {
+@@ -147,18 +154,11 @@ public class SectionPosition extends BaseBlockPosition {
}
public static Stream a(SectionPosition sectionposition, int i) {
@@ -228,7 +181,7 @@ index ca3f63f5e5e4e926de562b4bfbbf72ad8a6b943f..22bc96f97d22e0748110982e4b1ff850
- int l = sectionposition.c();
-
- return a(j - i, k - i, l - i, j + i, k + i, l + i);
-+ return a(sectionposition.x - i, sectionposition.y - i, sectionposition.z - i, sectionposition.x + i, sectionposition.y + i, sectionposition.z + i); // Paper - simplify/inline
++ return a(sectionposition.getX() - i, sectionposition.getY() - i, sectionposition.getZ() - i, sectionposition.getX() + i, sectionposition.getY() + i, sectionposition.getZ() + i); // Paper - simplify/inline
}
public static Stream b(ChunkCoordIntPair chunkcoordintpair, int i) {
diff --git a/Spigot-Server-Patches/0536-Optimize-Light-Engine.patch b/Spigot-Server-Patches/0504-Optimize-Light-Engine.patch
similarity index 88%
rename from Spigot-Server-Patches/0536-Optimize-Light-Engine.patch
rename to Spigot-Server-Patches/0504-Optimize-Light-Engine.patch
index 56f8be81f..3c31180a4 100644
--- a/Spigot-Server-Patches/0536-Optimize-Light-Engine.patch
+++ b/Spigot-Server-Patches/0504-Optimize-Light-Engine.patch
@@ -24,24 +24,11 @@ Massive update to light to improve performance and chunk loading/generation.
7) Buffer non urgent tasks even if queueUpdate is called multiple times to improve efficiency.
8) Fix NPE risk that crashes server in getting nibble data
-diff --git a/src/main/java/net/minecraft/server/Block.java b/src/main/java/net/minecraft/server/Block.java
-index d2207a2c95690de586ab2d181b64955a6d2ea70d..66244a9d0e253b3709df4ae2adcd21e44ebbfc90 100644
---- a/src/main/java/net/minecraft/server/Block.java
-+++ b/src/main/java/net/minecraft/server/Block.java
-@@ -310,7 +310,7 @@ public class Block implements IMaterial {
- return false;
- }
-
-- @Deprecated
-+ public final boolean canOcclude(IBlockData blockData) { return n(blockData); } @Deprecated // Paper - OBFHELPER
- public final boolean n(IBlockData iblockdata) {
- return this.j;
- }
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
-index 8efe036be0c74a5ceb6a18e019c4a08a49a28693..7d50b94cb37ea921451af1baa47c8900e99b37e1 100644
+index 604e7004b659daed2844ba1a76bf09288ec549e5..ef980f9859d1d7d0d5e13d0d70e998055f92135e 100644
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
-@@ -1100,7 +1100,7 @@ public class ChunkProviderServer extends IChunkProvider {
+@@ -1044,7 +1044,7 @@ public class ChunkProviderServer extends IChunkProvider {
if (ChunkProviderServer.this.tickDistanceManager()) {
return true;
} else {
@@ -50,46 +37,6 @@ index 8efe036be0c74a5ceb6a18e019c4a08a49a28693..7d50b94cb37ea921451af1baa47c8900
return super.executeNext() || execChunkTask; // Paper
}
} finally {
-diff --git a/src/main/java/net/minecraft/server/IBlockData.java b/src/main/java/net/minecraft/server/IBlockData.java
-index 296b41bf36ee1ace5bd9db2b810bf926b5f5278f..b39554faf235b6f81c86542673dfb4508d4c3e5a 100644
---- a/src/main/java/net/minecraft/server/IBlockData.java
-+++ b/src/main/java/net/minecraft/server/IBlockData.java
-@@ -24,6 +24,7 @@ public class IBlockData extends BlockDataAbstract implements
- private final boolean e;
- private final boolean isAir; // Paper
- private final boolean isTicking; // Paper
-+ private final boolean canOcclude; // Paper
-
- public IBlockData(Block block, ImmutableMap, Comparable>> immutablemap) {
- super(block, immutablemap);
-@@ -31,6 +32,7 @@ public class IBlockData extends BlockDataAbstract implements
- this.e = block.o(this);
- this.isAir = this.getBlock().isAir(this); // Paper
- this.isTicking = this.getBlock().isTicking(this); // Paper
-+ this.canOcclude = this.getBlock().canOcclude(this); // Paper
- }
-
- public void c() {
-@@ -83,7 +85,7 @@ public class IBlockData extends BlockDataAbstract implements
- return this.c == null || this.c.h;
- }
-
-- public boolean g() {
-+ public final boolean g() { // Paper
- return this.e;
- }
-
-@@ -151,8 +153,8 @@ public class IBlockData extends BlockDataAbstract implements
- return this.c != null ? this.c.c : this.getBlock().k(this, iblockaccess, blockposition);
- }
-
-- public boolean o() {
-- return this.c != null ? this.c.b : this.getBlock().n(this);
-+ public final boolean o() { // Paper
-+ return canOcclude; // Paper
- }
-
- public VoxelShape getShape(IBlockAccess iblockaccess, BlockPosition blockposition) {
diff --git a/src/main/java/net/minecraft/server/LightEngineBlock.java b/src/main/java/net/minecraft/server/LightEngineBlock.java
index 07fadc21ee12138b52cc77c50da536fec5b032f5..a61d0a27e9525505eedaec8cde44216e807eb9a8 100644
--- a/src/main/java/net/minecraft/server/LightEngineBlock.java
@@ -264,10 +211,10 @@ index 2eb37fb5796d423a70fa7321899a19b6625bbecc..13d067f48647dea63ef1bf3a2a3e0868
if (l1 == i) {
l1 = Long.MAX_VALUE;
diff --git a/src/main/java/net/minecraft/server/LightEngineLayer.java b/src/main/java/net/minecraft/server/LightEngineLayer.java
-index f72ff8495bcf704c15040676b95c51fecb72b73a..faa432779ec70c2c6b5fe7fe3523f171e26d3a5f 100644
+index 3e9731bcdd4c6370c11ffc93f9fafcaf60fe932b..b5d5dd1075fd6aabbfbbd60f219b76593fc54a76 100644
--- a/src/main/java/net/minecraft/server/LightEngineLayer.java
+++ b/src/main/java/net/minecraft/server/LightEngineLayer.java
-@@ -11,9 +11,9 @@ public abstract class LightEngineLayer, S e
+@@ -11,10 +11,37 @@ public abstract class LightEngineLayer, S e
protected final EnumSkyBlock b;
protected final S c;
private boolean f;
@@ -277,9 +224,37 @@ index f72ff8495bcf704c15040676b95c51fecb72b73a..faa432779ec70c2c6b5fe7fe3523f171
- private final IBlockAccess[] h = new IBlockAccess[2];
+ private final IChunkAccess[] h = new IChunkAccess[2]; // Paper
++ // Paper start - see fully commented out method below (look for Bedrock)
++ // optimized method with less branching for when scenarios arent needed.
++ // avoid using mutable version if can
++ protected final IBlockData getBlockOptimized(int x, int y, int z, MutableInt mutableint) {
++ IChunkAccess iblockaccess = this.a(x >> 4, z >> 4);
++
++ if (iblockaccess == null) {
++ mutableint.setValue(16);
++ return Blocks.BEDROCK.getBlockData();
++ } else {
++ this.pos.setValues(x, y, z);
++ IBlockData iblockdata = iblockaccess.getType(x, y, z);
++ mutableint.setValue(iblockdata.b(this.a.getWorld(), this.pos));
++ return iblockdata.l() && iblockdata.e() ? iblockdata : Blocks.AIR.getBlockData();
++ }
++ }
++ protected final IBlockData getBlockOptimized(int x, int y, int z) {
++ IChunkAccess iblockaccess = this.a(x >> 4, z >> 4);
++
++ if (iblockaccess == null) {
++ return Blocks.BEDROCK.getBlockData();
++ } else {
++ IBlockData iblockdata = iblockaccess.getType(x, y, z);
++ return iblockdata.l() && iblockdata.e() ? iblockdata : Blocks.AIR.getBlockData();
++ }
++ }
++ // Paper end
public LightEngineLayer(ILightAccess ilightaccess, EnumSkyBlock enumskyblock, S s0) {
super(16, 256, 8192);
-@@ -33,7 +33,7 @@ public abstract class LightEngineLayer, S e
+ this.a = ilightaccess;
+@@ -33,7 +60,7 @@ public abstract class LightEngineLayer, S e
}
@Nullable
@@ -288,7 +263,7 @@ index f72ff8495bcf704c15040676b95c51fecb72b73a..faa432779ec70c2c6b5fe7fe3523f171
long k = ChunkCoordIntPair.pair(i, j);
for (int l = 0; l < 2; ++l) {
-@@ -42,7 +42,7 @@ public abstract class LightEngineLayer, S e
+@@ -42,7 +69,7 @@ public abstract class LightEngineLayer, S e
}
}
@@ -297,7 +272,7 @@ index f72ff8495bcf704c15040676b95c51fecb72b73a..faa432779ec70c2c6b5fe7fe3523f171
for (int i1 = 1; i1 > 0; --i1) {
this.g[i1] = this.g[i1 - 1];
-@@ -59,37 +59,64 @@ public abstract class LightEngineLayer, S e
+@@ -59,37 +86,39 @@ public abstract class LightEngineLayer, S e
Arrays.fill(this.h, (Object) null);
}
@@ -308,7 +283,31 @@ index f72ff8495bcf704c15040676b95c51fecb72b73a..faa432779ec70c2c6b5fe7fe3523f171
- }
-
- return Blocks.AIR.getBlockData();
-+ // Paper start - unused, optimized versions below, comment out to detect changes
+- } else {
+- int j = SectionPosition.a(BlockPosition.b(i));
+- int k = SectionPosition.a(BlockPosition.d(i));
+- IBlockAccess iblockaccess = this.a(j, k);
+-
+- if (iblockaccess == null) {
+- if (mutableint != null) {
+- mutableint.setValue(16);
+- }
+-
+- return Blocks.BEDROCK.getBlockData();
+- } else {
+- this.d.g(i);
+- IBlockData iblockdata = iblockaccess.getType(this.d);
+- boolean flag = iblockdata.l() && iblockdata.e();
+-
+- if (mutableint != null) {
+- mutableint.setValue(iblockdata.b(this.a.getWorld(), (BlockPosition) this.d));
+- }
+-
+- return flag ? iblockdata : Blocks.AIR.getBlockData();
+- }
+- }
+- }
++ // Paper start - comment out, see getBlockOptimized
+// protected IBlockData a(long i, @Nullable MutableInt mutableint) {
+// if (i == Long.MAX_VALUE) {
+// if (mutableint != null) {
@@ -330,7 +329,7 @@ index f72ff8495bcf704c15040676b95c51fecb72b73a..faa432779ec70c2c6b5fe7fe3523f171
+// } else {
+// this.d.g(i);
+// IBlockData iblockdata = iblockaccess.getType(this.d);
-+// boolean flag = iblockdata.o() && iblockdata.g();
++// boolean flag = iblockdata.l() && iblockdata.e();
+//
+// if (mutableint != null) {
+// mutableint.setValue(iblockdata.b(this.a.getWorld(), (BlockPosition) this.d));
@@ -340,56 +339,11 @@ index f72ff8495bcf704c15040676b95c51fecb72b73a..faa432779ec70c2c6b5fe7fe3523f171
+// }
+// }
+// }
-+ // optimized method with less branching for when scenarios arent needed.
-+ // avoid using mutable version if can
-+ protected final IBlockData getBlockOptimized(int x, int y, int z, MutableInt mutableint) {
-+ IChunkAccess iblockaccess = this.a(x >> 4, z >> 4);
-+
-+ if (iblockaccess == null) {
-+ mutableint.setValue(16);
-+ return Blocks.BEDROCK.getBlockData();
- } else {
-- int j = SectionPosition.a(BlockPosition.b(i));
-- int k = SectionPosition.a(BlockPosition.d(i));
-- IBlockAccess iblockaccess = this.a(j, k);
--
-- if (iblockaccess == null) {
-- if (mutableint != null) {
-- mutableint.setValue(16);
-- }
--
-- return Blocks.BEDROCK.getBlockData();
-- } else {
-- this.d.g(i);
-- IBlockData iblockdata = iblockaccess.getType(this.d);
-- boolean flag = iblockdata.o() && iblockdata.g();
--
-- if (mutableint != null) {
-- mutableint.setValue(iblockdata.b(this.a.getWorld(), (BlockPosition) this.d));
-- }
-+ this.pos.setValues(x, y, z);
-+ IBlockData iblockdata = iblockaccess.getType(x, y, z);
-+ mutableint.setValue(iblockdata.b(this.a.getWorld(), this.pos));
-+ return iblockdata.o() && iblockdata.g() ? iblockdata : Blocks.AIR.getBlockData();
-+ }
-+ }
-+ protected final IBlockData getBlockOptimized(int x, int y, int z) {
-+ IChunkAccess iblockaccess = this.a(x >> 4, z >> 4);
-
-- return flag ? iblockdata : Blocks.AIR.getBlockData();
-- }
-+ if (iblockaccess == null) {
-+ return Blocks.BEDROCK.getBlockData();
-+ } else {
-+ IBlockData iblockdata = iblockaccess.getType(x, y, z);
-+ return iblockdata.o() && iblockdata.g() ? iblockdata : Blocks.AIR.getBlockData();
- }
- }
+ // Paper end
protected VoxelShape a(IBlockData iblockdata, long i, EnumDirection enumdirection) {
- return iblockdata.o() ? iblockdata.a(this.a.getWorld(), this.d.g(i), enumdirection) : VoxelShapes.a();
-@@ -124,8 +151,9 @@ public abstract class LightEngineLayer, S e
+ return iblockdata.l() ? iblockdata.a(this.a.getWorld(), this.d.g(i), enumdirection) : VoxelShapes.a();
+@@ -124,8 +153,9 @@ public abstract class LightEngineLayer, S e
return i == Long.MAX_VALUE ? 0 : 15 - this.c.i(i);
}
@@ -568,10 +522,10 @@ index f0b57784006752e031800a12a1a3c1a5945c636b..32b52ca2462fa206b1184025cb3837d6
if (i2 != j) {
int l2;
diff --git a/src/main/java/net/minecraft/server/LightEngineStorage.java b/src/main/java/net/minecraft/server/LightEngineStorage.java
-index b0b7544592981bcff22c8acee7230a211918ef28..f2575fb69714397bb8e1f9d402689c7816d73b6c 100644
+index b8b06c790adfa0246b1a6fb5eab1f63bf5ef8b0b..b98e60772bad7e06845b50fdc11e98c0ea775d3d 100644
--- a/src/main/java/net/minecraft/server/LightEngineStorage.java
+++ b/src/main/java/net/minecraft/server/LightEngineStorage.java
-@@ -20,42 +20,42 @@ public abstract class LightEngineStorage> e
+@@ -20,9 +20,9 @@ public abstract class LightEngineStorage> e
protected final LongSet c = new LongOpenHashSet();
protected final LongSet d = new LongOpenHashSet();
protected volatile M e_visible; protected final Object visibleUpdateLock = new Object(); // Paper - diff on change, should be "visible" - force compile fail on usage change
@@ -583,6 +537,7 @@ index b0b7544592981bcff22c8acee7230a211918ef28..f2575fb69714397bb8e1f9d402689c78
protected final Long2ObjectMap i = Long2ObjectMaps.synchronize(new Long2ObjectOpenHashMap());
private final LongSet n = new LongOpenHashSet();
private final LongSet o = new LongOpenHashSet();
+@@ -30,33 +30,33 @@ public abstract class LightEngineStorage> e
protected volatile boolean j;
protected LightEngineStorage(EnumSkyBlock enumskyblock, ILightAccess ilightaccess, M m0) {
@@ -623,7 +578,7 @@ index b0b7544592981bcff22c8acee7230a211918ef28..f2575fb69714397bb8e1f9d402689c78
return m0.c(i);
}
-@@ -69,27 +69,57 @@ public abstract class LightEngineStorage> e
+@@ -70,27 +70,57 @@ public abstract class LightEngineStorage> e
protected abstract int d(long i);
protected int i(long i) {
@@ -692,16 +647,16 @@ index b0b7544592981bcff22c8acee7230a211918ef28..f2575fb69714397bb8e1f9d402689c78
}
}
}
-@@ -121,17 +151,23 @@ public abstract class LightEngineStorage> e
+@@ -122,17 +152,23 @@ public abstract class LightEngineStorage> e
}
if (k >= 2 && j != 2) {
-- if (this.o.contains(i)) {
-- this.o.remove(i);
+- if (this.p.contains(i)) {
+- this.p.remove(i);
- } else {
-+ if (!this.o.remove(i)) { // Paper - remove useless contains - credit to JellySquid
-+ //this.o.remove(i); // Paper
-+ //} else { // Pape
++ if (!this.p.remove(i)) { // Paper - remove useless contains - credit to JellySquid
++ //this.p.remove(i); // Paper
++ //} else { // Paper
this.f.a(i, this.j(i));
this.g.add(i);
this.k(i);
@@ -723,7 +678,7 @@ index b0b7544592981bcff22c8acee7230a211918ef28..f2575fb69714397bb8e1f9d402689c78
}
}
}
-@@ -157,9 +193,9 @@ public abstract class LightEngineStorage> e
+@@ -158,9 +194,9 @@ public abstract class LightEngineStorage> e
return SectionPosition.e(j) == i;
});
} else {
@@ -736,7 +691,7 @@ index b0b7544592981bcff22c8acee7230a211918ef28..f2575fb69714397bb8e1f9d402689c78
for (int i1 = 0; i1 < 16; ++i1) {
for (int j1 = 0; j1 < 16; ++j1) {
-@@ -186,7 +222,7 @@ public abstract class LightEngineStorage> e
+@@ -187,7 +223,7 @@ public abstract class LightEngineStorage> e
NibbleArray nibblearray;
while (longiterator.hasNext()) {
@@ -745,8 +700,8 @@ index b0b7544592981bcff22c8acee7230a211918ef28..f2575fb69714397bb8e1f9d402689c78
this.a(lightenginelayer, i);
NibbleArray nibblearray1 = (NibbleArray) this.i.remove(i);
-@@ -204,48 +240,56 @@ public abstract class LightEngineStorage> e
- longiterator = this.o.iterator();
+@@ -205,7 +241,7 @@ public abstract class LightEngineStorage> e
+ longiterator = this.p.iterator();
while (longiterator.hasNext()) {
- i = (Long) longiterator.next();
@@ -754,16 +709,11 @@ index b0b7544592981bcff22c8acee7230a211918ef28..f2575fb69714397bb8e1f9d402689c78
this.l(i);
}
- this.o.clear();
- this.j = false;
-- ObjectIterator objectiterator = this.i.long2ObjectEntrySet().iterator();
-+ ObjectIterator> objectiterator = Long2ObjectMaps.fastIterator(this.i); // Paper
-
+@@ -216,12 +252,13 @@ public abstract class LightEngineStorage> e
Entry entry;
long j;
+ NibbleArray test = null; // Paper
-+ LongSet propagating = new LongOpenHashSet(); // Paper - credit JellySquid for idea to move this up
while (objectiterator.hasNext()) {
entry = (Entry) objectiterator.next();
j = entry.getLongKey();
@@ -775,66 +725,48 @@ index b0b7544592981bcff22c8acee7230a211918ef28..f2575fb69714397bb8e1f9d402689c78
this.a(lightenginelayer, j);
this.f.a(j, nibblearray);
this.g.add(j);
- }
-+ if (!flag1) propagating.add(j); // Paper
-+ objectiterator.remove(); // Paper
- }
- }
-
- this.f.c();
-- if (!flag1) {
-- longiterator = this.i.keySet().iterator();
-+ if (!flag1) {// Paper - diff on change, change propagating add a few lines up
-+ longiterator = propagating.iterator(); // Paper
+@@ -234,14 +271,14 @@ public abstract class LightEngineStorage> e
+ longiterator = this.i.keySet().iterator();
while (longiterator.hasNext()) {
- i = (Long) longiterator.next();
-- if (this.g(i)) {
-- int k = SectionPosition.c(SectionPosition.b(i));
-- int l = SectionPosition.c(SectionPosition.c(i));
-- int i1 = SectionPosition.c(SectionPosition.d(i));
-+ // Paper start
-+ i = longiterator.nextLong();
-+ if (true) { // don't check hasLight, this iterator is filtered already
-+ int secX = (int) (i >> 42);
-+ int secY = (int) (i << 44 >> 44);
-+ int secZ = (int) (i << 22 >> 42);
-+ int k = secX << 4; // baseX
-+ int l = secY << 4; // baseY
-+ int i1 = secZ << 4; // baseZ
-+ // Paper end
- EnumDirection[] aenumdirection = LightEngineStorage.k;
- int j1 = aenumdirection.length;
++ i = longiterator.nextLong(); // Paper
+ this.b(lightenginelayer, i);
+ }
+ } else {
+ longiterator = this.n.iterator();
- for (int k1 = 0; k1 < j1; ++k1) {
- EnumDirection enumdirection = aenumdirection[k1];
-- long l1 = SectionPosition.a(i, enumdirection);
--
-- if (!this.i.containsKey(l1) && this.g(l1)) {
-+ long l1 = SectionPosition.getAdjacentFromSectionPos(secX, secY, secZ, enumdirection); // Paper - avoid extra unpacking
-+ if (!propagating.contains(l1) && this.g(l1)) { // Paper - use propagating
- for (int i2 = 0; i2 < 16; ++i2) {
- for (int j2 = 0; j2 < 16; ++j2) {
- long k2;
-@@ -287,6 +331,8 @@ public abstract class LightEngineStorage> e
+ while (longiterator.hasNext()) {
+- i = (Long) longiterator.next();
++ i = longiterator.nextLong(); // Paper
+ this.b(lightenginelayer, i);
}
}
+@@ -262,15 +299,20 @@ public abstract class LightEngineStorage> e
-+ // Paper start - moved above - Credit JellySquid for idea
-+ /*
- objectiterator = this.i.long2ObjectEntrySet().iterator();
-
- while (objectiterator.hasNext()) {
-@@ -295,7 +341,8 @@ public abstract class LightEngineStorage> e
- if (this.g(j)) {
- objectiterator.remove();
- }
-- }
-+ }*/
+ private void b(LightEngineLayer lightenginelayer, long i) {
+ if (this.g(i)) {
+- int j = SectionPosition.c(SectionPosition.b(i));
+- int k = SectionPosition.c(SectionPosition.c(i));
+- int l = SectionPosition.c(SectionPosition.d(i));
++ // Paper start
++ int secX = (int) (i >> 42);
++ int secY = (int) (i << 44 >> 44);
++ int secZ = (int) (i << 22 >> 42);
++ int j = secX << 4; // baseX
++ int k = secY << 4; // baseY
++ int l = secZ << 4; // baseZ
+ // Paper end
+ EnumDirection[] aenumdirection = LightEngineStorage.k;
+ int i1 = aenumdirection.length;
- }
- }
+ for (int j1 = 0; j1 < i1; ++j1) {
+ EnumDirection enumdirection = aenumdirection[j1];
+- long k1 = SectionPosition.a(i, enumdirection);
++ long k1 = SectionPosition.getAdjacentFromSectionPos(secX, secY, secZ, enumdirection); // Paper - avoid extra unpacking
+
+ if (!this.i.containsKey(k1) && this.g(k1)) {
+ for (int l1 = 0; l1 < 16; ++l1) {
diff --git a/src/main/java/net/minecraft/server/LightEngineStorageArray.java b/src/main/java/net/minecraft/server/LightEngineStorageArray.java
index 37c44a89f28c44915fcae5a7e2c4797b1c123723..549c2551c2b59730bf53a80f8706d388d96ad932 100644
--- a/src/main/java/net/minecraft/server/LightEngineStorageArray.java
@@ -1095,7 +1027,7 @@ index 097f58e9ac3f4096d3b9dad75b6ebe76021fa92c..f744f62c93370d096c113f92ee81a823
lightenginelayer.a(Long.MAX_VALUE, l3, 15, false);
}
diff --git a/src/main/java/net/minecraft/server/LightEngineThreaded.java b/src/main/java/net/minecraft/server/LightEngineThreaded.java
-index 8776799de033f02b0f87e9ea7e4a4ce912e94dd4..9ef39f1f51f9960865f6418115b08e8d7de86509 100644
+index a9dc8466278f9ec2becbcb643e6e1c973df72b82..968a1f71a44122ef0c4236d4251497f0b813d3b9 100644
--- a/src/main/java/net/minecraft/server/LightEngineThreaded.java
+++ b/src/main/java/net/minecraft/server/LightEngineThreaded.java
@@ -14,8 +14,98 @@ import org.apache.logging.log4j.Logger;
@@ -1211,7 +1143,7 @@ index 8776799de033f02b0f87e9ea7e4a4ce912e94dd4..9ef39f1f51f9960865f6418115b08e8d
@@ -111,8 +201,11 @@ public class LightEngineThreaded extends LightEngine implements AutoCloseable {
private void a(int i, int j, IntSupplier intsupplier, LightEngineThreaded.Update lightenginethreaded_update, Runnable runnable) {
- this.e.a(ChunkTaskQueueSorter.a(() -> { // Paper - decompile error
+ this.e.a(ChunkTaskQueueSorter.a(() -> {
- this.c.add(Pair.of(lightenginethreaded_update, runnable));
- if (this.c.size() >= this.f) {
+ // Paper start
@@ -1337,22 +1269,22 @@ index 8cedfdd820cc02a76607b53e0b054fc74654f907..a9795394c9b17f9f0ce4c4f9c8f51a48
private static final int nibbleBucketSizeMultiplier = Integer.getInteger("Paper.nibbleBucketSize", 3072);
private static final int maxPoolSize = Integer.getInteger("Paper.maxNibblePoolSize", (int) Math.min(6, Math.max(1, Runtime.getRuntime().maxMemory() / 1024 / 1024 / 1024)) * (nibbleBucketSizeMultiplier * 8));
diff --git a/src/main/java/net/minecraft/server/PlayerChunk.java b/src/main/java/net/minecraft/server/PlayerChunk.java
-index 69899c100dd86c6c4795013364472336327ce036..2edb4904d3071aa9de6517c375410b814a45cfbe 100644
+index 446c401b3139f8c6c0e70d883340f0140d94b752..a3bce8f13bf278af2d6870891daa9bf692b4e267 100644
--- a/src/main/java/net/minecraft/server/PlayerChunk.java
+++ b/src/main/java/net/minecraft/server/PlayerChunk.java
-@@ -728,6 +728,7 @@ public class PlayerChunk {
+@@ -716,6 +716,7 @@ public class PlayerChunk {
ioPriority = com.destroystokyo.paper.io.PrioritizedTaskQueue.HIGH_PRIORITY;
}
chunkMap.world.asyncChunkTaskManager.raisePriority(location.x, location.z, ioPriority);
+ chunkMap.world.getChunkProvider().getLightEngine().changePriority(location.pair(), getCurrentPriority(), priority);
}
if (getCurrentPriority() != priority) {
- this.w.a(this.location, this::getCurrentPriority, priority, this::setPriority); // use preferred priority
+ this.v.a(this.location, this::getCurrentPriority, priority, this::setPriority); // use preferred priority
diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java
-index 98adcb6390105a183d66975ed9659906b609ce08..201221df63d4ec8e704fee9126240891f2b1c37d 100644
+index e9703cee3b175b220917b83d80e9904b1af17abe..3b2c3d55ef7bd31d8562623fe40d76c9d4eee7c8 100644
--- a/src/main/java/net/minecraft/server/PlayerChunkMap.java
+++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java
-@@ -647,6 +647,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
+@@ -653,6 +653,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
// Paper end
}
@@ -1361,10 +1293,10 @@ index 98adcb6390105a183d66975ed9659906b609ce08..201221df63d4ec8e704fee9126240891
return () -> {
PlayerChunk playerchunk = this.getVisibleChunk(i);
diff --git a/src/main/java/net/minecraft/server/ThreadedMailbox.java b/src/main/java/net/minecraft/server/ThreadedMailbox.java
-index 8082569022384a3ba03fb4a6f1ae12b443598dcb..3db8073f5182fe4dd4c710b202afc323dfb9b2d2 100644
+index 35f4d2d9591e625ab0bbeab7b606761e74965eec..698d82dd736529a8cbfad5c6bed70ab97f0064bb 100644
--- a/src/main/java/net/minecraft/server/ThreadedMailbox.java
+++ b/src/main/java/net/minecraft/server/ThreadedMailbox.java
-@@ -93,7 +93,8 @@ public class ThreadedMailbox implements Mailbox, AutoCloseable, Runnable {
+@@ -109,7 +109,8 @@ public class ThreadedMailbox implements Mailbox, AutoCloseable, Runnable {
}
@@ -1375,10 +1307,10 @@ index 8082569022384a3ba03fb4a6f1ae12b443598dcb..3db8073f5182fe4dd4c710b202afc323
this.a.a(t0);
this.f();
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
-index 49da7352dcee6c352904cabe8b5db0152c427029..46e261b6513b52f5562387b661de4a409ea515a3 100644
+index b79302b83921111d5fa32794babf1fa57b7bbcb1..bed2cbabc0ac921bfdc4c6e4a04973a5411ebaa0 100644
--- a/src/main/java/net/minecraft/server/WorldServer.java
+++ b/src/main/java/net/minecraft/server/WorldServer.java
-@@ -685,6 +685,7 @@ public class WorldServer extends World {
+@@ -709,6 +709,7 @@ public class WorldServer extends World implements GeneratorAccessSeed {
}
gameprofilerfiller.exit();
timings.chunkTicksBlocks.stopTiming(); // Paper
diff --git a/Spigot-Server-Patches/0537-Delay-Chunk-Unloads-based-on-Player-Movement.patch b/Spigot-Server-Patches/0505-Delay-Chunk-Unloads-based-on-Player-Movement.patch
similarity index 90%
rename from Spigot-Server-Patches/0537-Delay-Chunk-Unloads-based-on-Player-Movement.patch
rename to Spigot-Server-Patches/0505-Delay-Chunk-Unloads-based-on-Player-Movement.patch
index 583c249a7..4738b38c7 100644
--- a/Spigot-Server-Patches/0537-Delay-Chunk-Unloads-based-on-Player-Movement.patch
+++ b/Spigot-Server-Patches/0505-Delay-Chunk-Unloads-based-on-Player-Movement.patch
@@ -17,10 +17,10 @@ This allows servers with smaller worlds who do less long distance exploring to s
wasting cpu cycles on saving/unloading/reloading chunks repeatedly.
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
-index c3f7717869c86d9ac6395615bceda324aea16b27..ecacb72b922927f06883b75e7d2cc1f904eb9f03 100644
+index 0746932a3191669052f15270f5c94efbce0bd0c2..0f4fca90fd6c3788a5762c96c344899cb1665466 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
-@@ -682,4 +682,13 @@ public class PaperWorldConfig {
+@@ -639,4 +639,13 @@ public class PaperWorldConfig {
private void viewDistance() {
this.noTickViewDistance = this.getInt("viewdistances.no-tick-view-distance", -1);
}
@@ -35,7 +35,7 @@ index c3f7717869c86d9ac6395615bceda324aea16b27..ecacb72b922927f06883b75e7d2cc1f9
+ }
}
diff --git a/src/main/java/net/minecraft/server/ChunkMapDistance.java b/src/main/java/net/minecraft/server/ChunkMapDistance.java
-index 35a4999b2c34ae62cba042885db25dd1837cb127..9a84d1749cf00316f1acadc55d45426267a94827 100644
+index 4c4108705e9d25912e57a7b3c28b4f1abad58377..893c0085bca0a8d77a85dba1cc29f2dec96c56ec 100644
--- a/src/main/java/net/minecraft/server/ChunkMapDistance.java
+++ b/src/main/java/net/minecraft/server/ChunkMapDistance.java
@@ -176,6 +176,27 @@ public abstract class ChunkMapDistance {
@@ -67,7 +67,7 @@ index 35a4999b2c34ae62cba042885db25dd1837cb127..9a84d1749cf00316f1acadc55d454262
if (arraysetsorted.isEmpty()) {
diff --git a/src/main/java/net/minecraft/server/Ticket.java b/src/main/java/net/minecraft/server/Ticket.java
-index 0d6e0f2ddaa85c04e626980591e9a78ac27fb42d..c79aa4a80a8a2288f7a50466abd677f388360ba1 100644
+index b5030d6f5d917ba33fb3c40903384fa7a56bc5f1..e41cb8613efc86499dfe3be36c9130ab6dc9b89e 100644
--- a/src/main/java/net/minecraft/server/Ticket.java
+++ b/src/main/java/net/minecraft/server/Ticket.java
@@ -9,11 +9,13 @@ public final class Ticket implements Comparable> {
@@ -84,13 +84,7 @@ index 0d6e0f2ddaa85c04e626980591e9a78ac27fb42d..c79aa4a80a8a2288f7a50466abd677f3
}
public int compareTo(Ticket> ticket) {
-@@ -57,12 +59,13 @@ public final class Ticket implements Comparable> {
- return this.b;
- }
-
-+ protected void setCurrentTick(long i) { a(i); } // Paper - OBFHELPER
- protected void a(long i) {
- this.d = i;
+@@ -63,7 +65,7 @@ public final class Ticket implements Comparable> {
}
protected boolean b(long i) {
diff --git a/Spigot-Server-Patches/0538-Add-Plugin-Tickets-to-API-Chunk-Methods.patch b/Spigot-Server-Patches/0506-Add-Plugin-Tickets-to-API-Chunk-Methods.patch
similarity index 89%
rename from Spigot-Server-Patches/0538-Add-Plugin-Tickets-to-API-Chunk-Methods.patch
rename to Spigot-Server-Patches/0506-Add-Plugin-Tickets-to-API-Chunk-Methods.patch
index 4ba303fea..7a51bfb67 100644
--- a/Spigot-Server-Patches/0538-Add-Plugin-Tickets-to-API-Chunk-Methods.patch
+++ b/Spigot-Server-Patches/0506-Add-Plugin-Tickets-to-API-Chunk-Methods.patch
@@ -22,10 +22,10 @@ wants it to collect even faster, they can restore that setting back to 1 instead
Not adding it to .getType() though to keep behavior consistent with vanilla for performance reasons.
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
-index 894917c8891a951edb251f019529d0f7bec7037d..568aefdf698facfc36edacc9332e83196c0d80bc 100644
+index 7c1e50e57cdb62364369455ca21b41456e8a010f..94005471723187cba438670a7e52363959ad4d02 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
-@@ -318,7 +318,7 @@ public final class CraftServer implements Server {
+@@ -342,7 +342,7 @@ public final class CraftServer implements Server {
ambientSpawn = configuration.getInt("spawn-limits.ambient");
console.autosavePeriod = configuration.getInt("ticks-per.autosave");
warningState = WarningState.value(configuration.getString("settings.deprecated-verbose"));
@@ -34,7 +34,7 @@ index 894917c8891a951edb251f019529d0f7bec7037d..568aefdf698facfc36edacc9332e8319
minimumAPI = configuration.getString("settings.minimum-api");
loadIcon();
}
-@@ -796,7 +796,7 @@ public final class CraftServer implements Server {
+@@ -819,7 +819,7 @@ public final class CraftServer implements Server {
waterAnimalSpawn = configuration.getInt("spawn-limits.water-animals");
ambientSpawn = configuration.getInt("spawn-limits.ambient");
warningState = WarningState.value(configuration.getString("settings.deprecated-verbose"));
@@ -44,10 +44,10 @@ index 894917c8891a951edb251f019529d0f7bec7037d..568aefdf698facfc36edacc9332e8319
printSaveWarning = false;
console.autosavePeriod = configuration.getInt("ticks-per.autosave");
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
-index 5992fdda8a5c66f77dbfca86d6261b98cce2b1e9..73ffc3c24d38c11982cb44bf0c08e761b9667cda 100644
+index 5ae74d0856f7fb4a7ee35e5d778d78fecaf99730..7096886c20e870061587860a663a184b21650246 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
-@@ -399,9 +399,22 @@ public class CraftWorld implements World {
+@@ -400,9 +400,22 @@ public class CraftWorld implements World {
@Override
public Chunk getChunkAt(int x, int z) {
@@ -71,7 +71,7 @@ index 5992fdda8a5c66f77dbfca86d6261b98cce2b1e9..73ffc3c24d38c11982cb44bf0c08e761
@Override
public Chunk getChunkAt(Block block) {
Preconditions.checkArgument(block != null, "null block");
-@@ -475,7 +488,7 @@ public class CraftWorld implements World {
+@@ -476,7 +489,7 @@ public class CraftWorld implements World {
public boolean unloadChunkRequest(int x, int z) {
org.spigotmc.AsyncCatcher.catchOp("chunk unload"); // Spigot
if (isChunkLoaded(x, z)) {
@@ -80,7 +80,7 @@ index 5992fdda8a5c66f77dbfca86d6261b98cce2b1e9..73ffc3c24d38c11982cb44bf0c08e761
}
return true;
-@@ -552,10 +565,12 @@ public class CraftWorld implements World {
+@@ -553,10 +566,12 @@ public class CraftWorld implements World {
org.spigotmc.AsyncCatcher.catchOp("chunk load"); // Spigot
// Paper start - Optimize this method
ChunkCoordIntPair chunkPos = new ChunkCoordIntPair(x, z);
@@ -94,7 +94,7 @@ index 5992fdda8a5c66f77dbfca86d6261b98cce2b1e9..73ffc3c24d38c11982cb44bf0c08e761
if (immediate == null) {
immediate = world.getChunkProvider().playerChunkMap.getUnloadingChunk(x, z);
}
-@@ -563,7 +578,7 @@ public class CraftWorld implements World {
+@@ -564,7 +579,7 @@ public class CraftWorld implements World {
if (!(immediate instanceof ProtoChunkExtension) && !(immediate instanceof net.minecraft.server.Chunk)) {
return false; // not full status
}
@@ -103,7 +103,7 @@ index 5992fdda8a5c66f77dbfca86d6261b98cce2b1e9..73ffc3c24d38c11982cb44bf0c08e761
world.getChunkAt(x, z); // make sure we're at ticket level 32 or lower
return true;
}
-@@ -590,7 +605,7 @@ public class CraftWorld implements World {
+@@ -591,7 +606,7 @@ public class CraftWorld implements World {
// we do this so we do not re-read the chunk data on disk
}
@@ -112,7 +112,7 @@ index 5992fdda8a5c66f77dbfca86d6261b98cce2b1e9..73ffc3c24d38c11982cb44bf0c08e761
world.getChunkProvider().getChunkAt(x, z, ChunkStatus.FULL, true);
return true;
// Paper end
-@@ -2489,6 +2504,7 @@ public class CraftWorld implements World {
+@@ -2492,6 +2507,7 @@ public class CraftWorld implements World {
}
return this.world.getChunkProvider().getChunkAtAsynchronously(x, z, gen, urgent).thenComposeAsync((either) -> {
net.minecraft.server.Chunk chunk = (net.minecraft.server.Chunk) either.left().orElse(null);
diff --git a/Spigot-Server-Patches/0506-Fix-CraftServer.unloadWorld-Leak.patch b/Spigot-Server-Patches/0506-Fix-CraftServer.unloadWorld-Leak.patch
deleted file mode 100644
index fb1455d4f..000000000
--- a/Spigot-Server-Patches/0506-Fix-CraftServer.unloadWorld-Leak.patch
+++ /dev/null
@@ -1,124 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Aikar
-Date: Fri, 8 May 2020 20:30:58 -0400
-Subject: [PATCH] Fix CraftServer.unloadWorld Leak
-
-The dimension manager was still registered which leaked the entire World
-
-diff --git a/src/main/java/net/minecraft/server/DimensionManager.java b/src/main/java/net/minecraft/server/DimensionManager.java
-index 393bc4dc700bbf8653db0662c7957f676b0a647a..410ab224fbb05bfbf4aa847d69b150bfe75d32f6 100644
---- a/src/main/java/net/minecraft/server/DimensionManager.java
-+++ b/src/main/java/net/minecraft/server/DimensionManager.java
-@@ -20,6 +20,15 @@ public class DimensionManager implements MinecraftSerializable {
- private final boolean hasSkyLight;
- private final GenLayerZoomer genLayerZoomer;
-
-+ // Paper start
-+ public static void unregister(String s, DimensionManager dimensionmanager) {
-+ if (dimensionmanager == OVERWORLD || dimensionmanager == NETHER || dimensionmanager == THE_END) { return; } // do not unregister the default worlds
-+ MCUtil.MAIN_EXECUTOR.execute(() -> {
-+ RegistryMaterials registry = (RegistryMaterials) IRegistry.DIMENSION_TYPE;
-+ registry.deleteValue(new MinecraftKey(s), dimensionmanager);
-+ });
-+ }
-+ // Paper end
- public static DimensionManager register(String s, DimensionManager dimensionmanager) {
- return (DimensionManager) IRegistry.a(IRegistry.DIMENSION_TYPE, dimensionmanager.id, s, dimensionmanager);
- }
-diff --git a/src/main/java/net/minecraft/server/RegistryID.java b/src/main/java/net/minecraft/server/RegistryID.java
-index e8a48b9a4c999281869dfb85577c2b44d6e30eb7..5335e7acc85f0fe9699e5ed59e5aaae5f381347d 100644
---- a/src/main/java/net/minecraft/server/RegistryID.java
-+++ b/src/main/java/net/minecraft/server/RegistryID.java
-@@ -9,12 +9,26 @@ import javax.annotation.Nullable;
- public class RegistryID implements Registry {
-
- private static final Object a = null;
-- private K[] b;
-+ private K[] b; // Paper - diff below
- private int[] c;
-- private K[] d;
-+ private K[] d; // Paper - diff below
- private int e;
- private int f;
- private java.util.BitSet usedIds; // Paper
-+ // Paper start
-+ public void removeValue(K value) {
-+ removeValue(value, this.b);
-+ removeValue(value, this.d);
-+ rehash(this.b.length);
-+ }
-+ public void removeValue(K value, K[] arr) {
-+ for (int i = 0; i < arr.length; i++) {
-+ K k = arr[i];
-+ if (k == value) {
-+ arr[i] = null;
-+ }
-+ }
-+ }
-
- public RegistryID(int i) {
- i = (int) ((float) i / 0.8F);
-@@ -58,6 +72,7 @@ public class RegistryID implements Registry {
- return this.e;
- }
-
-+ private void rehash(int i) { d(i); } // Paper - OBFHELPER
- private void d(int i) {
- K[] ak = this.b;
- int[] aint = this.c;
-diff --git a/src/main/java/net/minecraft/server/RegistryMaterials.java b/src/main/java/net/minecraft/server/RegistryMaterials.java
-index 8477febca23b575da21023b4d7c18bb679cf3b30..dcdd8d38dee89ae7ac404a431e51a61c50b6d45c 100644
---- a/src/main/java/net/minecraft/server/RegistryMaterials.java
-+++ b/src/main/java/net/minecraft/server/RegistryMaterials.java
-@@ -22,18 +22,23 @@ public class RegistryMaterials extends IRegistryWritable {
- private int V;
-
- public RegistryMaterials() {}
-+ public T deleteValue(MinecraftKey minecraftkey, T value) {
-+ this.b.removeValue(value); // Diff 1
-+ this.d = null; // Diff 2
-+ return this.c.remove(minecraftkey); // Diff 3
-+ }
-
- @Override
- public V a(int i, MinecraftKey minecraftkey, V v0) {
-- this.b.a(v0, i);
-+ this.b.a(v0, i); // Paper - diff above 1
- Validate.notNull(minecraftkey);
- Validate.notNull(v0);
-- this.d = null;
-+ this.d = null; // Diff 2
- if (this.c.containsKey(minecraftkey)) {
- RegistryMaterials.LOGGER.debug("Adding duplicate key '{}' to registry", minecraftkey);
- }
-
-- this.c.put(minecraftkey, v0);
-+ this.c.put(minecraftkey, v0); // Paper - diff3
- if (this.V <= i) {
- this.V = i + 1;
- }
-diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
-index b89f99a66fe2ab9ad4c956c38c9e4b1d79716c9c..c2b7cb36052455eef2100a1924dc76a5921fa858 100644
---- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
-+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
-@@ -60,6 +60,7 @@ import net.minecraft.server.EntityPlayer;
- import net.minecraft.server.EnumDifficulty;
- import net.minecraft.server.EnumGamemode;
- import net.minecraft.server.IRecipe;
-+import net.minecraft.server.IRegistry;
- import net.minecraft.server.Item;
- import net.minecraft.server.ItemWorldMap;
- import net.minecraft.server.Items;
-@@ -1099,7 +1100,11 @@ public final class CraftServer implements Server {
- }
-
- worlds.remove(world.getName().toLowerCase(java.util.Locale.ENGLISH));
-- console.worldServer.remove(handle.getWorldProvider().getDimensionManager());
-+ // Paper start
-+ DimensionManager dimensionManager = handle.getWorldProvider().getDimensionManager();
-+ DimensionManager.unregister(world.getName().toLowerCase(java.util.Locale.ENGLISH), dimensionManager);
-+ console.worldServer.remove(dimensionManager);
-+ // Paper end
- return true;
- }
-
diff --git a/Spigot-Server-Patches/0539-Fix-missing-chunks-due-to-integer-overflow.patch b/Spigot-Server-Patches/0507-Fix-missing-chunks-due-to-integer-overflow.patch
similarity index 90%
rename from Spigot-Server-Patches/0539-Fix-missing-chunks-due-to-integer-overflow.patch
rename to Spigot-Server-Patches/0507-Fix-missing-chunks-due-to-integer-overflow.patch
index 3bea36db8..7554af844 100644
--- a/Spigot-Server-Patches/0539-Fix-missing-chunks-due-to-integer-overflow.patch
+++ b/Spigot-Server-Patches/0507-Fix-missing-chunks-due-to-integer-overflow.patch
@@ -13,10 +13,10 @@ The fix for the issue is quite simple, casting chunk coordinates to longs
allows the distance calculation to avoid overflow and work as intended.
diff --git a/src/main/java/net/minecraft/server/WorldChunkManagerTheEnd.java b/src/main/java/net/minecraft/server/WorldChunkManagerTheEnd.java
-index 985f54067073909f413a0c9bb574017bf6d177f3..1ba0f43702b6c576fa9251bef574b7d52406f2f1 100644
+index 3abf1a61dfdb89c6df9338bc4947a64be5c91e2f..631a028dd262476f257c382f488320fee42584cd 100644
--- a/src/main/java/net/minecraft/server/WorldChunkManagerTheEnd.java
+++ b/src/main/java/net/minecraft/server/WorldChunkManagerTheEnd.java
-@@ -36,7 +36,9 @@ public class WorldChunkManagerTheEnd extends WorldChunkManager {
+@@ -50,7 +50,9 @@ public class WorldChunkManagerTheEnd extends WorldChunkManager {
int l = j / 2;
int i1 = i % 2;
int j1 = j % 2;
diff --git a/Spigot-Server-Patches/0540-Fix-CraftScheduler-runTaskTimerAsynchronously-Plugin.patch b/Spigot-Server-Patches/0508-Fix-CraftScheduler-runTaskTimerAsynchronously-Plugin.patch
similarity index 100%
rename from Spigot-Server-Patches/0540-Fix-CraftScheduler-runTaskTimerAsynchronously-Plugin.patch
rename to Spigot-Server-Patches/0508-Fix-CraftScheduler-runTaskTimerAsynchronously-Plugin.patch
diff --git a/Spigot-Server-Patches/0541-Fix-piston-physics-inconsistency-MC-188840.patch b/Spigot-Server-Patches/0509-Fix-piston-physics-inconsistency-MC-188840.patch
similarity index 84%
rename from Spigot-Server-Patches/0541-Fix-piston-physics-inconsistency-MC-188840.patch
rename to Spigot-Server-Patches/0509-Fix-piston-physics-inconsistency-MC-188840.patch
index 91358261d..8e81d5690 100644
--- a/Spigot-Server-Patches/0541-Fix-piston-physics-inconsistency-MC-188840.patch
+++ b/Spigot-Server-Patches/0509-Fix-piston-physics-inconsistency-MC-188840.patch
@@ -32,10 +32,10 @@ This patch fixes https://bugs.mojang.com/browse/MC-188840
This patch also fixes rail duping and carpet duping.
diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java
-index f0284e81db3ab7c45018de2b446f2d8296df15c3..8444819f071b13e98ba07032520016a664b7b9bc 100644
+index 08f744ee5e83d317f872f9c48e2037a24327d76f..f9831b1ac15c9fa08c7201a43fe9f1824ddc03c3 100644
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
-@@ -442,4 +442,9 @@ public class PaperConfig {
+@@ -421,4 +421,9 @@ public class PaperConfig {
consoleHasAllPermissions = getBoolean("settings.console-has-all-permissions", consoleHasAllPermissions);
}
@@ -46,10 +46,10 @@ index f0284e81db3ab7c45018de2b446f2d8296df15c3..8444819f071b13e98ba07032520016a6
+ }
}
diff --git a/src/main/java/net/minecraft/server/BlockPiston.java b/src/main/java/net/minecraft/server/BlockPiston.java
-index 39cd8ab5925ceb9494e0ac910c73338c24ecda2c..73ac83832121e0390b7c4649681fc247e3d8c30b 100644
+index 6b1253fe7e8d4bb71d4d19c063d3e84c167c4d7b..0fb6debc0cd5f522614f32f3df1b5f37a415a0f5 100644
--- a/src/main/java/net/minecraft/server/BlockPiston.java
+++ b/src/main/java/net/minecraft/server/BlockPiston.java
-@@ -376,12 +376,24 @@ public class BlockPiston extends BlockDirectional {
+@@ -368,12 +368,24 @@ public class BlockPiston extends BlockDirectional {
}
for (k = list.size() - 1; k >= 0; --k) {
@@ -63,25 +63,24 @@ index 39cd8ab5925ceb9494e0ac910c73338c24ecda2c..73ac83832121e0390b7c4649681fc247
blockposition3 = blockposition3.shift(enumdirection1);
map.remove(blockposition3);
world.setTypeAndData(blockposition3, (IBlockData) Blocks.MOVING_PISTON.getBlockData().set(BlockPiston.FACING, enumdirection), 68);
-- world.setTileEntity(blockposition3, BlockPistonMoving.a((IBlockData) list1.get(k), enumdirection, flag, false));
+ // Paper start - fix a variety of piston desync dupes
+ if (!allowDesync) {
+ iblockdata1 = world.getType(oldPos);
+ map.replace(oldPos, iblockdata1);
+ }
-+ world.setTileEntity(blockposition3, BlockPistonMoving.a(allowDesync ? list1.get(k) : iblockdata1, enumdirection, flag, false));
+ world.setTileEntity(blockposition3, BlockPistonMoving.a((IBlockData) list1.get(k), enumdirection, flag, false));
+ if (!allowDesync) {
+ world.setTypeAndData(oldPos, Blocks.AIR.getBlockData(), 2 | 4 | 16 | 1024); // set air to prevent later physics updates from seeing this block
+ }
+ // Paper end - fix a variety of piston desync dupes
- --j;
- aiblockdata[j] = iblockdata1;
+ aiblockdata[j++] = iblockdata1;
}
+
diff --git a/src/main/java/net/minecraft/server/TileEntityPiston.java b/src/main/java/net/minecraft/server/TileEntityPiston.java
-index 489175abd8e582a3c082364fec357c4f061a22d7..d700e8281fe50b1c4131ac260ff6c0d0dd8412f0 100644
+index 5b941321a7fdc561e6b794a1dce5d600083c505d..e7b7e468fc874b0fbcd43f87d816a42420f9b05e 100644
--- a/src/main/java/net/minecraft/server/TileEntityPiston.java
+++ b/src/main/java/net/minecraft/server/TileEntityPiston.java
-@@ -275,7 +275,7 @@ public class TileEntityPiston extends TileEntity implements ITickable {
+@@ -256,7 +256,7 @@ public class TileEntityPiston extends TileEntity implements ITickable {
IBlockData iblockdata = Block.b(this.a, (GeneratorAccess) this.world, this.position);
if (iblockdata.isAir()) {
@@ -89,4 +88,4 @@ index 489175abd8e582a3c082364fec357c4f061a22d7..d700e8281fe50b1c4131ac260ff6c0d0
+ this.world.setTypeAndData(this.position, this.a, com.destroystokyo.paper.PaperConfig.allowPistonDuplication ? 84 : (84 | 2)); // Paper - force notify (flag 2), it's possible the set type by the piston block (which doesn't notify) set this block to air
Block.a(this.a, iblockdata, this.world, this.position, 3);
} else {
- if (iblockdata.b((IBlockState) BlockProperties.C) && (Boolean) iblockdata.get(BlockProperties.C)) {
+ if (iblockdata.b(BlockProperties.C) && (Boolean) iblockdata.get(BlockProperties.C)) {
diff --git a/Spigot-Server-Patches/0509-MC-183249-Don-t-generate-Carving-Masks-BitSet-unless.patch b/Spigot-Server-Patches/0509-MC-183249-Don-t-generate-Carving-Masks-BitSet-unless.patch
deleted file mode 100644
index 613fea34f..000000000
--- a/Spigot-Server-Patches/0509-MC-183249-Don-t-generate-Carving-Masks-BitSet-unless.patch
+++ /dev/null
@@ -1,43 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Aikar
-Date: Sat, 9 May 2020 12:11:47 -0400
-Subject: [PATCH] MC-183249: Don't generate Carving Masks BitSet unless needed
-
-This was using SIGNIFICANT amounts of memory allocating many
-long[]'s for BitSets for every ProtoChunk in the cache that had
-been unloaded and reloaded.
-
-This will result in a nice memory reduction.
-
-diff --git a/src/main/java/net/minecraft/server/ChunkRegionLoader.java b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
-index fa893b14bcef9bab6891dea2c4375b09d74ac038..e625842e524f18e469f7695b27d52d4d04892266 100644
---- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java
-+++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
-@@ -472,7 +472,12 @@ public class ChunkRegionLoader {
- for (int l = 0; l < k; ++l) {
- WorldGenStage.Features worldgenstage_features = aworldgenstage_features[l];
-
-- nbttagcompound3.setByteArray(worldgenstage_features.toString(), ichunkaccess.a(worldgenstage_features).toByteArray());
-+ // Paper start - don't create carving mask bitsets if not even at that chunk status yet
-+ BitSet mask = protochunk.getCarvingMaskIfSet(worldgenstage_features);
-+ if (mask != null) {
-+ nbttagcompound3.setByteArray(worldgenstage_features.toString(), mask.toByteArray());
-+ }
-+ // Paper end
- }
-
- nbttagcompound1.set("CarvingMasks", nbttagcompound3);
-diff --git a/src/main/java/net/minecraft/server/ProtoChunk.java b/src/main/java/net/minecraft/server/ProtoChunk.java
-index a78b240621e0407fff67b018224c39fc4f97f4e5..2eb14bbf888f5e5601441743cb7642da6ee1249c 100644
---- a/src/main/java/net/minecraft/server/ProtoChunk.java
-+++ b/src/main/java/net/minecraft/server/ProtoChunk.java
-@@ -43,7 +43,8 @@ public class ProtoChunk implements IChunkAccess {
- private final ProtoChunkTickList q;
- private final ProtoChunkTickList r;
- private long s;
-- private final Map t;
-+ private final Map t;public BitSet getCarvingMaskIfSet(WorldGenStage.Features worldgenstage_features) { return this.t.get(worldgenstage_features); } // Paper
-+ // Paper end
- private volatile boolean u;
- private final World world; // Paper - Anti-Xray - Add world
-
diff --git a/Spigot-Server-Patches/0542-Fix-sand-duping.patch b/Spigot-Server-Patches/0510-Fix-sand-duping.patch
similarity index 94%
rename from Spigot-Server-Patches/0542-Fix-sand-duping.patch
rename to Spigot-Server-Patches/0510-Fix-sand-duping.patch
index a42ac1b7f..6cf9476b0 100644
--- a/Spigot-Server-Patches/0542-Fix-sand-duping.patch
+++ b/Spigot-Server-Patches/0510-Fix-sand-duping.patch
@@ -7,7 +7,7 @@ If the falling block dies during teleportation (entity#move), then we need
to detect that by placing a check after the move.
diff --git a/src/main/java/net/minecraft/server/EntityFallingBlock.java b/src/main/java/net/minecraft/server/EntityFallingBlock.java
-index 6683f7c5f31b88187961335c5f708b8a4f77b5af..243a8c570dd7cc5b1b622ff130c7339f9bcfc79a 100644
+index 40ab0a1e5b8e31f1ef3b2444366784a65f034341..6697b94550054ebbc8d4b3761bd9f36eb7e4ba8a 100644
--- a/src/main/java/net/minecraft/server/EntityFallingBlock.java
+++ b/src/main/java/net/minecraft/server/EntityFallingBlock.java
@@ -64,6 +64,11 @@ public class EntityFallingBlock extends Entity {
diff --git a/Spigot-Server-Patches/0543-Prevent-position-desync-in-playerconnection-causing-.patch b/Spigot-Server-Patches/0511-Prevent-position-desync-in-playerconnection-causing-.patch
similarity index 86%
rename from Spigot-Server-Patches/0543-Prevent-position-desync-in-playerconnection-causing-.patch
rename to Spigot-Server-Patches/0511-Prevent-position-desync-in-playerconnection-causing-.patch
index b5b0331a0..faf47ee8f 100644
--- a/Spigot-Server-Patches/0543-Prevent-position-desync-in-playerconnection-causing-.patch
+++ b/Spigot-Server-Patches/0511-Prevent-position-desync-in-playerconnection-causing-.patch
@@ -14,10 +14,10 @@ behaviour, we need to move all of this dangerous logic outside
of the move call and into an appropriate place in the tick method.
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
-index f9cb87a3be35575ecf3362b10dc7fe5ebadb56ec..2109afc8ca0af636be2d7e7c041e3160448f4a38 100644
+index e34290011bb5d7bcfb677b70fdec1a525a082e0e..bcb0ea6704b185a41f92d6cab24e4cf4ff91ebbc 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
-@@ -1080,6 +1080,11 @@ public class PlayerConnection implements PacketListenerPlayIn {
+@@ -1097,6 +1097,11 @@ public class PlayerConnection implements PacketListenerPlayIn {
}
this.player.move(EnumMoveType.PLAYER, new Vec3D(d7, d8, d9));
@@ -26,6 +26,6 @@ index f9cb87a3be35575ecf3362b10dc7fe5ebadb56ec..2109afc8ca0af636be2d7e7c041e3160
+ return; // ... thanks Mojang for letting move calls teleport across dimensions.
+ }
+ // Paper end - prevent position desync
- this.player.onGround = packetplayinflying.b();
double d12 = d8;
+ d7 = d4 - this.player.locX();
diff --git a/Spigot-Server-Patches/0512-Fix-enderdragon-exp-dupe.patch b/Spigot-Server-Patches/0512-Fix-enderdragon-exp-dupe.patch
new file mode 100644
index 000000000..9fcd5db58
--- /dev/null
+++ b/Spigot-Server-Patches/0512-Fix-enderdragon-exp-dupe.patch
@@ -0,0 +1,28 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Spottedleaf
+Date: Fri, 12 Jun 2020 22:25:11 -0700
+Subject: [PATCH] Fix enderdragon exp dupe
+
+Properly track death stage when unloading/loading in the
+dragon
+
+diff --git a/src/main/java/net/minecraft/server/EntityEnderDragon.java b/src/main/java/net/minecraft/server/EntityEnderDragon.java
+index 43e3755f0fa75b5f72ec620f3f6647ef6bce38c5..3a37e481729abc890cb2f9884b8501f630c3cf32 100644
+--- a/src/main/java/net/minecraft/server/EntityEnderDragon.java
++++ b/src/main/java/net/minecraft/server/EntityEnderDragon.java
+@@ -830,6 +830,7 @@ public class EntityEnderDragon extends EntityInsentient implements IMonster {
+ public void saveData(NBTTagCompound nbttagcompound) {
+ super.saveData(nbttagcompound);
+ nbttagcompound.setInt("DragonPhase", this.bN.a().getControllerPhase().b());
++ nbttagcompound.setInt("Paper.DeathTick", this.deathAnimationTicks); // Paper
+ }
+
+ @Override
+@@ -838,6 +839,7 @@ public class EntityEnderDragon extends EntityInsentient implements IMonster {
+ if (nbttagcompound.hasKey("DragonPhase")) {
+ this.bN.setControllerPhase(DragonControllerPhase.getById(nbttagcompound.getInt("DragonPhase")));
+ }
++ this.deathAnimationTicks = nbttagcompound.getInt("Paper.DeathTick"); // Paper
+
+ }
+
diff --git a/Spigot-Server-Patches/0545-Inventory-getHolder-method-without-block-snapshot.patch b/Spigot-Server-Patches/0513-Inventory-getHolder-method-without-block-snapshot.patch
similarity index 92%
rename from Spigot-Server-Patches/0545-Inventory-getHolder-method-without-block-snapshot.patch
rename to Spigot-Server-Patches/0513-Inventory-getHolder-method-without-block-snapshot.patch
index 24e430cfb..5ea9d7c29 100644
--- a/Spigot-Server-Patches/0545-Inventory-getHolder-method-without-block-snapshot.patch
+++ b/Spigot-Server-Patches/0513-Inventory-getHolder-method-without-block-snapshot.patch
@@ -5,10 +5,10 @@ Subject: [PATCH] Inventory getHolder method without block snapshot
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java
-index 47827fbf1b80f88ffff8a252df10d70758c68703..57858327a4909fe536724371ac25f1cdede8c885 100644
+index a04213325b8266623b076f1233539512a0a0207f..726631348243566654d08abe9b5bf4ab3a2885f9 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java
-@@ -519,6 +519,13 @@ public class CraftInventory implements Inventory {
+@@ -521,6 +521,13 @@ public class CraftInventory implements Inventory {
return inventory.getOwner();
}
diff --git a/Spigot-Server-Patches/0546-Expose-Arrow-getItemStack.patch b/Spigot-Server-Patches/0514-Expose-Arrow-getItemStack.patch
similarity index 83%
rename from Spigot-Server-Patches/0546-Expose-Arrow-getItemStack.patch
rename to Spigot-Server-Patches/0514-Expose-Arrow-getItemStack.patch
index 0d64b1dda..36652f251 100644
--- a/Spigot-Server-Patches/0546-Expose-Arrow-getItemStack.patch
+++ b/Spigot-Server-Patches/0514-Expose-Arrow-getItemStack.patch
@@ -5,10 +5,10 @@ Subject: [PATCH] Expose Arrow getItemStack
diff --git a/src/main/java/net/minecraft/server/EntityArrow.java b/src/main/java/net/minecraft/server/EntityArrow.java
-index 9c97edf9c9e9a8cdf029264f6b563090142c686b..e66f6b30069af5b9031c7c78a2bb3d3a645034c0 100644
+index c552962a9a2c8dac6794ef6698943c7d91ea45c4..6195a45e30d9a9d76e24fbc2493020917a8b87b9 100644
--- a/src/main/java/net/minecraft/server/EntityArrow.java
+++ b/src/main/java/net/minecraft/server/EntityArrow.java
-@@ -556,6 +556,8 @@ public abstract class EntityArrow extends Entity implements IProjectile {
+@@ -520,6 +520,8 @@ public abstract class EntityArrow extends IProjectile {
}
}
@@ -18,7 +18,7 @@ index 9c97edf9c9e9a8cdf029264f6b563090142c686b..e66f6b30069af5b9031c7c78a2bb3d3a
@Override
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java
-index 228e1327ca8821cc7e1542d2c09cdeb3365024a5..27897182559044d7079953e302ecfaa67918536a 100644
+index cf40d62492dc207815487d6f64e7d11892adc09b..5a0a78d7edead8712090dfb9c53ff904abf5b118 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java
@@ -102,6 +102,13 @@ public class CraftArrow extends AbstractProjectile implements AbstractArrow {
diff --git a/Spigot-Server-Patches/0547-Add-and-implement-PlayerRecipeBookClickEvent.patch b/Spigot-Server-Patches/0515-Add-and-implement-PlayerRecipeBookClickEvent.patch
similarity index 92%
rename from Spigot-Server-Patches/0547-Add-and-implement-PlayerRecipeBookClickEvent.patch
rename to Spigot-Server-Patches/0515-Add-and-implement-PlayerRecipeBookClickEvent.patch
index 13f7bfcdf..d7f11254f 100644
--- a/Spigot-Server-Patches/0547-Add-and-implement-PlayerRecipeBookClickEvent.patch
+++ b/Spigot-Server-Patches/0515-Add-and-implement-PlayerRecipeBookClickEvent.patch
@@ -5,10 +5,10 @@ Subject: [PATCH] Add and implement PlayerRecipeBookClickEvent
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
-index 2109afc8ca0af636be2d7e7c041e3160448f4a38..10e3bf60f13fbc8e26071bcfe8d19cbb635662a9 100644
+index bcb0ea6704b185a41f92d6cab24e4cf4ff91ebbc..92802301e420da4eb64b0d942f914ee30c9b784b 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
-@@ -2476,9 +2476,15 @@ public class PlayerConnection implements PacketListenerPlayIn {
+@@ -2515,9 +2515,15 @@ public class PlayerConnection implements PacketListenerPlayIn {
PlayerConnectionUtils.ensureMainThread(packetplayinautorecipe, this, this.player.getWorldServer());
this.player.resetIdleTimer();
if (!this.player.isSpectator() && this.player.activeContainer.windowId == packetplayinautorecipe.b() && this.player.activeContainer.c(this.player) && this.player.activeContainer instanceof ContainerRecipeBook) {
diff --git a/Spigot-Server-Patches/0548-Add-PrepareGrindstoneEvent.patch b/Spigot-Server-Patches/0516-Add-PrepareGrindstoneEvent.patch
similarity index 93%
rename from Spigot-Server-Patches/0548-Add-PrepareGrindstoneEvent.patch
rename to Spigot-Server-Patches/0516-Add-PrepareGrindstoneEvent.patch
index f0a00ab8e..a6c0e1687 100644
--- a/Spigot-Server-Patches/0548-Add-PrepareGrindstoneEvent.patch
+++ b/Spigot-Server-Patches/0516-Add-PrepareGrindstoneEvent.patch
@@ -5,7 +5,7 @@ Subject: [PATCH] Add PrepareGrindstoneEvent
diff --git a/src/main/java/net/minecraft/server/ContainerGrindstone.java b/src/main/java/net/minecraft/server/ContainerGrindstone.java
-index ed88e208d00f3b19b5c5916cf87513ab511a5fb1..83cb0cd64c81eb35fa49eecff93b40f08e0a5606 100644
+index fe9a083b724a8657cac8462b3f44d3cc12a4db58..716304021f85a86a2f9492f5fb98e86bb7f089d2 100644
--- a/src/main/java/net/minecraft/server/ContainerGrindstone.java
+++ b/src/main/java/net/minecraft/server/ContainerGrindstone.java
@@ -10,6 +10,10 @@ import org.bukkit.craftbukkit.inventory.CraftInventoryGrindstone;
diff --git a/Spigot-Server-Patches/0529-Optimize-sending-packets-to-nearby-locations-sounds-.patch b/Spigot-Server-Patches/0529-Optimize-sending-packets-to-nearby-locations-sounds-.patch
deleted file mode 100644
index c15c5465f..000000000
--- a/Spigot-Server-Patches/0529-Optimize-sending-packets-to-nearby-locations-sounds-.patch
+++ /dev/null
@@ -1,73 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Aikar
-Date: Sat, 23 May 2020 17:03:41 -0400
-Subject: [PATCH] Optimize sending packets to nearby locations (sounds/effects)
-
-Instead of using the entire world or player list, use the distance
-maps to only iterate players who are even seeing the chunk the packet
-is originating from.
-
-This will drastically cut down on packet sending cost for worlds with
-lots of players in them.
-
-diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java
-index f0fe864026dc10cd809f06dc9d4e823c21494a8d..5b634f2385f6dbb62cf3884daabded3870e8b8cc 100644
---- a/src/main/java/net/minecraft/server/PlayerList.java
-+++ b/src/main/java/net/minecraft/server/PlayerList.java
-@@ -1031,11 +1031,30 @@ public abstract class PlayerList {
- world = (WorldServer) entityhuman.world;
- }
-
-- List extends EntityHuman> players1 = world == null ? players : world.players;
-- for (int j = 0; j < players1.size(); ++j) {
-- EntityHuman entity = players1.get(j);
-- if (!(entity instanceof EntityPlayer)) continue;
-- EntityPlayer entityplayer = (EntityPlayer) entity;
-+ // Paper start
-+ if ((world == null || world.chunkProvider == null) && dimensionmanager != null) {
-+ world = dimensionmanager.world;
-+ }
-+ if (world == null) {
-+ LOGGER.error("Sending packet to invalid world" + entityhuman + " " + dimensionmanager + " - " + packet.getClass().getName(), new Throwable());
-+ return; // ??? shouldn't happen...
-+ }
-+ PlayerChunkMap chunkMap = world.chunkMap;
-+ Object[] backingSet;
-+ if (chunkMap == null) {
-+ // Really shouldn't happen...
-+ backingSet = world.players.toArray();
-+ } else {
-+ com.destroystokyo.paper.util.misc.PooledLinkedHashSets.PooledObjectLinkedOpenHashSet nearbyPlayers = chunkMap.playerViewDistanceBroadcastMap.getObjectsInRange(MCUtil.fastFloor(d0) >> 4, MCUtil.fastFloor(d2) >> 4);
-+ if (nearbyPlayers == null) {
-+ return;
-+ }
-+ backingSet = nearbyPlayers.getBackingSet();
-+ }
-+
-+ for (Object object : backingSet) {
-+ if (!(object instanceof EntityPlayer)) continue;
-+ EntityPlayer entityplayer = (EntityPlayer) object;
- // Paper end
-
- // CraftBukkit start - Test if player receiving packet can see the source of the packet
-diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
-index aaf85a1497de98522e3a01d4f81a267c4b0cc087..2c9acffe5a62af43ff4f4ccdb6962929d645e226 100644
---- a/src/main/java/net/minecraft/server/WorldServer.java
-+++ b/src/main/java/net/minecraft/server/WorldServer.java
-@@ -70,6 +70,7 @@ public class WorldServer extends World {
- }
- }
- // Paper end
-+ public final PlayerChunkMap chunkMap; // Paper
- private final MinecraftServer server;
- private final WorldNBTStorage dataManager;
- public boolean savingDisabled;
-@@ -208,6 +209,8 @@ public class WorldServer extends World {
- }, gameprofilerfiller, false, gen, env);
- this.pvpMode = minecraftserver.getPVP();
- worlddata.world = this;
-+ if (chunkProvider == null) { chunkMap = null; new Throwable("World created without a ChunkProvider!").printStackTrace(); } // Paper - figure out if something weird happened here
-+ else chunkMap = ((ChunkProviderServer) chunkProvider).playerChunkMap;
- // CraftBukkit end
- if (com.destroystokyo.paper.PaperConfig.useOptimizedTickList) {
- this.nextTickListBlock = new com.destroystokyo.paper.server.ticklist.PaperTickList<>(this, (block) -> { // Paper - optimise TickListServer
diff --git a/Spigot-Server-Patches/0544-Fix-enderdragon-exp-dupe.patch b/Spigot-Server-Patches/0544-Fix-enderdragon-exp-dupe.patch
deleted file mode 100644
index f37907b17..000000000
--- a/Spigot-Server-Patches/0544-Fix-enderdragon-exp-dupe.patch
+++ /dev/null
@@ -1,37 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Spottedleaf
-Date: Fri, 12 Jun 2020 22:25:11 -0700
-Subject: [PATCH] Fix enderdragon exp dupe
-
-Properly track death stage when unloading/loading in the
-dragon
-
-diff --git a/src/main/java/net/minecraft/server/EntityEnderDragon.java b/src/main/java/net/minecraft/server/EntityEnderDragon.java
-index aecdaacfc7da560759bc513680d76f55820d5046..7daebfdab5c6e258d3e426643c0dbd374774ff5d 100644
---- a/src/main/java/net/minecraft/server/EntityEnderDragon.java
-+++ b/src/main/java/net/minecraft/server/EntityEnderDragon.java
-@@ -33,7 +33,7 @@ public class EntityEnderDragon extends EntityInsentient implements IMonster {
- public float bx;
- public float by;
- public boolean bz;
-- public int bA;
-+ public int bA; public final int getDeathTicks() { return this.bA; } public final void setDeathTicks(final int value) { this.bA = value; } // Paper
- public float bB;
- @Nullable
- public EntityEnderCrystal currentEnderCrystal;
-@@ -833,6 +833,7 @@ public class EntityEnderDragon extends EntityInsentient implements IMonster {
- public void b(NBTTagCompound nbttagcompound) {
- super.b(nbttagcompound);
- nbttagcompound.setInt("DragonPhase", this.bO.a().getControllerPhase().b());
-+ nbttagcompound.setInt("Paper.DeathTick", this.getDeathTicks()); // Paper
- }
-
- @Override
-@@ -841,6 +842,7 @@ public class EntityEnderDragon extends EntityInsentient implements IMonster {
- if (nbttagcompound.hasKey("DragonPhase")) {
- this.bO.setControllerPhase(DragonControllerPhase.getById(nbttagcompound.getInt("DragonPhase")));
- }
-+ this.setDeathTicks(nbttagcompound.getInt("Paper.DeathTick")); // Paper
-
- }
-
diff --git a/Spigot-Server-Patches/0511-Implement-JellySquid-s-Entity-Collision-optimisation.patch b/removed/1.16/0511-Implement-JellySquid-s-Entity-Collision-optimisation.patch
similarity index 100%
rename from Spigot-Server-Patches/0511-Implement-JellySquid-s-Entity-Collision-optimisation.patch
rename to removed/1.16/0511-Implement-JellySquid-s-Entity-Collision-optimisation.patch
diff --git a/Spigot-Server-Patches/0512-Remove-some-Streams-usage-in-Entity-Collision.patch b/removed/1.16/0512-Remove-some-Streams-usage-in-Entity-Collision.patch
similarity index 100%
rename from Spigot-Server-Patches/0512-Remove-some-Streams-usage-in-Entity-Collision.patch
rename to removed/1.16/0512-Remove-some-Streams-usage-in-Entity-Collision.patch
diff --git a/Spigot-Server-Patches/0513-Ensure-Entity-AABB-s-are-never-invalid.patch b/removed/1.16/0513-Ensure-Entity-AABB-s-are-never-invalid.patch
similarity index 100%
rename from Spigot-Server-Patches/0513-Ensure-Entity-AABB-s-are-never-invalid.patch
rename to removed/1.16/0513-Ensure-Entity-AABB-s-are-never-invalid.patch
diff --git a/Spigot-Server-Patches/0516-Optimize-WorldBorder-collision-checks-and-air.patch b/removed/1.16/0516-Optimize-WorldBorder-collision-checks-and-air.patch
similarity index 100%
rename from Spigot-Server-Patches/0516-Optimize-WorldBorder-collision-checks-and-air.patch
rename to removed/1.16/0516-Optimize-WorldBorder-collision-checks-and-air.patch
diff --git a/Spigot-Server-Patches/0518-Optimize-Pathfinder-Remove-Streams-Optimized-collect.patch b/removed/1.16/0518-Optimize-Pathfinder-Remove-Streams-Optimized-collect.patch
similarity index 100%
rename from Spigot-Server-Patches/0518-Optimize-Pathfinder-Remove-Streams-Optimized-collect.patch
rename to removed/1.16/0518-Optimize-Pathfinder-Remove-Streams-Optimized-collect.patch
diff --git a/Spigot-Server-Patches/0524-Add-permission-for-command-blocks.patch b/removed/1.16/0524-Add-permission-for-command-blocks.patch
similarity index 100%
rename from Spigot-Server-Patches/0524-Add-permission-for-command-blocks.patch
rename to removed/1.16/0524-Add-permission-for-command-blocks.patch
diff --git a/Spigot-Server-Patches/0530-Optimize-Villagers.patch b/removed/1.16/0530-Optimize-Villagers.patch
similarity index 100%
rename from Spigot-Server-Patches/0530-Optimize-Villagers.patch
rename to removed/1.16/0530-Optimize-Villagers.patch
diff --git a/work/Bukkit b/work/Bukkit
index 6f3c5f4a5..8edeffe67 160000
--- a/work/Bukkit
+++ b/work/Bukkit
@@ -1 +1 @@
-Subproject commit 6f3c5f4a5a0867ef265df9d58b48bdc43079e3dd
+Subproject commit 8edeffe67d1821afd48d16cd0ec2572251f24ee8
diff --git a/work/CraftBukkit b/work/CraftBukkit
index 3f0c33387..d1fb662ec 160000
--- a/work/CraftBukkit
+++ b/work/CraftBukkit
@@ -1 +1 @@
-Subproject commit 3f0c333870ba74705e98d19322174d6f0c10c900
+Subproject commit d1fb662ec53c4fd8bc718039b76a3e9a11346371
diff --git a/work/Spigot b/work/Spigot
index 758abbeee..8fc58f10a 160000
--- a/work/Spigot
+++ b/work/Spigot
@@ -1 +1 @@
-Subproject commit 758abbeee4e12f5ff65470999dd9955d0ebb49cd
+Subproject commit 8fc58f10ab171ca1979afa2065909214a0ffab32