From 7fe98bd520978d3017828cbfde8eff8709278110 Mon Sep 17 00:00:00 2001 From: Jake Potrebic <15055071+Machine-Maker@users.noreply.github.com> Date: Mon, 14 Jun 2021 01:37:14 -0700 Subject: [PATCH] more patches (#5827) * more patches * even moar patches --- ...Holder-method-without-block-snapshot.patch | 0 .../0209-Expose-Arrow-getItemStack.patch | 0 ...implement-PlayerRecipeBookClickEvent.patch | 0 .../1.17}/0493-Optimize-Light-Engine.patch | 2 + .../1.17}/0501-Fix-enderdragon-exp-dupe.patch | 2 + ...mit-lightning-strike-effect-distance.patch | 1 + .../0503-Expose-Arrow-getItemStack.patch | 36 ---------- ...sure-Entity-AABB-s-are-never-invalid.patch | 48 ------------- ...WorldBorder-collision-checks-and-air.patch | 71 ------------------- ...up-duplicated-GameProfile-Properties.patch | 68 ------------------ ...nk-Unloads-based-on-Player-Movement.patch} | 50 ++++++------- ...Optimize-Bit-Operations-by-inlining.patch} | 0 ...ch => 0448-incremental-chunk-saving.patch} | 2 +- ...Plugin-Tickets-to-API-Chunk-Methods.patch} | 68 ++++++++---------- ...sing-chunks-due-to-integer-overflow.patch} | 16 ++--- ...r-runTaskTimerAsynchronously-Plugin.patch} | 6 +- ...ton-physics-inconsistency-MC-188840.patch} | 30 ++++---- .../0453-Fix-sand-duping.patch} | 12 ++-- ...desync-in-playerconnection-causing-.patch} | 6 +- ...older-method-without-block-snapshot.patch} | 22 ++---- .../0456-Expose-Arrow-getItemStack.patch | 24 +++++++ ...mplement-PlayerRecipeBookClickEvent.patch} | 14 ++-- ...-Hide-sync-chunk-writes-behind-flag.patch} | 2 +- ...9-Add-permission-for-command-blocks.patch} | 32 ++++----- ...sure-Entity-AABB-s-are-never-invalid.patch | 32 +++++++++ ...WorldBorder-collision-checks-and-air.patch | 50 +++++++++++++ ...d-Difficulty-Remembering-Difficulty.patch} | 59 +++++++-------- .../0463-Paper-dumpitem-command.patch} | 52 ++++++-------- ...64-Don-t-allow-null-UUID-s-for-chat.patch} | 20 ++---- ...Legacy-Component-serialization-size.patch} | 14 ++-- ...466-Support-old-UUID-format-for-NBT.patch} | 46 ++++++++---- ...up-duplicated-GameProfile-Properties.patch | 47 ++++++++++++ 32 files changed, 369 insertions(+), 463 deletions(-) rename patches/{api-unmapped => api}/0208-Inventory-getHolder-method-without-block-snapshot.patch (100%) rename patches/{api-unmapped => api}/0209-Expose-Arrow-getItemStack.patch (100%) rename patches/{api-unmapped => api}/0210-Add-and-implement-PlayerRecipeBookClickEvent.patch (100%) rename patches/{server-remapped => removed/1.17}/0493-Optimize-Light-Engine.patch (99%) rename patches/{server-remapped => removed/1.17}/0501-Fix-enderdragon-exp-dupe.patch (96%) rename patches/{server-remapped => removed/1.17}/0506-Limit-lightning-strike-effect-distance.patch (98%) delete mode 100644 patches/server-remapped/0503-Expose-Arrow-getItemStack.patch delete mode 100644 patches/server-remapped/0508-Ensure-Entity-AABB-s-are-never-invalid.patch delete mode 100644 patches/server-remapped/0509-Optimize-WorldBorder-collision-checks-and-air.patch delete mode 100644 patches/server-remapped/0515-Clean-up-duplicated-GameProfile-Properties.patch rename patches/{server-remapped/0494-Delay-Chunk-Unloads-based-on-Player-Movement.patch => server/0446-Delay-Chunk-Unloads-based-on-Player-Movement.patch} (73%) rename patches/server/{0446-Optimize-Bit-Operations-by-inlining.patch => 0447-Optimize-Bit-Operations-by-inlining.patch} (100%) rename patches/server/{0447-incremental-chunk-saving.patch => 0448-incremental-chunk-saving.patch} (99%) rename patches/{server-remapped/0495-Add-Plugin-Tickets-to-API-Chunk-Methods.patch => server/0449-Add-Plugin-Tickets-to-API-Chunk-Methods.patch} (62%) rename patches/{server-remapped/0496-Fix-missing-chunks-due-to-integer-overflow.patch => server/0450-Fix-missing-chunks-due-to-integer-overflow.patch} (75%) rename patches/{server-remapped/0497-Fix-CraftScheduler-runTaskTimerAsynchronously-Plugin.patch => server/0451-Fix-CraftScheduler-runTaskTimerAsynchronously-Plugin.patch} (76%) rename patches/{server-remapped/0498-Fix-piston-physics-inconsistency-MC-188840.patch => server/0452-Fix-piston-physics-inconsistency-MC-188840.patch} (72%) rename patches/{server-remapped/0499-Fix-sand-duping.patch => server/0453-Fix-sand-duping.patch} (81%) rename patches/{server-remapped/0500-Prevent-position-desync-in-playerconnection-causing-.patch => server/0454-Prevent-position-desync-in-playerconnection-causing-.patch} (86%) rename patches/{server-remapped/0502-Inventory-getHolder-method-without-block-snapshot.patch => server/0455-Inventory-getHolder-method-without-block-snapshot.patch} (56%) create mode 100644 patches/server/0456-Expose-Arrow-getItemStack.patch rename patches/{server-remapped/0504-Add-and-implement-PlayerRecipeBookClickEvent.patch => server/0457-Add-and-implement-PlayerRecipeBookClickEvent.patch} (76%) rename patches/{server-remapped/0505-Hide-sync-chunk-writes-behind-flag.patch => server/0458-Hide-sync-chunk-writes-behind-flag.patch} (93%) rename patches/{server-remapped/0507-Add-permission-for-command-blocks.patch => server/0459-Add-permission-for-command-blocks.patch} (68%) create mode 100644 patches/server/0460-Ensure-Entity-AABB-s-are-never-invalid.patch create mode 100644 patches/server/0461-Optimize-WorldBorder-collision-checks-and-air.patch rename patches/{server-remapped/0510-Fix-Per-World-Difficulty-Remembering-Difficulty.patch => server/0462-Fix-Per-World-Difficulty-Remembering-Difficulty.patch} (57%) rename patches/{server-remapped/0511-Paper-dumpitem-command.patch => server/0463-Paper-dumpitem-command.patch} (55%) rename patches/{server-remapped/0512-Don-t-allow-null-UUID-s-for-chat.patch => server/0464-Don-t-allow-null-UUID-s-for-chat.patch} (53%) rename patches/{server-remapped/0513-Improve-Legacy-Component-serialization-size.patch => server/0465-Improve-Legacy-Component-serialization-size.patch} (81%) rename patches/{server-remapped/0514-Support-old-UUID-format-for-NBT.patch => server/0466-Support-old-UUID-format-for-NBT.patch} (51%) create mode 100644 patches/server/0467-Clean-up-duplicated-GameProfile-Properties.patch diff --git a/patches/api-unmapped/0208-Inventory-getHolder-method-without-block-snapshot.patch b/patches/api/0208-Inventory-getHolder-method-without-block-snapshot.patch similarity index 100% rename from patches/api-unmapped/0208-Inventory-getHolder-method-without-block-snapshot.patch rename to patches/api/0208-Inventory-getHolder-method-without-block-snapshot.patch diff --git a/patches/api-unmapped/0209-Expose-Arrow-getItemStack.patch b/patches/api/0209-Expose-Arrow-getItemStack.patch similarity index 100% rename from patches/api-unmapped/0209-Expose-Arrow-getItemStack.patch rename to patches/api/0209-Expose-Arrow-getItemStack.patch diff --git a/patches/api-unmapped/0210-Add-and-implement-PlayerRecipeBookClickEvent.patch b/patches/api/0210-Add-and-implement-PlayerRecipeBookClickEvent.patch similarity index 100% rename from patches/api-unmapped/0210-Add-and-implement-PlayerRecipeBookClickEvent.patch rename to patches/api/0210-Add-and-implement-PlayerRecipeBookClickEvent.patch diff --git a/patches/server-remapped/0493-Optimize-Light-Engine.patch b/patches/removed/1.17/0493-Optimize-Light-Engine.patch similarity index 99% rename from patches/server-remapped/0493-Optimize-Light-Engine.patch rename to patches/removed/1.17/0493-Optimize-Light-Engine.patch index 53f26fe554..6b16fce1cd 100644 --- a/patches/server-remapped/0493-Optimize-Light-Engine.patch +++ b/patches/removed/1.17/0493-Optimize-Light-Engine.patch @@ -24,6 +24,8 @@ 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 +1.17: Depends on chunk urgency patch as well + diff --git a/src/main/java/net/minecraft/server/level/ChunkHolder.java b/src/main/java/net/minecraft/server/level/ChunkHolder.java index 8260636da673ef095728c208db2d6237bab2db19..9e3629884709126574a52ad44fe7523f01dbcce9 100644 --- a/src/main/java/net/minecraft/server/level/ChunkHolder.java diff --git a/patches/server-remapped/0501-Fix-enderdragon-exp-dupe.patch b/patches/removed/1.17/0501-Fix-enderdragon-exp-dupe.patch similarity index 96% rename from patches/server-remapped/0501-Fix-enderdragon-exp-dupe.patch rename to patches/removed/1.17/0501-Fix-enderdragon-exp-dupe.patch index 38690afc49..ccc32f2cc8 100644 --- a/patches/server-remapped/0501-Fix-enderdragon-exp-dupe.patch +++ b/patches/removed/1.17/0501-Fix-enderdragon-exp-dupe.patch @@ -6,6 +6,8 @@ Subject: [PATCH] Fix enderdragon exp dupe Properly track death stage when unloading/loading in the dragon +1.17: Mojang fixed in 1.17(maybe before, idk) + diff --git a/src/main/java/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java b/src/main/java/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java index ec9436005a3a6fdfb4783d1092bb361224eb6414..b224a630f8adb1fa357c838e6b32c784aed0b15b 100644 --- a/src/main/java/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java diff --git a/patches/server-remapped/0506-Limit-lightning-strike-effect-distance.patch b/patches/removed/1.17/0506-Limit-lightning-strike-effect-distance.patch similarity index 98% rename from patches/server-remapped/0506-Limit-lightning-strike-effect-distance.patch rename to patches/removed/1.17/0506-Limit-lightning-strike-effect-distance.patch index 1f74c2ced9..f29d1e4440 100644 --- a/patches/server-remapped/0506-Limit-lightning-strike-effect-distance.patch +++ b/patches/removed/1.17/0506-Limit-lightning-strike-effect-distance.patch @@ -3,6 +3,7 @@ From: Trigary Date: Fri, 14 Sep 2018 17:42:08 +0200 Subject: [PATCH] Limit lightning strike effect distance +Doesnt seem to apply anymore as spigot isn't using relative distance for lightning diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java index 1655bca0502e7b871de4addaa163536d86547a02..978062774c1db286bfb9b0ffdef19d880b1f249b 100644 diff --git a/patches/server-remapped/0503-Expose-Arrow-getItemStack.patch b/patches/server-remapped/0503-Expose-Arrow-getItemStack.patch deleted file mode 100644 index cafd641bc1..0000000000 --- a/patches/server-remapped/0503-Expose-Arrow-getItemStack.patch +++ /dev/null @@ -1,36 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Nesaak <52047222+Nesaak@users.noreply.github.com> -Date: Sat, 23 May 2020 10:31:11 -0400 -Subject: [PATCH] Expose Arrow getItemStack - - -diff --git a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java -index 3ce431c1fdf1f5bd62b49f26cca188e939e98efa..6225f390b51733217a809910182f58acea1055e2 100644 ---- a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java -+++ b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java -@@ -556,6 +556,7 @@ public abstract class AbstractArrow extends Projectile { - } - } - -+ public final ItemStack getOriginalItemStack() { return getPickupItem(); } // Paper - OBFHELPER - exists purely due to overrides all as protected and dont want to change them all - protected abstract ItemStack getPickupItem(); - - @Override -diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java -index 5b898118a46007a85254931c7b5bd18d7cda99be..91d32aff07e81608a2f8ecb1301ef3c08533494b 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 { - getHandle().pickup = net.minecraft.world.entity.projectile.AbstractArrow.Pickup.byOrdinal(status.ordinal()); - } - -+ // Paper start -+ @Override -+ public org.bukkit.craftbukkit.inventory.CraftItemStack getItemStack() { -+ return org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(getHandle().getOriginalItemStack()); -+ } -+ //Paper end -+ - @Override - public void setTicksLived(int value) { - super.setTicksLived(value); diff --git a/patches/server-remapped/0508-Ensure-Entity-AABB-s-are-never-invalid.patch b/patches/server-remapped/0508-Ensure-Entity-AABB-s-are-never-invalid.patch deleted file mode 100644 index f77fef5ea0..0000000000 --- a/patches/server-remapped/0508-Ensure-Entity-AABB-s-are-never-invalid.patch +++ /dev/null @@ -1,48 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Aikar -Date: Sun, 10 May 2020 22:12:46 -0400 -Subject: [PATCH] Ensure Entity AABB's are never invalid - - -diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index d9bb00752ac81b2171d3ad25fd84904467a18e3b..728379292728cf58f5512feae3cdc74392980f68 100644 ---- a/src/main/java/net/minecraft/world/entity/Entity.java -+++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -66,6 +66,7 @@ import net.minecraft.world.Nameable; - import net.minecraft.world.damagesource.DamageSource; - import net.minecraft.world.entity.animal.AbstractFish; - import net.minecraft.world.entity.animal.Animal; -+import net.minecraft.world.entity.decoration.HangingEntity; - import net.minecraft.world.entity.item.ItemEntity; - import net.minecraft.world.entity.player.Player; - import net.minecraft.world.entity.vehicle.AbstractMinecart; -@@ -478,7 +479,7 @@ public abstract class Entity implements Nameable, CommandSource, net.minecraft.s - - public void setPos(double x, double y, double z) { - this.setPosRaw(x, y, z); -- this.setBoundingBox(this.dimensions.makeBoundingBox(x, y, z)); -+ //this.a(this.size.a(d0, d1, d2)); // Paper - move into setPositionRaw - if (valid) ((ServerLevel) level).updateChunkPos(this); // CraftBukkit - } - -@@ -2998,6 +2999,7 @@ public abstract class Entity implements Nameable, CommandSource, net.minecraft.s - return new AABB(vec3d, vec3d1); - } - -+ public final void setBoundingBox(AABB axisalignedbb) { setBoundingBox(axisalignedbb); } // Paper - OBFHELPER - public void setBoundingBox(AABB boundingBox) { - // CraftBukkit start - block invalid bounding boxes - double minX = boundingBox.minX, -@@ -3436,6 +3438,12 @@ public abstract class Entity implements Nameable, CommandSource, net.minecraft.s - } - - public void setPosRaw(double x, double y, double z) { -+ // Paper start - never allow AABB to become desynced from position -+ // hanging has its own special logic -+ if (!(this instanceof HangingEntity) && (this.position.x != x || this.position.y != y || this.position.z != z)) { -+ this.setBoundingBox(this.dimensions.makeBoundingBox(x, y, z)); -+ } -+ // Paper end - if (this.position.x != x || this.position.y != y || this.position.z != z) { - this.position = new Vec3(x, y, z); - int i = Mth.floor(x); diff --git a/patches/server-remapped/0509-Optimize-WorldBorder-collision-checks-and-air.patch b/patches/server-remapped/0509-Optimize-WorldBorder-collision-checks-and-air.patch deleted file mode 100644 index bc82f5847c..0000000000 --- a/patches/server-remapped/0509-Optimize-WorldBorder-collision-checks-and-air.patch +++ /dev/null @@ -1,71 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Spottedleaf -Date: Sun, 10 May 2020 22:49:05 -0400 -Subject: [PATCH] Optimize WorldBorder collision checks and air - - -diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index 728379292728cf58f5512feae3cdc74392980f68..e9a658b11e2b6683831dc3f5bd20be9a7840ed69 100644 ---- a/src/main/java/net/minecraft/world/entity/Entity.java -+++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -102,7 +102,6 @@ import net.minecraft.world.phys.AABB; - import net.minecraft.world.phys.HitResult; - import net.minecraft.world.phys.Vec2; - import net.minecraft.world.phys.Vec3; --import net.minecraft.world.phys.shapes.BooleanOp; - import net.minecraft.world.phys.shapes.CollisionContext; - import net.minecraft.world.phys.shapes.Shapes; - import net.minecraft.world.phys.shapes.VoxelShape; -@@ -908,7 +907,7 @@ public abstract class Entity implements Nameable, CommandSource, net.minecraft.s - AABB axisalignedbb = this.getBoundingBox(); - CollisionContext voxelshapecollision = CollisionContext.of(this); - VoxelShape voxelshape = this.level.getWorldBorder().getCollisionShape(); -- Stream stream = Shapes.joinIsNotEmpty(voxelshape, Shapes.create(axisalignedbb.deflate(1.0E-7D)), BooleanOp.AND) ? Stream.empty() : Stream.of(voxelshape); -+ Stream stream = !this.level.getWorldBorder().isInBounds(axisalignedbb) ? Stream.empty() : Stream.of(voxelshape); // Paper - Stream stream1 = this.level.getEntityCollisions(this, axisalignedbb.expandTowards(movement), (entity) -> { - return true; - }); -diff --git a/src/main/java/net/minecraft/world/level/CollisionSpliterator.java b/src/main/java/net/minecraft/world/level/CollisionSpliterator.java -index feca9ff34936686c0665ae0dbc926869087df3a7..60f8585a736af5b654b8aaed89a39a8bf5e91301 100644 ---- a/src/main/java/net/minecraft/world/level/CollisionSpliterator.java -+++ b/src/main/java/net/minecraft/world/level/CollisionSpliterator.java -@@ -143,10 +143,10 @@ public class CollisionSpliterator extends AbstractSpliterator { - AABB axisalignedbb = this.source.getBoundingBox(); - - if (!isBoxFullyWithinWorldBorder(worldborder, axisalignedbb)) { -- VoxelShape voxelshape = worldborder.getCollisionShape(); -- -- if (!isOutsideBorder(voxelshape, axisalignedbb) && isCloseToBorder(voxelshape, axisalignedbb)) { -- consumer.accept(voxelshape); -+ // Paper start -+ if (worldborder.isInBounds(axisalignedbb.deflate(1.0E-7D)) && !worldborder.isInBounds(axisalignedbb.grow(1.0E-7D))) { -+ consumer.accept(worldborder.asVoxelShape()); -+ // Paper end - return true; - } - } -diff --git a/src/main/java/net/minecraft/world/level/border/WorldBorder.java b/src/main/java/net/minecraft/world/level/border/WorldBorder.java -index 7a728ca96ee2eaf776c391ba8351196a526e18ec..aaa6251838483de5c46913534413151b5cb1d3fe 100644 ---- a/src/main/java/net/minecraft/world/level/border/WorldBorder.java -+++ b/src/main/java/net/minecraft/world/level/border/WorldBorder.java -@@ -52,6 +52,7 @@ public class WorldBorder { - return (double) pos.getMaxBlockX() > this.getMinX() && (double) pos.getMinBlockX() < this.getMaxX() && (double) pos.getMaxBlockZ() > this.getMinZ() && (double) pos.getMinBlockZ() < this.getMaxZ(); - } - -+ public final boolean isInBounds(AABB aabb) { return this.isWithinBounds(aabb); } // Paper - OBFHELPER - public boolean isWithinBounds(AABB box) { - return box.maxX > this.getMinX() && box.minX < this.getMaxX() && box.maxZ > this.getMinZ() && box.minZ < this.getMaxZ(); - } -diff --git a/src/main/java/net/minecraft/world/phys/shapes/Shapes.java b/src/main/java/net/minecraft/world/phys/shapes/Shapes.java -index 1603eb3f7d90a4b3a028b20776566db77d09c123..f28d2126bc29fad3971a32cf85a7a7c4803b36ab 100644 ---- a/src/main/java/net/minecraft/world/phys/shapes/Shapes.java -+++ b/src/main/java/net/minecraft/world/phys/shapes/Shapes.java -@@ -252,7 +252,7 @@ public final class Shapes { - BlockState iblockdata = world.getTypeIfLoaded(blockposition_mutableblockposition); // Paper - if (iblockdata == null) return 0.0D; // Paper - -- if ((k2 != 1 || iblockdata.hasLargeCollisionShape()) && (k2 != 2 || iblockdata.is(Blocks.MOVING_PISTON))) { -+ if (!iblockdata.isAir() && (k2 != 1 || iblockdata.hasLargeCollisionShape()) && (k2 != 2 || iblockdata.is(Blocks.MOVING_PISTON))) { // Paper - initial = iblockdata.getCollisionShape((BlockGetter) world, blockposition_mutableblockposition, context).collide(enumdirection_enumaxis2, box.move((double) (-blockposition_mutableblockposition.getX()), (double) (-blockposition_mutableblockposition.getY()), (double) (-blockposition_mutableblockposition.getZ())), initial); - if (Math.abs(initial) < 1.0E-7D) { - return 0.0D; diff --git a/patches/server-remapped/0515-Clean-up-duplicated-GameProfile-Properties.patch b/patches/server-remapped/0515-Clean-up-duplicated-GameProfile-Properties.patch deleted file mode 100644 index 40c9060216..0000000000 --- a/patches/server-remapped/0515-Clean-up-duplicated-GameProfile-Properties.patch +++ /dev/null @@ -1,68 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Aikar -Date: Wed, 1 Jul 2020 03:12:06 -0400 -Subject: [PATCH] Clean up duplicated GameProfile Properties - -We had a bug where we accidently cloned properties resulting in skulls -growing to large sizes and preventing login. - -This now automatically cleans up the extra properties. - -diff --git a/src/main/java/net/minecraft/nbt/NbtUtils.java b/src/main/java/net/minecraft/nbt/NbtUtils.java -index f57c5e441045a81072a2edfed0f199d90e6d7fde..3abfd21ea84c54aec6256008b3b9e6bbc7ae694c 100644 ---- a/src/main/java/net/minecraft/nbt/NbtUtils.java -+++ b/src/main/java/net/minecraft/nbt/NbtUtils.java -@@ -59,8 +59,8 @@ public final class NbtUtils { - while (iterator.hasNext()) { - String s1 = (String) iterator.next(); - ListTag nbttaglist = nbttagcompound1.getList(s1, 10); -- -- for (int i = 0; i < nbttaglist.size(); ++i) { -+ if (nbttaglist.size() == 0) continue; // Paper - remove duplicate properties -+ for (int i = nbttaglist.size() - 1; i < nbttaglist.size(); ++i) { // Paper - remove duplicate properties - CompoundTag nbttagcompound2 = nbttaglist.getCompound(i); - String s2 = nbttagcompound2.getString("Value"); - -@@ -246,7 +246,7 @@ public final class NbtUtils { - Optional optional = property.getValue(propertiesTag.getString(key)); - - if (optional.isPresent()) { -- return (StateHolder) state.setValue(property, (Comparable) optional.get()); -+ return state.setValue(property, optional.get()); // Paper - decompile error - } else { - NbtUtils.LOGGER.warn("Unable to read property: {} with value: {} for blockstate: {}", key, propertiesTag.getString(key), mainTag.toString()); - return state; -@@ -276,8 +276,8 @@ public final class NbtUtils { - return nbttagcompound; - } - -- private static > String getName(net.minecraft.world.level.block.state.properties.Property property, Comparable value) { -- return property.value(value); -+ private static > String getName(net.minecraft.world.level.block.state.properties.Property property, Comparable value) {// Paper - decompile error -+ return property.getName((T) value);// Paper - decompile error - } - - public static CompoundTag update(DataFixer fixer, DataFixTypes fixTypes, CompoundTag tag, int oldVersion) { -diff --git a/src/main/java/net/minecraft/world/item/PlayerHeadItem.java b/src/main/java/net/minecraft/world/item/PlayerHeadItem.java -index 1cb67832a849db96f1cce95c32b41574e990e5b7..d97be7a1dfa7ad413afb8ff7668189fd37baf264 100644 ---- a/src/main/java/net/minecraft/world/item/PlayerHeadItem.java -+++ b/src/main/java/net/minecraft/world/item/PlayerHeadItem.java -@@ -59,6 +59,18 @@ public class PlayerHeadItem extends StandingAndWallBlockItem { - return true; - } else { - // CraftBukkit start -+ // Paper start - clean up old duplicated properties -+ CompoundTag properties = tag.getCompound("SkullOwner").getCompound("Properties"); -+ for (String key : properties.getAllKeys()) { -+ net.minecraft.nbt.ListTag values = properties.getList(key, 10); -+ if (values.size() > 1) { -+ net.minecraft.nbt.Tag texture = values.get(values.size() - 1); -+ values = new net.minecraft.nbt.ListTag(); -+ values.add(texture); -+ properties.put(key, values); -+ } -+ } -+ // Paper end - net.minecraft.nbt.ListTag textures = tag.getCompound("SkullOwner").getCompound("Properties").getList("textures", 10); // Safe due to method contracts - for (int i = 0; i < textures.size(); i++) { - if (textures.get(i) instanceof CompoundTag && !((CompoundTag) textures.get(i)).contains("Signature", 8) && ((CompoundTag) textures.get(i)).getString("Value").trim().isEmpty()) { diff --git a/patches/server-remapped/0494-Delay-Chunk-Unloads-based-on-Player-Movement.patch b/patches/server/0446-Delay-Chunk-Unloads-based-on-Player-Movement.patch similarity index 73% rename from patches/server-remapped/0494-Delay-Chunk-Unloads-based-on-Player-Movement.patch rename to patches/server/0446-Delay-Chunk-Unloads-based-on-Player-Movement.patch index a8c890b13a..a7a809be4c 100644 --- a/patches/server-remapped/0494-Delay-Chunk-Unloads-based-on-Player-Movement.patch +++ b/patches/server/0446-Delay-Chunk-Unloads-based-on-Player-Movement.patch @@ -17,14 +17,13 @@ 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 6463d3e4837d032a35654a035f42b8a805e0e286..1655bca0502e7b871de4addaa163536d86547a02 100644 +index 3bc6329d3ea48966cb99e792f9b35e2d2d71a34b..1f4d0d3493e748f52eb3b679c0a8a1306c0cc8b4 100644 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java -@@ -637,4 +637,13 @@ public class PaperWorldConfig { - private void viewDistance() { +@@ -495,6 +495,15 @@ public class PaperWorldConfig { this.noTickViewDistance = this.getInt("viewdistances.no-tick-view-distance", -1); } -+ + + public long delayChunkUnloadsBy; + private void delayChunkUnloadsBy() { + delayChunkUnloadsBy = PaperConfig.getSeconds(getString("delay-chunk-unloads-by", "10s")); @@ -33,12 +32,15 @@ index 6463d3e4837d032a35654a035f42b8a805e0e286..1655bca0502e7b871de4addaa163536d + delayChunkUnloadsBy *= 20; + } + } - } ++ + public boolean altItemDespawnRateEnabled; + public Map altItemDespawnRateMap; + private void altItemDespawnRate() { diff --git a/src/main/java/net/minecraft/server/level/DistanceManager.java b/src/main/java/net/minecraft/server/level/DistanceManager.java -index e41f388e8350010a471410436adf15a906f07e97..e0241b9d60cd2b72f8fb774f1ab4753dfd615184 100644 +index 577b391dcba1db712c1e2c83296e1c87b3e34ab2..d94241bcca4f2fd5e464a860bd356af504dc68b7 100644 --- a/src/main/java/net/minecraft/server/level/DistanceManager.java +++ b/src/main/java/net/minecraft/server/level/DistanceManager.java -@@ -185,6 +185,27 @@ public abstract class DistanceManager { +@@ -181,6 +181,27 @@ public abstract class DistanceManager { boolean removed = false; // CraftBukkit if (arraysetsorted.remove(ticket)) { removed = true; // CraftBukkit @@ -56,7 +58,7 @@ index e41f388e8350010a471410436adf15a906f07e97..e0241b9d60cd2b72f8fb774f1ab4753d + if (!hasPlayer && playerChunk != null && playerChunk.isFullChunkReady()) { + Ticket delayUnload = new Ticket(TicketType.DELAY_UNLOAD, 33, i); + delayUnload.delayUnloadBy = delayChunkUnloadsBy; -+ delayUnload.setCurrentTick(this.ticketTickCounter); ++ delayUnload.setCreatedTick(this.ticketTickCounter); + arraysetsorted.remove(delayUnload); + // refresh ticket + arraysetsorted.add(delayUnload); @@ -67,13 +69,13 @@ index e41f388e8350010a471410436adf15a906f07e97..e0241b9d60cd2b72f8fb774f1ab4753d if (arraysetsorted.isEmpty()) { diff --git a/src/main/java/net/minecraft/server/level/Ticket.java b/src/main/java/net/minecraft/server/level/Ticket.java -index c0bfe136ccb9ad4fc0f8ccdd703254205213ec8e..f7898bd7806684d2c068898cecbf835d834df461 100644 +index 8b0c6e1a649400908dbb674dfb4cdd1aa0ce1d38..a7aa7a9038d4812a9d1e4e72c4dbbbe10df15820 100644 --- a/src/main/java/net/minecraft/server/level/Ticket.java +++ b/src/main/java/net/minecraft/server/level/Ticket.java -@@ -9,11 +9,13 @@ public final class Ticket implements Comparable> { +@@ -7,11 +7,13 @@ public final class Ticket implements Comparable> { + private final int ticketLevel; public final T key; public final T getObjectReason() { return this.key; } // Paper - OBFHELPER private long createdTick; public final long getCreationTick() { return this.createdTick; } // Paper - OBFHELPER - public int priority = 0; // Paper + public long delayUnloadBy; // Paper protected Ticket(TicketType type, int level, T argument) { @@ -83,25 +85,25 @@ index c0bfe136ccb9ad4fc0f8ccdd703254205213ec8e..f7898bd7806684d2c068898cecbf835d + this.delayUnloadBy = type.timeout; // Paper } - public int compareTo(Ticket ticket) { -@@ -63,7 +65,7 @@ public final class Ticket implements Comparable> { + @Override +@@ -60,7 +62,7 @@ public final class Ticket implements Comparable> { } protected boolean timedOut(long currentTick) { -- long j = this.type.timeout(); -+ long j = delayUnloadBy; // Paper - - return j != 0L && currentTick - this.createdTick > j; +- long l = this.type.timeout(); ++ long l = delayUnloadBy; // Paper + return l != 0L && currentTick - this.createdTick > l; } + } diff --git a/src/main/java/net/minecraft/server/level/TicketType.java b/src/main/java/net/minecraft/server/level/TicketType.java -index 2444f6f676db543509b14e8c882491dc3f41b264..531ebf1bafec2b295af9f6dfec8f4b6466688287 100644 +index 78fbb4c3e52e900956ae0811aaf934c81ee5ea48..8770fe0db46b01e8b608637df4f1a669a3f4cdde 100644 --- a/src/main/java/net/minecraft/server/level/TicketType.java +++ b/src/main/java/net/minecraft/server/level/TicketType.java -@@ -30,6 +30,7 @@ public class TicketType { - public static final TicketType ASYNC_LOAD = create("async_load", Long::compareTo); // Paper - public static final TicketType PRIORITY = create("priority", Comparator.comparingLong(ChunkPos::toLong), 300); // Paper - public static final TicketType URGENT = create("urgent", Comparator.comparingLong(ChunkPos::toLong), 300); // Paper +@@ -28,6 +28,7 @@ public class TicketType { + public static final TicketType UNKNOWN = TicketType.create("unknown", Comparator.comparingLong(ChunkPos::toLong), 1); + public static final TicketType PLUGIN = TicketType.create("plugin", (a, b) -> 0); // CraftBukkit + public static final TicketType PLUGIN_TICKET = TicketType.create("plugin_ticket", (plugin1, plugin2) -> plugin1.getClass().getName().compareTo(plugin2.getClass().getName())); // CraftBukkit + public static final TicketType DELAY_UNLOAD = create("delay_unload", Long::compareTo, 300); // Paper - public static TicketType create(String name, Comparator comparator) { - return new TicketType<>(name, comparator, 0L); + public static TicketType create(String name, Comparator argumentComparator) { + return new TicketType<>(name, argumentComparator, 0L); diff --git a/patches/server/0446-Optimize-Bit-Operations-by-inlining.patch b/patches/server/0447-Optimize-Bit-Operations-by-inlining.patch similarity index 100% rename from patches/server/0446-Optimize-Bit-Operations-by-inlining.patch rename to patches/server/0447-Optimize-Bit-Operations-by-inlining.patch diff --git a/patches/server/0447-incremental-chunk-saving.patch b/patches/server/0448-incremental-chunk-saving.patch similarity index 99% rename from patches/server/0447-incremental-chunk-saving.patch rename to patches/server/0448-incremental-chunk-saving.patch index 36c5663041..ece4224cd0 100644 --- a/patches/server/0447-incremental-chunk-saving.patch +++ b/patches/server/0448-incremental-chunk-saving.patch @@ -5,7 +5,7 @@ Subject: [PATCH] incremental chunk saving diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java -index 3bc6329d3ea48966cb99e792f9b35e2d2d71a34b..ec51a9e19670888584e5324a57a47aa9c676d423 100644 +index 1f4d0d3493e748f52eb3b679c0a8a1306c0cc8b4..91917b11163c0740d5e5effc5e93d494e2b2d73e 100644 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java @@ -47,6 +47,21 @@ public class PaperWorldConfig { diff --git a/patches/server-remapped/0495-Add-Plugin-Tickets-to-API-Chunk-Methods.patch b/patches/server/0449-Add-Plugin-Tickets-to-API-Chunk-Methods.patch similarity index 62% rename from patches/server-remapped/0495-Add-Plugin-Tickets-to-API-Chunk-Methods.patch rename to patches/server/0449-Add-Plugin-Tickets-to-API-Chunk-Methods.patch index 2d4cc183be..ab4ec662b0 100644 --- a/patches/server-remapped/0495-Add-Plugin-Tickets-to-API-Chunk-Methods.patch +++ b/patches/server/0449-Add-Plugin-Tickets-to-API-Chunk-Methods.patch @@ -22,40 +22,32 @@ 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 92f1a6d32a96fee682342e86c3ffd3c65292150b..2ec41cb87cec97780f1fa8abfbb756fca4dba1bf 100644 +index 94670ec4de01341822f6affe0fa1c9774dd6131b..6bc5ba51c90723c7138b1b5d2381cb215f1e5271 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -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")); -- TicketType.PLUGIN.timeout = configuration.getInt("chunk-gc.period-in-ticks"); -+ TicketType.PLUGIN.timeout = Math.min(20, configuration.getInt("chunk-gc.period-in-ticks")); // Paper - cap plugin loads to 1 second - minimumAPI = configuration.getString("settings.minimum-api"); - loadIcon(); +@@ -346,7 +346,7 @@ public final class CraftServer implements Server { + this.ambientSpawn = this.configuration.getInt("spawn-limits.ambient"); + console.autosavePeriod = this.configuration.getInt("ticks-per.autosave"); + this.warningState = WarningState.value(this.configuration.getString("settings.deprecated-verbose")); +- TicketType.PLUGIN.timeout = this.configuration.getInt("chunk-gc.period-in-ticks"); ++ TicketType.PLUGIN.timeout = Math.min(20, this.configuration.getInt("chunk-gc.period-in-ticks")); // Paper - cap plugin loads to 1 second + this.minimumAPI = this.configuration.getString("settings.minimum-api"); + this.loadIcon(); } -@@ -832,7 +832,7 @@ public final class CraftServer implements Server { - waterAmbientSpawn = configuration.getInt("spawn-limits.water-ambient"); - ambientSpawn = configuration.getInt("spawn-limits.ambient"); - warningState = WarningState.value(configuration.getString("settings.deprecated-verbose")); -- TicketType.PLUGIN.timeout = configuration.getInt("chunk-gc.period-in-ticks"); +@@ -834,7 +834,7 @@ public final class CraftServer implements Server { + this.waterAmbientSpawn = this.configuration.getInt("spawn-limits.water-ambient"); + this.ambientSpawn = this.configuration.getInt("spawn-limits.ambient"); + this.warningState = WarningState.value(this.configuration.getString("settings.deprecated-verbose")); +- TicketType.PLUGIN.timeout = this.configuration.getInt("chunk-gc.period-in-ticks"); + TicketType.PLUGIN.timeout = Math.min(20, configuration.getInt("chunk-gc.period-in-ticks")); // Paper - cap plugin loads to 1 second - minimumAPI = configuration.getString("settings.minimum-api"); - printSaveWarning = false; - console.autosavePeriod = configuration.getInt("ticks-per.autosave"); + this.minimumAPI = this.configuration.getString("settings.minimum-api"); + this.printSaveWarning = false; + console.autosavePeriod = this.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 7261e22a71d219efe0949a08c5d3f10747759469..4436b3d23dc8f33925da1ec539ea16307e0785b9 100644 +index 72c9ad9f75c20d6c1a6d54e2913e2f9918c11ffd..f72471ac82907a0d5112598b3289689495285944 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -@@ -30,6 +30,7 @@ import net.minecraft.network.protocol.game.ClientboundCustomSoundPacket; - import net.minecraft.network.protocol.game.ClientboundLevelEventPacket; - import net.minecraft.network.protocol.game.ClientboundSetTimePacket; - import net.minecraft.resources.ResourceLocation; -+import net.minecraft.server.MCUtil; - import net.minecraft.server.level.ChunkHolder; - import net.minecraft.server.level.ChunkMap; - import net.minecraft.server.level.DistanceManager; -@@ -389,8 +390,21 @@ public class CraftWorld implements World { +@@ -405,8 +405,21 @@ public class CraftWorld implements World { @Override public Chunk getChunkAt(int x, int z) { @@ -72,22 +64,22 @@ index 7261e22a71d219efe0949a08c5d3f10747759469..4436b3d23dc8f33925da1ec539ea1630 + + // Paper start + private void addTicket(int x, int z) { -+ MCUtil.MAIN_EXECUTOR.execute(() -> world.getChunkSource().addRegionTicket(TicketType.PLUGIN, new ChunkPos(x, z), 0, Unit.INSTANCE)); // Paper ++ net.minecraft.server.MCUtil.MAIN_EXECUTOR.execute(() -> world.getChunkSource().addRegionTicket(TicketType.PLUGIN, new ChunkPos(x, z), 0, Unit.INSTANCE)); // Paper } + // Paper end @Override public Chunk getChunkAt(Block block) { -@@ -465,7 +479,7 @@ public class CraftWorld implements World { +@@ -481,7 +494,7 @@ public class CraftWorld implements World { public boolean unloadChunkRequest(int x, int z) { org.spigotmc.AsyncCatcher.catchOp("chunk unload"); // Spigot - if (isChunkLoaded(x, z)) { -- world.getChunkSource().removeRegionTicket(TicketType.PLUGIN, new ChunkPos(x, z), 1, Unit.INSTANCE); -+ world.getChunkSource().removeRegionTicket(TicketType.PLUGIN, new ChunkPos(x, z), 0, Unit.INSTANCE); // Paper + if (this.isChunkLoaded(x, z)) { +- this.world.getChunkSource().removeRegionTicket(TicketType.PLUGIN, new ChunkPos(x, z), 1, Unit.INSTANCE); ++ this.world.getChunkSource().removeRegionTicket(TicketType.PLUGIN, new ChunkPos(x, z), 0, Unit.INSTANCE); // Paper } return true; -@@ -542,9 +556,12 @@ public class CraftWorld implements World { +@@ -558,9 +571,12 @@ public class CraftWorld implements World { org.spigotmc.AsyncCatcher.catchOp("chunk load"); // Spigot // Paper start - Optimize this method ChunkPos chunkPos = new ChunkPos(x, z); @@ -101,7 +93,7 @@ index 7261e22a71d219efe0949a08c5d3f10747759469..4436b3d23dc8f33925da1ec539ea1630 if (immediate == null) { immediate = world.getChunkSource().chunkMap.getUnloadingChunk(x, z); } -@@ -552,7 +569,7 @@ public class CraftWorld implements World { +@@ -568,7 +584,7 @@ public class CraftWorld implements World { if (!(immediate instanceof ImposterProtoChunk) && !(immediate instanceof net.minecraft.world.level.chunk.LevelChunk)) { return false; // not full status } @@ -110,7 +102,7 @@ index 7261e22a71d219efe0949a08c5d3f10747759469..4436b3d23dc8f33925da1ec539ea1630 world.getChunk(x, z); // make sure we're at ticket level 32 or lower return true; } -@@ -579,7 +596,7 @@ public class CraftWorld implements World { +@@ -594,7 +610,7 @@ public class CraftWorld implements World { // we do this so we do not re-read the chunk data on disk } @@ -119,11 +111,11 @@ index 7261e22a71d219efe0949a08c5d3f10747759469..4436b3d23dc8f33925da1ec539ea1630 world.getChunkSource().getChunk(x, z, ChunkStatus.FULL, true); return true; // Paper end -@@ -2529,6 +2546,7 @@ public class CraftWorld implements World { - } +@@ -2544,6 +2560,7 @@ public class CraftWorld implements World { + return this.world.getChunkSource().getChunkAtAsynchronously(x, z, gen, urgent).thenComposeAsync((either) -> { net.minecraft.world.level.chunk.LevelChunk chunk = (net.minecraft.world.level.chunk.LevelChunk) either.left().orElse(null); + if (chunk != null) addTicket(x, z); // Paper - return CompletableFuture.completedFuture(chunk == null ? null : chunk.getBukkitChunk()); + return java.util.concurrent.CompletableFuture.completedFuture(chunk == null ? null : chunk.getBukkitChunk()); }, net.minecraft.server.MinecraftServer.getServer()); } diff --git a/patches/server-remapped/0496-Fix-missing-chunks-due-to-integer-overflow.patch b/patches/server/0450-Fix-missing-chunks-due-to-integer-overflow.patch similarity index 75% rename from patches/server-remapped/0496-Fix-missing-chunks-due-to-integer-overflow.patch rename to patches/server/0450-Fix-missing-chunks-due-to-integer-overflow.patch index f86c4c1c6b..0cfdc16188 100644 --- a/patches/server-remapped/0496-Fix-missing-chunks-due-to-integer-overflow.patch +++ b/patches/server/0450-Fix-missing-chunks-due-to-integer-overflow.patch @@ -13,17 +13,15 @@ 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/world/level/biome/TheEndBiomeSource.java b/src/main/java/net/minecraft/world/level/biome/TheEndBiomeSource.java -index af006c2e45e0a14367a0bc850c319024c6b82024..063369d3a64b4afc9cc6e1d20360900595e1a05f 100644 +index 7f7b0c961a76119b6004da03fe01ff4e2ae41628..9a64ab092ac8616ed8b9ea5c1e8677dda5c4333c 100644 --- a/src/main/java/net/minecraft/world/level/biome/TheEndBiomeSource.java +++ b/src/main/java/net/minecraft/world/level/biome/TheEndBiomeSource.java -@@ -75,7 +75,9 @@ public class TheEndBiomeSource extends BiomeSource { +@@ -84,7 +84,7 @@ public class TheEndBiomeSource extends BiomeSource { int l = j / 2; - int i1 = i % 2; - int j1 = j % 2; -- float f = 100.0F - Mth.sqrt((float) (i * i + j * j)) * 8.0F; -+ // Paper start - cast ints to long to avoid integer overflow -+ float f = 100.0F - Mth.sqrt((long) i * (long) i + (long) j * (long) j) * 8.0F; -+ // Paper end - + int m = i % 2; + int n = j % 2; +- float f = 100.0F - Mth.sqrt((float)(i * i + j * j)) * 8.0F; ++ float f = 100.0F - Mth.sqrt((long) i * (long) i + (long) j * (long) j) * 8.0F; // Paper - cast ints to long to avoid integer overflow f = Mth.clamp(f, -100.0F, 80.0F); + for(int o = -12; o <= 12; ++o) { diff --git a/patches/server-remapped/0497-Fix-CraftScheduler-runTaskTimerAsynchronously-Plugin.patch b/patches/server/0451-Fix-CraftScheduler-runTaskTimerAsynchronously-Plugin.patch similarity index 76% rename from patches/server-remapped/0497-Fix-CraftScheduler-runTaskTimerAsynchronously-Plugin.patch rename to patches/server/0451-Fix-CraftScheduler-runTaskTimerAsynchronously-Plugin.patch index 423af0ebf9..1e146b3ec8 100644 --- a/patches/server-remapped/0497-Fix-CraftScheduler-runTaskTimerAsynchronously-Plugin.patch +++ b/patches/server/0451-Fix-CraftScheduler-runTaskTimerAsynchronously-Plugin.patch @@ -7,15 +7,15 @@ Subject: [PATCH] Fix CraftScheduler#runTaskTimerAsynchronously(Plugin, diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java -index ca90237a53c9a026919d28adaedf483ca3c7c2a8..13e461ffb2ee2e7d0440c0f60809ea99629b843c 100644 +index dd1e8b170e87bff2089f642f41dcf7442a8ccd16..33480893ddee34a1983c5f1c4b14db98ff438528 100644 --- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java +++ b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java @@ -184,7 +184,7 @@ public class CraftScheduler implements BukkitScheduler { @Override public void runTaskTimerAsynchronously(Plugin plugin, Consumer task, long delay, long period) throws IllegalArgumentException { -- runTaskTimerAsynchronously(plugin, (Object) task, delay, CraftTask.NO_REPEATING); -+ runTaskTimerAsynchronously(plugin, (Object) task, delay, period); +- this.runTaskTimerAsynchronously(plugin, (Object) task, delay, CraftTask.NO_REPEATING); ++ this.runTaskTimerAsynchronously(plugin, (Object) task, delay, period); } @Override diff --git a/patches/server-remapped/0498-Fix-piston-physics-inconsistency-MC-188840.patch b/patches/server/0452-Fix-piston-physics-inconsistency-MC-188840.patch similarity index 72% rename from patches/server-remapped/0498-Fix-piston-physics-inconsistency-MC-188840.patch rename to patches/server/0452-Fix-piston-physics-inconsistency-MC-188840.patch index 1d54c7bad6..8910512100 100644 --- a/patches/server-remapped/0498-Fix-piston-physics-inconsistency-MC-188840.patch +++ b/patches/server/0452-Fix-piston-physics-inconsistency-MC-188840.patch @@ -47,10 +47,10 @@ index 7f140333c2e62012fa572c1a061d84432426997f..b67ba8f75e4a3358d7c2462918b85b0b + } } diff --git a/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java b/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java -index 40a18302dd682e5ade4ec77ac7f316b6c0f8c112..44876557515eaa6bbe33344b3d3ba03aee58409f 100644 +index 44cc09006eac6315d167a2628857f9942eb1fc13..aea9a2dc4164f5728e711efb3009bde8862c7345 100644 --- a/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java +++ b/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java -@@ -398,12 +398,24 @@ public class PistonBaseBlock extends DirectionalBlock { +@@ -411,14 +411,26 @@ public class PistonBaseBlock extends DirectionalBlock { } for (k = list.size() - 1; k >= 0; --k) { @@ -63,14 +63,16 @@ index 40a18302dd682e5ade4ec77ac7f316b6c0f8c112..44876557515eaa6bbe33344b3d3ba03a + // Paper end - fix a variety of piston desync dupes blockposition3 = blockposition3.relative(enumdirection1); map.remove(blockposition3); - world.setBlock(blockposition3, (BlockState) Blocks.MOVING_PISTON.defaultBlockState().setValue(PistonBaseBlock.FACING, dir), 68); -- world.setBlockEntity(blockposition3, MovingPistonBlock.newMovingBlockEntity((BlockState) list1.get(k), dir, retract, false)); + BlockState iblockdata2 = (BlockState) Blocks.MOVING_PISTON.defaultBlockState().setValue(PistonBaseBlock.FACING, dir); + + world.setBlock(blockposition3, iblockdata2, 68); +- world.setBlockEntity(MovingPistonBlock.newMovingBlockEntity(blockposition3, iblockdata2, (BlockState) list1.get(k), dir, retract, false)); + // Paper start - fix a variety of piston desync dupes + if (!allowDesync) { + iblockdata1 = world.getBlockState(oldPos); + map.replace(oldPos, iblockdata1); + } -+ world.setBlockEntity(blockposition3, MovingPistonBlock.newMovingBlockEntity(allowDesync ? list1.get(k) : iblockdata1, dir, retract, false)); ++ world.setBlockEntity(MovingPistonBlock.newMovingBlockEntity(blockposition3, iblockdata2, allowDesync ? list1.get(k) : iblockdata1, dir, retract, false)); + if (!allowDesync) { + world.setBlock(oldPos, Blocks.AIR.defaultBlockState(), 2 | 4 | 16 | 1024); // set air to prevent later physics updates from seeing this block + } @@ -79,15 +81,15 @@ index 40a18302dd682e5ade4ec77ac7f316b6c0f8c112..44876557515eaa6bbe33344b3d3ba03a } diff --git a/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java b/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java -index 73888713746e7ddd72ba9ac9d33d8e616eb3bd25..001e90da8b09e16b6df4849a5bac4f4821000c94 100644 +index 9b631698d1c736f61e07a5a1253127f4081dc90d..87bedba9ab495edcce289c6665271d92b7165944 100644 --- a/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java -@@ -279,7 +279,7 @@ public class PistonMovingBlockEntity extends BlockEntity implements TickableBloc - BlockState iblockdata = Block.updateFromNeighbourShapes(this.movedState, (LevelAccessor) this.level, this.worldPosition); - - if (iblockdata.isAir()) { -- this.level.setBlock(this.worldPosition, this.movedState, 84); -+ this.level.setBlock(this.worldPosition, this.movedState, 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.updateOrDestroy(this.movedState, iblockdata, this.level, this.worldPosition, 3); +@@ -281,7 +281,7 @@ public class PistonMovingBlockEntity extends BlockEntity { + if (blockEntity.movedState != null && world.getBlockState(pos).is(Blocks.MOVING_PISTON)) { + BlockState blockState = Block.updateFromNeighbourShapes(blockEntity.movedState, world, pos); + if (blockState.isAir()) { +- world.setBlock(pos, blockEntity.movedState, 84); ++ world.setBlock(pos, blockEntity.movedState, 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.updateOrDestroy(blockEntity.movedState, blockState, world, pos, 3); } else { - if (iblockdata.hasProperty(BlockStateProperties.WATERLOGGED) && (Boolean) iblockdata.getValue(BlockStateProperties.WATERLOGGED)) { + if (blockState.hasProperty(BlockStateProperties.WATERLOGGED) && blockState.getValue(BlockStateProperties.WATERLOGGED)) { diff --git a/patches/server-remapped/0499-Fix-sand-duping.patch b/patches/server/0453-Fix-sand-duping.patch similarity index 81% rename from patches/server-remapped/0499-Fix-sand-duping.patch rename to patches/server/0453-Fix-sand-duping.patch index d06a661655..dd88074406 100644 --- a/patches/server-remapped/0499-Fix-sand-duping.patch +++ b/patches/server/0453-Fix-sand-duping.patch @@ -7,27 +7,27 @@ 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/world/entity/item/FallingBlockEntity.java b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java -index ff8f7e4569a889ead1512b7c9908f9c5cad9eed5..2ba81e7179c7f9e2e1add1ad6bd6b96ee12c5da1 100644 +index 2332a00780edcf054ec63a60a42962033d0cc74a..2fad050547242028d4ff2deb613e074190f51341 100644 --- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java +++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java -@@ -101,6 +101,11 @@ public class FallingBlockEntity extends Entity { +@@ -106,6 +106,11 @@ public class FallingBlockEntity extends Entity { @Override public void tick() { + // Paper start - fix sand duping -+ if (this.removed) { ++ if (this.isRemoved()) { + return; + } + // Paper end - fix sand duping if (this.blockState.isAir()) { - this.remove(); + this.discard(); } else { -@@ -123,6 +128,12 @@ public class FallingBlockEntity extends Entity { +@@ -128,6 +133,12 @@ public class FallingBlockEntity extends Entity { this.move(MoverType.SELF, this.getDeltaMovement()); + // Paper start - fix sand duping -+ if (this.removed) { ++ if (this.isRemoved()) { + return; + } + // Paper end - fix sand duping diff --git a/patches/server-remapped/0500-Prevent-position-desync-in-playerconnection-causing-.patch b/patches/server/0454-Prevent-position-desync-in-playerconnection-causing-.patch similarity index 86% rename from patches/server-remapped/0500-Prevent-position-desync-in-playerconnection-causing-.patch rename to patches/server/0454-Prevent-position-desync-in-playerconnection-causing-.patch index 9994f830fa..032768e519 100644 --- a/patches/server-remapped/0500-Prevent-position-desync-in-playerconnection-causing-.patch +++ b/patches/server/0454-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/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 0625bc7ffd07b66b27176fe62ae3061aa7c67df2..fbafb89cc63744d942933546026e272122bd9fba 100644 +index b5325f19458467b307db629a00359af41004124a..7c9ac85431f8c5a325c94c0e7d1db0315b2d62c1 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -1324,6 +1324,11 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener { +@@ -1345,6 +1345,11 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser this.player.move(MoverType.PLAYER, new Vec3(d7, d8, d9)); this.player.setOnGround(packet.isOnGround()); // CraftBukkit - SPIGOT-5810, SPIGOT-5835: reset by this.player.move @@ -28,4 +28,4 @@ index 0625bc7ffd07b66b27176fe62ae3061aa7c67df2..fbafb89cc63744d942933546026e2721 + // Paper end - prevent position desync double d12 = d8; - d7 = d4 - this.player.getX(); + d7 = d0 - this.player.getX(); diff --git a/patches/server-remapped/0502-Inventory-getHolder-method-without-block-snapshot.patch b/patches/server/0455-Inventory-getHolder-method-without-block-snapshot.patch similarity index 56% rename from patches/server-remapped/0502-Inventory-getHolder-method-without-block-snapshot.patch rename to patches/server/0455-Inventory-getHolder-method-without-block-snapshot.patch index d25c9ffc5a..888e64518b 100644 --- a/patches/server-remapped/0502-Inventory-getHolder-method-without-block-snapshot.patch +++ b/patches/server/0455-Inventory-getHolder-method-without-block-snapshot.patch @@ -5,33 +5,25 @@ 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 ef2d18d19a86b3701855aa1ac126462e663f8fcd..7ccc085228f373e6eba55d809bed480d43d5c211 100644 +index 56bd3290fdf011590594d68128eb3fe9ca71506c..7850dfa9130761905030856786a97a008c700687 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java -@@ -10,6 +10,7 @@ import net.minecraft.world.inventory.PlayerEnderChestContainer; - import net.minecraft.world.level.block.entity.AbstractFurnaceBlockEntity; - import net.minecraft.world.level.block.entity.BarrelBlockEntity; - import net.minecraft.world.level.block.entity.BlastFurnaceBlockEntity; -+import net.minecraft.world.level.block.entity.BlockEntity; - import net.minecraft.world.level.block.entity.BrewingStandBlockEntity; - import net.minecraft.world.level.block.entity.DispenserBlockEntity; - import net.minecraft.world.level.block.entity.DropperBlockEntity; -@@ -525,6 +526,13 @@ public class CraftInventory implements Inventory { - return inventory.getOwner(); +@@ -525,6 +525,13 @@ public class CraftInventory implements Inventory { + return this.inventory.getOwner(); } + // Paper start - getHolder without snapshot + @Override + public InventoryHolder getHolder(boolean useSnapshot) { -+ return inventory instanceof BlockEntity ? ((BlockEntity) inventory).getOwner(useSnapshot) : getHolder(); ++ return inventory instanceof net.minecraft.world.level.block.entity.BlockEntity ? ((net.minecraft.world.level.block.entity.BlockEntity) inventory).getOwner(useSnapshot) : getHolder(); + } + // Paper end + @Override public int getMaxStackSize() { - return inventory.getMaxStackSize(); + return this.inventory.getMaxStackSize(); diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryDoubleChest.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryDoubleChest.java -index 3245dfa94410d319e53543c862c990e80ed3c72d..23dcf6e9332bd2b42ebb851497483e41948355d8 100644 +index 01d425d359f2d6d87b6c01b435a9cfcfe11caa20..4707a651dc80086efa852bcfba38a534e7f1f3d0 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryDoubleChest.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryDoubleChest.java @@ -64,6 +64,13 @@ public class CraftInventoryDoubleChest extends CraftInventory implements DoubleC @@ -47,4 +39,4 @@ index 3245dfa94410d319e53543c862c990e80ed3c72d..23dcf6e9332bd2b42ebb851497483e41 + @Override public Location getLocation() { - return getLeftSide().getLocation().add(getRightSide().getLocation()).multiply(0.5); + return this.getLeftSide().getLocation().add(this.getRightSide().getLocation()).multiply(0.5); diff --git a/patches/server/0456-Expose-Arrow-getItemStack.patch b/patches/server/0456-Expose-Arrow-getItemStack.patch new file mode 100644 index 0000000000..3529a49750 --- /dev/null +++ b/patches/server/0456-Expose-Arrow-getItemStack.patch @@ -0,0 +1,24 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Nesaak <52047222+Nesaak@users.noreply.github.com> +Date: Sat, 23 May 2020 10:31:11 -0400 +Subject: [PATCH] Expose Arrow getItemStack + + +diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java +index 376885c8148da619a3b203145d315ebaf44994fb..88defdc48c72580bbf029910f159dedccf67dc1e 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 { + this.getHandle().pickup = net.minecraft.world.entity.projectile.AbstractArrow.Pickup.byOrdinal(status.ordinal()); + } + ++ // Paper start ++ @Override ++ public org.bukkit.craftbukkit.inventory.CraftItemStack getItemStack() { ++ return org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(getHandle().getPickupItem()); ++ } ++ //Paper end ++ + @Override + public void setTicksLived(int value) { + super.setTicksLived(value); diff --git a/patches/server-remapped/0504-Add-and-implement-PlayerRecipeBookClickEvent.patch b/patches/server/0457-Add-and-implement-PlayerRecipeBookClickEvent.patch similarity index 76% rename from patches/server-remapped/0504-Add-and-implement-PlayerRecipeBookClickEvent.patch rename to patches/server/0457-Add-and-implement-PlayerRecipeBookClickEvent.patch index 412fc1c8ad..dd62e3c0fe 100644 --- a/patches/server-remapped/0504-Add-and-implement-PlayerRecipeBookClickEvent.patch +++ b/patches/server/0457-Add-and-implement-PlayerRecipeBookClickEvent.patch @@ -5,25 +5,23 @@ Subject: [PATCH] Add and implement PlayerRecipeBookClickEvent diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index fbafb89cc63744d942933546026e272122bd9fba..a0b2fc3fe59d97b9282a9451f35542b39df774e7 100644 +index 7c9ac85431f8c5a325c94c0e7d1db0315b2d62c1..c65f6eda0cff66ae9007e92002075e1f6fd631cd 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -2770,9 +2770,15 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener { +@@ -2778,9 +2778,14 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel()); this.player.resetLastActionTime(); - if (!this.player.isSpectator() && this.player.containerMenu.containerId == packet.getContainerId() && this.player.containerMenu.isSynched(this.player) && this.player.containerMenu instanceof RecipeBookMenu) { + if (!this.player.isSpectator() && this.player.containerMenu.containerId == packet.getContainerId() && this.player.containerMenu instanceof RecipeBookMenu) { - this.server.getRecipeManager().byKey(packet.getRecipe()).ifPresent((irecipe) -> { - ((RecipeBookMenu) this.player.containerMenu).handlePlacement(packet.isShiftDown(), irecipe, this.player); -- }); + // Paper start - fire event for clicking recipes in the recipe book + com.destroystokyo.paper.event.player.PlayerRecipeBookClickEvent event = new com.destroystokyo.paper.event.player.PlayerRecipeBookClickEvent( + player.getBukkitEntity(), org.bukkit.craftbukkit.util.CraftNamespacedKey.fromMinecraft(packet.getRecipe()), packet.isShiftDown()); + if (event.callEvent()) { + this.server.getRecipeManager().byKey(org.bukkit.craftbukkit.util.CraftNamespacedKey.toMinecraft(event.getRecipe())).ifPresent((irecipe) -> { -+ ((ContainerRecipeBook) this.player.activeContainer).a(event.isMakeAll(), irecipe, this.player); -+ }); -+ } -+ // Paper end ++ ((RecipeBookMenu) this.player.containerMenu).handlePlacement(event.isMakeAll(), irecipe, this.player); + }); ++ } // Paper end } } diff --git a/patches/server-remapped/0505-Hide-sync-chunk-writes-behind-flag.patch b/patches/server/0458-Hide-sync-chunk-writes-behind-flag.patch similarity index 93% rename from patches/server-remapped/0505-Hide-sync-chunk-writes-behind-flag.patch rename to patches/server/0458-Hide-sync-chunk-writes-behind-flag.patch index 43a0839a47..f00dbd43a0 100644 --- a/patches/server-remapped/0505-Hide-sync-chunk-writes-behind-flag.patch +++ b/patches/server/0458-Hide-sync-chunk-writes-behind-flag.patch @@ -9,7 +9,7 @@ on harddrives. -DPaper.enable-sync-chunk-writes=true to enable diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java -index 545096d9ba403396b6aaa7bb6d912f2de08a967e..3450a58fc02a472eb710aa1a31f6fecefc982b6f 100644 +index e3409d5f4ddcaa4edecfa4b3c638a12624b09f1b..c9d80a5430cc66d6189bf337770af43121a5bfd5 100644 --- a/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java +++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java @@ -108,7 +108,7 @@ public class DedicatedServerProperties extends Settings +Date: Sun, 10 May 2020 22:12:46 -0400 +Subject: [PATCH] Ensure Entity AABB's are never invalid + + +diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java +index 11ae525a5d2bd29bfe658d683c53a0ab2626616a..fd0cef886761e71fe331aa60806c186c23ed19bc 100644 +--- a/src/main/java/net/minecraft/world/entity/Entity.java ++++ b/src/main/java/net/minecraft/world/entity/Entity.java +@@ -540,7 +540,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, n + + public void setPos(double x, double y, double z) { + this.setPosRaw(x, y, z); +- this.setBoundingBox(this.makeBoundingBox()); ++ // this.setBoundingBox(this.makeBoundingBox()); // Paper - move into setPositionRaw + } + + protected AABB makeBoundingBox() { +@@ -3717,6 +3717,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, n + } + + public final void setPosRaw(double x, double y, double z) { ++ // Paper start - never allow AABB to become desynced from position ++ // hanging has its own special logic ++ if (!(this instanceof net.minecraft.world.entity.decoration.HangingEntity) && (this.position.x != x || this.position.y != y || this.position.z != z)) { ++ this.setBoundingBox(this.dimensions.makeBoundingBox(x, y, z)); ++ } ++ // Paper end + if (this.position.x != x || this.position.y != y || this.position.z != z) { + this.position = new Vec3(x, y, z); + int i = Mth.floor(x); diff --git a/patches/server/0461-Optimize-WorldBorder-collision-checks-and-air.patch b/patches/server/0461-Optimize-WorldBorder-collision-checks-and-air.patch new file mode 100644 index 0000000000..01936bbbf9 --- /dev/null +++ b/patches/server/0461-Optimize-WorldBorder-collision-checks-and-air.patch @@ -0,0 +1,50 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Spottedleaf +Date: Sun, 10 May 2020 22:49:05 -0400 +Subject: [PATCH] Optimize WorldBorder collision checks and air + + +diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java +index fd0cef886761e71fe331aa60806c186c23ed19bc..96da70f1077f70c4bd5ba1196292a856deb25286 100644 +--- a/src/main/java/net/minecraft/world/entity/Entity.java ++++ b/src/main/java/net/minecraft/world/entity/Entity.java +@@ -1024,7 +1024,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, n + AABB axisalignedbb = this.getBoundingBox(); + CollisionContext voxelshapecollision = CollisionContext.of(this); + VoxelShape voxelshape = this.level.getWorldBorder().getCollisionShape(); +- Stream stream = Shapes.joinIsNotEmpty(voxelshape, Shapes.create(axisalignedbb.deflate(1.0E-7D)), BooleanOp.AND) ? Stream.empty() : Stream.of(voxelshape); ++ Stream stream = !this.level.getWorldBorder().isWithinBounds(axisalignedbb) ? Stream.empty() : Stream.of(voxelshape); // Paper + Stream stream1 = this.level.getEntityCollisions(this, axisalignedbb.expandTowards(movement), (entity) -> { + return true; + }); +diff --git a/src/main/java/net/minecraft/world/level/CollisionSpliterator.java b/src/main/java/net/minecraft/world/level/CollisionSpliterator.java +index 90039d01ef481ba206f2e952c99a755e94201ea3..2e93f33d6c9074c246c2289523b1fda20a2cf0dd 100644 +--- a/src/main/java/net/minecraft/world/level/CollisionSpliterator.java ++++ b/src/main/java/net/minecraft/world/level/CollisionSpliterator.java +@@ -135,9 +135,10 @@ public class CollisionSpliterator extends AbstractSpliterator { + WorldBorder worldBorder = this.collisionGetter.getWorldBorder(); + AABB aABB = this.source.getBoundingBox(); + if (!isBoxFullyWithinWorldBorder(worldBorder, aABB)) { +- VoxelShape voxelShape = worldBorder.getCollisionShape(); +- if (!isOutsideBorder(voxelShape, aABB) && isCloseToBorder(voxelShape, aABB)) { +- action.accept(voxelShape); ++ // Paper start ++ if (worldBorder.isWithinBounds(aABB.deflate(1.0E-7D)) && !worldBorder.isWithinBounds(aABB.inflate(1.0E-7D))) { ++ action.accept(worldBorder.asVoxelShape()); ++ // Paper end + return true; + } + } +diff --git a/src/main/java/net/minecraft/world/phys/shapes/Shapes.java b/src/main/java/net/minecraft/world/phys/shapes/Shapes.java +index 94f58332bb1408971fe65e5fd0401457ab986441..ceeec68fba8dacdc5b023c8817a6863b28c0e132 100644 +--- a/src/main/java/net/minecraft/world/phys/shapes/Shapes.java ++++ b/src/main/java/net/minecraft/world/phys/shapes/Shapes.java +@@ -240,7 +240,7 @@ public final class Shapes { + mutableBlockPos.set(axisCycle, q, r, p); + BlockState blockState = world.getTypeIfLoaded(mutableBlockPos); // Paper + if (blockState == null) return 0.0D; // Paper +- if ((s != 1 || blockState.hasLargeCollisionShape()) && (s != 2 || blockState.is(Blocks.MOVING_PISTON))) { ++ if (!blockState.isAir() && (s != 1 || blockState.hasLargeCollisionShape()) && (s != 2 || blockState.is(Blocks.MOVING_PISTON))) { // Paper + initial = blockState.getCollisionShape(world, mutableBlockPos, context).collide(axis3, box.move((double)(-mutableBlockPos.getX()), (double)(-mutableBlockPos.getY()), (double)(-mutableBlockPos.getZ())), initial); + if (Math.abs(initial) < 1.0E-7D) { + return 0.0D; diff --git a/patches/server-remapped/0510-Fix-Per-World-Difficulty-Remembering-Difficulty.patch b/patches/server/0462-Fix-Per-World-Difficulty-Remembering-Difficulty.patch similarity index 57% rename from patches/server-remapped/0510-Fix-Per-World-Difficulty-Remembering-Difficulty.patch rename to patches/server/0462-Fix-Per-World-Difficulty-Remembering-Difficulty.patch index 568d1c34e6..eec5efcc02 100644 --- a/patches/server-remapped/0510-Fix-Per-World-Difficulty-Remembering-Difficulty.patch +++ b/patches/server/0462-Fix-Per-World-Difficulty-Remembering-Difficulty.patch @@ -8,61 +8,52 @@ makes it so that the server keeps the last difficulty used instead of restoring the server.properties every single load. diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index f530c739b6aee3718eb5d0e0e6a09d882d817c68..19544b794b5a46c129016172798ff7294fcfed33 100644 +index 363dcebb3b2d5a2512776a191f6716ed3d0e8aff..1feda8b44364c748497174944b26abc4f058f354 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -1645,11 +1645,15 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop SUBCOMMANDS = ImmutableSet.builder().add("heap", "entity", "reload", "version", "debug", "chunkinfo", "dumpwaiting", "syncloadinfo", "fixlight").build(); -+ private static final ImmutableSet SUBCOMMANDS = ImmutableSet.builder().add("heap", "entity", "reload", "version", "debug", "chunkinfo", "dumpwaiting", "syncloadinfo", "fixlight", "dumpitem").build(); +- private static final ImmutableSet SUBCOMMANDS = ImmutableSet.builder().add("heap", "entity", "reload", "version", "debug", "chunkinfo", "fixlight").build(); ++ private static final ImmutableSet SUBCOMMANDS = ImmutableSet.builder().add("heap", "entity", "reload", "version", "debug", "chunkinfo", "fixlight", "dumpitem").build(); public PaperCommand(String name) { super(name); -@@ -168,6 +171,9 @@ public class PaperCommand extends Command { +@@ -156,6 +159,9 @@ public class PaperCommand extends Command { case "reload": doReload(sender); break; @@ -46,18 +46,18 @@ index 528c860fc0c04431e0ebb2ae6bc96bf9c2d04789..6fad9329213e4e8a3ef9ce7fb568ad22 case "debug": doDebug(sender, args); break; -@@ -200,6 +206,19 @@ public class PaperCommand extends Command { - return true; - } +@@ -420,6 +426,19 @@ public class PaperCommand extends Command { + Command.broadcastCommandMessage(sender, ChatColor.GREEN + "Paper config reload complete."); + } + private void doDumpItem(CommandSender sender) { + ItemStack itemInHand = ((CraftPlayer) sender).getItemInHand(); + net.minecraft.world.item.ItemStack itemStack = CraftItemStack.asNMSCopy(itemInHand); -+ CompoundTag tag = itemStack.getTag(); ++ net.minecraft.nbt.CompoundTag tag = itemStack.getTag(); + if (tag != null) { -+ String nbt = org.bukkit.craftbukkit.util.CraftChatMessage.fromComponent(tag.getNbtPrettyComponent()); -+ Bukkit.getConsoleSender().sendMessage(nbt); -+ sender.sendMessage(nbt); ++ net.kyori.adventure.text.Component nbtComponent = io.papermc.paper.adventure.PaperAdventure.asAdventure(net.minecraft.nbt.NbtUtils.toPrettyComponent(tag)); ++ Bukkit.getConsoleSender().sendMessage(nbtComponent); ++ sender.sendMessage(nbtComponent); + } else { + sender.sendMessage("Item does not have NBT"); + } @@ -66,15 +66,3 @@ index 528c860fc0c04431e0ebb2ae6bc96bf9c2d04789..6fad9329213e4e8a3ef9ce7fb568ad22 private void doFixLight(CommandSender sender, String[] args) { if (!(sender instanceof Player)) { sender.sendMessage("Only players can use this command"); -diff --git a/src/main/java/net/minecraft/nbt/Tag.java b/src/main/java/net/minecraft/nbt/Tag.java -index 85e9c5f4620fcf48cb3655fbb2db58b3fb31aa74..ba204cf135be333d4ac1c06ee6c2e961faadf8cb 100644 ---- a/src/main/java/net/minecraft/nbt/Tag.java -+++ b/src/main/java/net/minecraft/nbt/Tag.java -@@ -26,6 +26,7 @@ public interface Tag { - return this.toString(); - } - -+ default Component getNbtPrettyComponent() { return this.getPrettyDisplay(); } // Paper - OBFHELPER - default Component getPrettyDisplay() { - return this.getPrettyDisplay("", 0); - } diff --git a/patches/server-remapped/0512-Don-t-allow-null-UUID-s-for-chat.patch b/patches/server/0464-Don-t-allow-null-UUID-s-for-chat.patch similarity index 53% rename from patches/server-remapped/0512-Don-t-allow-null-UUID-s-for-chat.patch rename to patches/server/0464-Don-t-allow-null-UUID-s-for-chat.patch index dfc52a21c5..1117d64336 100644 --- a/patches/server-remapped/0512-Don-t-allow-null-UUID-s-for-chat.patch +++ b/patches/server/0464-Don-t-allow-null-UUID-s-for-chat.patch @@ -5,23 +5,15 @@ Subject: [PATCH] Don't allow null UUID's for chat diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundChatPacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundChatPacket.java -index 002a6c7933f64405707d7d34d3e5c17584539623..a983785bf3bc43f65bd0809870c14a9fd30a3fc1 100644 +index 26a229f7aa3f4425ed572e2d50730b4e978bf33e..a9fdfa7ec2a022e8adaa62721fb56748884686f5 100644 --- a/src/main/java/net/minecraft/network/protocol/game/ClientboundChatPacket.java +++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundChatPacket.java -@@ -3,6 +3,7 @@ package net.minecraft.network.protocol.game; - - import java.io.IOException; - import java.util.UUID; -+import net.minecraft.Util; - import net.minecraft.network.FriendlyByteBuf; - import net.minecraft.network.chat.ChatType; - import net.minecraft.network.chat.Component; -@@ -21,7 +22,7 @@ public class ClientboundChatPacket implements Packet { - public ClientboundChatPacket(Component message, ChatType location, UUID senderUuid) { +@@ -18,7 +18,7 @@ public class ClientboundChatPacket implements Packet { + public ClientboundChatPacket(Component message, ChatType location, UUID sender) { this.message = message; this.type = location; -- this.sender = senderUuid; -+ this.sender = senderUuid != null ? senderUuid : Util.getNullUUID(); // Paper +- this.sender = sender; ++ this.sender = sender != null ? sender : net.minecraft.Util.NIL_UUID; } - @Override + public ClientboundChatPacket(FriendlyByteBuf buf) { diff --git a/patches/server-remapped/0513-Improve-Legacy-Component-serialization-size.patch b/patches/server/0465-Improve-Legacy-Component-serialization-size.patch similarity index 81% rename from patches/server-remapped/0513-Improve-Legacy-Component-serialization-size.patch rename to patches/server/0465-Improve-Legacy-Component-serialization-size.patch index 2f031e9064..8d30b49c6b 100644 --- a/patches/server-remapped/0513-Improve-Legacy-Component-serialization-size.patch +++ b/patches/server/0465-Improve-Legacy-Component-serialization-size.patch @@ -7,7 +7,7 @@ Don't constantly send format: false for all formatting options when parent alrea has it false diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java b/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java -index b27af66795d902a2e95d692fa0ff18eccbef8a75..b89660244ffad484e3fbf69ccb9cdc1bc178d2ad 100644 +index 0de5a46423ae0403dcbfca630dfd7c5ac1e1761d..26d43c229caf9f8504af7071c3a61ec6da7e27ec 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java @@ -46,6 +46,7 @@ public final class CraftChatMessage { @@ -15,11 +15,11 @@ index b27af66795d902a2e95d692fa0ff18eccbef8a75..b89660244ffad484e3fbf69ccb9cdc1b private static final Pattern INCREMENTAL_PATTERN_KEEP_NEWLINES = Pattern.compile("(" + String.valueOf(org.bukkit.ChatColor.COLOR_CHAR) + "[0-9a-fk-orx])|((?:(?:https?):\\/\\/)?(?:[-\\w_\\.]{2,}\\.[a-z]{2,4}.*?(?=[\\.\\?!,;:]?(?:[" + String.valueOf(org.bukkit.ChatColor.COLOR_CHAR) + " ]|$))))", Pattern.CASE_INSENSITIVE); // ChatColor.b does not explicitly reset, its more of empty + private static final Style EMPTY = Style.EMPTY.withItalic(false); // Paper - OBFHELPER - private static final Style RESET = Style.EMPTY.withBold(false).withItalic(false).setUnderline(false).setStrikethrough(false).setRandom(false); + private static final Style RESET = Style.EMPTY.withBold(false).withItalic(false).withUnderlined(false).withStrikethrough(false).withObfuscated(false); private final List list = new ArrayList(); @@ -67,6 +68,7 @@ public final class CraftChatMessage { - Matcher matcher = (keepNewlines ? INCREMENTAL_PATTERN_KEEP_NEWLINES : INCREMENTAL_PATTERN).matcher(message); + Matcher matcher = (keepNewlines ? StringMessage.INCREMENTAL_PATTERN_KEEP_NEWLINES : StringMessage.INCREMENTAL_PATTERN).matcher(message); String match = null; boolean needsAdd = false; + boolean hasReset = false; // Paper @@ -30,7 +30,7 @@ index b27af66795d902a2e95d692fa0ff18eccbef8a75..b89660244ffad484e3fbf69ccb9cdc1b throw new AssertionError("Unexpected message format"); } } else { // Color resets formatting -- modifier = RESET.withColor(format); +- this.modifier = StringMessage.RESET.withColor(format); + // Paper start - improve legacy formatting + Style previous = modifier; + modifier = (!hasReset ? RESET : EMPTY).withColor(format); @@ -42,13 +42,13 @@ index b27af66795d902a2e95d692fa0ff18eccbef8a75..b89660244ffad484e3fbf69ccb9cdc1b + modifier = modifier.withItalic(false); + } + if (previous.isObfuscated()) { -+ modifier = modifier.setRandom(false); ++ modifier = modifier.withObfuscated(false); + } + if (previous.isStrikethrough()) { -+ modifier = modifier.setStrikethrough(false); ++ modifier = modifier.withStrikethrough(false); + } + if (previous.isUnderlined()) { -+ modifier = modifier.setUnderline(false); ++ modifier = modifier.withUnderlined(false); + } + // Paper end } diff --git a/patches/server-remapped/0514-Support-old-UUID-format-for-NBT.patch b/patches/server/0466-Support-old-UUID-format-for-NBT.patch similarity index 51% rename from patches/server-remapped/0514-Support-old-UUID-format-for-NBT.patch rename to patches/server/0466-Support-old-UUID-format-for-NBT.patch index ffba727ac3..0418f312a1 100644 --- a/patches/server-remapped/0514-Support-old-UUID-format-for-NBT.patch +++ b/patches/server/0466-Support-old-UUID-format-for-NBT.patch @@ -8,10 +8,10 @@ We have stored UUID in plenty of places that did not get DFU'd So just look for old format and load it if it exists. diff --git a/src/main/java/net/minecraft/nbt/CompoundTag.java b/src/main/java/net/minecraft/nbt/CompoundTag.java -index c856ca720a9329a94bb07eaa3060c034f95718b3..0b739b5f040697049893d311c99456dbc5470e93 100644 +index 1aa3af8c7714b2c850fb4264c863db8e639e6284..2a805d6bbeede50898d36258976ff25ee0aea165 100644 --- a/src/main/java/net/minecraft/nbt/CompoundTag.java +++ b/src/main/java/net/minecraft/nbt/CompoundTag.java -@@ -142,6 +142,12 @@ public class CompoundTag implements Tag { +@@ -121,6 +121,12 @@ public class CompoundTag implements Tag { public void setUUID(String prefix, UUID uuid) { putUUID(prefix, uuid); } // Paper - OBFHELPER public void putUUID(String key, UUID value) { @@ -24,9 +24,9 @@ index c856ca720a9329a94bb07eaa3060c034f95718b3..0b739b5f040697049893d311c99456db this.tags.put(key, NbtUtils.createUUID(value)); } -@@ -151,11 +157,21 @@ public class CompoundTag implements Tag { +@@ -129,10 +135,20 @@ public class CompoundTag implements Tag { + * You must use {@link #hasUUID(String)} before or else it will throw an NPE. */ - public UUID getUUID(String prefix) { return getUUID(prefix); } // Paper - OBFHELPER public UUID getUUID(String key) { + // Paper start - support old format + if (!contains(key, 11) && this.contains(key + "Most", 99) && this.contains(key + "Least", 99)) { @@ -36,29 +36,45 @@ index c856ca720a9329a94bb07eaa3060c034f95718b3..0b739b5f040697049893d311c99456db return NbtUtils.loadUUID(this.get(key)); } - public final boolean hasUUID(String s) { return this.hasUUID(s); } // Paper - OBFHELPER public boolean hasUUID(String key) { + // Paper start - support old format + if (this.contains(key + "Most", 99) && this.contains(key + "Least", 99)) { + return true; + } + // Paper end - Tag nbtbase = this.get(key); - - return nbtbase != null && nbtbase.getType() == IntArrayTag.TYPE && ((IntArrayTag) nbtbase).getAsIntArray().length == 4; + Tag tag = this.get(key); + return tag != null && tag.getType() == IntArrayTag.TYPE && ((IntArrayTag)tag).getAsIntArray().length == 4; + } diff --git a/src/main/java/net/minecraft/nbt/NbtUtils.java b/src/main/java/net/minecraft/nbt/NbtUtils.java -index bf0da04ec9db3ec8313bddb06c278c13073819d1..f57c5e441045a81072a2edfed0f199d90e6d7fde 100644 +index 57c9575a9714acb95d9dced672955a96d71dfd1e..dc136cd4d5d4ba1e0e53a7187b3a2e836e185c19 100644 --- a/src/main/java/net/minecraft/nbt/NbtUtils.java +++ b/src/main/java/net/minecraft/nbt/NbtUtils.java -@@ -40,6 +40,11 @@ public final class NbtUtils { - s = tag.getString("Name"); +@@ -40,14 +40,14 @@ import org.apache.logging.log4j.LogManager; + import org.apache.logging.log4j.Logger; + + public final class NbtUtils { +- private static final Comparator YXZ_LISTTAG_INT_COMPARATOR = Comparator.comparingInt((listTag) -> { ++ private static final Comparator YXZ_LISTTAG_INT_COMPARATOR = Comparator.comparingInt((listTag) -> { // Paper - decompile fix + return listTag.getInt(1); + }).thenComparingInt((listTag) -> { + return listTag.getInt(0); + }).thenComparingInt((listTag) -> { + return listTag.getInt(2); + }); +- private static final Comparator YXZ_LISTTAG_DOUBLE_COMPARATOR = Comparator.comparingDouble((listTag) -> { ++ private static final Comparator YXZ_LISTTAG_DOUBLE_COMPARATOR = Comparator.comparingDouble((listTag) -> { // Paper - decompile fix + return listTag.getDouble(1); + }).thenComparingDouble((listTag) -> { + return listTag.getDouble(0); +@@ -76,6 +76,11 @@ public final class NbtUtils { + string = compound.getString("Name"); } + // Paper start - support string UUID's -+ if (tag.contains("Id", 8)) { -+ uuid = UUID.fromString(tag.getString("Id")); ++ if (compound.contains("Id", 8)) { ++ uUID = UUID.fromString(compound.getString("Id")); + } + // Paper end - if (tag.hasUUID("Id")) { - uuid = tag.getUUID("Id"); + if (compound.hasUUID("Id")) { + uUID = compound.getUUID("Id"); } diff --git a/patches/server/0467-Clean-up-duplicated-GameProfile-Properties.patch b/patches/server/0467-Clean-up-duplicated-GameProfile-Properties.patch new file mode 100644 index 0000000000..495144b4fb --- /dev/null +++ b/patches/server/0467-Clean-up-duplicated-GameProfile-Properties.patch @@ -0,0 +1,47 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Aikar +Date: Wed, 1 Jul 2020 03:12:06 -0400 +Subject: [PATCH] Clean up duplicated GameProfile Properties + +We had a bug where we accidently cloned properties resulting in skulls +growing to large sizes and preventing login. + +This now automatically cleans up the extra properties. + +diff --git a/src/main/java/net/minecraft/nbt/NbtUtils.java b/src/main/java/net/minecraft/nbt/NbtUtils.java +index dc136cd4d5d4ba1e0e53a7187b3a2e836e185c19..1a9435a55e20170244497be70d86d989a4e0f78f 100644 +--- a/src/main/java/net/minecraft/nbt/NbtUtils.java ++++ b/src/main/java/net/minecraft/nbt/NbtUtils.java +@@ -93,7 +93,8 @@ public final class NbtUtils { + for(String string2 : compoundTag.getAllKeys()) { + ListTag listTag = compoundTag.getList(string2, 10); + +- for(int i = 0; i < listTag.size(); ++i) { ++ if (listTag.size() == 0) continue; // Paper - remove duplicate properties ++ for (int i = listTag.size() - 1; i < listTag.size(); ++i) { // Paper - remove duplicate properties + CompoundTag compoundTag2 = listTag.getCompound(i); + String string3 = compoundTag2.getString("Value"); + if (compoundTag2.contains("Signature", 8)) { +diff --git a/src/main/java/net/minecraft/world/item/PlayerHeadItem.java b/src/main/java/net/minecraft/world/item/PlayerHeadItem.java +index 7fb2cc8d49a2d8f256f625cb99b66ef8efc3fc0e..f9980110a4614bb0206dce3dc796d9459069b750 100644 +--- a/src/main/java/net/minecraft/world/item/PlayerHeadItem.java ++++ b/src/main/java/net/minecraft/world/item/PlayerHeadItem.java +@@ -53,6 +53,18 @@ public class PlayerHeadItem extends StandingAndWallBlockItem { + }); + // CraftBukkit start + } else { ++ // Paper start - clean up old duplicated properties ++ CompoundTag properties = nbt.getCompound("SkullOwner").getCompound("Properties"); ++ for (String key : properties.getAllKeys()) { ++ net.minecraft.nbt.ListTag values = properties.getList(key, 10); ++ if (values.size() > 1) { ++ net.minecraft.nbt.Tag texture = values.get(values.size() - 1); ++ values = new net.minecraft.nbt.ListTag(); ++ values.add(texture); ++ properties.put(key, values); ++ } ++ } ++ // Paper end + net.minecraft.nbt.ListTag textures = nbt.getCompound("SkullOwner").getCompound("Properties").getList("textures", 10); // Safe due to method contracts + for (int i = 0; i < textures.size(); i++) { + if (textures.get(i) instanceof CompoundTag && !((CompoundTag) textures.get(i)).contains("Signature", 8) && ((CompoundTag) textures.get(i)).getString("Value").trim().isEmpty()) {