diff --git a/patches/server/0104-Don-t-lookup-game-profiles-that-have-no-UUID-and-no-.patch b/patches/server/0104-Don-t-lookup-game-profiles-that-have-no-UUID-and-no-.patch index 038e2fbd21..f7dfc982e6 100644 --- a/patches/server/0104-Don-t-lookup-game-profiles-that-have-no-UUID-and-no-.patch +++ b/patches/server/0104-Don-t-lookup-game-profiles-that-have-no-UUID-and-no-.patch @@ -5,14 +5,14 @@ Subject: [PATCH] Don't lookup game profiles that have no UUID and no name diff --git a/src/main/java/net/minecraft/server/players/GameProfileCache.java b/src/main/java/net/minecraft/server/players/GameProfileCache.java -index 1924757cec5d7f2d13ef35f9bbe1554d786713d7..0a2875f63523cc5eeec603e18eb62520587a8475 100644 +index 1924757cec5d7f2d13ef35f9bbe1554d786713d7..f13b0143ad89386f8e8d350ebacf98f4f66f18a8 100644 --- a/src/main/java/net/minecraft/server/players/GameProfileCache.java +++ b/src/main/java/net/minecraft/server/players/GameProfileCache.java @@ -89,6 +89,7 @@ public class GameProfileCache { } }; -+ if (!org.apache.commons.lang3.StringUtils.isBlank(name)) // Paper - Don't lookup a profile with a blank name) ++ if (!org.apache.commons.lang3.StringUtils.isBlank(name)) // Paper - Don't lookup a profile with a blank name repository.findProfilesByNames(new String[]{name}, profilelookupcallback); GameProfile gameprofile = (GameProfile) atomicreference.get(); diff --git a/patches/server/0105-Add-setting-for-proxy-online-mode-status.patch b/patches/server/0105-Add-setting-for-proxy-online-mode-status.patch index 073bea1053..af9d409ee8 100644 --- a/patches/server/0105-Add-setting-for-proxy-online-mode-status.patch +++ b/patches/server/0105-Add-setting-for-proxy-online-mode-status.patch @@ -23,14 +23,14 @@ index 1ee3e38703175707dec6493a1785b1bbc5170793..73b398ffc86498151944bedb0ef12d63 @Override diff --git a/src/main/java/net/minecraft/server/players/GameProfileCache.java b/src/main/java/net/minecraft/server/players/GameProfileCache.java -index 0a2875f63523cc5eeec603e18eb62520587a8475..64f7c3180a745a62bb5d71a42668cc67b5d56c3a 100644 +index f13b0143ad89386f8e8d350ebacf98f4f66f18a8..64f7c3180a745a62bb5d71a42668cc67b5d56c3a 100644 --- a/src/main/java/net/minecraft/server/players/GameProfileCache.java +++ b/src/main/java/net/minecraft/server/players/GameProfileCache.java @@ -89,7 +89,8 @@ public class GameProfileCache { } }; -- if (!org.apache.commons.lang3.StringUtils.isBlank(name)) // Paper - Don't lookup a profile with a blank name) +- if (!org.apache.commons.lang3.StringUtils.isBlank(name)) // Paper - Don't lookup a profile with a blank name + if (!org.apache.commons.lang3.StringUtils.isBlank(name) // Paper - Don't lookup a profile with a blank name + && io.papermc.paper.configuration.GlobalConfiguration.get().proxies.isProxyOnlineMode()) // Paper - Add setting for proxy online mode status repository.findProfilesByNames(new String[]{name}, profilelookupcallback); diff --git a/patches/server/0900-Fix-HumanEntity-drop-not-updating-the-client-inv.patch b/patches/server/0900-Fix-HumanEntity-drop-not-updating-the-client-inv.patch index e8652816d7..4aea1758ef 100644 --- a/patches/server/0900-Fix-HumanEntity-drop-not-updating-the-client-inv.patch +++ b/patches/server/0900-Fix-HumanEntity-drop-not-updating-the-client-inv.patch @@ -7,7 +7,7 @@ Subject: [PATCH] Fix HumanEntity#drop not updating the client inv public net.minecraft.server.level.ServerPlayer containerSynchronizer diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java -index 5e5fda690605f767b33f8225bffea98d23299fea..52c9244194f3c0182f3a6010ed97d4238efd4eb4 100644 +index 5e5fda690605f767b33f8225bffea98d23299fea..897e693492bdf9293154535d5772929bc2b1a523 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java @@ -755,8 +755,15 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { @@ -16,7 +16,7 @@ index 5e5fda690605f767b33f8225bffea98d23299fea..52c9244194f3c0182f3a6010ed97d423 public boolean dropItem(boolean dropAll) { - if (!(this.getHandle() instanceof ServerPlayer)) return false; - return ((ServerPlayer) this.getHandle()).drop(dropAll); -+ // Paper start - notify client of remote slot change ++ // Paper start - Fix HumanEntity#drop not updating the client inv + if (!(this.getHandle() instanceof ServerPlayer player)) return false; + boolean success = player.drop(dropAll); + if (!success) return false; @@ -24,7 +24,7 @@ index 5e5fda690605f767b33f8225bffea98d23299fea..52c9244194f3c0182f3a6010ed97d423 + final java.util.OptionalInt optionalSlot = player.containerMenu.findSlot(inv, inv.selected); + optionalSlot.ifPresent(slot -> player.containerSynchronizer.sendSlotChange(player.containerMenu, slot, inv.getSelected())); + return true; -+ // Paper end ++ // Paper end - Fix HumanEntity#drop not updating the client inv } @Override diff --git a/patches/server/0901-Add-CompostItemEvent-and-EntityCompostItemEvent.patch b/patches/server/0901-Add-CompostItemEvent-and-EntityCompostItemEvent.patch index efa34d8b7c..c5176a356f 100644 --- a/patches/server/0901-Add-CompostItemEvent-and-EntityCompostItemEvent.patch +++ b/patches/server/0901-Add-CompostItemEvent-and-EntityCompostItemEvent.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Add CompostItemEvent and EntityCompostItemEvent diff --git a/src/main/java/net/minecraft/world/level/block/ComposterBlock.java b/src/main/java/net/minecraft/world/level/block/ComposterBlock.java -index 413b307acaad5823b9e06f49fa2faf561f5f7b9a..de8b5cab7925c1c46478952ed2cb2bd40f9a9c48 100644 +index 413b307acaad5823b9e06f49fa2faf561f5f7b9a..d78fe4081bc2938326066e0afddb4a6c833a4bf7 100644 --- a/src/main/java/net/minecraft/world/level/block/ComposterBlock.java +++ b/src/main/java/net/minecraft/world/level/block/ComposterBlock.java @@ -328,7 +328,21 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder { @@ -13,7 +13,7 @@ index 413b307acaad5823b9e06f49fa2faf561f5f7b9a..de8b5cab7925c1c46478952ed2cb2bd4 float f = ComposterBlock.COMPOSTABLES.getFloat(itemstack.getItem()); - if ((i != 0 || f <= 0.0F) && rand >= (double) f) { -+ // Paper start ++ // Paper start - Add CompostItemEvent and EntityCompostItemEvent + boolean willRaiseLevel = !((i != 0 || f <= 0.0F) && rand >= (double) f); + final io.papermc.paper.event.block.CompostItemEvent event; + if (entity == null) { @@ -27,7 +27,7 @@ index 413b307acaad5823b9e06f49fa2faf561f5f7b9a..de8b5cab7925c1c46478952ed2cb2bd4 + willRaiseLevel = event.willRaiseLevel(); + + if (!willRaiseLevel) { -+ // Paper end ++ // Paper end - Add CompostItemEvent and EntityCompostItemEvent return iblockdata; } else { int j = i + 1; @@ -35,11 +35,11 @@ index 413b307acaad5823b9e06f49fa2faf561f5f7b9a..de8b5cab7925c1c46478952ed2cb2bd4 this.changed = true; BlockState iblockdata = ComposterBlock.addItem((Entity) null, this.state, this.level, this.pos, itemstack); -+ // Paper start ++ // Paper start - Add CompostItemEvent and EntityCompostItemEvent + if (iblockdata == null) { + return; + } -+ // Paper end ++ // Paper end - Add CompostItemEvent and EntityCompostItemEvent this.level.levelEvent(1500, this.pos, iblockdata != this.state ? 1 : 0); this.removeItemNoUpdate(0); } diff --git a/patches/server/0904-Fix-text-display-error-on-spawn.patch b/patches/server/0904-Fix-text-display-error-on-spawn.patch index 359b41bd67..7074ea7170 100644 --- a/patches/server/0904-Fix-text-display-error-on-spawn.patch +++ b/patches/server/0904-Fix-text-display-error-on-spawn.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Fix text display error on spawn diff --git a/src/main/java/net/minecraft/world/entity/Display.java b/src/main/java/net/minecraft/world/entity/Display.java -index dcbaa06f807ba3c1b64c96b3c2dd84d46d6be751..58de4a3ff0b5494fa576a902f33de4cd38b9c7be 100644 +index dcbaa06f807ba3c1b64c96b3c2dd84d46d6be751..2ecd3ed5b36475125c6f63af2612011fc8fba8a5 100644 --- a/src/main/java/net/minecraft/world/entity/Display.java +++ b/src/main/java/net/minecraft/world/entity/Display.java @@ -864,7 +864,7 @@ public abstract class Display extends Entity { @@ -13,7 +13,7 @@ index dcbaa06f807ba3c1b64c96b3c2dd84d46d6be751..58de4a3ff0b5494fa576a902f33de4cd b = loadFlag(b, nbt, "see_through", (byte)2); b = loadFlag(b, nbt, "default_background", (byte)4); - Optional optional = Display.TextDisplay.Align.CODEC.decode(NbtOps.INSTANCE, nbt.get("alignment")).resultOrPartial(Util.prefix("Display entity", Display.LOGGER::error)).map(Pair::getFirst); -+ Optional optional = Display.TextDisplay.Align.CODEC.decode(NbtOps.INSTANCE, nbt.get("alignment")).result().map(Pair::getFirst); // Paper - hide error message ++ Optional optional = Display.TextDisplay.Align.CODEC.decode(NbtOps.INSTANCE, nbt.get("alignment")).result().map(Pair::getFirst); // Paper - Hide text display error on spawn if (optional.isPresent()) { byte var10000; switch ((Display.TextDisplay.Align)optional.get()) { diff --git a/patches/server/0905-Fix-certain-inventories-returning-null-Locations.patch b/patches/server/0905-Fix-inventories-returning-null-Locations.patch similarity index 79% rename from patches/server/0905-Fix-certain-inventories-returning-null-Locations.patch rename to patches/server/0905-Fix-inventories-returning-null-Locations.patch index 47b96132fa..ca5f09c8df 100644 --- a/patches/server/0905-Fix-certain-inventories-returning-null-Locations.patch +++ b/patches/server/0905-Fix-inventories-returning-null-Locations.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Wed, 15 Mar 2023 18:29:45 -0700 -Subject: [PATCH] Fix certain inventories returning null Locations +Subject: [PATCH] Fix inventories returning null Locations Wandering Trader, AbstractHorse, Beacon and Composter inventories returned null locations when a block or entity location is readily available @@ -9,14 +9,14 @@ when a block or entity location is readily available Co-authored-by: Lukas Planz diff --git a/src/main/java/net/minecraft/world/SimpleContainer.java b/src/main/java/net/minecraft/world/SimpleContainer.java -index d5eeb2fcb119b815213aeffb3811d4a843502e50..061e870e0cdd5bf00351b7e8104361bce86809f3 100644 +index d5eeb2fcb119b815213aeffb3811d4a843502e50..ff1aba1e69cfde633fd01724f1a8d0af7f59437f 100644 --- a/src/main/java/net/minecraft/world/SimpleContainer.java +++ b/src/main/java/net/minecraft/world/SimpleContainer.java @@ -63,6 +63,16 @@ public class SimpleContainer implements Container, StackedContentsCompatible { @Override public Location getLocation() { -+ // Paper start ++ // Paper start - Fix inventories returning null Locations + // When the block inventory does not have a tile state that implements getLocation, e. g. composters + if (this.bukkitOwner instanceof org.bukkit.inventory.BlockInventoryHolder blockInventoryHolder) { + return blockInventoryHolder.getBlock().getLocation(); @@ -25,29 +25,29 @@ index d5eeb2fcb119b815213aeffb3811d4a843502e50..061e870e0cdd5bf00351b7e8104361bc + if (this.bukkitOwner instanceof org.bukkit.entity.Entity entity) { + return entity.getLocation(); + } -+ // Paper end ++ // Paper end - Fix inventories returning null Locations return null; } diff --git a/src/main/java/net/minecraft/world/inventory/BeaconMenu.java b/src/main/java/net/minecraft/world/inventory/BeaconMenu.java -index 0b1a0be964d799f1706c273092dc653fa04e8014..a6e712606ece631502ae4c7513403092df77524f 100644 +index 0b1a0be964d799f1706c273092dc653fa04e8014..3c67132bd3c1e4886f7ba823fe330b019359ac9d 100644 --- a/src/main/java/net/minecraft/world/inventory/BeaconMenu.java +++ b/src/main/java/net/minecraft/world/inventory/BeaconMenu.java @@ -51,6 +51,12 @@ public class BeaconMenu extends AbstractContainerMenu { public int getMaxStackSize() { return 1; } -+ // Paper start ++ // Paper start - Fix inventories returning null Locations + @Override + public org.bukkit.Location getLocation() { + return context.getLocation(); + } -+ // Paper end ++ // Paper end - Fix inventories returning null Locations }; checkContainerDataCount(propertyDelegate, 3); this.beaconData = propertyDelegate; diff --git a/src/main/java/net/minecraft/world/inventory/MerchantContainer.java b/src/main/java/net/minecraft/world/inventory/MerchantContainer.java -index 083e50e27685f441ede4c75e913d671fe45d1d15..98cbcf67d8fdb1c80fb7ba8ba7734821e2818da6 100644 +index 083e50e27685f441ede4c75e913d671fe45d1d15..ac4ec7157cf93b0cbc4472dc42fbbbff3402335a 100644 --- a/src/main/java/net/minecraft/world/inventory/MerchantContainer.java +++ b/src/main/java/net/minecraft/world/inventory/MerchantContainer.java @@ -65,7 +65,7 @@ public class MerchantContainer implements Container { @@ -55,7 +55,7 @@ index 083e50e27685f441ede4c75e913d671fe45d1d15..98cbcf67d8fdb1c80fb7ba8ba7734821 @Override public Location getLocation() { - return (this.merchant instanceof Villager) ? ((Villager) this.merchant).getBukkitEntity().getLocation() : null; -+ return (this.merchant instanceof AbstractVillager) ? ((AbstractVillager) this.merchant).getBukkitEntity().getLocation() : null; // Paper ++ return (this.merchant instanceof AbstractVillager) ? ((AbstractVillager) this.merchant).getBukkitEntity().getLocation() : null; // Paper - Fix inventories returning null Locations } // CraftBukkit end diff --git a/patches/server/0908-Optimize-Hoppers.patch b/patches/server/0908-Optimize-Hoppers.patch index 33fd16b6e3..da2c0e69cf 100644 --- a/patches/server/0908-Optimize-Hoppers.patch +++ b/patches/server/0908-Optimize-Hoppers.patch @@ -50,19 +50,19 @@ index 0000000000000000000000000000000000000000..5c42823726e70ce6c9d0121d07431548 + } +} diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 7c9f7aefc59ae1a785b261f80f25d3304f3bdd22..c9e1ded332fc320e87e0b4b95b97905ea0c91803 100644 +index 7c9f7aefc59ae1a785b261f80f25d3304f3bdd22..45f7e7efa8cf407cae2db657074478565590bd12 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -1672,6 +1672,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop 0; // Paper -+ net.minecraft.world.level.block.entity.HopperBlockEntity.skipHopperEvents = worldserver.paperConfig().hopper.disableMoveEvent || org.bukkit.event.inventory.InventoryMoveItemEvent.getHandlerList().getRegisteredListeners().length == 0; // Paper ++ net.minecraft.world.level.block.entity.HopperBlockEntity.skipHopperEvents = worldserver.paperConfig().hopper.disableMoveEvent || org.bukkit.event.inventory.InventoryMoveItemEvent.getHandlerList().getRegisteredListeners().length == 0; // Paper - Perf: Optimize Hoppers worldserver.hasEntityMoveEvent = io.papermc.paper.event.entity.EntityMoveEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper this.profiler.push(() -> { diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java -index 80682ce58d0b0ce0409d162f447b585163c36753..ae7214c6f72b85ec51230809db97b66fd2fcd298 100644 +index 80682ce58d0b0ce0409d162f447b585163c36753..9f1dfb6c7c44d0525792d3517bfdad6479fb12a7 100644 --- a/src/main/java/net/minecraft/world/item/ItemStack.java +++ b/src/main/java/net/minecraft/world/item/ItemStack.java @@ -749,10 +749,16 @@ public final class ItemStack { @@ -70,29 +70,29 @@ index 80682ce58d0b0ce0409d162f447b585163c36753..ae7214c6f72b85ec51230809db97b66f public ItemStack copy() { - if (this.isEmpty()) { -+ // Paper start ++ // Paper start - Perf: Optimize Hoppers + return this.copy(false); + } + + public ItemStack copy(boolean originalItem) { + if (!originalItem && this.isEmpty()) { -+ // Paper end ++ // Paper end - Perf: Optimize Hoppers return ItemStack.EMPTY; } else { - ItemStack itemstack = new ItemStack(this.getItem(), this.count); -+ ItemStack itemstack = new ItemStack(originalItem ? this.item : this.getItem(), this.count); // Paper ++ ItemStack itemstack = new ItemStack(originalItem ? this.item : this.getItem(), this.count); // Paper - Perf: Optimize Hoppers itemstack.setPopTime(this.getPopTime()); if (this.tag != null) { diff --git a/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java -index 5bdad1866386908b9fef74d15862eb107fabe68f..370a25d2deb54f10a35ee24d9e7e92fbfde60edf 100644 +index 5bdad1866386908b9fef74d15862eb107fabe68f..a6f47fa9f6065ed669414996b447e2daf34b3495 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java @@ -26,6 +26,7 @@ import co.aikar.timings.MinecraftTimings; // Paper import co.aikar.timings.Timing; // Paper public abstract class BlockEntity { -+ static boolean ignoreTileUpdates; // Paper ++ static boolean ignoreTileUpdates; // Paper - Perf: Optimize Hoppers public Timing tickTimer = MinecraftTimings.getTileEntityTimings(this); // Paper // CraftBukkit start - data containers @@ -100,19 +100,19 @@ index 5bdad1866386908b9fef74d15862eb107fabe68f..370a25d2deb54f10a35ee24d9e7e92fb public void setChanged() { if (this.level != null) { -+ if (ignoreTileUpdates) return; // Paper ++ if (ignoreTileUpdates) return; // Paper - Perf: Optimize Hoppers BlockEntity.setChanged(this.level, this.worldPosition, this.blockState); } diff --git a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java -index f98367830e87d5f1428448931f756d9277699563..d4dcf7fe26474ae07374e7761d823bc5c8b54f97 100644 +index f98367830e87d5f1428448931f756d9277699563..df1c1c27b7c0065f8179d59bdb9de01dde22befa 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java @@ -151,6 +151,43 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen } -+ // Paper start - optimize hoppers ++ // Paper start - Perf: Optimize Hoppers + private static final int HOPPER_EMPTY = 0; + private static final int HOPPER_HAS_ITEMS = 1; + private static final int HOPPER_IS_FULL = 2; @@ -147,7 +147,7 @@ index f98367830e87d5f1428448931f756d9277699563..d4dcf7fe26474ae07374e7761d823bc5 + + return empty ? HOPPER_EMPTY : (full ? HOPPER_IS_FULL : HOPPER_HAS_ITEMS); + } -+ // Paper end - optimize hoppers ++ // Paper end - Perf: Optimize Hoppers + private static boolean tryMoveItems(Level world, BlockPos pos, BlockState state, HopperBlockEntity blockEntity, BooleanSupplier booleansupplier) { if (world.isClientSide) { @@ -157,14 +157,14 @@ index f98367830e87d5f1428448931f756d9277699563..d4dcf7fe26474ae07374e7761d823bc5 boolean flag = false; - if (!blockEntity.isEmpty()) { -+ int fullState = getFullState(blockEntity); // Paper - optimize hoppers ++ int fullState = getFullState(blockEntity); // Paper - Perf: Optimize Hoppers + -+ if (fullState != HOPPER_EMPTY) { // Paper - optimize hoppers ++ if (fullState != HOPPER_EMPTY) { // Paper - Perf: Optimize Hopperss flag = HopperBlockEntity.ejectItems(world, pos, state, (Container) blockEntity, blockEntity); // CraftBukkit } - if (!blockEntity.inventoryFull()) { -+ if (fullState != HOPPER_IS_FULL || flag) { // Paper - optimize hoppers ++ if (fullState != HOPPER_IS_FULL || flag) { // Paper - Perf: Optimize Hoppers flag |= booleansupplier.getAsBoolean(); } @@ -172,7 +172,7 @@ index f98367830e87d5f1428448931f756d9277699563..d4dcf7fe26474ae07374e7761d823bc5 return false; } -+ // Paper start - Optimize Hoppers ++ // Paper start - Perf: Optimize Hoppers + private static boolean skipPullModeEventFire; + private static boolean skipPushModeEventFire; + public static boolean skipHopperEvents; @@ -366,7 +366,7 @@ index f98367830e87d5f1428448931f756d9277699563..d4dcf7fe26474ae07374e7761d823bc5 + } + private static final java.util.function.BiPredicate STACK_SIZE_TEST = (itemstack, i) -> itemstack.getCount() >= itemstack.getMaxStackSize(); + private static final java.util.function.BiPredicate IS_EMPTY_TEST = (itemstack, i) -> itemstack.isEmpty(); -+ // Paper end ++ // Paper end - Perf: Optimize Hoppers + private static boolean ejectItems(Level world, BlockPos blockposition, BlockState iblockdata, Container iinventory, HopperBlockEntity hopper) { // CraftBukkit Container iinventory1 = HopperBlockEntity.getAttachedContainer(world, blockposition, iblockdata); @@ -453,7 +453,7 @@ index f98367830e87d5f1428448931f756d9277699563..d4dcf7fe26474ae07374e7761d823bc5 - return false; + // return false; -+ // Paper end ++ // Paper end - Perf: Optimize Hoppers } } } @@ -466,7 +466,7 @@ index f98367830e87d5f1428448931f756d9277699563..d4dcf7fe26474ae07374e7761d823bc5 - - return itemstack.getCount() >= itemstack.getMaxStackSize(); - }); -+ // Paper start - optimize hoppers ++ // Paper start - Perf: Optimize Hoppers + if (inventory instanceof WorldlyContainer worldlyContainer) { + for (final int slot : worldlyContainer.getSlotsForFace(direction)) { + final ItemStack stack = inventory.getItem(slot); @@ -484,14 +484,14 @@ index f98367830e87d5f1428448931f756d9277699563..d4dcf7fe26474ae07374e7761d823bc5 + } + return true; + } -+ // Paper end - optimize hoppers ++ // Paper end - Perf: Optimize Hoppers } private static boolean isEmptyContainer(Container inv, Direction facing) { - return HopperBlockEntity.getSlots(inv, facing).allMatch((i) -> { - return inv.getItem(i).isEmpty(); - }); -+ return allMatch(inv, facing, IS_EMPTY_TEST); ++ return allMatch(inv, facing, IS_EMPTY_TEST); // Paper - Perf: Optimize Hoppers } public static boolean suckInItems(Level world, Hopper hopper) { @@ -502,7 +502,7 @@ index f98367830e87d5f1428448931f756d9277699563..d4dcf7fe26474ae07374e7761d823bc5 - return HopperBlockEntity.isEmptyContainer(iinventory, enumdirection) ? false : HopperBlockEntity.getSlots(iinventory, enumdirection).anyMatch((i) -> { - return HopperBlockEntity.a(hopper, iinventory, i, enumdirection, world); // Spigot - }); -+ // Paper start - optimize hoppers and remove streams ++ // Paper start - Perf: Optimize Hoppers + skipPullModeEventFire = skipHopperEvents; + // merge container isEmpty check and move logic into one loop + if (iinventory instanceof WorldlyContainer worldlyContainer) { @@ -528,7 +528,7 @@ index f98367830e87d5f1428448931f756d9277699563..d4dcf7fe26474ae07374e7761d823bc5 + } + return false; + } -+ // Paper end ++ // Paper end - Perf: Optimize Hoppers } else { Iterator iterator = HopperBlockEntity.getItemsAtAndAbove(world, hopper).iterator(); @@ -579,7 +579,7 @@ index f98367830e87d5f1428448931f756d9277699563..d4dcf7fe26474ae07374e7761d823bc5 - - itemstack1.shrink(origCount - itemstack2.getCount()); // Spigot - iinventory.setItem(i, itemstack1); -+ // Paper start - replace pull logic; MAKE SURE TO CHECK FOR DIFFS WHEN UPDATING ++ // Paper start - Perf: Optimize Hoppers; replace pull logic; MAKE SURE TO CHECK FOR DIFFS WHEN UPDATING + if (!itemstack.isEmpty() && HopperBlockEntity.canTakeItemFromContainer(ihopper, iinventory, itemstack, i, enumdirection)) { // If this logic changes, update above. this is left unused incase reflective plugins + return hopperPull(world, ihopper, iinventory, itemstack, i); + // ItemStack itemstack1 = itemstack.copy(); @@ -620,7 +620,7 @@ index f98367830e87d5f1428448931f756d9277699563..d4dcf7fe26474ae07374e7761d823bc5 + + // itemstack1.shrink(origCount - itemstack2.getCount()); // Spigot + // iinventory.setItem(i, itemstack1); -+ // Paper end ++ // Paper end - Perf: Optimize Hoppers } return false; @@ -630,13 +630,13 @@ index f98367830e87d5f1428448931f756d9277699563..d4dcf7fe26474ae07374e7761d823bc5 // CraftBukkit start - InventoryPickupItemEvent event = new InventoryPickupItemEvent(inventory.getOwner().getInventory(), (org.bukkit.entity.Item) itemEntity.getBukkitEntity()); + if (InventoryPickupItemEvent.getHandlerList().getRegisteredListeners().length > 0) { // Paper - optimize hoppers -+ InventoryPickupItemEvent event = new InventoryPickupItemEvent(getInventory(inventory), (org.bukkit.entity.Item) itemEntity.getBukkitEntity()); // Paper - use getInventory() to avoid snapshot creation ++ InventoryPickupItemEvent event = new InventoryPickupItemEvent(getInventory(inventory), (org.bukkit.entity.Item) itemEntity.getBukkitEntity()); // Paper - Perf: Optimize Hoppers; use getInventory() to avoid snapshot creation itemEntity.level().getCraftServer().getPluginManager().callEvent(event); if (event.isCancelled()) { return false; } // CraftBukkit end -+ } // Paper - optimize hoppers ++ } // Paper - Perf: Optimize Hoppers ItemStack itemstack = itemEntity.getItem().copy(); ItemStack itemstack1 = HopperBlockEntity.addItem((Container) null, inventory, itemstack, (Direction) null); @@ -644,9 +644,9 @@ index f98367830e87d5f1428448931f756d9277699563..d4dcf7fe26474ae07374e7761d823bc5 stack = stack.split(to.getMaxStackSize()); } // Spigot end -+ ignoreTileUpdates = true; // Paper ++ ignoreTileUpdates = true; // Paper - Perf: Optimize Hoppers to.setItem(slot, stack); -+ ignoreTileUpdates = false; // Paper ++ ignoreTileUpdates = false; // Paper - Perf: Optimize Hoppers stack = leftover; // Paper flag = true; } else if (HopperBlockEntity.canMergeItems(itemstack1, stack)) { @@ -654,16 +654,16 @@ index f98367830e87d5f1428448931f756d9277699563..d4dcf7fe26474ae07374e7761d823bc5 // CraftBukkit end } -+ // Paper start - optimize hopper item suck in ++ // Paper start - Perf: Optimize Hoppers + static final AABB HOPPER_ITEM_SUCK_OVERALL = Hopper.SUCK.bounds(); + static final AABB[] HOPPER_ITEM_SUCK_INDIVIDUAL = Hopper.SUCK.toAabbs().toArray(new AABB[0]); -+ // Paper end - optimize hopper item suck in ++ // Paper end - Perf: Optimize Hoppers + public static List getItemsAtAndAbove(Level world, Hopper hopper) { - return (List) hopper.getSuckShape().toAabbs().stream().flatMap((axisalignedbb) -> { - return world.getEntitiesOfClass(ItemEntity.class, axisalignedbb.move(hopper.getLevelX() - 0.5D, hopper.getLevelY() - 0.5D, hopper.getLevelZ() - 0.5D), EntitySelector.ENTITY_STILL_ALIVE).stream(); - }).collect(Collectors.toList()); -+ // Paper start - optimize hopper item suck in ++ // Paper start - Perf: Optimize Hoppers + // eliminate multiple getEntitiesOfClass() but maintain the voxelshape collision by moving + // the individual AABB checks into the predicate + final double shiftX = hopper.getLevelX() - 0.5D; @@ -682,23 +682,23 @@ index f98367830e87d5f1428448931f756d9277699563..d4dcf7fe26474ae07374e7761d823bc5 + + return false; + }); -+ // Paper end - optimize hopper item suck in ++ // Paper end - Perf: Optimize Hoppers } @Nullable public static Container getContainerAt(Level world, BlockPos pos) { - return HopperBlockEntity.getContainerAt(world, (double) pos.getX() + 0.5D, (double) pos.getY() + 0.5D, (double) pos.getZ() + 0.5D); -+ return HopperBlockEntity.getContainerAt(world, (double) pos.getX() + 0.5D, (double) pos.getY() + 0.5D, (double) pos.getZ() + 0.5D, true); // Paper ++ return HopperBlockEntity.getContainerAt(world, (double) pos.getX() + 0.5D, (double) pos.getY() + 0.5D, (double) pos.getZ() + 0.5D, true); // Paper - Perf: Optimize Hoppers } @Nullable private static Container getContainerAt(Level world, double x, double y, double z) { -+ // Paper start - add optimizeEntities parameter ++ // Paper start - Perf: Optimize Hoppers + return HopperBlockEntity.getContainerAt(world, x, y, z, false); + } + @Nullable + private static Container getContainerAt(Level world, double x, double y, double z, final boolean optimizeEntities) { -+ // Paper end - add optimizeEntities parameter ++ // Paper end - Perf: Optimize Hoppers Object object = null; BlockPos blockposition = BlockPos.containing(x, y, z); if ( !world.spigotConfig.hopperCanLoadChunks && !world.hasChunkAt( blockposition ) ) return null; // Spigot @@ -708,8 +708,8 @@ index f98367830e87d5f1428448931f756d9277699563..d4dcf7fe26474ae07374e7761d823bc5 - if (object == null) { - List list = world.getEntities((Entity) null, new AABB(x - 0.5D, y - 0.5D, z - 0.5D, x + 0.5D, y + 0.5D, z + 0.5D), EntitySelector.CONTAINER_ENTITY_SELECTOR); -+ if (object == null && (!optimizeEntities || !world.paperConfig().hopper.ignoreOccludingBlocks || !iblockdata.getBukkitMaterial().isOccluding())) { // Paper -+ List list = world.getEntitiesOfClass((Class)Container.class, new AABB(x - 0.5D, y - 0.5D, z - 0.5D, x + 0.5D, y + 0.5D, z + 0.5D), EntitySelector.CONTAINER_ENTITY_SELECTOR); // Paper - optimize hoppers, use getEntitiesOfClass ++ if (object == null && (!optimizeEntities || !world.paperConfig().hopper.ignoreOccludingBlocks || !iblockdata.getBukkitMaterial().isOccluding())) { // Paper - Perf: Optimize Hoppers ++ List list = world.getEntitiesOfClass((Class)Container.class, new AABB(x - 0.5D, y - 0.5D, z - 0.5D, x + 0.5D, y + 0.5D, z + 0.5D), EntitySelector.CONTAINER_ENTITY_SELECTOR); // Paper - Perf: Optimize Hoppers if (!list.isEmpty()) { object = (Container) list.get(world.random.nextInt(list.size())); @@ -718,12 +718,12 @@ index f98367830e87d5f1428448931f756d9277699563..d4dcf7fe26474ae07374e7761d823bc5 private static boolean canMergeItems(ItemStack first, ItemStack second) { - return first.getCount() <= first.getMaxStackSize() && ItemStack.isSameItemSameTags(first, second); -+ return first.getCount() < first.getMaxStackSize() && first.is(second.getItem()) && first.getDamageValue() == second.getDamageValue() && ((first.isEmpty() && second.isEmpty()) || java.util.Objects.equals(first.getTag(), second.getTag())); // Paper - used to return true for full itemstacks?! ++ return first.getCount() < first.getMaxStackSize() && first.is(second.getItem()) && first.getDamageValue() == second.getDamageValue() && ((first.isEmpty() && second.isEmpty()) || java.util.Objects.equals(first.getTag(), second.getTag())); // Paper - Perf: Optimize Hoppers; used to return true for full itemstacks?! } @Override diff --git a/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java -index 7cbd403f9e96e7ce35475c8102cd9f9c04819c27..64875525df244db838560f5fefb7b1b07b0f1f51 100644 +index 7cbd403f9e96e7ce35475c8102cd9f9c04819c27..a94300a457b25f0e33a8eeabba6dd5720ca9ab1e 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java @@ -93,12 +93,19 @@ public abstract class RandomizableContainerBlockEntity extends BaseContainerBloc @@ -731,20 +731,20 @@ index 7cbd403f9e96e7ce35475c8102cd9f9c04819c27..64875525df244db838560f5fefb7b1b0 public boolean isEmpty() { this.unpackLootTable((Player)null); - return this.getItems().stream().allMatch(ItemStack::isEmpty); -+ // Paper start ++ // Paper start - Perf: Optimize Hoppers + for (final ItemStack itemStack : this.getItems()) { + if (!itemStack.isEmpty()) { + return false; + } + } + return true; -+ // Paper end ++ // Paper end - Perf: Optimize Hoppers } @Override public ItemStack getItem(int slot) { - this.unpackLootTable((Player)null); -+ if (slot == 0) this.unpackLootTable((Player)null); // Paper ++ if (slot == 0) this.unpackLootTable((Player) null); // Paper - Perf: Optimize Hoppers return this.getItems().get(slot); } diff --git a/patches/server/0909-Fix-beehives-generating-from-using-bonemeal.patch b/patches/server/0909-Fix-beehives-generating-from-using-bonemeal.patch index 88ae1ee91b..e0c9d13bb8 100644 --- a/patches/server/0909-Fix-beehives-generating-from-using-bonemeal.patch +++ b/patches/server/0909-Fix-beehives-generating-from-using-bonemeal.patch @@ -5,31 +5,31 @@ Subject: [PATCH] Fix beehives generating from using bonemeal diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java -index ae7214c6f72b85ec51230809db97b66fd2fcd298..3f420bbe8c2b9128a051030c4acd3603ea487132 100644 +index 9f1dfb6c7c44d0525792d3517bfdad6479fb12a7..8d051e23e16cef71e54fef2955720f604c306221 100644 --- a/src/main/java/net/minecraft/world/item/ItemStack.java +++ b/src/main/java/net/minecraft/world/item/ItemStack.java @@ -422,6 +422,7 @@ public final class ItemStack { } for (CraftBlockState blockstate : blocks) { world.setBlock(blockstate.getPosition(),blockstate.getHandle(), blockstate.getFlag()); // SPIGOT-7248 - manual update to avoid physics where appropriate -+ if (blockstate instanceof org.bukkit.craftbukkit.block.CapturedBlockState capturedBlockState) capturedBlockState.checkTreeBlockHack(); // Paper ++ if (blockstate instanceof org.bukkit.craftbukkit.block.CapturedBlockState capturedBlockState) capturedBlockState.checkTreeBlockHack(); // Paper - Fix beehives generating from using bonemeal } entityhuman.awardStat(Stats.ITEM_USED.get(item)); // SPIGOT-7236 - award stat } diff --git a/src/main/java/org/bukkit/craftbukkit/block/CapturedBlockState.java b/src/main/java/org/bukkit/craftbukkit/block/CapturedBlockState.java -index 2aab5ba9e90f09e6d679ee0d0d5d5e52c44b677f..a8760f015b9ee3ee408c3b9220266eb76b313ba0 100644 +index 2aab5ba9e90f09e6d679ee0d0d5d5e52c44b677f..c17c8b2bff32bfd101675d73f8ab81b35a9e1c15 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CapturedBlockState.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CapturedBlockState.java @@ -31,6 +31,12 @@ public final class CapturedBlockState extends CraftBlockState { public boolean update(boolean force, boolean applyPhysics) { boolean result = super.update(force, applyPhysics); -+ // Paper start ++ // Paper start - Fix beehives generating from using bonemeal + this.checkTreeBlockHack(); + return result; + } + public void checkTreeBlockHack() { -+ // Paper end ++ // Paper end - Fix beehives generating from using bonemeal // SPIGOT-5537: Horrible hack to manually add bees given World.captureTreeGeneration does not support tiles if (this.treeBlock && this.getType() == Material.BEE_NEST) { WorldGenLevel generatoraccessseed = this.world.getHandle(); @@ -38,7 +38,7 @@ index 2aab5ba9e90f09e6d679ee0d0d5d5e52c44b677f..a8760f015b9ee3ee408c3b9220266eb7 } - return result; -+ // Paper ++ // Paper - Fix beehives generating from using bonemeal } @Override diff --git a/patches/server/0911-Treat-sequence-violations-like-they-should-be.patch b/patches/server/0911-Treat-sequence-violations-like-they-should-be.patch index f08f796d75..1300b8f449 100644 --- a/patches/server/0911-Treat-sequence-violations-like-they-should-be.patch +++ b/patches/server/0911-Treat-sequence-violations-like-they-should-be.patch @@ -5,14 +5,14 @@ Subject: [PATCH] Treat sequence violations like they should be diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index ab5b354b0fb42535e8d176a219876e23f08c1f3d..e0bdb0ef35494b376960613bd6e319d179676bf3 100644 +index ab5b354b0fb42535e8d176a219876e23f08c1f3d..b55af3bceba3d78110bc9eac6ea136b43d90cd5d 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java @@ -2043,6 +2043,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl public void ackBlockChangesUpTo(int sequence) { if (sequence < 0) { -+ this.disconnect("Expected packet sequence nr >= 0", org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_ACTION); // Paper ++ this.disconnect("Expected packet sequence nr >= 0", org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_ACTION); // Paper - Treat sequence violations like they should be throw new IllegalArgumentException("Expected packet sequence nr >= 0"); } else { this.ackBlockChangesUpTo = Math.max(sequence, this.ackBlockChangesUpTo); diff --git a/patches/server/0913-Prevent-causing-expired-keys-from-impacting-new-join.patch b/patches/server/0913-Prevent-causing-expired-keys-from-impacting-new-join.patch index 66b0be1bb3..d79d1c3697 100644 --- a/patches/server/0913-Prevent-causing-expired-keys-from-impacting-new-join.patch +++ b/patches/server/0913-Prevent-causing-expired-keys-from-impacting-new-join.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Prevent causing expired keys from impacting new joins diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundPlayerInfoUpdatePacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundPlayerInfoUpdatePacket.java -index 0e54e8faa48751a651b953bec72543a94edf74bc..aa1c6de4d6cb7bbca33d25895c54707d220ab62a 100644 +index 0e54e8faa48751a651b953bec72543a94edf74bc..d43106eb89b14667e85cd6e8fa047d64f2e8ec87 100644 --- a/src/main/java/net/minecraft/network/protocol/game/ClientboundPlayerInfoUpdatePacket.java +++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundPlayerInfoUpdatePacket.java @@ -96,7 +96,13 @@ public class ClientboundPlayerInfoUpdatePacket implements Packet { - buf.writeNullable(entry.chatSession, RemoteChatSession.Data::write); -+ // Paper start ++ // Paper start - Prevent causing expired keys from impacting new joins + RemoteChatSession.Data chatSession = entry.chatSession; + if (chatSession != null && chatSession.profilePublicKey().hasExpired()) { + chatSession = null; + } + buf.writeNullable(chatSession, RemoteChatSession.Data::write); -+ // Paper end ++ // Paper end - Prevent causing expired keys from impacting new joins }), UPDATE_GAME_MODE((serialized, buf) -> { serialized.gameMode = GameType.byId(buf.readVarInt()); diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index e0bdb0ef35494b376960613bd6e319d179676bf3..361d31a4a527c32ff3b8cd2e763e23963ec0a2b4 100644 +index b55af3bceba3d78110bc9eac6ea136b43d90cd5d..48bae46261f592923c8c6f1d56c92ce6a121f1b8 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java @@ -287,6 +287,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl private int knownMovePacketCount; @Nullable private RemoteChatSession chatSession; -+ private boolean hasLoggedExpiry = false; // Paper ++ private boolean hasLoggedExpiry = false; // Paper - Prevent causing expired keys from impacting new joins private SignedMessageChain.Decoder signedMessageDecoder; private final LastSeenMessagesValidator lastSeenMessages = new LastSeenMessagesValidator(20); private final MessageSignatureCache messageSignatureCache = MessageSignatureCache.createDefault(); @@ -39,12 +39,12 @@ index e0bdb0ef35494b376960613bd6e319d179676bf3..361d31a4a527c32ff3b8cd2e763e2396 this.disconnect(Component.translatable("multiplayer.disconnect.idling"), org.bukkit.event.player.PlayerKickEvent.Cause.IDLING); // Paper - kick event cause } -+ // Paper start ++ // Paper start - Prevent causing expired keys from impacting new joins + if (!hasLoggedExpiry && this.chatSession != null && this.chatSession.profilePublicKey().data().hasExpired()) { + LOGGER.info("Player profile key for {} has expired!", this.player.getName().getString()); + hasLoggedExpiry = true; + } -+ // Paper end ++ // Paper end - Prevent causing expired keys from impacting new joins + } @@ -53,7 +53,7 @@ index e0bdb0ef35494b376960613bd6e319d179676bf3..361d31a4a527c32ff3b8cd2e763e2396 private void resetPlayerChatState(RemoteChatSession session) { this.chatSession = session; -+ this.hasLoggedExpiry = false; // Paper ++ this.hasLoggedExpiry = false; // Paper - Prevent causing expired keys from impacting new joins this.signedMessageDecoder = session.createMessageDecoder(this.player.getUUID()); this.chatMessageChain.append(() -> { this.player.setChatSession(session); diff --git a/patches/server/0914-Prevent-GameEvents-being-fired-from-unloaded-chunks.patch b/patches/server/0914-Prevent-GameEvents-being-fired-from-unloaded-chunks.patch index c98ffaa074..05d48a9e06 100644 --- a/patches/server/0914-Prevent-GameEvents-being-fired-from-unloaded-chunks.patch +++ b/patches/server/0914-Prevent-GameEvents-being-fired-from-unloaded-chunks.patch @@ -5,18 +5,18 @@ Subject: [PATCH] Prevent GameEvents being fired from unloaded chunks diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index 4e8e1f4562b3edb7041e299b6719e965df975636..a7f2e8755af41abc66070f1971e526b4f05bc710 100644 +index 4e8e1f4562b3edb7041e299b6719e965df975636..dae52be48e9789db2fbbff699f3e0c44086c864f 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java @@ -1724,6 +1724,11 @@ public class ServerLevel extends Level implements WorldGenLevel { @Override public void gameEvent(GameEvent event, Vec3 emitterPos, GameEvent.Context emitter) { -+ // Paper start ++ // Paper start - Prevent GameEvents being fired from unloaded chunks + if (this.getChunkIfLoadedImmediately((Mth.floor(emitterPos.x) >> 4), (Mth.floor(emitterPos.z) >> 4)) == null) { + return; + } -+ // Paper end ++ // Paper end - Prevent GameEvents being fired from unloaded chunks this.gameEventDispatcher.post(event, emitterPos, emitter); } diff --git a/patches/server/0915-Use-array-for-gamerule-storage.patch b/patches/server/0915-Use-array-for-gamerule-storage.patch index 6750b6a93a..41d8673025 100644 --- a/patches/server/0915-Use-array-for-gamerule-storage.patch +++ b/patches/server/0915-Use-array-for-gamerule-storage.patch @@ -5,14 +5,14 @@ Subject: [PATCH] Use array for gamerule storage diff --git a/src/main/java/net/minecraft/world/level/GameRules.java b/src/main/java/net/minecraft/world/level/GameRules.java -index 6c1af24f2f02ef5fe1be135b4071362f2297147a..4f2fa47d094348bb8f86a86e808019ddba56e187 100644 +index 6c1af24f2f02ef5fe1be135b4071362f2297147a..a9be16e53a9df34af3495048aa9af7b1a3efea4a 100644 --- a/src/main/java/net/minecraft/world/level/GameRules.java +++ b/src/main/java/net/minecraft/world/level/GameRules.java @@ -114,6 +114,7 @@ public class GameRules { public static final GameRules.Key RULE_DO_VINES_SPREAD = GameRules.register("doVinesSpread", GameRules.Category.UPDATES, GameRules.BooleanValue.create(true)); public static final GameRules.Key RULE_ENDER_PEARLS_VANISH_ON_DEATH = GameRules.register("enderPearlsVanishOnDeath", GameRules.Category.PLAYER, GameRules.BooleanValue.create(true)); private final Map, GameRules.Value> rules; -+ private final GameRules.Value[] gameruleArray; // Paper ++ private final GameRules.Value[] gameruleArray; // Paper - Perf: Use array for gamerule storage private static > GameRules.Key register(String name, GameRules.Category category, GameRules.Type type) { GameRules.Key gamerules_gamerulekey = new GameRules.Key<>(name, category); @@ -21,18 +21,18 @@ index 6c1af24f2f02ef5fe1be135b4071362f2297147a..4f2fa47d094348bb8f86a86e808019dd public GameRules() { - this.rules = (Map) GameRules.GAME_RULE_TYPES.entrySet().stream().collect(ImmutableMap.toImmutableMap(Entry::getKey, (entry) -> { -+ // Paper start - use this to ensure gameruleArray is initialized ++ // Paper start - Perf: Use array for gamerule storage + this((Map) GameRules.GAME_RULE_TYPES.entrySet().stream().collect(ImmutableMap.toImmutableMap(Entry::getKey, (entry) -> { return ((GameRules.Type) entry.getValue()).createRule(); - })); + }))); -+ // Paper end ++ // Paper end - Perf: Use array for gamerule storage } private GameRules(Map, GameRules.Value> rules) { this.rules = rules; + -+ // Paper start ++ // Paper start - Perf: Use array for gamerule storage + int arraySize = rules.keySet().stream().mapToInt(key -> key.gameRuleIndex).max().orElse(-1) + 1; + GameRules.Value[] values = new GameRules.Value[arraySize]; + @@ -41,12 +41,12 @@ index 6c1af24f2f02ef5fe1be135b4071362f2297147a..4f2fa47d094348bb8f86a86e808019dd + } + + this.gameruleArray = values; -+ // Paper end ++ // Paper end - Perf: Use array for gamerule storage } public > T getRule(GameRules.Key key) { - return (T) this.rules.get(key); // CraftBukkit - decompile error -+ return key == null ? null : (T) this.gameruleArray[key.gameRuleIndex]; // Paper ++ return key == null ? null : (T) this.gameruleArray[key.gameRuleIndex]; // Paper - Perf: Use array for gamerule storage } public CompoundTag createTag() { @@ -54,10 +54,10 @@ index 6c1af24f2f02ef5fe1be135b4071362f2297147a..4f2fa47d094348bb8f86a86e808019dd } public static final class Key> { -+ // Paper start ++ // Paper start - Perf: Use array for gamerule storage + private static int lastGameRuleIndex = 0; + public final int gameRuleIndex = lastGameRuleIndex++; -+ // Paper end ++ // Paper end - Perf: Use array for gamerule storage final String id; private final GameRules.Category category; diff --git a/patches/server/0920-Fix-DamageCause-for-Falling-Blocks.patch b/patches/server/0920-Fix-DamageCause-for-Falling-Blocks.patch index e1935baf2e..7a7127e5a3 100644 --- a/patches/server/0920-Fix-DamageCause-for-Falling-Blocks.patch +++ b/patches/server/0920-Fix-DamageCause-for-Falling-Blocks.patch @@ -5,18 +5,18 @@ Subject: [PATCH] Fix DamageCause for Falling Blocks diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java -index dfab64b21eedfbdd129c881b7c862ad962c78f3d..454365ea4795ac6c0e30530f795cbdb511908440 100644 +index dfab64b21eedfbdd129c881b7c862ad962c78f3d..c4745b8151f41ab55abe01ac30a5c5e54f1fbf7e 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -1085,6 +1085,11 @@ public class CraftEventFactory { } else if (source.is(DamageTypes.SONIC_BOOM)) { cause = DamageCause.SONIC_BOOM; } -+ // Paper start - fix handle of Falling Blocks ++ // Paper start - fix falling block handling + else if (source.is(DamageTypes.FALLING_STALACTITE) || source.is(DamageTypes.FALLING_BLOCK) || source.is(DamageTypes.FALLING_ANVIL)) { + cause = DamageCause.FALLING_BLOCK; + } -+ // Paper end ++ // Paper end - fix falling block handling return CraftEventFactory.callEntityDamageEvent(damager, entity, cause, modifiers, modifierFunctions, cancelled, source.isCritical()); // Paper - add critical damage API } else if (source.is(DamageTypes.FELL_OUT_OF_WORLD)) { diff --git a/patches/server/0921-Avoid-Lazy-Initialization-for-Enum-Fields.patch b/patches/server/0921-Avoid-Lazy-Initialization-for-Enum-Fields.patch index 809f5d1710..346c3fd86c 100644 --- a/patches/server/0921-Avoid-Lazy-Initialization-for-Enum-Fields.patch +++ b/patches/server/0921-Avoid-Lazy-Initialization-for-Enum-Fields.patch @@ -7,14 +7,14 @@ This patch is meant to get rid of any instances of lazy initialization that Mine This has the possibility to create race condition issues, and generally don't make sense to be lazily done anyways. diff --git a/src/main/java/com/mojang/math/OctahedralGroup.java b/src/main/java/com/mojang/math/OctahedralGroup.java -index a5a889d40228a0d6c7259caf8cb2554588d9aaf9..bbd407ab618fc89a82a6724ba3503d8b4a397016 100644 +index a5a889d40228a0d6c7259caf8cb2554588d9aaf9..5009192046e5e083d14cef3f448b98b978dd54bf 100644 --- a/src/main/java/com/mojang/math/OctahedralGroup.java +++ b/src/main/java/com/mojang/math/OctahedralGroup.java @@ -111,6 +111,7 @@ public enum OctahedralGroup implements StringRepresentable { this.permutation = axisTransformation; this.transformation = (new Matrix3f()).scaling(flipX ? -1.0F : 1.0F, flipY ? -1.0F : 1.0F, flipZ ? -1.0F : 1.0F); this.transformation.mul(axisTransformation.transformation()); -+ this.initializeRotationDirections(); // Paper ++ this.initializeRotationDirections(); // Paper - Avoid Lazy Initialization for Enum Fields } private BooleanList packInversions() { @@ -23,7 +23,7 @@ index a5a889d40228a0d6c7259caf8cb2554588d9aaf9..bbd407ab618fc89a82a6724ba3503d8b } - public Direction rotate(Direction direction) { -+ public void initializeRotationDirections() { // Paper ++ public void initializeRotationDirections() { // Paper - Avoid Lazy Initialization for Enum Fields if (this.rotatedDirections == null) { this.rotatedDirections = Maps.newEnumMap(Direction.class); Direction.Axis[] axiss = Direction.Axis.values(); @@ -31,10 +31,10 @@ index a5a889d40228a0d6c7259caf8cb2554588d9aaf9..bbd407ab618fc89a82a6724ba3503d8b } } -+ // Paper start - Move lazy initialization to constructor ++ // Paper start - Avoid Lazy Initialization for Enum Fields + } + public Direction rotate(Direction direction) { -+ // Paper end ++ // Paper end - Avoid Lazy Initialization for Enum Fields return this.rotatedDirections.get(direction); } diff --git a/patches/server/0925-Expand-PlayerItemMendEvent.patch b/patches/server/0925-Expand-PlayerItemMendEvent.patch index 0ad40b41eb..6147d4eabf 100644 --- a/patches/server/0925-Expand-PlayerItemMendEvent.patch +++ b/patches/server/0925-Expand-PlayerItemMendEvent.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Expand PlayerItemMendEvent diff --git a/src/main/java/net/minecraft/world/entity/ExperienceOrb.java b/src/main/java/net/minecraft/world/entity/ExperienceOrb.java -index 5685951b71a8b81c7a71fd93b099b276d535b401..2a689581565bebc01ba354a3564d30327486953d 100644 +index 5685951b71a8b81c7a71fd93b099b276d535b401..b37e13c5de1a0a22a3713d04b203afc6c03ccbac 100644 --- a/src/main/java/net/minecraft/world/entity/ExperienceOrb.java +++ b/src/main/java/net/minecraft/world/entity/ExperienceOrb.java @@ -337,7 +337,7 @@ public class ExperienceOrb extends Entity { @@ -13,7 +13,7 @@ index 5685951b71a8b81c7a71fd93b099b276d535b401..2a689581565bebc01ba354a3564d3032 int j = Math.min(this.xpToDurability(amount), itemstack.getDamageValue()); // CraftBukkit start - org.bukkit.event.player.PlayerItemMendEvent event = CraftEventFactory.callPlayerItemMendEvent(player, this, itemstack, entry.getKey(), j); -+ org.bukkit.event.player.PlayerItemMendEvent event = CraftEventFactory.callPlayerItemMendEvent(player, this, itemstack, entry.getKey(), j, this::durabilityToXp); // Paper ++ org.bukkit.event.player.PlayerItemMendEvent event = CraftEventFactory.callPlayerItemMendEvent(player, this, itemstack, entry.getKey(), j, this::durabilityToXp); // Paper - Expand PlayerItemMendEvent j = event.getRepairAmount(); if (event.isCancelled()) { return amount; @@ -22,18 +22,18 @@ index 5685951b71a8b81c7a71fd93b099b276d535b401..2a689581565bebc01ba354a3564d3032 itemstack.setDamageValue(itemstack.getDamageValue() - j); - int k = amount - this.durabilityToXp(j); -+ int k = amount - event.getDurabilityToXpOperation().applyAsInt(j); // Paper ++ int k = amount - event.getDurabilityToXpOperation().applyAsInt(j); // Paper - Expand PlayerItemMendEvent this.value = k; // CraftBukkit - update exp value of orb for PlayerItemMendEvent calls -+ // Paper start ++ // Paper start - Expand PlayerItemMendEvent + if (j == 0 && amount == k) { // if repair amount is 0 and no xp was removed, don't do recursion; treat as cancelled + return k; + } -+ // Paper end ++ // Paper end - Expand PlayerItemMendEvent return k > 0 ? this.repairPlayerItems(player, k) : 0; } else { diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index b1d12c30dd23e092531c0d4d3af367262ccb5402..809932208bdf8e01d7bc73f885c44497a4ce4a95 100644 +index b1d12c30dd23e092531c0d4d3af367262ccb5402..cc0824b3a8e4cb0bbefd53f91faf3942c097a004 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -1754,11 +1754,11 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @@ -41,17 +41,17 @@ index b1d12c30dd23e092531c0d4d3af367262ccb5402..809932208bdf8e01d7bc73f885c44497 int i = Math.min(orb.xpToDurability(amount), itemstack.getDamageValue()); - org.bukkit.event.player.PlayerItemMendEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerItemMendEvent(handle, orb, itemstack, stackEntry.getKey(), i); -+ org.bukkit.event.player.PlayerItemMendEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerItemMendEvent(handle, orb, itemstack, stackEntry.getKey(), i, orb::durabilityToXp); // Paper ++ org.bukkit.event.player.PlayerItemMendEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerItemMendEvent(handle, orb, itemstack, stackEntry.getKey(), i, orb::durabilityToXp); // Paper - Expand PlayerItemMendEvent i = event.getRepairAmount(); orb.discard(); if (!event.isCancelled()) { - amount -= orb.durabilityToXp(i); -+ amount -= event.getDurabilityToXpOperation().applyAsInt(i); // Paper ++ amount -= event.getDurabilityToXpOperation().applyAsInt(i); // Paper - Expand PlayerItemMendEvent itemstack.setDamageValue(itemstack.getDamageValue() - i); } } diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java -index 454365ea4795ac6c0e30530f795cbdb511908440..a6897c9a46d9cef083d5424c5b4a2ed0a32dfe3b 100644 +index c4745b8151f41ab55abe01ac30a5c5e54f1fbf7e..99befdda75711c815f974d7260d8b979ce4e8694 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -1321,10 +1321,10 @@ public class CraftEventFactory { @@ -59,11 +59,11 @@ index 454365ea4795ac6c0e30530f795cbdb511908440..a6897c9a46d9cef083d5424c5b4a2ed0 } - public static PlayerItemMendEvent callPlayerItemMendEvent(net.minecraft.world.entity.player.Player entity, net.minecraft.world.entity.ExperienceOrb orb, net.minecraft.world.item.ItemStack nmsMendedItem, net.minecraft.world.entity.EquipmentSlot slot, int repairAmount) { -+ public static PlayerItemMendEvent callPlayerItemMendEvent(net.minecraft.world.entity.player.Player entity, net.minecraft.world.entity.ExperienceOrb orb, net.minecraft.world.item.ItemStack nmsMendedItem, net.minecraft.world.entity.EquipmentSlot slot, int repairAmount, java.util.function.IntUnaryOperator durabilityToXpOp) { // Paper ++ public static PlayerItemMendEvent callPlayerItemMendEvent(net.minecraft.world.entity.player.Player entity, net.minecraft.world.entity.ExperienceOrb orb, net.minecraft.world.item.ItemStack nmsMendedItem, net.minecraft.world.entity.EquipmentSlot slot, int repairAmount, java.util.function.IntUnaryOperator durabilityToXpOp) { // Paper - Expand PlayerItemMendEvent Player player = (Player) entity.getBukkitEntity(); org.bukkit.inventory.ItemStack bukkitStack = CraftItemStack.asCraftMirror(nmsMendedItem); - PlayerItemMendEvent event = new PlayerItemMendEvent(player, bukkitStack, CraftEquipmentSlot.getSlot(slot), (ExperienceOrb) orb.getBukkitEntity(), repairAmount); -+ PlayerItemMendEvent event = new PlayerItemMendEvent(player, bukkitStack, CraftEquipmentSlot.getSlot(slot), (ExperienceOrb) orb.getBukkitEntity(), repairAmount, durabilityToXpOp); // Paper ++ PlayerItemMendEvent event = new PlayerItemMendEvent(player, bukkitStack, CraftEquipmentSlot.getSlot(slot), (ExperienceOrb) orb.getBukkitEntity(), repairAmount, durabilityToXpOp); // Paper - Expand PlayerItemMendEvent Bukkit.getPluginManager().callEvent(event); return event; } diff --git a/patches/server/0926-Refresh-ProjectileSource-for-projectiles.patch b/patches/server/0926-Refresh-ProjectileSource-for-projectiles.patch index a29b7a8db9..e6f66bc842 100644 --- a/patches/server/0926-Refresh-ProjectileSource-for-projectiles.patch +++ b/patches/server/0926-Refresh-ProjectileSource-for-projectiles.patch @@ -14,19 +14,19 @@ clearing the owner. Co-authored-by: Warrior <50800980+Warriorrrr@users.noreply.github.com> diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index 2d8223ff9e3f51e43946cfcc1bd638235c48ec11..f5df304943abd40d2c9fee2f4d84fa1374eba387 100644 +index 2d8223ff9e3f51e43946cfcc1bd638235c48ec11..3ef46f1a9859c5ba9ea2fcda3b65816679cfc519 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java @@ -386,6 +386,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S public boolean inWorld = false; public boolean generation; public int maxAirTicks = this.getDefaultMaxAirSupply(); // CraftBukkit - SPIGOT-6907: re-implement LivingEntity#setMaximumAir() -+ @Nullable // Paper ++ @Nullable // Paper - Refresh ProjectileSource for projectiles public org.bukkit.projectiles.ProjectileSource projectileSource; // For projectiles only public boolean lastDamageCancelled; // SPIGOT-5339, SPIGOT-6252, SPIGOT-6777: Keep track if the event was canceled public boolean persistentInvisibility = false; diff --git a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java -index 270dd1db56b187bffaedba9f2b86b3e46dda3152..2f058cec80c6ef7a5a5ca065dc6c9fe353c521de 100644 +index 270dd1db56b187bffaedba9f2b86b3e46dda3152..5b6d5c799cc8e601a01b6967917e15ba1e2db721 100644 --- a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java +++ b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java @@ -50,14 +50,31 @@ public abstract class Projectile extends Entity implements TraceableEntity { @@ -35,16 +35,16 @@ index 270dd1db56b187bffaedba9f2b86b3e46dda3152..2f058cec80c6ef7a5a5ca065dc6c9fe3 } - this.projectileSource = (entity != null && entity.getBukkitEntity() instanceof ProjectileSource) ? (ProjectileSource) entity.getBukkitEntity() : null; // CraftBukkit - -+ // Paper start - Fix null owners not being handled ++ // Paper start - Refresh ProjectileSource for projectiles + else { + this.ownerUUID = null; + this.cachedOwner = null; + this.projectileSource = null; + } -+ // Paper end ++ // Paper end - Refresh ProjectileSource for projectiles + this.refreshProjectileSource(false); // Paper + } -+ // Paper start ++ // Paper start - Refresh ProjectileSource for projectiles + public void refreshProjectileSource(boolean fillCache) { + if (fillCache) { + this.getOwner(); @@ -53,13 +53,13 @@ index 270dd1db56b187bffaedba9f2b86b3e46dda3152..2f058cec80c6ef7a5a5ca065dc6c9fe3 + this.projectileSource = projSource; + } } -+ // Paper end ++ // Paper end - Refresh ProjectileSource for projectiles @Nullable @Override public Entity getOwner() { if (this.cachedOwner != null && !this.cachedOwner.isRemoved()) { -+ this.refreshProjectileSource(false); // Paper ++ this.refreshProjectileSource(false); // Paper - Refresh ProjectileSource for projectiles return this.cachedOwner; } else { if (this.ownerUUID != null) { @@ -67,19 +67,19 @@ index 270dd1db56b187bffaedba9f2b86b3e46dda3152..2f058cec80c6ef7a5a5ca065dc6c9fe3 ServerLevel worldserver = (ServerLevel) world; this.cachedOwner = worldserver.getEntity(this.ownerUUID); -+ this.refreshProjectileSource(false); // Paper ++ this.refreshProjectileSource(false); // Paper - Refresh ProjectileSource for projectiles return this.cachedOwner; } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/AbstractProjectile.java b/src/main/java/org/bukkit/craftbukkit/entity/AbstractProjectile.java -index 2c376687349825833e6d9a5ca92ce6afb98c36a3..0f7ae4a5c672039828454bf18c770dd99e250212 100644 +index 2c376687349825833e6d9a5ca92ce6afb98c36a3..856984601a59f51544b741f5f2137028b53c9439 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/AbstractProjectile.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/AbstractProjectile.java @@ -60,6 +60,7 @@ public abstract class AbstractProjectile extends CraftEntity implements Projecti @Override public final org.bukkit.projectiles.ProjectileSource getShooter() { -+ this.getHandle().refreshProjectileSource(true); // Paper ++ this.getHandle().refreshProjectileSource(true); // Paper - Refresh ProjectileSource for projectiles return this.getHandle().projectileSource; } diff --git a/patches/server/0928-Fix-block-place-logic.patch b/patches/server/0928-Fix-block-place-logic.patch index 0f786528da..227c84be9e 100644 --- a/patches/server/0928-Fix-block-place-logic.patch +++ b/patches/server/0928-Fix-block-place-logic.patch @@ -9,7 +9,7 @@ Fix several issues when a player interact with a block: * poi can desync when the BlockPhysicsEvent is cancelled diff --git a/src/main/java/net/minecraft/world/item/BlockItem.java b/src/main/java/net/minecraft/world/item/BlockItem.java -index e581dc10f3c805f7f8b6e4c842092609e7e1a0f8..6819cea2858f0035a4fbf3671612d43fead883b6 100644 +index e581dc10f3c805f7f8b6e4c842092609e7e1a0f8..b6b5abba349fecfecd8f3a3c237693607f9bf0ad 100644 --- a/src/main/java/net/minecraft/world/item/BlockItem.java +++ b/src/main/java/net/minecraft/world/item/BlockItem.java @@ -130,7 +130,7 @@ public class BlockItem extends Item { @@ -17,12 +17,12 @@ index e581dc10f3c805f7f8b6e4c842092609e7e1a0f8..6819cea2858f0035a4fbf3671612d43f SoundType soundeffecttype = iblockdata1.getSoundType(); - // world.playSound(entityhuman, blockposition, this.getPlaceSound(iblockdata1), SoundCategory.BLOCKS, (soundeffecttype.getVolume() + 1.0F) / 2.0F, soundeffecttype.getPitch() * 0.8F); -+ if (entityhuman == null) world.playSound(entityhuman, blockposition, this.getPlaceSound(iblockdata1), net.minecraft.sounds.SoundSource.BLOCKS, (soundeffecttype.getVolume() + 1.0F) / 2.0F, soundeffecttype.getPitch() * 0.8F); // Paper - reintroduce this for the dispenser (i.e the shulker) ++ if (entityhuman == null) world.playSound(entityhuman, blockposition, this.getPlaceSound(iblockdata1), net.minecraft.sounds.SoundSource.BLOCKS, (soundeffecttype.getVolume() + 1.0F) / 2.0F, soundeffecttype.getPitch() * 0.8F); // Paper - Fix block place logic; reintroduce this for the dispenser (i.e the shulker) world.gameEvent(GameEvent.BLOCK_PLACE, blockposition, GameEvent.Context.of(entityhuman, iblockdata1)); if ((entityhuman == null || !entityhuman.getAbilities().instabuild) && itemstack != ItemStack.EMPTY) { // CraftBukkit itemstack.shrink(1); diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java -index 3f420bbe8c2b9128a051030c4acd3603ea487132..453f48b540560a340721d762ca80eadf229c4dce 100644 +index 8d051e23e16cef71e54fef2955720f604c306221..9ac862354c7026845287344bbc2a94c958f65a59 100644 --- a/src/main/java/net/minecraft/world/item/ItemStack.java +++ b/src/main/java/net/minecraft/world/item/ItemStack.java @@ -493,13 +493,7 @@ public final class ItemStack { @@ -36,19 +36,19 @@ index 3f420bbe8c2b9128a051030c4acd3603ea487132..453f48b540560a340721d762ca80eadf - } - - tileentityjukebox.setTheItem(record); -+ tileentityjukebox.setTheItem(this.copy()); // Paper - sync this with record item, jukebox has now an inventory ++ tileentityjukebox.setTheItem(this.copy()); // Paper - Fix block place logic; sync this with record item, jukebox has now an inventory world.gameEvent(GameEvent.BLOCK_CHANGE, blockposition, GameEvent.Context.of(entityhuman, world.getBlockState(blockposition))); } diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index c7eb97008b8096f69602678722506fddbeac3148..7a4c21beaa4004f72cbfe75e567cafb3279a1c94 100644 +index c7eb97008b8096f69602678722506fddbeac3148..28e56e61ff5c14683f55780ed83e593f6b06503c 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java @@ -1038,17 +1038,18 @@ public abstract class Level implements LevelAccessor, AutoCloseable { // CraftBukkit start iblockdata1.updateIndirectNeighbourShapes(this, blockposition, k, j - 1); // Don't call an event for the old block to limit event spam CraftWorld world = ((ServerLevel) this).getWorld(); -+ boolean cancelledUpdates = false; // Paper ++ boolean cancelledUpdates = false; // Paper - Fix block place logic if (world != null && ((ServerLevel)this).hasPhysicsEvent) { // Paper BlockPhysicsEvent event = new BlockPhysicsEvent(world.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), CraftBlockData.fromData(iblockdata)); this.getCraftServer().getPluginManager().callEvent(event); @@ -56,13 +56,13 @@ index c7eb97008b8096f69602678722506fddbeac3148..7a4c21beaa4004f72cbfe75e567cafb3 - if (event.isCancelled()) { - return; - } -+ cancelledUpdates = event.isCancelled(); // Paper ++ cancelledUpdates = event.isCancelled(); // Paper - Fix block place logic } // CraftBukkit end -+ if (!cancelledUpdates) { // Paper ++ if (!cancelledUpdates) { // Paper - Fix block place logic iblockdata.updateNeighbourShapes(this, blockposition, k, j - 1); iblockdata.updateIndirectNeighbourShapes(this, blockposition, k, j - 1); -+ } // Paper ++ } // Paper - Fix block place logic } // CraftBukkit start - SPIGOT-5710 diff --git a/patches/server/0929-Fix-spigot-sound-playing-for-BlockItem-ItemStacks.patch b/patches/server/0929-Fix-spigot-sound-playing-for-BlockItem-ItemStacks.patch index c65f4bdd36..65daee2e55 100644 --- a/patches/server/0929-Fix-spigot-sound-playing-for-BlockItem-ItemStacks.patch +++ b/patches/server/0929-Fix-spigot-sound-playing-for-BlockItem-ItemStacks.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Fix spigot sound playing for BlockItem ItemStacks diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java -index 453f48b540560a340721d762ca80eadf229c4dce..b5e91462e403f4f53879be82301f5bae6cf564d2 100644 +index 9ac862354c7026845287344bbc2a94c958f65a59..b7e30d0a3c3c945addfa22c805af9608d68284b5 100644 --- a/src/main/java/net/minecraft/world/item/ItemStack.java +++ b/src/main/java/net/minecraft/world/item/ItemStack.java @@ -544,7 +544,11 @@ public final class ItemStack { @@ -13,11 +13,11 @@ index 453f48b540560a340721d762ca80eadf229c4dce..b5e91462e403f4f53879be82301f5bae // SPIGOT-1288 - play sound stripped from ItemBlock if (this.item instanceof BlockItem) { - SoundType soundeffecttype = ((BlockItem) this.item).getBlock().defaultBlockState().getSoundType(); // TODO: not strictly correct, however currently only affects decorated pots -+ // Paper start ++ // Paper start - Fix spigot sound playing for BlockItem ItemStacks + BlockPos position = new net.minecraft.world.item.context.BlockPlaceContext(context).getClickedPos(); + net.minecraft.world.level.block.state.BlockState blockData = world.getBlockState(position); + SoundType soundeffecttype = blockData.getSoundType(); -+ // Paper end ++ // Paper end - Fix spigot sound playing for BlockItem ItemStacks world.playSound(entityhuman, blockposition, soundeffecttype.getPlaceSound(), SoundSource.BLOCKS, (soundeffecttype.getVolume() + 1.0F) / 2.0F, soundeffecttype.getPitch() * 0.8F); } diff --git a/patches/server/0931-Don-t-enforce-icanhasbukkit-default-if-alias-block-e.patch b/patches/server/0931-Don-t-enforce-icanhasbukkit-default-if-alias-block-e.patch index 19c94cb4d0..bedbcb956a 100644 --- a/patches/server/0931-Don-t-enforce-icanhasbukkit-default-if-alias-block-e.patch +++ b/patches/server/0931-Don-t-enforce-icanhasbukkit-default-if-alias-block-e.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Don't enforce icanhasbukkit default if alias block exists diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index 56e5dff13323068ad2911649e6285aa915d787bd..d0cc462f3ca02218978ac14358d533e3a4d8b066 100644 +index 56e5dff13323068ad2911649e6285aa915d787bd..15dfa910d91ac49f4d264d0289b891a47beabe25 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -352,7 +352,11 @@ public final class CraftServer implements Server { @@ -17,7 +17,7 @@ index 56e5dff13323068ad2911649e6285aa915d787bd..d0cc462f3ca02218978ac14358d533e3 + final YamlConfiguration commandsDefaults = YamlConfiguration.loadConfiguration(new InputStreamReader(this.getClass().getClassLoader().getResourceAsStream("configurations/commands.yml"), Charsets.UTF_8)); + if (this.commandsConfiguration.contains("aliases")) commandsDefaults.set("aliases", null); + this.commandsConfiguration.setDefaults(commandsDefaults); -+ // Paper stop - dont enforce icanhasbukkit default if alias block exists ++ // Paper stop - don't enforce icanhasbukkit default if alias block exists this.saveCommandsConfig(); // Migrate aliases from old file and add previously implicit $1- to pass all arguments diff --git a/patches/server/0935-Temp-Pre-init-PlayerChunkLoaderData-in-order-to-prep.patch b/patches/server/0935-Temp-Pre-init-PlayerChunkLoaderData-in-order-to-prep.patch index 0d77ba1bea..4ff44ca179 100644 --- a/patches/server/0935-Temp-Pre-init-PlayerChunkLoaderData-in-order-to-prep.patch +++ b/patches/server/0935-Temp-Pre-init-PlayerChunkLoaderData-in-order-to-prep.patch @@ -6,14 +6,14 @@ Subject: [PATCH] Temp: Pre-init PlayerChunkLoaderData in order to prepopulate diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java -index aca49044899f65d7e91e5762fb58dbaffbfbd4c9..a74a8a027c99eef199c1a6a54232ac2c8ffb9d08 100644 +index aca49044899f65d7e91e5762fb58dbaffbfbd4c9..ef8bbef6e4143b9432ee2ae2fb79e2aa2a9b84df 100644 --- a/src/main/java/org/bukkit/craftbukkit/Main.java +++ b/src/main/java/org/bukkit/craftbukkit/Main.java @@ -368,6 +368,7 @@ public class Main { tryPreloadClass(net.minecraft.world.level.lighting.LayerLightEventListener.DummyLightLayerEventListener.class.getName()); tryPreloadClass(net.minecraft.world.level.lighting.LayerLightEventListener.class.getName()); tryPreloadClass(net.minecraft.util.ExceptionCollector.class.getName()); -+ tryPreloadClass(io.papermc.paper.chunk.system.RegionizedPlayerChunkLoader.PlayerChunkLoaderData.class.getName()); ++ tryPreloadClass(io.papermc.paper.chunk.system.RegionizedPlayerChunkLoader.PlayerChunkLoaderData.class.getName()); // Paper - Prepopulate BFS lookup for potatos // Paper end } } diff --git a/patches/server/0937-Properly-Cancel-Usable-Items.patch b/patches/server/0937-Properly-cancel-usable-items.patch similarity index 82% rename from patches/server/0937-Properly-Cancel-Usable-Items.patch rename to patches/server/0937-Properly-cancel-usable-items.patch index 4122f9b89f..59b569391c 100644 --- a/patches/server/0937-Properly-Cancel-Usable-Items.patch +++ b/patches/server/0937-Properly-cancel-usable-items.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com> Date: Tue, 23 May 2023 22:33:36 -0400 -Subject: [PATCH] Properly Cancel Usable Items +Subject: [PATCH] Properly cancel usable items This fixes the bug causing cancelling PlayerInteractEvent to cause items to continue to be used despite being cancelled on the server. @@ -10,14 +10,14 @@ The underlying issue of this is that the client modifies their synced data value them in order for the client to reset their using item state. diff --git a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java -index f58386e952d29a16d160b628a23efbe102791277..82f26186156a487f29ad3abff3f68852e5b8a1f9 100644 +index f58386e952d29a16d160b628a23efbe102791277..d0404f7f103b4f98f9d76cf2a5cddec0dfa47b6f 100644 --- a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java @@ -557,6 +557,7 @@ public class ServerPlayerGameMode { } // Paper end - extend Player Interact cancellation player.getBukkitEntity().updateInventory(); // SPIGOT-2867 -+ this.player.resyncUsingItem(this.player); // Paper - Resend player's using item status ++ this.player.resyncUsingItem(this.player); // Paper - Properly cancel usable items enuminteractionresult = (event.useItemInHand() != Event.Result.ALLOW) ? InteractionResult.SUCCESS : InteractionResult.PASS; } else if (this.gameModeForPlayer == GameType.SPECTATOR) { MenuProvider itileinventory = iblockdata.getMenuProvider(world, blockposition); @@ -25,39 +25,39 @@ index f58386e952d29a16d160b628a23efbe102791277..82f26186156a487f29ad3abff3f68852 return enuminteractionresult1; } -+ // Paper start - Cancel only if cancelled + if the interact result is different from default response ++ // Paper start - Properly cancel usable items; Cancel only if cancelled + if the interact result is different from default response + else if (this.interactResult && this.interactResult != cancelledItem) { + this.player.resyncUsingItem(this.player); + } -+ // Paper end ++ // Paper end - Properly cancel usable items } return enuminteractionresult; // CraftBukkit end diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 361d31a4a527c32ff3b8cd2e763e23963ec0a2b4..ab2fcbdd9567e18a59eb70b3557da7a3f4a91f38 100644 +index 48bae46261f592923c8c6f1d56c92ce6a121f1b8..589662812bc6f6fb09d50d8793c7ed4cb1140af8 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java @@ -1955,6 +1955,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl } if (cancelled) { -+ this.player.resyncUsingItem(this.player); // Paper - Resend player's using item status ++ this.player.resyncUsingItem(this.player); // Paper - Properly cancel usable items this.player.getBukkitEntity().updateInventory(); // SPIGOT-2524 return; } diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index 070d9630af6d8c29de9df3b59ce14c57637ebf6d..3ce5c06a6c154c0b8c9f2aaaa0a2f9d092cc4551 100644 +index 070d9630af6d8c29de9df3b59ce14c57637ebf6d..668297b8978cbde6635254122f8f29f4a7ead45b 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java @@ -3813,6 +3813,11 @@ public abstract class LivingEntity extends Entity implements Attackable { return ((Byte) this.entityData.get(LivingEntity.DATA_LIVING_ENTITY_FLAGS) & 2) > 0 ? InteractionHand.OFF_HAND : InteractionHand.MAIN_HAND; } -+ // Paper start ++ // Paper start - Properly cancel usable items + public void resyncUsingItem(ServerPlayer serverPlayer) { + this.getEntityData().resendPossiblyDesyncedDataValues(java.util.List.of(DATA_LIVING_ENTITY_FLAGS), serverPlayer); + } -+ // Paper end ++ // Paper end - Properly cancel usable items private void updatingUsingItem() { if (this.isUsingItem()) { if (ItemStack.isSameItem(this.getItemInHand(this.getUsedItemHand()), this.useItem)) { diff --git a/patches/server/0938-Add-event-for-player-editing-sign.patch b/patches/server/0938-Add-event-for-player-editing-sign.patch index a434075f6d..236c286da9 100644 --- a/patches/server/0938-Add-event-for-player-editing-sign.patch +++ b/patches/server/0938-Add-event-for-player-editing-sign.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Add event for player editing sign diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java -index b5e91462e403f4f53879be82301f5bae6cf564d2..b44c596194f3e9fdd29f3eef1065612f46e7cd66 100644 +index b7e30d0a3c3c945addfa22c805af9608d68284b5..244fcdcb153b1f4d842405302261afe1cce67daa 100644 --- a/src/main/java/net/minecraft/world/item/ItemStack.java +++ b/src/main/java/net/minecraft/world/item/ItemStack.java @@ -523,7 +523,7 @@ public final class ItemStack { @@ -13,12 +13,12 @@ index b5e91462e403f4f53879be82301f5bae6cf564d2..b44c596194f3e9fdd29f3eef1065612f if (world.getBlockEntity(SignItem.openSign) instanceof SignBlockEntity tileentitysign) { if (world.getBlockState(SignItem.openSign).getBlock() instanceof SignBlock blocksign) { - blocksign.openTextEdit(entityhuman, tileentitysign, true, org.bukkit.event.player.PlayerSignOpenEvent.Cause.PLACE); // Craftbukkit -+ blocksign.openTextEdit(entityhuman, tileentitysign, true, io.papermc.paper.event.player.PlayerOpenSignEvent.Cause.PLACE); // Paper ++ blocksign.openTextEdit(entityhuman, tileentitysign, true, io.papermc.paper.event.player.PlayerOpenSignEvent.Cause.PLACE); // Paper - Add PlayerOpenSignEvent } } } finally { diff --git a/src/main/java/net/minecraft/world/level/block/SignBlock.java b/src/main/java/net/minecraft/world/level/block/SignBlock.java -index 57b79e7fa34755e68b06f5b3010e68745cabbb7e..a09f6a2f9fdbe8361f67b543f3b337789897b982 100644 +index 57b79e7fa34755e68b06f5b3010e68745cabbb7e..27a1e8ffc43efe4e086e7fd88ee4d80c23f98674 100644 --- a/src/main/java/net/minecraft/world/level/block/SignBlock.java +++ b/src/main/java/net/minecraft/world/level/block/SignBlock.java @@ -118,7 +118,7 @@ public abstract class SignBlock extends BaseEntityBlock implements SimpleWaterlo @@ -26,7 +26,7 @@ index 57b79e7fa34755e68b06f5b3010e68745cabbb7e..a09f6a2f9fdbe8361f67b543f3b33778 return InteractionResult.SUCCESS; } else if (!this.otherPlayerIsEditingSign(player, tileentitysign) && player.mayBuild() && this.hasEditableText(player, tileentitysign, flag1)) { - this.openTextEdit(player, tileentitysign, flag1, org.bukkit.event.player.PlayerSignOpenEvent.Cause.INTERACT); // CraftBukkit -+ this.openTextEdit(player, tileentitysign, flag1, io.papermc.paper.event.player.PlayerOpenSignEvent.Cause.INTERACT); // Paper ++ this.openTextEdit(player, tileentitysign, flag1, io.papermc.paper.event.player.PlayerOpenSignEvent.Cause.INTERACT); // Paper - Add PlayerOpenSignEvent return this.getInteractionResult(flag); } else { return InteractionResult.PASS; @@ -34,7 +34,7 @@ index 57b79e7fa34755e68b06f5b3010e68745cabbb7e..a09f6a2f9fdbe8361f67b543f3b33778 return blockpropertywood; } -+ @io.papermc.paper.annotation.DoNotUse @Deprecated // Paper ++ @io.papermc.paper.annotation.DoNotUse @Deprecated // Paper - Add PlayerOpenSignEvent public void openTextEdit(Player player, SignBlockEntity blockEntity, boolean front) { - // Craftbukkit start - this.openTextEdit(player, blockEntity, front, org.bukkit.event.player.PlayerSignOpenEvent.Cause.UNKNOWN); @@ -42,7 +42,7 @@ index 57b79e7fa34755e68b06f5b3010e68745cabbb7e..a09f6a2f9fdbe8361f67b543f3b33778 - - public void openTextEdit(Player entityhuman, SignBlockEntity tileentitysign, boolean flag, org.bukkit.event.player.PlayerSignOpenEvent.Cause cause) { - if (!org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerSignOpenEvent(entityhuman, tileentitysign, flag, cause)) { -+ // Paper start - PlayerOpenSignEvent ++ // Paper start - Add PlayerOpenSignEvent + this.openTextEdit(player, blockEntity, front, io.papermc.paper.event.player.PlayerOpenSignEvent.Cause.UNKNOWN); + } + public void openTextEdit(Player entityhuman, SignBlockEntity tileentitysign, boolean flag, io.papermc.paper.event.player.PlayerOpenSignEvent.Cause cause) { @@ -62,32 +62,32 @@ index 57b79e7fa34755e68b06f5b3010e68745cabbb7e..a09f6a2f9fdbe8361f67b543f3b33778 + case INTERACT -> org.bukkit.event.player.PlayerSignOpenEvent.Cause.INTERACT; + case UNKNOWN -> org.bukkit.event.player.PlayerSignOpenEvent.Cause.UNKNOWN; + }; -+ // Paper end - PlayerOpenSignEvent -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerSignOpenEvent(entityhuman, tileentitysign, flag, legacyCause)) { // Paper ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerSignOpenEvent(entityhuman, tileentitysign, flag, legacyCause)) { ++ // Paper end - Add PlayerOpenSignEvent return; } - // Craftbukkit end -+ } // Paper ++ } // Paper - Add PlayerOpenSignEvent tileentitysign.setAllowedPlayerEditor(entityhuman.getUUID()); entityhuman.openTextEdit(tileentitysign, flag); } diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java b/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java -index 94caa0915e1a9ec1c46c7a0380db840901cc8063..3b33aed51a84ee30b1e7bceecb0d3840866e0748 100644 +index 94caa0915e1a9ec1c46c7a0380db840901cc8063..3ebfc8e5b5462e6e532f8e8901fd5f8f386bbf34 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java @@ -139,9 +139,15 @@ public class CraftSign extends CraftBlockEntityState< Preconditions.checkArgument(sign.isPlaced(), "Sign must be placed"); Preconditions.checkArgument(sign.getWorld() == player.getWorld(), "Sign must be in same world as Player"); -+ // Paper start ++ // Paper start - Add PlayerOpenSignEvent + io.papermc.paper.event.player.PlayerOpenSignEvent event = new io.papermc.paper.event.player.PlayerOpenSignEvent((Player) player, sign, side, io.papermc.paper.event.player.PlayerOpenSignEvent.Cause.PLUGIN); + if (!event.callEvent()) return; + if (PlayerSignOpenEvent.getHandlerList().getRegisteredListeners().length > 0) { -+ // Paper end ++ // Paper end - Add PlayerOpenSignEvent if (!CraftEventFactory.callPlayerSignOpenEvent(player, sign, side, PlayerSignOpenEvent.Cause.PLUGIN)) { return; } -+ } // Paper ++ } // Paper - Add PlayerOpenSignEvent SignBlockEntity handle = ((CraftSign) sign).getTileEntity(); handle.setAllowedPlayerEditor(player.getUniqueId()); diff --git a/patches/server/0939-Only-tick-item-frames-if-players-can-see-it.patch b/patches/server/0939-Only-tick-item-frames-if-players-can-see-it.patch index b3de8c9a7c..704c5443df 100644 --- a/patches/server/0939-Only-tick-item-frames-if-players-can-see-it.patch +++ b/patches/server/0939-Only-tick-item-frames-if-players-can-see-it.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Only tick item frames if players can see it In the event that an item frame cannot be seen by any players, ticking the item frame every tick is unnecessary. This can be a very hot section of the entity tracker when lots of item frames are present on a server, so this reduces the logic which speeds it up. diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java -index 9d5d32705f9d8aadb51019f17b4db76a9bc6a04b..625a598eb5f3c9c5ea60ae9ea50974bb08abbf85 100644 +index 9d5d32705f9d8aadb51019f17b4db76a9bc6a04b..4eee77a14c941b637ec9e9dc844e67c5e933bfe7 100644 --- a/src/main/java/net/minecraft/server/level/ServerEntity.java +++ b/src/main/java/net/minecraft/server/level/ServerEntity.java @@ -111,7 +111,7 @@ public class ServerEntity { @@ -14,7 +14,7 @@ index 9d5d32705f9d8aadb51019f17b4db76a9bc6a04b..625a598eb5f3c9c5ea60ae9ea50974bb Entity entity = this.entity; - if (entity instanceof ItemFrame) { -+ if (!this.trackedPlayers.isEmpty() && entity instanceof ItemFrame) { // Paper - Only tick item frames if players can see it ++ if (!this.trackedPlayers.isEmpty() && entity instanceof ItemFrame) { // Paper - Perf: Only tick item frames if players can see it ItemFrame entityitemframe = (ItemFrame) entity; if (true || this.tickCount % 10 == 0) { // CraftBukkit - Moved below, should always enter this block diff --git a/patches/server/0940-Fix-cmd-permission-levels-for-command-blocks.patch b/patches/server/0940-Fix-cmd-permission-levels-for-command-blocks.patch index 7f1a397233..fede763c81 100644 --- a/patches/server/0940-Fix-cmd-permission-levels-for-command-blocks.patch +++ b/patches/server/0940-Fix-cmd-permission-levels-for-command-blocks.patch @@ -5,24 +5,24 @@ Subject: [PATCH] Fix cmd permission levels for command blocks diff --git a/src/main/java/net/minecraft/commands/CommandSourceStack.java b/src/main/java/net/minecraft/commands/CommandSourceStack.java -index 82ca6267bca684a8f04ca37d40816686677a852a..4e81a823c49807d9978aeaef8293baaa67194c4d 100644 +index 82ca6267bca684a8f04ca37d40816686677a852a..ec4152f7372ddad216039a489fb5d72f963b4f18 100644 --- a/src/main/java/net/minecraft/commands/CommandSourceStack.java +++ b/src/main/java/net/minecraft/commands/CommandSourceStack.java @@ -204,10 +204,29 @@ public class CommandSourceStack implements ExecutionCommandSource= level; } -+ // Paper start ++ // Paper start - Fix permission levels for command blocks + private boolean forceRespectPermissionLevel() { + return this.source == CommandSource.NULL || (this.source instanceof final net.minecraft.world.level.BaseCommandBlock commandBlock && commandBlock.getLevel().paperConfig().commandBlocks.forceFollowPermLevel); + } -+ // Paper end ++ // Paper end - Fix permission levels for command blocks + // CraftBukkit start public boolean hasPermission(int i, String bukkitPermission) { - // World is null when loading functions - return ((this.getLevel() == null || !this.getLevel().getCraftServer().ignoreVanillaPermissions) && this.permissionLevel >= i) || this.getBukkitSender().hasPermission(bukkitPermission); -+ // Paper start ++ // Paper start - Fix permission levels for command blocks + final java.util.function.BooleanSupplier hasBukkitPerm = () -> this.source == CommandSource.NULL /*treat NULL as having all bukkit perms*/ || this.getBukkitSender().hasPermission(bukkitPermission); // lazily check bukkit perms to the benefit of custom permission setups + // if the server is null, we must check the vanilla perm level system + // if ignoreVanillaPermissions is true, we can skip vanilla perms and just run the bukkit perm check @@ -36,12 +36,12 @@ index 82ca6267bca684a8f04ca37d40816686677a852a..4e81a823c49807d9978aeaef8293baaa + } + } + return hasBukkitPerm.getAsBoolean(); -+ // Paper end ++ // Paper end - Fix permission levels for command blocks } // CraftBukkit end diff --git a/src/main/java/net/minecraft/commands/Commands.java b/src/main/java/net/minecraft/commands/Commands.java -index 6abef7947cadca6bccac809a8d58d38961132e0f..55a835bbe69453fe010d03f3b2e80b954dfc208e 100644 +index 6abef7947cadca6bccac809a8d58d38961132e0f..1a5b1be217e210db3f498b93fbcae7509be597ee 100644 --- a/src/main/java/net/minecraft/commands/Commands.java +++ b/src/main/java/net/minecraft/commands/Commands.java @@ -296,16 +296,7 @@ public class Commands { @@ -58,7 +58,7 @@ index 6abef7947cadca6bccac809a8d58d38961132e0f..55a835bbe69453fe010d03f3b2e80b95 - || cmd.equalsIgnoreCase("pardon") || cmd.equalsIgnoreCase("pardon-ip") || cmd.equalsIgnoreCase("reload")) { - return; - } -+ // Paper - use proper permission levels to block these commands ++ // Paper - Fix permission levels for command blocks // Handle vanilla commands; if (sender.getLevel().getCraftServer().getCommandBlockOverride(args[0])) { diff --git a/patches/server/0942-Call-missing-BlockDispenseEvent.patch b/patches/server/0942-Call-missing-BlockDispenseEvent.patch index 8b8394dbe5..09aac68d23 100644 --- a/patches/server/0942-Call-missing-BlockDispenseEvent.patch +++ b/patches/server/0942-Call-missing-BlockDispenseEvent.patch @@ -5,20 +5,20 @@ Subject: [PATCH] Call missing BlockDispenseEvent diff --git a/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java b/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java -index 415d387f8cfa3ae99b1c809233c86c18b76ad1e2..0286740aabe04e6e78ad6efd003a1e1a1ab6a460 100644 +index 415d387f8cfa3ae99b1c809233c86c18b76ad1e2..5165651f1ddcda78f2551d02ca5a4a5ea97ac91a 100644 --- a/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java +++ b/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java @@ -1106,6 +1106,13 @@ public interface DispenseItemBehavior { this.setSuccess(true); if (iblockdata.is(Blocks.RESPAWN_ANCHOR)) { if ((Integer) iblockdata.getValue(RespawnAnchorBlock.CHARGE) != 4) { -+ // Paper start ++ // Paper start - Call missing BlockDispenseEvent + ItemStack result = org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockDispenseEvent(pointer, blockposition, stack, this); + if (result != null) { + this.setSuccess(false); + return result; + } -+ // Paper end ++ // Paper end - Call missing BlockDispenseEvent RespawnAnchorBlock.charge((Entity) null, worldserver, blockposition, iblockdata); stack.shrink(1); } else { @@ -26,13 +26,13 @@ index 415d387f8cfa3ae99b1c809233c86c18b76ad1e2..0286740aabe04e6e78ad6efd003a1e1a Optional optional = HoneycombItem.getWaxed(iblockdata); if (optional.isPresent()) { -+ // Paper start ++ // Paper start - Call missing BlockDispenseEvent + ItemStack result = org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockDispenseEvent(pointer, blockposition, stack, this); + if (result != null) { + this.setSuccess(false); + return result; + } -+ // Paper end ++ // Paper end - Call missing BlockDispenseEvent worldserver.setBlockAndUpdate(blockposition, (BlockState) optional.get()); worldserver.levelEvent(3003, blockposition, 0); stack.shrink(1); @@ -40,24 +40,24 @@ index 415d387f8cfa3ae99b1c809233c86c18b76ad1e2..0286740aabe04e6e78ad6efd003a1e1a if (!worldserver.getBlockState(blockposition1).is(BlockTags.CONVERTABLE_TO_MUD)) { return this.defaultDispenseItemBehavior.dispense(pointer, stack); } else { -+ // Paper start ++ // Paper start - Call missing BlockDispenseEvent + ItemStack result = org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockDispenseEvent(pointer, blockposition1, stack, this); + if (result != null) { + return result; + } -+ // Paper end ++ // Paper end - Call missing BlockDispenseEvent if (!worldserver.isClientSide) { for (int k = 0; k < 5; ++k) { worldserver.sendParticles(ParticleTypes.SPLASH, (double) blockposition.getX() + worldserver.random.nextDouble(), (double) (blockposition.getY() + 1), (double) blockposition.getZ() + worldserver.random.nextDouble(), 1, 0.0D, 0.0D, 0.0D, 1.0D); diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java -index a6897c9a46d9cef083d5424c5b4a2ed0a32dfe3b..5ead89e46d9cf17980baf35cda000bc4c0e7425b 100644 +index 99befdda75711c815f974d7260d8b979ce4e8694..ba7f9ac6068bae43c628015fa07b32794fea9369 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -2098,6 +2098,32 @@ public class CraftEventFactory { } // Paper end -+ // Paper start - missing BlockDispenseEvent calls ++ // Paper start - Call missing BlockDispenseEvent + @Nullable + public static ItemStack handleBlockDispenseEvent(net.minecraft.core.dispenser.BlockSource pointer, BlockPos to, ItemStack itemStack, net.minecraft.core.dispenser.DispenseItemBehavior instance) { + org.bukkit.block.Block bukkitBlock = pointer.level().getWorld().getBlockAt(pointer.pos().getX(), pointer.pos().getY(), pointer.pos().getZ()); @@ -81,7 +81,7 @@ index a6897c9a46d9cef083d5424c5b4a2ed0a32dfe3b..5ead89e46d9cf17980baf35cda000bc4 + } + return null; + } -+ // Paper end - missing BlockDispenseEvent calls ++ // Paper end - Call missing BlockDispenseEvent + // Paper start - add EntityFertilizeEggEvent /** diff --git a/patches/server/0943-Don-t-load-chunks-for-supporting-block-checks.patch b/patches/server/0943-Don-t-load-chunks-for-supporting-block-checks.patch index e4c46db9bd..b9ac71bda7 100644 --- a/patches/server/0943-Don-t-load-chunks-for-supporting-block-checks.patch +++ b/patches/server/0943-Don-t-load-chunks-for-supporting-block-checks.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Don't load chunks for supporting block checks diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index f5df304943abd40d2c9fee2f4d84fa1374eba387..a2607d0782e8d72d7e531a2b078674bc78daa5e3 100644 +index 3ef46f1a9859c5ba9ea2fcda3b65816679cfc519..d3ec25371478e5f4bfb3886f4765f6eaf54a39ce 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java @@ -1362,7 +1362,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S diff --git a/patches/server/0945-Add-Sign-getInteractableSideFor.patch b/patches/server/0945-Add-Sign-getInteractableSideFor.patch index d9c5a89205..3e0f85b62d 100644 --- a/patches/server/0945-Add-Sign-getInteractableSideFor.patch +++ b/patches/server/0945-Add-Sign-getInteractableSideFor.patch @@ -5,18 +5,18 @@ Subject: [PATCH] Add Sign#getInteractableSideFor diff --git a/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java -index da3d947c58bdb79372e64b2cea6e49b99a4a9ad8..a3ec2f522be2d02b9e37810799cecc2ba14f58f3 100644 +index da3d947c58bdb79372e64b2cea6e49b99a4a9ad8..9bc1e7f03106cc35ac79bc9d7cced2bc5871b36c 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java @@ -66,13 +66,18 @@ public class SignBlockEntity extends BlockEntity implements CommandSource { // C } public boolean isFacingFrontText(net.minecraft.world.entity.player.Player player) { -+ // Paper start ++ // Paper start - Add Sign#getInteractableSideFor + return this.isFacingFrontText(player.getX(), player.getZ()); + } + public boolean isFacingFrontText(double x, double z) { -+ // Paper end ++ // Paper end - Add Sign#getInteractableSideFor Block block = this.getBlockState().getBlock(); if (block instanceof SignBlock) { @@ -24,13 +24,13 @@ index da3d947c58bdb79372e64b2cea6e49b99a4a9ad8..a3ec2f522be2d02b9e37810799cecc2b Vec3 vec3d = blocksign.getSignHitboxCenterPosition(this.getBlockState()); - double d0 = player.getX() - ((double) this.getBlockPos().getX() + vec3d.x); - double d1 = player.getZ() - ((double) this.getBlockPos().getZ() + vec3d.z); -+ double d0 = x - ((double) this.getBlockPos().getX() + vec3d.x); // Paper -+ double d1 = z - ((double) this.getBlockPos().getZ() + vec3d.z); // Paper ++ double d0 = x - ((double) this.getBlockPos().getX() + vec3d.x); // Paper - Add Sign#getInteractableSideFor ++ double d1 = z - ((double) this.getBlockPos().getZ() + vec3d.z); // Paper - Add Sign#getInteractableSideFor float f = blocksign.getYRotationDegrees(this.getBlockState()); float f1 = (float) (Mth.atan2(d1, d0) * 57.2957763671875D) - 90.0F; diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java b/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java -index 3b33aed51a84ee30b1e7bceecb0d3840866e0748..2a70c68af92967851f5caf8e67e433355ff48d44 100644 +index 3ebfc8e5b5462e6e532f8e8901fd5f8f386bbf34..2725fd91596a69e12996e838267b6612f745a4bb 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java @@ -169,6 +169,14 @@ public class CraftSign extends CraftBlockEntityState< diff --git a/patches/server/0946-Array-backed-synched-entity-data.patch b/patches/server/0946-Array-backed-synched-entity-data.patch index 84bf2095b4..20c0e69844 100644 --- a/patches/server/0946-Array-backed-synched-entity-data.patch +++ b/patches/server/0946-Array-backed-synched-entity-data.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Array backed synched entity data Original code by jellysquid3 in Lithium, licensed under the GNU Lesser General Public License v3.0 (https://www.gnu.org/licenses/lgpl-3.0.html) diff --git a/src/main/java/net/minecraft/network/syncher/SynchedEntityData.java b/src/main/java/net/minecraft/network/syncher/SynchedEntityData.java -index ccb7d92b6c36b6225a2e640f8cea6c0da37464c8..a043c382c37058032548a5192e17f5f816abe5a6 100644 +index ccb7d92b6c36b6225a2e640f8cea6c0da37464c8..fa3faf436dc1c5ed2d53abaec6e126d3e3c22c36 100644 --- a/src/main/java/net/minecraft/network/syncher/SynchedEntityData.java +++ b/src/main/java/net/minecraft/network/syncher/SynchedEntityData.java @@ -34,6 +34,11 @@ public class SynchedEntityData { @@ -17,7 +17,7 @@ index ccb7d92b6c36b6225a2e640f8cea6c0da37464c8..a043c382c37058032548a5192e17f5f8 + private static final int DEFAULT_ENTRY_COUNT = 10; + private static final int GROW_FACTOR = 8; + private SynchedEntityData.DataItem[] itemsArray = new SynchedEntityData.DataItem[DEFAULT_ENTRY_COUNT]; -+ // Paper end ++ // Paper end - array backed synched entity data public SynchedEntityData(Entity trackedEntity) { this.entity = trackedEntity; @@ -33,7 +33,7 @@ index ccb7d92b6c36b6225a2e640f8cea6c0da37464c8..a043c382c37058032548a5192e17f5f8 + } + + this.itemsArray[key.getId()] = datawatcher_item; -+ // Paper end ++ // Paper end - array backed synched entity data } public boolean hasItem(EntityDataAccessor key) { @@ -50,7 +50,7 @@ index ccb7d92b6c36b6225a2e640f8cea6c0da37464c8..a043c382c37058032548a5192e17f5f8 + } + + return (DataItem) this.itemsArray[id]; -+ // Paper end ++ // Paper end - array backed synched entity data // Spigot end } diff --git a/patches/server/0948-Fix-BanList-API.patch b/patches/server/0948-Fix-BanList-API.patch index ecc87d62a0..f61cc30d0c 100644 --- a/patches/server/0948-Fix-BanList-API.patch +++ b/patches/server/0948-Fix-BanList-API.patch @@ -208,7 +208,7 @@ index 172202accf4448a933fcf1ff820316c7910dd7f7..50ee7656580d386db473c054f5c5ec57 return null; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index 809932208bdf8e01d7bc73f885c44497a4ce4a95..5e17e19b79e6d98e95e1daae33c6430b3dfb151e 100644 +index cc0824b3a8e4cb0bbefd53f91faf3942c097a004..4c5ad6275f12a656d5d02ba1c0736fed55ac561e 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -1652,23 +1652,23 @@ public class CraftPlayer extends CraftHumanEntity implements Player { diff --git a/patches/server/0952-ExperienceOrb-should-call-EntitySpawnEvent.patch b/patches/server/0952-ExperienceOrb-should-call-EntitySpawnEvent.patch index e6d854a0e3..0a5366e668 100644 --- a/patches/server/0952-ExperienceOrb-should-call-EntitySpawnEvent.patch +++ b/patches/server/0952-ExperienceOrb-should-call-EntitySpawnEvent.patch @@ -5,7 +5,7 @@ Subject: [PATCH] ExperienceOrb should call EntitySpawnEvent diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java -index 5ead89e46d9cf17980baf35cda000bc4c0e7425b..7fe4d29f7734ba9642f1a64c161df7d24b88a18a 100644 +index ba7f9ac6068bae43c628015fa07b32794fea9369..ab576ca90606d3c9dabf08ae9f37a339cf1c3f5a 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -734,7 +734,10 @@ public class CraftEventFactory { diff --git a/patches/server/0955-Implement-PlayerFailMoveEvent.patch b/patches/server/0955-Implement-PlayerFailMoveEvent.patch index 3ac0346c49..807a4fa81e 100644 --- a/patches/server/0955-Implement-PlayerFailMoveEvent.patch +++ b/patches/server/0955-Implement-PlayerFailMoveEvent.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Implement PlayerFailMoveEvent diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index ab2fcbdd9567e18a59eb70b3557da7a3f4a91f38..bed713a7c13cd11c2ea7d8397aee1159f42eac7d 100644 +index 589662812bc6f6fb09d50d8793c7ed4cb1140af8..12d714fe819fedd358921c1a146372087e5fb9d1 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java @@ -1316,8 +1316,8 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl diff --git a/patches/server/0956-Folia-scheduler-and-owned-region-API.patch b/patches/server/0956-Folia-scheduler-and-owned-region-API.patch index d1bfe767a5..22f55be902 100644 --- a/patches/server/0956-Folia-scheduler-and-owned-region-API.patch +++ b/patches/server/0956-Folia-scheduler-and-owned-region-API.patch @@ -1148,7 +1148,7 @@ index 0000000000000000000000000000000000000000..d306f911757a4d556c82c0070d4837db + } +} diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index c9e1ded332fc320e87e0b4b95b97905ea0c91803..9a3ee0a2b2b41baea6988ee0ad64ff5cf61dde9f 100644 +index 45f7e7efa8cf407cae2db657074478565590bd12..d34f0d5abd93ed1729a00405d78a34a1873ba086 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -1629,6 +1629,20 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop 0; // Paper - net.minecraft.world.level.block.entity.HopperBlockEntity.skipHopperEvents = worldserver.paperConfig().hopper.disableMoveEvent || org.bukkit.event.inventory.InventoryMoveItemEvent.getHandlerList().getRegisteredListeners().length == 0; // Paper + net.minecraft.world.level.block.entity.HopperBlockEntity.skipHopperEvents = worldserver.paperConfig().hopper.disableMoveEvent || org.bukkit.event.inventory.InventoryMoveItemEvent.getHandlerList().getRegisteredListeners().length == 0; // Paper - Perf: Optimize Hoppers worldserver.hasEntityMoveEvent = io.papermc.paper.event.entity.EntityMoveEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index a7f2e8755af41abc66070f1971e526b4f05bc710..9a7d5aa722eb1e56da8e9e11b46179c9f9ab716f 100644 +index dae52be48e9789db2fbbff699f3e0c44086c864f..2e293fb94024d21769faf0e60e79e91efac79007 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java @@ -570,6 +570,17 @@ public class ServerLevel extends Level implements WorldGenLevel { @@ -52,7 +52,7 @@ index a7f2e8755af41abc66070f1971e526b4f05bc710..9a7d5aa722eb1e56da8e9e11b46179c9 // Add env and gen to constructor, IWorldDataServer -> WorldDataServer public ServerLevel(MinecraftServer minecraftserver, Executor executor, LevelStorageSource.LevelStorageAccess convertable_conversionsession, PrimaryLevelData iworlddataserver, ResourceKey resourcekey, LevelStem worlddimension, ChunkProgressListener worldloadlistener, boolean flag, long i, List list, boolean flag1, @Nullable RandomSequences randomsequences, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider) { diff --git a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java -index 16cb80c64ebf33b9621fdbd6655becb85db487fa..8e6b4880e9596cf2e9c34fb90f03897f05475000 100644 +index 8bfd31ce3b4f88f0b32adb242c53771d9930b855..921d9d8bc6265631073d105fb8de68562f902778 100644 --- a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java @@ -124,7 +124,7 @@ public class ServerPlayerGameMode { @@ -65,13 +65,13 @@ index 16cb80c64ebf33b9621fdbd6655becb85db487fa..8e6b4880e9596cf2e9c34fb90f03897f if (this.hasDelayedDestroy) { diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index 3ce5c06a6c154c0b8c9f2aaaa0a2f9d092cc4551..c5a07b414da0209035f3f186f72a8913243187be 100644 +index 668297b8978cbde6635254122f8f29f4a7ead45b..ceb3bfbd955111af183eb16c0946109251289d40 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java @@ -3818,6 +3818,10 @@ public abstract class LivingEntity extends Entity implements Attackable { this.getEntityData().resendPossiblyDesyncedDataValues(java.util.List.of(DATA_LIVING_ENTITY_FLAGS), serverPlayer); } - // Paper end + // Paper end - Properly cancel usable items + // Paper start - lag compensate eating + protected long eatStartTime; + protected int totalEatTimeTicks; diff --git a/patches/server/1010-Optimise-nearby-player-retrieval.patch b/patches/server/1010-Optimise-nearby-player-retrieval.patch index 2659e9fd38..764647638f 100644 --- a/patches/server/1010-Optimise-nearby-player-retrieval.patch +++ b/patches/server/1010-Optimise-nearby-player-retrieval.patch @@ -8,7 +8,7 @@ we can instead use the nearby player tracking system to reduce the number of tests per search. diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index 9a7d5aa722eb1e56da8e9e11b46179c9f9ab716f..672dcf1d82b4a858167be678888d3fb672c1384a 100644 +index 2e293fb94024d21769faf0e60e79e91efac79007..9f1ba9240b6a8ea0ca19344a49e93a63e3132729 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java @@ -581,6 +581,115 @@ public class ServerLevel extends Level implements WorldGenLevel { diff --git a/patches/server/1011-Fix-missing-map-initialize-event-call.patch b/patches/server/1011-Fix-missing-map-initialize-event-call.patch index 6bcc31b494..8e3ae38957 100644 --- a/patches/server/1011-Fix-missing-map-initialize-event-call.patch +++ b/patches/server/1011-Fix-missing-map-initialize-event-call.patch @@ -7,7 +7,7 @@ Subject: [PATCH] Fix missing map initialize event call public net.minecraft.world.level.storage.DimensionDataStorage readSavedData(Ljava/util/function/Function;Lnet/minecraft/util/datafix/DataFixTypes;Ljava/lang/String;)Lnet/minecraft/world/level/saveddata/SavedData; diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index 672dcf1d82b4a858167be678888d3fb672c1384a..79b6602570de0e213faef04f9605f206aa5b7840 100644 +index 9f1ba9240b6a8ea0ca19344a49e93a63e3132729..ad4a987c1de4265f9f0d6a8769aaed95d0a66786 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java @@ -2133,13 +2133,25 @@ public class ServerLevel extends Level implements WorldGenLevel { diff --git a/patches/server/1016-Add-player-idle-duration-API.patch b/patches/server/1016-Add-player-idle-duration-API.patch index ca5244769b..a3b91651f5 100644 --- a/patches/server/1016-Add-player-idle-duration-API.patch +++ b/patches/server/1016-Add-player-idle-duration-API.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Add player idle duration API Implements API for getting and resetting a player's idle duration. diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index 0eaa7d410ef93713f59d0cfb3cf4112a004e886c..9314506770f7841d15371d81c1c63504d1ecd2ad 100644 +index 85983812ac86ead64bdf3789a49c46302a9566ef..2a639bc8d3edca5eb7bfca2cc117b56587e5e525 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -3311,6 +3311,18 @@ public class CraftPlayer extends CraftHumanEntity implements Player { diff --git a/patches/server/1019-Allow-null-itemstack-for-Player-sendEquipmentChange.patch b/patches/server/1019-Allow-null-itemstack-for-Player-sendEquipmentChange.patch index d5c60aea75..9267ffa134 100644 --- a/patches/server/1019-Allow-null-itemstack-for-Player-sendEquipmentChange.patch +++ b/patches/server/1019-Allow-null-itemstack-for-Player-sendEquipmentChange.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Allow null itemstack for Player#sendEquipmentChange diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index 9314506770f7841d15371d81c1c63504d1ecd2ad..5513ceedd304995d6c8cbec0f6b629ef1b30d3e7 100644 +index 2a639bc8d3edca5eb7bfca2cc117b56587e5e525..132692091fdec45f0330c8bc668cc16873db2976 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -1083,7 +1083,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { diff --git a/patches/server/1023-Broadcast-take-item-packets-with-collector-as-source.patch b/patches/server/1023-Broadcast-take-item-packets-with-collector-as-source.patch index 1d1ab9746c..0268bd6315 100644 --- a/patches/server/1023-Broadcast-take-item-packets-with-collector-as-source.patch +++ b/patches/server/1023-Broadcast-take-item-packets-with-collector-as-source.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Broadcast take item packets with collector as source This fixes players (which can't view the collector) seeing item pickups with themselves as the target. diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index c5a07b414da0209035f3f186f72a8913243187be..d90d86f6b6e656bc6680afa07c7a9e99e6325851 100644 +index ceb3bfbd955111af183eb16c0946109251289d40..c30ae7d8b5ee601db30111054c74ce60625d8203 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java @@ -3703,7 +3703,7 @@ public abstract class LivingEntity extends Entity implements Attackable { diff --git a/patches/server/1032-Don-t-fire-sync-events-during-worldgen.patch b/patches/server/1032-Don-t-fire-sync-events-during-worldgen.patch index 7d3e2ef653..231b72f7c3 100644 --- a/patches/server/1032-Don-t-fire-sync-events-during-worldgen.patch +++ b/patches/server/1032-Don-t-fire-sync-events-during-worldgen.patch @@ -19,7 +19,7 @@ where generation happened directly to a ServerLevel and the entity still has the flag set. diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index 79b6602570de0e213faef04f9605f206aa5b7840..0567fbf194d3dfef3f2348c4b1f69ac857dc5648 100644 +index ad4a987c1de4265f9f0d6a8769aaed95d0a66786..a1fd04399ef61d0257d1e4a6bb627e4a1b7a7ceb 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java @@ -1681,6 +1681,7 @@ public class ServerLevel extends Level implements WorldGenLevel { @@ -31,7 +31,7 @@ index 79b6602570de0e213faef04f9605f206aa5b7840..0567fbf194d3dfef3f2348c4b1f69ac8 if (entity.valid) { MinecraftServer.LOGGER.error("Attempted Double World add on " + entity, new Throwable()); diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index ec6a75e266725ce9de09f44cb7ed4096cf23a211..63e445beaeedcbd6f06991e7ef504af9943e0c9f 100644 +index aef714923ff1e9d476aacd9bfaa80f85dc84890b..d77faa799de1b7cc23adb91d82a45a05532532f1 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java @@ -713,7 +713,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S @@ -68,7 +68,7 @@ index 940b8d0b89d7e55c938aefbe80ee71b0db3dacb8..abb2a02e0fc1deedb0ad76aec64f74ce }, () -> { EntityType.LOGGER.warn("Skipping Entity with id {}", nbt.getString("id")); diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index d90d86f6b6e656bc6680afa07c7a9e99e6325851..f242b2c56bfc2f17e87125e642538d58feb253e0 100644 +index c30ae7d8b5ee601db30111054c74ce60625d8203..7204fc4d535fb7cf5579aa51148e6a1262f3124d 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java @@ -1133,6 +1133,11 @@ public abstract class LivingEntity extends Entity implements Attackable { diff --git a/patches/server/1034-Restore-vanilla-entity-drops-behavior.patch b/patches/server/1034-Restore-vanilla-entity-drops-behavior.patch index eedc31601e..3f6577f1b1 100644 --- a/patches/server/1034-Restore-vanilla-entity-drops-behavior.patch +++ b/patches/server/1034-Restore-vanilla-entity-drops-behavior.patch @@ -50,7 +50,7 @@ index 67a4c0a436cb1a0b5b9fc7c80dc501b1fb546f8f..d8bea03eb39b393751a69c4cfc8c0042 if (entityitem == null) { return null; diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index 63e445beaeedcbd6f06991e7ef504af9943e0c9f..020cddd4c62aa952ae0f9d5a0e73d033fb3ab7c8 100644 +index d77faa799de1b7cc23adb91d82a45a05532532f1..29853426230ef7e95c7060cf1a44870d369d5f68 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java @@ -2703,6 +2703,25 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S @@ -104,7 +104,7 @@ index 63e445beaeedcbd6f06991e7ef504af9943e0c9f..020cddd4c62aa952ae0f9d5a0e73d033 return this.spawnAtLocation(entityitem); } diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index f242b2c56bfc2f17e87125e642538d58feb253e0..4cbdc1c36b1afb93f7c261b4ecbc5a766a00a288 100644 +index 7204fc4d535fb7cf5579aa51148e6a1262f3124d..3b7459226ae022c9e1de6dbf775046a767b409c9 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java @@ -254,7 +254,7 @@ public abstract class LivingEntity extends Entity implements Attackable { @@ -165,7 +165,7 @@ index ab708b256183fc54fe8e13f341d8a38acf611739..a9c1f99ba2461333bd154ac16e812031 } } diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java -index e42c87a38787e3528dd663627da9c4286e1d8bfc..69bce85eb00b4f8d26c4e1333cf778ef5084d07b 100644 +index 57b11760b420f09111899a7e19f0d555785b425f..b648d1960280d6aa235e511edf30848ee20bb693 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -939,17 +939,21 @@ public class CraftEventFactory { diff --git a/patches/server/1036-Dont-resend-blocks-on-interactions.patch b/patches/server/1036-Dont-resend-blocks-on-interactions.patch index 89a6d56c83..69edfadb34 100644 --- a/patches/server/1036-Dont-resend-blocks-on-interactions.patch +++ b/patches/server/1036-Dont-resend-blocks-on-interactions.patch @@ -8,7 +8,7 @@ In general, the client now has an acknowledgment system which will prevent block It should be noted that this system does not yet support block entities, so those still need to resynced when needed. diff --git a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java -index 8e6b4880e9596cf2e9c34fb90f03897f05475000..c4bafa1b5c50d953502b5d918eb28dfe692a180d 100644 +index 921d9d8bc6265631073d105fb8de68562f902778..3c567a9ea921a6ae36f4dc5e16a8394ab62460a8 100644 --- a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java @@ -199,7 +199,7 @@ public class ServerPlayerGameMode { @@ -149,7 +149,7 @@ index 277555a26e8281dd1a626e572794b08cf51d00c5..aa0f09a18ea781e027ea70928b30d3e9 return false; } diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java -index 666533627e772e5e85ba04e65dd2b376efc0b139..bab97eedd92f7131fd0cd478580ddd52d2173de9 100644 +index 32a3729b9f1caca789af8176737fc510761ee960..5caf48c84b8dd46903dbdacaa3a5e13272374e0e 100644 --- a/src/main/java/net/minecraft/world/item/ItemStack.java +++ b/src/main/java/net/minecraft/world/item/ItemStack.java @@ -457,10 +457,12 @@ public final class ItemStack { diff --git a/patches/server/1037-Keep-previous-behavior-for-setResourcePack.patch b/patches/server/1037-Keep-previous-behavior-for-setResourcePack.patch index 255ed26116..a3de6ac330 100644 --- a/patches/server/1037-Keep-previous-behavior-for-setResourcePack.patch +++ b/patches/server/1037-Keep-previous-behavior-for-setResourcePack.patch @@ -10,7 +10,7 @@ packs before sending the new pack. Other API exists for adding a new pack to the existing packs on a client. diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index 5513ceedd304995d6c8cbec0f6b629ef1b30d3e7..103e311bb37e9686b53d8dde645f4a2d1301e4be 100644 +index 132692091fdec45f0330c8bc668cc16873db2976..a257e7a998b79f33662cc96c8f5e6329910bdec6 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -2351,8 +2351,10 @@ public class CraftPlayer extends CraftHumanEntity implements Player { diff --git a/patches/server/1042-Fix-NPE-on-null-loc-for-EntityTeleportEvent.patch b/patches/server/1042-Fix-NPE-on-null-loc-for-EntityTeleportEvent.patch index f0ca125467..795c995ce3 100644 --- a/patches/server/1042-Fix-NPE-on-null-loc-for-EntityTeleportEvent.patch +++ b/patches/server/1042-Fix-NPE-on-null-loc-for-EntityTeleportEvent.patch @@ -26,7 +26,7 @@ index 3fec07b250a8f145e30c8c41888e47d2a3c902e1..2ddd033e1c3a2e5c8950b93c83849192 x = to.getX(); y = to.getY(); diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index 4cbdc1c36b1afb93f7c261b4ecbc5a766a00a288..8ac9c65caab86d30c31be0b713a7896a24637457 100644 +index 3b7459226ae022c9e1de6dbf775046a767b409c9..97dbd1c8c8b6301bb607079575589dcceab0f881 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java @@ -4204,7 +4204,7 @@ public abstract class LivingEntity extends Entity implements Attackable { diff --git a/patches/server/1043-Add-experience-points-API.patch b/patches/server/1043-Add-experience-points-API.patch index f8f091d895..67e0c99c80 100644 --- a/patches/server/1043-Add-experience-points-API.patch +++ b/patches/server/1043-Add-experience-points-API.patch @@ -18,7 +18,7 @@ index 7f3466340891b4409d1399ebeb2ca865d77841cd..0a9ee8aee52b34566f1613229951e33e // Paper start - send SoundEffect to everyone who can see fromEntity private static void sendSoundEffect(Player fromEntity, double x, double y, double z, SoundEvent soundEffect, SoundSource soundCategory, float volume, float pitch) { diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index 103e311bb37e9686b53d8dde645f4a2d1301e4be..a4db69d8d814c03fa9efe79492c7cc3c736af5a4 100644 +index a257e7a998b79f33662cc96c8f5e6329910bdec6..1359db54d76c1eb81ef65a6dc6f56b3ffad4bb62 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -1821,6 +1821,49 @@ public class CraftPlayer extends CraftHumanEntity implements Player { diff --git a/patches/server/1045-Add-drops-to-shear-events.patch b/patches/server/1045-Add-drops-to-shear-events.patch index bafa35c1b8..df6f2b963b 100644 --- a/patches/server/1045-Add-drops-to-shear-events.patch +++ b/patches/server/1045-Add-drops-to-shear-events.patch @@ -233,7 +233,7 @@ index 8adcfc8f6772a32b5915e4a07100e8eb735f907a..b5d6857eaf2bed14adcb5f5e80d91b44 } diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java -index 69bce85eb00b4f8d26c4e1333cf778ef5084d07b..f2de6aa8c1ed96bd0dfd028212cf3c5c570020c3 100644 +index b648d1960280d6aa235e511edf30848ee20bb693..417e63d99216edd23d784ac5733432c541baf452 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -1718,20 +1718,20 @@ public class CraftEventFactory { diff --git a/patches/server/1048-Correctly-check-if-bucket-dispenses-will-succeed-for.patch b/patches/server/1048-Correctly-check-if-bucket-dispenses-will-succeed-for.patch index 761c0530e9..28d8d3e499 100644 --- a/patches/server/1048-Correctly-check-if-bucket-dispenses-will-succeed-for.patch +++ b/patches/server/1048-Correctly-check-if-bucket-dispenses-will-succeed-for.patch @@ -8,7 +8,7 @@ in order to fire the BlockDispenseEvent. This patch corrects that. diff --git a/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java b/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java -index f42a86549e389ec53962f7a5e7a625f351cd4724..a1739f6f091fe922ac0e97141fc9446664713fc3 100644 +index 6b7d8b7b6665aa87af4bd8aa00f75fb2c9dd4b6b..409d6415162d87d611694795a3864693f9ec6432 100644 --- a/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java +++ b/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java @@ -628,7 +628,13 @@ public interface DispenseItemBehavior { diff --git a/patches/server/1051-Properly-handle-experience-dropping-on-block-break.patch b/patches/server/1051-Properly-handle-experience-dropping-on-block-break.patch index edc6007964..fe8724fbc2 100644 --- a/patches/server/1051-Properly-handle-experience-dropping-on-block-break.patch +++ b/patches/server/1051-Properly-handle-experience-dropping-on-block-break.patch @@ -7,7 +7,7 @@ This causes spawnAfterBreak to spawn xp by default, removing the need to manuall For classes that use custom xp amounts, they can drop the resources with disabling diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index b8bf9eaae60040a3ba3d395712aa91940a71bea2..afd2e9bcdf94f3511bcd68cab5e72284f07fd016 100644 +index 2c2189a31c608c99abe6a9c0a78bdcb717b51aba..00ff7de3fe0feb166a792c61aa81a1e201d7e928 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java @@ -1103,7 +1103,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable {