From 2397b86efaebaae59e224654539c63d99da4c5be Mon Sep 17 00:00:00 2001 From: Jake Potrebic <15055071+Machine-Maker@users.noreply.github.com> Date: Sat, 12 Jun 2021 09:56:13 -0700 Subject: [PATCH] more patches (#5807) --- ...Add-setPlayerProfile-API-for-Skulls.patch} | 0 .../0082-Fill-Profile-Property-Events.patch} | 0 ...layerAdvancementCriterionGrantEvent.patch} | 0 .../0084-Add-ArmorStand-Item-Meta.patch} | 0 .../0085-Optimize-Hoppers.patch} | 0 .../0086-Tameable-getOwnerUniqueId-API.patch} | 0 ...-PlayerProfile-in-AsyncPreLoginEven.patch} | 2 +- ...d-extended-PaperServerListPingEvent.patch} | 0 .../0088-Player.setPlayerProfile-API.patch | 0 ...sted-Ice-from-loading-holding-chunks.patch | 1 + patches/server/0006-MC-Utils.patch | 18 ++ ...-MinecraftKey-Information-to-Objects.patch | 13 +- .../server/0099-Fix-Old-Sign-Conversion.patch | 4 +- .../0164-Add-PlayerArmorChangeEvent.patch | 12 -- ...-get-a-BlockState-without-a-snapshot.patch | 11 +- .../server/0168-AsyncTabCompleteEvent.patch | 4 +- ...0-Ability-to-apply-mending-to-XP-API.patch | 13 +- ...Add-setPlayerProfile-API-for-Skulls.patch} | 31 +--- .../0174-Fill-Profile-Property-Events.patch} | 0 ...layerAdvancementCriterionGrantEvent.patch} | 8 +- .../0176-Add-ArmorStand-Item-Meta.patch} | 108 ++++++------ ...Extend-Player-Interact-cancellation.patch} | 32 +--- .../0178-Tameable-getOwnerUniqueId-API.patch} | 14 +- ...-crits-helps-mitigate-hacked-client.patch} | 6 +- ...e-Explicit-Network-Manager-Flushing.patch} | 6 +- ...t-extended-PaperServerListPingEvent.patch} | 162 ++---------------- .../0182-Improved-Async-Task-Scheduler.patch} | 34 ++-- ...-PlayerProfile-in-AsyncPreLoginEven.patch} | 8 +- .../0184-Player.setPlayerProfile-API.patch} | 55 +++--- 29 files changed, 178 insertions(+), 364 deletions(-) rename patches/{api-unmapped/0080-Add-setPlayerProfile-API-for-Skulls.patch => api/0081-Add-setPlayerProfile-API-for-Skulls.patch} (100%) rename patches/{api-unmapped/0081-Fill-Profile-Property-Events.patch => api/0082-Fill-Profile-Property-Events.patch} (100%) rename patches/{api-unmapped/0082-PlayerAdvancementCriterionGrantEvent.patch => api/0083-PlayerAdvancementCriterionGrantEvent.patch} (100%) rename patches/{api-unmapped/0083-Add-ArmorStand-Item-Meta.patch => api/0084-Add-ArmorStand-Item-Meta.patch} (100%) rename patches/{api-unmapped/0084-Optimize-Hoppers.patch => api/0085-Optimize-Hoppers.patch} (100%) rename patches/{api-unmapped/0085-Tameable-getOwnerUniqueId-API.patch => api/0086-Tameable-getOwnerUniqueId-API.patch} (100%) rename patches/{api-unmapped/0086-Ability-to-change-PlayerProfile-in-AsyncPreLoginEven.patch => api/0087-Ability-to-change-PlayerProfile-in-AsyncPreLoginEven.patch} (97%) rename patches/{api-unmapped/0087-Add-extended-PaperServerListPingEvent.patch => api/0088-Add-extended-PaperServerListPingEvent.patch} (100%) rename patches/{api-unmapped => api}/0088-Player.setPlayerProfile-API.patch (100%) rename patches/{server-remapped => removed/1.17}/0196-Prevent-Frosted-Ice-from-loading-holding-chunks.patch (95%) rename patches/{server-remapped/0189-Add-setPlayerProfile-API-for-Skulls.patch => server/0173-Add-setPlayerProfile-API-for-Skulls.patch} (69%) rename patches/{server-remapped/0190-Fill-Profile-Property-Events.patch => server/0174-Fill-Profile-Property-Events.patch} (100%) rename patches/{server-remapped/0191-PlayerAdvancementCriterionGrantEvent.patch => server/0175-PlayerAdvancementCriterionGrantEvent.patch} (76%) rename patches/{server-remapped/0192-Add-ArmorStand-Item-Meta.patch => server/0176-Add-ArmorStand-Item-Meta.patch} (70%) rename patches/{server-remapped/0193-Extend-Player-Interact-cancellation.patch => server/0177-Extend-Player-Interact-cancellation.patch} (60%) rename patches/{server-remapped/0194-Tameable-getOwnerUniqueId-API.patch => server/0178-Tameable-getOwnerUniqueId-API.patch} (70%) rename patches/{server-remapped/0195-Toggleable-player-crits-helps-mitigate-hacked-client.patch => server/0179-Toggleable-player-crits-helps-mitigate-hacked-client.patch} (87%) rename patches/{server-remapped/0197-Disable-Explicit-Network-Manager-Flushing.patch => server/0180-Disable-Explicit-Network-Manager-Flushing.patch} (86%) rename patches/{server-remapped/0198-Implement-extended-PaperServerListPingEvent.patch => server/0181-Implement-extended-PaperServerListPingEvent.patch} (57%) rename patches/{server-remapped/0199-Improved-Async-Task-Scheduler.patch => server/0182-Improved-Async-Task-Scheduler.patch} (91%) rename patches/{server-remapped/0200-Ability-to-change-PlayerProfile-in-AsyncPreLoginEven.patch => server/0183-Ability-to-change-PlayerProfile-in-AsyncPreLoginEven.patch} (88%) rename patches/{server-remapped/0201-Player.setPlayerProfile-API.patch => server/0184-Player.setPlayerProfile-API.patch} (72%) diff --git a/patches/api-unmapped/0080-Add-setPlayerProfile-API-for-Skulls.patch b/patches/api/0081-Add-setPlayerProfile-API-for-Skulls.patch similarity index 100% rename from patches/api-unmapped/0080-Add-setPlayerProfile-API-for-Skulls.patch rename to patches/api/0081-Add-setPlayerProfile-API-for-Skulls.patch diff --git a/patches/api-unmapped/0081-Fill-Profile-Property-Events.patch b/patches/api/0082-Fill-Profile-Property-Events.patch similarity index 100% rename from patches/api-unmapped/0081-Fill-Profile-Property-Events.patch rename to patches/api/0082-Fill-Profile-Property-Events.patch diff --git a/patches/api-unmapped/0082-PlayerAdvancementCriterionGrantEvent.patch b/patches/api/0083-PlayerAdvancementCriterionGrantEvent.patch similarity index 100% rename from patches/api-unmapped/0082-PlayerAdvancementCriterionGrantEvent.patch rename to patches/api/0083-PlayerAdvancementCriterionGrantEvent.patch diff --git a/patches/api-unmapped/0083-Add-ArmorStand-Item-Meta.patch b/patches/api/0084-Add-ArmorStand-Item-Meta.patch similarity index 100% rename from patches/api-unmapped/0083-Add-ArmorStand-Item-Meta.patch rename to patches/api/0084-Add-ArmorStand-Item-Meta.patch diff --git a/patches/api-unmapped/0084-Optimize-Hoppers.patch b/patches/api/0085-Optimize-Hoppers.patch similarity index 100% rename from patches/api-unmapped/0084-Optimize-Hoppers.patch rename to patches/api/0085-Optimize-Hoppers.patch diff --git a/patches/api-unmapped/0085-Tameable-getOwnerUniqueId-API.patch b/patches/api/0086-Tameable-getOwnerUniqueId-API.patch similarity index 100% rename from patches/api-unmapped/0085-Tameable-getOwnerUniqueId-API.patch rename to patches/api/0086-Tameable-getOwnerUniqueId-API.patch diff --git a/patches/api-unmapped/0086-Ability-to-change-PlayerProfile-in-AsyncPreLoginEven.patch b/patches/api/0087-Ability-to-change-PlayerProfile-in-AsyncPreLoginEven.patch similarity index 97% rename from patches/api-unmapped/0086-Ability-to-change-PlayerProfile-in-AsyncPreLoginEven.patch rename to patches/api/0087-Ability-to-change-PlayerProfile-in-AsyncPreLoginEven.patch index a2a9f5270f..ca04155516 100644 --- a/patches/api-unmapped/0086-Ability-to-change-PlayerProfile-in-AsyncPreLoginEven.patch +++ b/patches/api/0087-Ability-to-change-PlayerProfile-in-AsyncPreLoginEven.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Ability to change PlayerProfile in AsyncPreLoginEvent This will allow you to change the players name or skin on login. diff --git a/src/main/java/org/bukkit/event/player/AsyncPlayerPreLoginEvent.java b/src/main/java/org/bukkit/event/player/AsyncPlayerPreLoginEvent.java -index 992d1025ca02020e87a9ab5db83d249427f41d69..a40b57edb1aeff71fc0b9767d410950da5c06283 100644 +index d3b4219a57fff4519ef8d803c333c854fafa7859..d512c23ad0275061593d99f005c72292dbb07e81 100644 --- a/src/main/java/org/bukkit/event/player/AsyncPlayerPreLoginEvent.java +++ b/src/main/java/org/bukkit/event/player/AsyncPlayerPreLoginEvent.java @@ -2,6 +2,9 @@ package org.bukkit.event.player; diff --git a/patches/api-unmapped/0087-Add-extended-PaperServerListPingEvent.patch b/patches/api/0088-Add-extended-PaperServerListPingEvent.patch similarity index 100% rename from patches/api-unmapped/0087-Add-extended-PaperServerListPingEvent.patch rename to patches/api/0088-Add-extended-PaperServerListPingEvent.patch diff --git a/patches/api-unmapped/0088-Player.setPlayerProfile-API.patch b/patches/api/0088-Player.setPlayerProfile-API.patch similarity index 100% rename from patches/api-unmapped/0088-Player.setPlayerProfile-API.patch rename to patches/api/0088-Player.setPlayerProfile-API.patch diff --git a/patches/server-remapped/0196-Prevent-Frosted-Ice-from-loading-holding-chunks.patch b/patches/removed/1.17/0196-Prevent-Frosted-Ice-from-loading-holding-chunks.patch similarity index 95% rename from patches/server-remapped/0196-Prevent-Frosted-Ice-from-loading-holding-chunks.patch rename to patches/removed/1.17/0196-Prevent-Frosted-Ice-from-loading-holding-chunks.patch index 4b912daff9..b7ea1f0c46 100644 --- a/patches/server-remapped/0196-Prevent-Frosted-Ice-from-loading-holding-chunks.patch +++ b/patches/removed/1.17/0196-Prevent-Frosted-Ice-from-loading-holding-chunks.patch @@ -3,6 +3,7 @@ From: Aikar Date: Sat, 10 Mar 2018 16:33:15 -0500 Subject: [PATCH] Prevent Frosted Ice from loading/holding chunks +1.17: Shouldn't be needed as blocks no longer tick without at least 1 radius chunk loaded. diff --git a/src/main/java/net/minecraft/world/level/block/FrostedIceBlock.java b/src/main/java/net/minecraft/world/level/block/FrostedIceBlock.java index ae2f5acd008d5d7163b56cb4a2d29354299959ca..99843f1ca4737d40ae0626fce931c97bbf5ab81d 100644 diff --git a/patches/server/0006-MC-Utils.patch b/patches/server/0006-MC-Utils.patch index 3101a34f9a..9d1ed65d5c 100644 --- a/patches/server/0006-MC-Utils.patch +++ b/patches/server/0006-MC-Utils.patch @@ -3518,6 +3518,24 @@ index 65bd706ca96f5c0ec4573da9fb144fb51d2de919..3a2e8bdc215a6af604bfaad01b670a36 public long[] getRaw() { return this.data; } +diff --git a/src/main/java/net/minecraft/util/thread/BlockableEventLoop.java b/src/main/java/net/minecraft/util/thread/BlockableEventLoop.java +index 08fb847add9f5a2c1ca6dfef31de7e711c8b9840..5b38966093fe60b298844961d015d5a9f03412a2 100644 +--- a/src/main/java/net/minecraft/util/thread/BlockableEventLoop.java ++++ b/src/main/java/net/minecraft/util/thread/BlockableEventLoop.java +@@ -78,6 +78,13 @@ public abstract class BlockableEventLoop implements Profiler + } + + } ++ // Paper start ++ public void scheduleOnMain(Runnable r0) { ++ // postToMainThread does not work the same as older versions of mc ++ // This method is actually used to create a TickTask, which can then be posted onto main ++ this.tell(this.wrapRunnable(r0)); ++ } ++ // Paper end + + @Override + public void tell(R runnable) { diff --git a/src/main/java/net/minecraft/world/entity/EntityType.java b/src/main/java/net/minecraft/world/entity/EntityType.java index 7f3d83d3d071f6b441ad119b1c93be035e911e70..89e7d02b88404ac5dce06595432ae95c9a4e5015 100644 --- a/src/main/java/net/minecraft/world/entity/EntityType.java diff --git a/patches/server/0008-Add-MinecraftKey-Information-to-Objects.patch b/patches/server/0008-Add-MinecraftKey-Information-to-Objects.patch index b96b5157a6..c0c8c9453a 100644 --- a/patches/server/0008-Add-MinecraftKey-Information-to-Objects.patch +++ b/patches/server/0008-Add-MinecraftKey-Information-to-Objects.patch @@ -95,7 +95,7 @@ index 89e7d02b88404ac5dce06595432ae95c9a4e5015..3ffaeb72be8cda7a2b9398b8909db5c2 return this.serialize; } 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 33884161de688c47c90a7b86196234acc80f9434..e4601134598e509a158ceacec6099a78bbabe89d 100644 +index 33884161de688c47c90a7b86196234acc80f9434..92b042080f06fb95958ff5e824830a84f2d1f2a6 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 @@ -20,7 +20,7 @@ import org.bukkit.inventory.InventoryHolder; @@ -107,15 +107,6 @@ index 33884161de688c47c90a7b86196234acc80f9434..e4601134598e509a158ceacec6099a78 public CustomTimingsHandler tickTimer = org.bukkit.craftbukkit.SpigotTimings.getTileEntityTimings(this); // Spigot // CraftBukkit start - data containers -@@ -28,7 +28,7 @@ public abstract class BlockEntity { - public CraftPersistentDataContainer persistentDataContainer; - // CraftBukkit end - private static final Logger LOGGER = LogManager.getLogger(); -- private final BlockEntityType type; -+ private final BlockEntityType type; public BlockEntityType getTileEntityType() { return type; } // Paper - OBFHELPER - @Nullable - protected Level level; - protected final BlockPos worldPosition; @@ -41,6 +41,26 @@ public abstract class BlockEntity { this.blockState = state; } @@ -127,7 +118,7 @@ index 33884161de688c47c90a7b86196234acc80f9434..e4601134598e509a158ceacec6099a78 + @Override + public ResourceLocation getMinecraftKey() { + if (tileEntityKey == null) { -+ tileEntityKey = BlockEntityType.getKey(this.getTileEntityType()); ++ tileEntityKey = BlockEntityType.getKey(this.type); + tileEntityKeyString = tileEntityKey != null ? tileEntityKey.toString() : null; + } + return tileEntityKey; diff --git a/patches/server/0099-Fix-Old-Sign-Conversion.patch b/patches/server/0099-Fix-Old-Sign-Conversion.patch index 017485dabf..21eb3aa76c 100644 --- a/patches/server/0099-Fix-Old-Sign-Conversion.patch +++ b/patches/server/0099-Fix-Old-Sign-Conversion.patch @@ -9,7 +9,7 @@ Subject: [PATCH] Fix Old Sign Conversion This causes Igloos and such to render broken signs. We fix this by ignoring sign conversion for Defined Structures 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 d6a4a2a59f1be0cc2e373dc326287b60db5559d2..9d777fce673c8f6b3ee2d69f5a6360a8a5ad8e84 100644 +index 66ab4deedd177f507d170a61ceca4c3ebbac9adc..77645019c88d61dde28b7598d8a29b7d0c23c209 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 @@ -30,6 +30,7 @@ public abstract class BlockEntity implements net.minecraft.server.KeyedObject { @@ -17,7 +17,7 @@ index d6a4a2a59f1be0cc2e373dc326287b60db5559d2..9d777fce673c8f6b3ee2d69f5a6360a8 // CraftBukkit end private static final Logger LOGGER = LogManager.getLogger(); + public boolean isLoadingStructure = false; // Paper - private final BlockEntityType type; public BlockEntityType getTileEntityType() { return type; } // Paper - OBFHELPER + private final BlockEntityType type; @Nullable protected Level level; 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 diff --git a/patches/server/0164-Add-PlayerArmorChangeEvent.patch b/patches/server/0164-Add-PlayerArmorChangeEvent.patch index 21828275b6..1c55b80d5e 100644 --- a/patches/server/0164-Add-PlayerArmorChangeEvent.patch +++ b/patches/server/0164-Add-PlayerArmorChangeEvent.patch @@ -4,18 +4,6 @@ Date: Fri, 10 Nov 2017 23:46:34 -0500 Subject: [PATCH] Add PlayerArmorChangeEvent -diff --git a/src/main/java/net/minecraft/world/entity/EquipmentSlot.java b/src/main/java/net/minecraft/world/entity/EquipmentSlot.java -index c82bb38b5b1c9204daef21455723d21509ad1c44..135a62fcdbd801c9997bc28c071743e8ff8c64c2 100644 ---- a/src/main/java/net/minecraft/world/entity/EquipmentSlot.java -+++ b/src/main/java/net/minecraft/world/entity/EquipmentSlot.java -@@ -20,6 +20,7 @@ public enum EquipmentSlot { - this.name = name; - } - -+ public EquipmentSlot.Type getType() { return this.getType(); } // Paper - OBFHELPER - public EquipmentSlot.Type getType() { - return this.type; - } diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java index 89913edf98d65f08f379d0d201f9963c23573478..28de49c8b5771491b168bba26e6033669c48e3c9 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java diff --git a/patches/server/0167-API-to-get-a-BlockState-without-a-snapshot.patch b/patches/server/0167-API-to-get-a-BlockState-without-a-snapshot.patch index 7b37b5ad1d..c5483d657a 100644 --- a/patches/server/0167-API-to-get-a-BlockState-without-a-snapshot.patch +++ b/patches/server/0167-API-to-get-a-BlockState-without-a-snapshot.patch @@ -13,18 +13,9 @@ also Avoid NPE during CraftBlockEntityState load if could not get TE If Tile Entity was null, correct Sign to return empty lines instead of 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 9d777fce673c8f6b3ee2d69f5a6360a8a5ad8e84..c3706b87ad36332a837caffb58bd4575cbc0172a 100644 +index 77645019c88d61dde28b7598d8a29b7d0c23c209..8a079ee3ed243fd19b1dd7eed2de1dd33785faa1 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 -@@ -31,7 +31,7 @@ public abstract class BlockEntity implements net.minecraft.server.KeyedObject { - // CraftBukkit end - private static final Logger LOGGER = LogManager.getLogger(); - public boolean isLoadingStructure = false; // Paper -- private final BlockEntityType type; public BlockEntityType getTileEntityType() { return type; } // Paper - OBFHELPER -+ private final BlockEntityType type; - @Nullable - protected Level level; - protected final BlockPos worldPosition; @@ -42,6 +42,7 @@ public abstract class BlockEntity implements net.minecraft.server.KeyedObject { this.type = type; this.worldPosition = pos.immutable(); diff --git a/patches/server/0168-AsyncTabCompleteEvent.patch b/patches/server/0168-AsyncTabCompleteEvent.patch index 8cb41e523d..22bff78e55 100644 --- a/patches/server/0168-AsyncTabCompleteEvent.patch +++ b/patches/server/0168-AsyncTabCompleteEvent.patch @@ -14,7 +14,7 @@ completion, such as offline players. Also adds isCommand and getLocation to the sync TabCompleteEvent diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index b2bbd25e5572f59add71579b676d5a4c719be239..737296e90e3547505a012fc516a4fc39a565343e 100644 +index b2bbd25e5572f59add71579b676d5a4c719be239..205e4ef25f49edc11a408c302d9ba68a59c68a5a 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java @@ -703,10 +703,10 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser @@ -39,7 +39,7 @@ index b2bbd25e5572f59add71579b676d5a4c719be239..737296e90e3547505a012fc516a4fc39 + com.destroystokyo.paper.event.server.AsyncTabCompleteEvent event; + java.util.List completions = new java.util.ArrayList<>(); + String buffer = packet.getCommand(); -+ event = new com.destroystokyo.paper.event.server.AsyncTabCompleteEvent(this.getPlayer(), completions, ++ event = new com.destroystokyo.paper.event.server.AsyncTabCompleteEvent(this.getCraftPlayer(), completions, + buffer, true, null); + event.callEvent(); + completions = event.isCancelled() ? com.google.common.collect.ImmutableList.of() : event.getCompletions(); diff --git a/patches/server/0170-Ability-to-apply-mending-to-XP-API.patch b/patches/server/0170-Ability-to-apply-mending-to-XP-API.patch index 06411572db..24489b2e5c 100644 --- a/patches/server/0170-Ability-to-apply-mending-to-XP-API.patch +++ b/patches/server/0170-Ability-to-apply-mending-to-XP-API.patch @@ -27,22 +27,25 @@ index 8203c93dcb56646df2614f2233aaf3a36f745d1c..71fb831ed3359e7986e279c987211f39 return experienceAmount * 2; } diff --git a/src/main/java/net/minecraft/world/item/enchantment/EnchantmentHelper.java b/src/main/java/net/minecraft/world/item/enchantment/EnchantmentHelper.java -index 27cdfbeb6cb2159075b35dd4f9e9557ec0eac7c2..d2d7b303e66bbba489e2003cc130dcd53e2a9854 100644 +index 27cdfbeb6cb2159075b35dd4f9e9557ec0eac7c2..069ce59faab5184ab9da8ca3fe1cebf7449cd7fe 100644 --- a/src/main/java/net/minecraft/world/item/enchantment/EnchantmentHelper.java +++ b/src/main/java/net/minecraft/world/item/enchantment/EnchantmentHelper.java -@@ -246,8 +246,8 @@ public class EnchantmentHelper { +@@ -246,8 +246,11 @@ public class EnchantmentHelper { return getItemEnchantmentLevel(Enchantments.CHANNELING, stack) > 0; } - @Nullable - public static Entry getRandomItemWith(Enchantment enchantment, LivingEntity entity) { -+ public static @javax.annotation.Nonnull ItemStack getRandomEquippedItemWithEnchant(Enchantment enchantment, LivingEntity entityliving) { Entry entry = getRandomItemWith(enchantment, entityliving); return entry != null ? entry.getValue() : ItemStack.NULL_ITEM; } // Paper - OBFHELPER ++ public static @javax.annotation.Nonnull ItemStack getRandomEquippedItemWithEnchant(Enchantment enchantment, LivingEntity entityliving) { ++ Entry entry = getRandomItemWith(enchantment, entityliving); ++ return entry != null ? entry.getValue() : ItemStack.EMPTY; ++ } // Paper - OBFHELPER + @Nullable public static Entry getRandomItemWith(Enchantment enchantment, LivingEntity entity) { return getRandomItemWith(enchantment, entity, (stack) -> { return true; }); diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index ed1c57f22adc8b96012eca426ed1e7b409e7d663..b1778f53de7974e03c7b56b0df69e31cdae8dd62 100644 +index ed1c57f22adc8b96012eca426ed1e7b409e7d663..75963a28b39f8835f1daba3d1b44655603124bf3 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -61,11 +61,14 @@ import net.minecraft.server.level.ServerPlayer; @@ -80,7 +83,7 @@ index ed1c57f22adc8b96012eca426ed1e7b409e7d663..b1778f53de7974e03c7b56b0df69e31c + int i = Math.min(orb.xpToDur(amount), itemstack.getDamageValue()); + org.bukkit.event.player.PlayerItemMendEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerItemMendEvent(handle, orb, itemstack, i); + i = event.getRepairAmount(); -+ orb.removed = true; ++ orb.discard(); + if (!event.isCancelled()) { + amount -= orb.durToXp(i); + itemstack.setDamageValue(itemstack.getDamageValue() - i); diff --git a/patches/server-remapped/0189-Add-setPlayerProfile-API-for-Skulls.patch b/patches/server/0173-Add-setPlayerProfile-API-for-Skulls.patch similarity index 69% rename from patches/server-remapped/0189-Add-setPlayerProfile-API-for-Skulls.patch rename to patches/server/0173-Add-setPlayerProfile-API-for-Skulls.patch index 746bff56a9..8c638a6d93 100644 --- a/patches/server-remapped/0189-Add-setPlayerProfile-API-for-Skulls.patch +++ b/patches/server/0173-Add-setPlayerProfile-API-for-Skulls.patch @@ -7,7 +7,7 @@ This allows you to create already filled textures on Skulls to avoid texture loo which commonly cause rate limit issues with Mojang API diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftSkull.java b/src/main/java/org/bukkit/craftbukkit/block/CraftSkull.java -index 2047ea32489d03051783d18a0dbaf456bfdbb2a1..a06c51a56846750ce59a70e9698c2b57c3517aad 100644 +index 1879ae835c437883f76330d6e2707460273d02db..df0ba7ed56fc635a4aa30934d1990043dbc3d8dc 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftSkull.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftSkull.java @@ -1,5 +1,7 @@ @@ -18,15 +18,7 @@ index 2047ea32489d03051783d18a0dbaf456bfdbb2a1..a06c51a56846750ce59a70e9698c2b57 import com.google.common.base.Preconditions; import com.mojang.authlib.GameProfile; import net.minecraft.server.MinecraftServer; -@@ -15,6 +17,7 @@ import org.bukkit.block.data.BlockData; - import org.bukkit.block.data.Directional; - import org.bukkit.block.data.Rotatable; - import org.bukkit.craftbukkit.entity.CraftPlayer; -+import javax.annotation.Nullable; - - public class CraftSkull extends CraftBlockEntityState implements Skull { - -@@ -105,6 +108,20 @@ public class CraftSkull extends CraftBlockEntityState implemen +@@ -105,6 +107,20 @@ public class CraftSkull extends CraftBlockEntityState implemen } } @@ -37,7 +29,7 @@ index 2047ea32489d03051783d18a0dbaf456bfdbb2a1..a06c51a56846750ce59a70e9698c2b57 + this.profile = CraftPlayerProfile.asAuthlibCopy(profile); + } + -+ @Nullable ++ @javax.annotation.Nullable + @Override + public PlayerProfile getPlayerProfile() { + return profile != null ? CraftPlayerProfile.asBukkitCopy(profile) : null; @@ -48,7 +40,7 @@ index 2047ea32489d03051783d18a0dbaf456bfdbb2a1..a06c51a56846750ce59a70e9698c2b57 public BlockFace getRotation() { BlockData blockData = getBlockData(); diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java -index 750661540f55d3c59119dcc909e706e571a2123b..aa64ffc23d8941ff05ea7791ddd628c3c6be90e4 100644 +index 5e345224e698bd80133dc194385c033369a60a33..33994a050826d10d69f375f65ecce2b56116cca0 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java @@ -4,10 +4,8 @@ import com.google.common.collect.ImmutableMap.Builder; @@ -77,7 +69,7 @@ index 750661540f55d3c59119dcc909e706e571a2123b..aa64ffc23d8941ff05ea7791ddd628c3 class CraftMetaSkull extends CraftMetaItem implements SkullMeta { @@ -149,6 +152,19 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta { - return hasOwner() ? profile.getName() : null; + return this.hasOwner() ? this.profile.getName() : null; } + // Paper start @@ -95,15 +87,4 @@ index 750661540f55d3c59119dcc909e706e571a2123b..aa64ffc23d8941ff05ea7791ddd628c3 + @Override public OfflinePlayer getOwningPlayer() { - if (hasOwner()) { -@@ -175,8 +191,8 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta { - } else { - // Paper start - Use Online Players Skull - GameProfile newProfile = null; -- net.minecraft.server.EntityPlayer player = net.minecraft.server.MinecraftServer.getServer().getPlayerList().getPlayerByName(name); -- if (player != null) newProfile = player.getProfile(); -+ net.minecraft.server.level.ServerPlayer player = net.minecraft.server.MinecraftServer.getServer().getPlayerList().getPlayerByName(name); -+ if (player != null) newProfile = player.getGameProfile(); - if (newProfile == null) newProfile = new GameProfile(null, name); - setProfile(newProfile); - // Paper end + if (this.hasOwner()) { diff --git a/patches/server-remapped/0190-Fill-Profile-Property-Events.patch b/patches/server/0174-Fill-Profile-Property-Events.patch similarity index 100% rename from patches/server-remapped/0190-Fill-Profile-Property-Events.patch rename to patches/server/0174-Fill-Profile-Property-Events.patch diff --git a/patches/server-remapped/0191-PlayerAdvancementCriterionGrantEvent.patch b/patches/server/0175-PlayerAdvancementCriterionGrantEvent.patch similarity index 76% rename from patches/server-remapped/0191-PlayerAdvancementCriterionGrantEvent.patch rename to patches/server/0175-PlayerAdvancementCriterionGrantEvent.patch index 6190b30a26..2db6d486c2 100644 --- a/patches/server-remapped/0191-PlayerAdvancementCriterionGrantEvent.patch +++ b/patches/server/0175-PlayerAdvancementCriterionGrantEvent.patch @@ -5,16 +5,16 @@ Subject: [PATCH] PlayerAdvancementCriterionGrantEvent diff --git a/src/main/java/net/minecraft/server/PlayerAdvancements.java b/src/main/java/net/minecraft/server/PlayerAdvancements.java -index 8df1803754817707a5ad292f65276871dacc4508..5ab62fc74085bbbb0c81b2f4d16a35c9345cd1f1 100644 +index f26bdd3d6eb0ae38c1d7b50f29942fcf2207e3a1..3d82f984648605d58fae3c57f145d0da8a2ae225 100644 --- a/src/main/java/net/minecraft/server/PlayerAdvancements.java +++ b/src/main/java/net/minecraft/server/PlayerAdvancements.java -@@ -297,6 +297,12 @@ public class PlayerAdvancements { +@@ -277,6 +277,12 @@ public class PlayerAdvancements { boolean flag1 = advancementprogress.isDone(); - if (advancementprogress.a(criterionName)) { + if (advancementprogress.grantProgress(criterionName)) { + // Paper start + if (!new com.destroystokyo.paper.event.player.PlayerAdvancementCriterionGrantEvent(this.player.getBukkitEntity(), advancement.bukkit, criterionName).callEvent()) { -+ advancementprogress.b(criterionName); ++ advancementprogress.revokeProgress(criterionName); + return false; + } + // Paper end diff --git a/patches/server-remapped/0192-Add-ArmorStand-Item-Meta.patch b/patches/server/0176-Add-ArmorStand-Item-Meta.patch similarity index 70% rename from patches/server-remapped/0192-Add-ArmorStand-Item-Meta.patch rename to patches/server/0176-Add-ArmorStand-Item-Meta.patch index 14798cca5e..636222360f 100644 --- a/patches/server-remapped/0192-Add-ArmorStand-Item-Meta.patch +++ b/patches/server/0176-Add-ArmorStand-Item-Meta.patch @@ -13,7 +13,7 @@ starting point for future additions in this area. Fixes GH-559 diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaArmorStand.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaArmorStand.java -index 783b9c7283492fb71776b61f9820c21a39868c47..6521f4f6f660885f59f024640239609fb67d691f 100644 +index aee796567f11c8b93ac9ec0b8cb8f3a8412b23ce..39b98305632271e7375afe6c7001f241c17e103d 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaArmorStand.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaArmorStand.java @@ -9,9 +9,22 @@ import org.bukkit.configuration.serialization.DelegateDeserialization; @@ -54,10 +54,10 @@ index 783b9c7283492fb71776b61f9820c21a39868c47..6521f4f6f660885f59f024640239609f this.entityTag = armorStand.entityTag; } -@@ -30,11 +50,47 @@ public class CraftMetaArmorStand extends CraftMetaItem { +@@ -30,11 +50,40 @@ public class CraftMetaArmorStand extends CraftMetaItem { if (tag.contains(ENTITY_TAG.NBT)) { - entityTag = tag.getCompound(ENTITY_TAG.NBT); + this.entityTag = tag.getCompound(ENTITY_TAG.NBT); + + // Paper start + if (entityTag.contains(INVISIBLE.NBT)) { @@ -85,120 +85,112 @@ index 783b9c7283492fb71776b61f9820c21a39868c47..6521f4f6f660885f59f024640239609f CraftMetaArmorStand(Map map) { super(map); -+ + // Paper start -+ boolean invis = SerializableMeta.getBoolean(map, INVISIBLE.BUKKIT); -+ boolean noBase = SerializableMeta.getBoolean(map, NO_BASE_PLATE.BUKKIT); -+ boolean showArms = SerializableMeta.getBoolean(map, SHOW_ARMS.BUKKIT); -+ boolean small = SerializableMeta.getBoolean(map, SMALL.BUKKIT); -+ boolean marker = SerializableMeta.getBoolean(map, MARKER.BUKKIT); -+ -+ this.invisible = invis; -+ this.noBasePlate = noBase; -+ this.showArms = showArms; -+ this.small = small; -+ this.marker = marker; ++ this.invisible = SerializableMeta.getBoolean(map, INVISIBLE.BUKKIT); ++ this.noBasePlate = SerializableMeta.getBoolean(map, NO_BASE_PLATE.BUKKIT); ++ this.showArms = SerializableMeta.getBoolean(map, SHOW_ARMS.BUKKIT); ++ this.small = SerializableMeta.getBoolean(map, SMALL.BUKKIT); ++ this.marker = SerializableMeta.getBoolean(map, MARKER.BUKKIT); + // Paper end } @Override -@@ -57,6 +113,32 @@ public class CraftMetaArmorStand extends CraftMetaItem { +@@ -57,6 +106,31 @@ public class CraftMetaArmorStand extends CraftMetaItem { void applyToItem(CompoundTag tag) { super.applyToItem(tag); + // Paper start -+ if (!isArmorStandEmpty() && entityTag == null) { -+ entityTag = new CompoundTag(); ++ if (!isArmorStandEmpty() && this.entityTag == null) { ++ this.entityTag = new CompoundTag(); + } + + if (isInvisible()) { -+ entityTag.putBoolean(INVISIBLE.NBT, invisible); ++ this.entityTag.putBoolean(INVISIBLE.NBT, this.invisible); + } + + if (hasNoBasePlate()) { -+ entityTag.putBoolean(NO_BASE_PLATE.NBT, noBasePlate); ++ this.entityTag.putBoolean(NO_BASE_PLATE.NBT, this.noBasePlate); + } + + if (shouldShowArms()) { -+ entityTag.putBoolean(SHOW_ARMS.NBT, showArms); ++ this.entityTag.putBoolean(SHOW_ARMS.NBT, this.showArms); + } + + if (isSmall()) { -+ entityTag.putBoolean(SMALL.NBT, small); ++ this.entityTag.putBoolean(SMALL.NBT, this.small); + } + + if (isMarker()) { -+ entityTag.putBoolean(MARKER.NBT, marker); ++ this.entityTag.putBoolean(MARKER.NBT, this.marker); + } + // Paper end -+ - if (entityTag != null) { + if (this.entityTag != null) { tag.put(ENTITY_TAG.NBT, entityTag); } -@@ -78,7 +160,7 @@ public class CraftMetaArmorStand extends CraftMetaItem { +@@ -78,7 +152,7 @@ public class CraftMetaArmorStand extends CraftMetaItem { } boolean isArmorStandEmpty() { -- return !(entityTag != null); -+ return !(isInvisible() || hasNoBasePlate() || shouldShowArms() || isSmall() || isMarker() || entityTag != null); +- return !(this.entityTag != null); ++ return !(this.isInvisible() || this.hasNoBasePlate() || this.shouldShowArms() || this.isSmall() || this.isMarker() || this.entityTag != null); } @Override -@@ -89,7 +171,13 @@ public class CraftMetaArmorStand extends CraftMetaItem { +@@ -89,7 +163,13 @@ public class CraftMetaArmorStand extends CraftMetaItem { if (meta instanceof CraftMetaArmorStand) { CraftMetaArmorStand that = (CraftMetaArmorStand) meta; -- return entityTag != null ? that.entityTag != null && this.entityTag.equals(that.entityTag) : entityTag == null; +- return this.entityTag != null ? that.entityTag != null && this.entityTag.equals(that.entityTag) : this.entityTag == null; + // Paper start -+ return invisible == that.invisible && -+ noBasePlate == that.noBasePlate && -+ showArms == that.showArms && -+ small == that.small && -+ marker == that.marker; ++ return this.invisible == that.invisible && ++ this.noBasePlate == that.noBasePlate && ++ this.showArms == that.showArms && ++ this.small == that.small && ++ this.marker == that.marker; + // Paper end } return true; } -@@ -104,9 +192,14 @@ public class CraftMetaArmorStand extends CraftMetaItem { +@@ -104,9 +184,14 @@ public class CraftMetaArmorStand extends CraftMetaItem { final int original; int hash = original = super.applyHash(); -- if (entityTag != null) { -- hash = 73 * hash + entityTag.hashCode(); +- if (this.entityTag != null) { +- hash = 73 * hash + this.entityTag.hashCode(); - } + // Paper start -+ hash += entityTag != null ? 73 * hash + entityTag.hashCode() : 0; -+ hash += isInvisible() ? 61 * hash + 1231 : 0; -+ hash += hasNoBasePlate() ? 61 * hash + 1231 : 0; -+ hash += shouldShowArms() ? 61 * hash + 1231 : 0; -+ hash += isSmall() ? 61 * hash + 1231 : 0; -+ hash += isMarker() ? 61 * hash + 1231 : 0; ++ hash += this.entityTag != null ? 73 * hash + this.entityTag.hashCode() : 0; ++ hash += this.isInvisible() ? 61 * hash + 1231 : 0; ++ hash += this.hasNoBasePlate() ? 61 * hash + 1231 : 0; ++ hash += this.shouldShowArms() ? 61 * hash + 1231 : 0; ++ hash += this.isSmall() ? 61 * hash + 1231 : 0; ++ hash += this.isMarker() ? 61 * hash + 1231 : 0; + // Paper end return original != hash ? CraftMetaArmorStand.class.hashCode() ^ hash : hash; } -@@ -115,6 +208,28 @@ public class CraftMetaArmorStand extends CraftMetaItem { +@@ -115,6 +200,28 @@ public class CraftMetaArmorStand extends CraftMetaItem { Builder serialize(Builder builder) { super.serialize(builder); + // Paper start -+ if (isInvisible()) { ++ if (this.isInvisible()) { + builder.put(INVISIBLE.BUKKIT, invisible); + } + -+ if (hasNoBasePlate()) { ++ if (this.hasNoBasePlate()) { + builder.put(NO_BASE_PLATE.BUKKIT, noBasePlate); + } + -+ if (shouldShowArms()) { ++ if (this.shouldShowArms()) { + builder.put(SHOW_ARMS.BUKKIT, showArms); + } + -+ if (isSmall()) { ++ if (this.isSmall()) { + builder.put(SMALL.BUKKIT, small); + } + -+ if (isMarker()) { ++ if (this.isMarker()) { + builder.put(MARKER.BUKKIT, marker); + } + // Paper end @@ -206,7 +198,7 @@ index 783b9c7283492fb71776b61f9820c21a39868c47..6521f4f6f660885f59f024640239609f return builder; } -@@ -128,4 +243,56 @@ public class CraftMetaArmorStand extends CraftMetaItem { +@@ -128,4 +235,56 @@ public class CraftMetaArmorStand extends CraftMetaItem { return clone; } @@ -264,10 +256,10 @@ index 783b9c7283492fb71776b61f9820c21a39868c47..6521f4f6f660885f59f024640239609f + // Paper end } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java -index 521699615778c4b724d10edfee1d3915e036eb2e..64f166fa93e998a58a895d785ff8c9e62dacb1bb 100644 +index 45f4f8265c51a5b08db8aa7f53915c4bd0536d39..4ad6fd7e110f949f0bd859331ed6a5109ade3008 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java -@@ -1441,6 +1441,14 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { +@@ -1442,6 +1442,14 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { CraftMetaCrossbow.CHARGED.NBT, CraftMetaCrossbow.CHARGED_PROJECTILES.NBT, CraftMetaSuspiciousStew.EFFECTS.NBT, @@ -281,15 +273,15 @@ index 521699615778c4b724d10edfee1d3915e036eb2e..64f166fa93e998a58a895d785ff8c9e6 + // Paper end CraftMetaCompass.LODESTONE_DIMENSION.NBT, CraftMetaCompass.LODESTONE_POS.NBT, - CraftMetaCompass.LODESTONE_TRACKED.NBT + CraftMetaCompass.LODESTONE_TRACKED.NBT, diff --git a/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java b/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java -index 9a351c137776ac622f4df7353bb353142b3a6ccc..42f577ed3508ba5a380648461e149f16ce97c9bd 100644 +index c1fc48881dffa61f461078bea5640f8c1a1f6570..b0bb30aebdba99a8fa929ec3c56e46b59d2467c9 100644 --- a/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java +++ b/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java -@@ -313,6 +313,7 @@ public class ItemMetaTest extends AbstractTestingBase { +@@ -314,6 +314,7 @@ public class ItemMetaTest extends AbstractTestingBase { final CraftMetaArmorStand meta = (CraftMetaArmorStand) cleanStack.getItemMeta(); - meta.entityTag = new NBTTagCompound(); - meta.entityTag.setBoolean("Small", true); + meta.entityTag = new CompoundTag(); + meta.entityTag.putBoolean("Small", true); + meta.setInvisible(true); // Paper cleanStack.setItemMeta(meta); return cleanStack; diff --git a/patches/server-remapped/0193-Extend-Player-Interact-cancellation.patch b/patches/server/0177-Extend-Player-Interact-cancellation.patch similarity index 60% rename from patches/server-remapped/0193-Extend-Player-Interact-cancellation.patch rename to patches/server/0177-Extend-Player-Interact-cancellation.patch index 826fede56c..670211c9b7 100644 --- a/patches/server-remapped/0193-Extend-Player-Interact-cancellation.patch +++ b/patches/server/0177-Extend-Player-Interact-cancellation.patch @@ -13,19 +13,11 @@ Update adjacent blocks of doors, double plants, pistons and beds when cancelling interaction. diff --git a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java -index 26ce794cb8d089c03fab5dd0a0c910783d10b72e..b1a53093eb5b5f359eedb6c252cf6d0d1ae8e409 100644 +index 9d303a962950c7464d1d4a2a0ce3f658628cc785..a67b7c82236d448bf10c257ab0a10476372ce89c 100644 --- a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java -@@ -23,6 +23,7 @@ import net.minecraft.core.BlockPos; - import net.minecraft.core.Direction; - import net.minecraft.network.protocol.game.ClientboundBlockBreakAckPacket; - import net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket; -+import net.minecraft.network.protocol.game.ClientboundContainerClosePacket; - import net.minecraft.network.protocol.game.ClientboundPlayerInfoPacket; - import net.minecraft.network.protocol.game.ServerboundPlayerActionPacket; - import net.minecraft.server.MinecraftServer; -@@ -180,6 +181,11 @@ public class ServerPlayerGameMode { - PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, pos, direction, this.player.inventory.getSelected(), InteractionHand.MAIN_HAND); +@@ -178,6 +178,11 @@ public class ServerPlayerGameMode { + PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, pos, direction, this.player.getInventory().getSelected(), InteractionHand.MAIN_HAND); if (event.isCancelled()) { // Let the client know the block still exists + // Paper start - brute force neighbor blocks for any attached blocks @@ -36,23 +28,15 @@ index 26ce794cb8d089c03fab5dd0a0c910783d10b72e..b1a53093eb5b5f359eedb6c252cf6d0d this.player.connection.send(new ClientboundBlockUpdatePacket(this.level, pos)); // Update any tile entity data for this block BlockEntity tileentity = this.level.getBlockEntity(pos); -@@ -484,6 +490,7 @@ public class ServerPlayerGameMode { - interactItemStack = stack.copy(); - - if (event.useInteractedBlock() == Event.Result.DENY) { -+ - // If we denied a door from opening, we need to send a correcting update to the client, as it already opened the door. - if (iblockdata.getBlock() instanceof DoorBlock) { - boolean bottom = iblockdata.getValue(DoorBlock.HALF) == DoubleBlockHalf.LOWER; -@@ -496,7 +503,13 @@ public class ServerPlayerGameMode { +@@ -493,7 +498,13 @@ public class ServerPlayerGameMode { // send a correcting update to the client for the block above as well, this because of replaceable blocks (such as grass, sea grass etc) player.connection.send(new ClientboundBlockUpdatePacket(world, blockposition.above())); + // Paper start - extend Player Interact cancellation // TODO: consider merging this into the extracted method -+ } else if (iblockdata.getBlock() instanceof StructureBlock) { -+ player.connection.send(new ClientboundContainerClosePacket()); -+ } else if (iblockdata.getBlock() instanceof CommandBlock) { -+ player.connection.send(new ClientboundContainerClosePacket()); ++ } else if (iblockdata.getBlock() instanceof net.minecraft.world.level.block.StructureBlock) { ++ player.connection.send(new net.minecraft.network.protocol.game.ClientboundContainerClosePacket(this.player.containerMenu.containerId)); ++ } else if (iblockdata.getBlock() instanceof net.minecraft.world.level.block.CommandBlock) { ++ player.connection.send(new net.minecraft.network.protocol.game.ClientboundContainerClosePacket(this.player.containerMenu.containerId)); } + // Paper end - extend Player Interact cancellation player.getBukkitEntity().updateInventory(); // SPIGOT-2867 diff --git a/patches/server-remapped/0194-Tameable-getOwnerUniqueId-API.patch b/patches/server/0178-Tameable-getOwnerUniqueId-API.patch similarity index 70% rename from patches/server-remapped/0194-Tameable-getOwnerUniqueId-API.patch rename to patches/server/0178-Tameable-getOwnerUniqueId-API.patch index 643044c740..d872f6cd13 100644 --- a/patches/server-remapped/0194-Tameable-getOwnerUniqueId-API.patch +++ b/patches/server/0178-Tameable-getOwnerUniqueId-API.patch @@ -7,30 +7,32 @@ This is faster if all you need is the UUID, as .getOwner() will cause an OfflinePlayer to be loaded from disk. diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractHorse.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractHorse.java -index 6136b3322a340d506ce744bcd15f71a158e46ad1..04b0b2449f20220c74892788080d40e3693151c5 100644 +index 27a1ca43792644fc239af81dea5510f25d3328e9..69c95644b2531c1fe1c4a6cf7fee12e997dd67f4 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractHorse.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractHorse.java -@@ -89,6 +89,9 @@ public abstract class CraftAbstractHorse extends CraftAnimals implements Abstrac +@@ -89,6 +89,10 @@ public abstract class CraftAbstractHorse extends CraftAnimals implements Abstrac } } ++ @Override + public UUID getOwnerUniqueId() { + return getOwnerUUID(); + } public UUID getOwnerUUID() { - return getHandle().getOwnerUUID(); + return this.getHandle().getOwnerUUID(); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftTameableAnimal.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftTameableAnimal.java -index 35587fd6d90dfd1da2075c3268692eac7a2eaa25..85fe4f07d35c514f2a7c7920ec416fb651434c83 100644 +index cc90c09c26b04689e4fffa890baf0e89c38665a3..0b152d8d20924fc1ce7f5bafb050216d250f6536 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftTameableAnimal.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftTameableAnimal.java -@@ -17,6 +17,9 @@ public class CraftTameableAnimal extends CraftAnimals implements Tameable, Creat +@@ -17,6 +17,10 @@ public class CraftTameableAnimal extends CraftAnimals implements Tameable, Creat return (TamableAnimal) super.getHandle(); } ++ @Override + public UUID getOwnerUniqueId() { + return getOwnerUUID(); + } public UUID getOwnerUUID() { try { - return getHandle().getOwnerUUID(); + return this.getHandle().getOwnerUUID(); diff --git a/patches/server-remapped/0195-Toggleable-player-crits-helps-mitigate-hacked-client.patch b/patches/server/0179-Toggleable-player-crits-helps-mitigate-hacked-client.patch similarity index 87% rename from patches/server-remapped/0195-Toggleable-player-crits-helps-mitigate-hacked-client.patch rename to patches/server/0179-Toggleable-player-crits-helps-mitigate-hacked-client.patch index 671d7965cc..92ccad3787 100644 --- a/patches/server-remapped/0195-Toggleable-player-crits-helps-mitigate-hacked-client.patch +++ b/patches/server/0179-Toggleable-player-crits-helps-mitigate-hacked-client.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Toggleable player crits, helps mitigate hacked clients. diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java -index 3c39f1bb3d88baaaed4dd43c51faeef89bb5c6c2..48f0385c7203c7955de5a015f3dc42be2ab7b681 100644 +index 3577100f850975020b74f077d688f59dbca78962..da4a110809eee691c1d5b072de335d75e1516eae 100644 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java @@ -192,6 +192,11 @@ public class PaperWorldConfig { @@ -21,10 +21,10 @@ index 3c39f1bb3d88baaaed4dd43c51faeef89bb5c6c2..48f0385c7203c7955de5a015f3dc42be private void allChunksAreSlimeChunks() { allChunksAreSlimeChunks = getBoolean("all-chunks-are-slime-chunks", false); diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java -index 43868c1e2d2c858a4f02119c3238f615f9b1ee72..63871a3a1981b2e8c7ad74214196e35684acb584 100644 +index d3fe3eabf4465101760951113b23edf2ce03e57d..4e8d38a6379d3dc1b7167b27479e6a27ea19ea19 100644 --- a/src/main/java/net/minecraft/world/entity/player/Player.java +++ b/src/main/java/net/minecraft/world/entity/player/Player.java -@@ -1131,6 +1131,7 @@ public abstract class Player extends LivingEntity { +@@ -1191,6 +1191,7 @@ public abstract class Player extends LivingEntity { boolean flag2 = flag && this.fallDistance > 0.0F && !this.onGround && !this.onClimbable() && !this.isInWater() && !this.hasEffect(MobEffects.BLINDNESS) && !this.isPassenger() && target instanceof LivingEntity; diff --git a/patches/server-remapped/0197-Disable-Explicit-Network-Manager-Flushing.patch b/patches/server/0180-Disable-Explicit-Network-Manager-Flushing.patch similarity index 86% rename from patches/server-remapped/0197-Disable-Explicit-Network-Manager-Flushing.patch rename to patches/server/0180-Disable-Explicit-Network-Manager-Flushing.patch index 45eef88da2..1d1675c64e 100644 --- a/patches/server-remapped/0197-Disable-Explicit-Network-Manager-Flushing.patch +++ b/patches/server/0180-Disable-Explicit-Network-Manager-Flushing.patch @@ -12,10 +12,10 @@ flushing on the netty event loop, so it won't do the flush on the main thread. Renable flushing by passing -Dpaper.explicit-flush=true diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java -index 3429c813a5b471cdfa561bd20849a303e5aacead..7f4681910751047a26fdfc6b59bc460449c02001 100644 +index 1d46187969b5792c255d0bf1966b427b905cb69c..0c5c62be83223e20f216df84413b8c2438db81ff 100644 --- a/src/main/java/net/minecraft/network/Connection.java +++ b/src/main/java/net/minecraft/network/Connection.java -@@ -73,6 +73,7 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -86,6 +86,7 @@ public class Connection extends SimpleChannelInboundHandler> { // Paper start - NetworkClient implementation public int protocolVersion; public java.net.InetSocketAddress virtualHost; @@ -23,7 +23,7 @@ index 3429c813a5b471cdfa561bd20849a303e5aacead..7f4681910751047a26fdfc6b59bc4604 // Paper end public Connection(PacketFlow side) { -@@ -240,7 +241,7 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -259,7 +260,7 @@ public class Connection extends SimpleChannelInboundHandler> { } if (this.channel != null) { diff --git a/patches/server-remapped/0198-Implement-extended-PaperServerListPingEvent.patch b/patches/server/0181-Implement-extended-PaperServerListPingEvent.patch similarity index 57% rename from patches/server-remapped/0198-Implement-extended-PaperServerListPingEvent.patch rename to patches/server/0181-Implement-extended-PaperServerListPingEvent.patch index 762c35c3ad..31680c41fc 100644 --- a/patches/server-remapped/0198-Implement-extended-PaperServerListPingEvent.patch +++ b/patches/server/0181-Implement-extended-PaperServerListPingEvent.patch @@ -175,55 +175,22 @@ index 0000000000000000000000000000000000000000..4c2351b03b58511b80017b58ee9b20ab + +} diff --git a/src/main/java/net/minecraft/network/protocol/status/ClientboundStatusResponsePacket.java b/src/main/java/net/minecraft/network/protocol/status/ClientboundStatusResponsePacket.java -index b985d238eadf857602636ba5e5c277d4b1992d35..5b2081f920304244df96de78b2c66cf8a49a5b85 100644 +index 67455a5ba75c9b816213e44d6872c5ddf8e27e98..23efad80934930beadf15e65781551d4ba7ff81b 100644 --- a/src/main/java/net/minecraft/network/protocol/status/ClientboundStatusResponsePacket.java +++ b/src/main/java/net/minecraft/network/protocol/status/ClientboundStatusResponsePacket.java -@@ -2,6 +2,7 @@ package net.minecraft.network.protocol.status; - - import com.google.gson.Gson; - import com.google.gson.GsonBuilder; -+import io.papermc.paper.adventure.AdventureComponent; // Paper - import java.io.IOException; - import net.minecraft.network.FriendlyByteBuf; - import net.minecraft.network.chat.Component; -@@ -12,7 +13,9 @@ import net.minecraft.util.LowerCaseEnumTypeAdapterFactory; +@@ -10,7 +10,9 @@ import net.minecraft.util.GsonHelper; + import net.minecraft.util.LowerCaseEnumTypeAdapterFactory; public class ClientboundStatusResponsePacket implements Packet { - - private static final Gson GSON = (new GsonBuilder()).registerTypeAdapter(ServerStatus.Version.class, new ServerStatus.Version.Serializer()).registerTypeAdapter(ServerStatus.Players.class, new ServerStatus.Players.Serializer()).registerTypeAdapter(ServerStatus.class, new ServerStatus.Serializer()).registerTypeHierarchyAdapter(Component.class, new Component.Serializer()).registerTypeHierarchyAdapter(Style.class, new Style.Serializer()).registerTypeAdapterFactory(new LowerCaseEnumTypeAdapterFactory()).create(); + private static final Gson GSON = (new GsonBuilder()).registerTypeAdapter(ServerStatus.Version.class, new ServerStatus.Version.Serializer()).registerTypeAdapter(ServerStatus.Players.class, new ServerStatus.Players.Serializer()).registerTypeAdapter(ServerStatus.class, new ServerStatus.Serializer()).registerTypeHierarchyAdapter(Component.class, new Component.Serializer()).registerTypeHierarchyAdapter(Style.class, new Style.Serializer()).registerTypeAdapterFactory(new LowerCaseEnumTypeAdapterFactory()) -+ .registerTypeAdapter(AdventureComponent.class, new AdventureComponent.Serializer()) ++ .registerTypeAdapter(io.papermc.paper.adventure.AdventureComponent.class, new io.papermc.paper.adventure.AdventureComponent.Serializer()) + .create(); - private ServerStatus status; + private final ServerStatus status; - public ClientboundStatusResponsePacket() {} -diff --git a/src/main/java/net/minecraft/network/protocol/status/ServerStatus.java b/src/main/java/net/minecraft/network/protocol/status/ServerStatus.java -index d6be3dd6cfed3f65325398fc33663cb251f87ac7..31d45cd635eae2ff406cb0441f2cd2aee833b945 100644 ---- a/src/main/java/net/minecraft/network/protocol/status/ServerStatus.java -+++ b/src/main/java/net/minecraft/network/protocol/status/ServerStatus.java -@@ -31,6 +31,7 @@ public class ServerStatus { - this.description = description; - } - -+ public Players getPlayers() { return getPlayers(); } // Paper - OBFHELPER - public ServerStatus.Players getPlayers() { - return this.players; - } -@@ -162,10 +163,12 @@ public class ServerStatus { - return this.numPlayers; - } - -+ public GameProfile[] getSample() { return getSample(); } // Paper - OBFHELPER - public GameProfile[] getSample() { - return this.sample; - } - -+ public void setSample(GameProfile[] sample) { setSample(sample); } // Paper - OBFHELPER - public void setSample(GameProfile[] sample) { - this.sample = sample; - } + public ClientboundStatusResponsePacket(ServerStatus metadata) { diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 4b3341877629c7065496fb0f0b4d509f5a48db6d..d34da1eb172a7dcda564680afecf3dc145bf09f3 100644 +index fb4385333ef8dd4fa22275753606df3020000539..a0c436fd5e7e03a0a01e59c046e65ebdcd88021a 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -2,6 +2,9 @@ package net.minecraft.server; @@ -236,7 +203,7 @@ index 4b3341877629c7065496fb0f0b4d509f5a48db6d..d34da1eb172a7dcda564680afecf3dc1 import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Sets; -@@ -1238,7 +1241,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop= 5000000000L) { this.lastServerStatus = i; this.status.setPlayers(new ServerStatus.Players(this.getMaxPlayers(), this.getPlayerCount())); @@ -246,28 +213,10 @@ index 4b3341877629c7065496fb0f0b4d509f5a48db6d..d34da1eb172a7dcda564680afecf3dc1 for (int k = 0; k < agameprofile.length; ++k) { diff --git a/src/main/java/net/minecraft/server/network/ServerStatusPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerStatusPacketListenerImpl.java -index 223df8d27c2ff1cbff634bca3dbde5cc24de7f98..f74e3cbdff8c2d83809f04f42717501d7b1a1ed2 100644 +index 9baa56d6da9c24706f1dbc8851fd68ca752cab26..d65191a50349ec86fe35df4ac1070f94fbb77b4c 100644 --- a/src/main/java/net/minecraft/server/network/ServerStatusPacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerStatusPacketListenerImpl.java -@@ -1,7 +1,7 @@ - package net.minecraft.server.network; - - import net.minecraft.server.MinecraftServer; --import net.minecraft.server.level.ServerPlayer; -+ - // CraftBukkit start - import com.mojang.authlib.GameProfile; - import java.net.InetSocketAddress; -@@ -11,8 +11,6 @@ import net.minecraft.network.Connection; - import net.minecraft.network.chat.Component; - import net.minecraft.network.chat.TranslatableComponent; - import net.minecraft.network.protocol.status.ClientboundPongResponsePacket; --import net.minecraft.network.protocol.status.ClientboundStatusResponsePacket; --import net.minecraft.network.protocol.status.ServerStatus; - import net.minecraft.network.protocol.status.ServerStatusPacketListener; - import net.minecraft.network.protocol.status.ServerboundPingRequestPacket; - import net.minecraft.network.protocol.status.ServerboundStatusRequestPacket; -@@ -47,15 +45,17 @@ public class ServerStatusPacketListenerImpl implements ServerStatusPacketListene +@@ -47,6 +47,8 @@ public class ServerStatusPacketListenerImpl implements ServerStatusPacketListene this.connection.disconnect(ServerStatusPacketListenerImpl.DISCONNECT_REASON); } else { this.hasRequestedStatus = true; @@ -275,88 +224,11 @@ index 223df8d27c2ff1cbff634bca3dbde5cc24de7f98..f74e3cbdff8c2d83809f04f42717501d + /* // CraftBukkit start // this.networkManager.sendPacket(new PacketStatusOutServerInfo(this.minecraftServer.getServerPing())); -- final Object[] players = server.getPlayerList().players.toArray(); -+ final Object[] players = minecraftServer.getPlayerList().players.toArray(); - class ServerListPingEvent extends org.bukkit.event.server.ServerListPingEvent { + final Object[] players = this.server.getPlayerList().players.toArray(); +@@ -142,6 +144,9 @@ public class ServerStatusPacketListenerImpl implements ServerStatusPacketListene + ping.setVersion(new ServerStatus.Version(this.server.getServerModName() + " " + this.server.getServerVersion(), version)); -- CraftIconCache icon = server.server.getServerIcon(); -+ CraftIconCache icon = minecraftServer.server.getServerIcon(); - - ServerListPingEvent() { -- super(((InetSocketAddress) connection.getRemoteAddress()).getAddress(), server.server.motd(), server.getPlayerList().getMaxPlayers()); // Paper - Adventure -+ super(((InetSocketAddress) networkManager.getSocketAddress()).getAddress(), minecraftServer.server.motd(), minecraftServer.getPlayerList().getMaxPlayers()); // Paper - Adventure - } - - @Override -@@ -71,7 +71,7 @@ public class ServerStatusPacketListenerImpl implements ServerStatusPacketListene - return new Iterator() { - int i; - int ret = Integer.MIN_VALUE; -- ServerPlayer player; -+ EntityPlayer player; - - @Override - public boolean hasNext() { -@@ -80,7 +80,7 @@ public class ServerStatusPacketListenerImpl implements ServerStatusPacketListene - } - final Object[] currentPlayers = players; - for (int length = currentPlayers.length, i = this.i; i < length; i++) { -- final ServerPlayer player = (ServerPlayer) currentPlayers[i]; -+ final EntityPlayer player = (EntityPlayer) currentPlayers[i]; - if (player != null) { - this.i = i + 1; - this.player = player; -@@ -95,7 +95,7 @@ public class ServerStatusPacketListenerImpl implements ServerStatusPacketListene - if (!hasNext()) { - throw new java.util.NoSuchElementException(); - } -- final ServerPlayer player = this.player; -+ final EntityPlayer player = this.player; - this.player = null; - this.ret = this.i - 1; - return player.getBukkitEntity(); -@@ -115,16 +115,16 @@ public class ServerStatusPacketListenerImpl implements ServerStatusPacketListene - } - - ServerListPingEvent event = new ServerListPingEvent(); -- this.server.server.getPluginManager().callEvent(event); -+ this.minecraftServer.server.getPluginManager().callEvent(event); - - java.util.List profiles = new java.util.ArrayList(players.length); - for (Object player : players) { - if (player != null) { -- profiles.add(((ServerPlayer) player).getGameProfile()); -+ profiles.add(((EntityPlayer) player).getProfile()); - } - } - -- ServerStatus.Players playerSample = new ServerStatus.Players(event.getMaxPlayers(), profiles.size()); -+ ServerPing.ServerPingPlayerSample playerSample = new ServerPing.ServerPingPlayerSample(event.getMaxPlayers(), profiles.size()); - // Spigot Start - if ( !profiles.isEmpty() ) - { -@@ -132,16 +132,19 @@ public class ServerStatusPacketListenerImpl implements ServerStatusPacketListene - profiles = profiles.subList( 0, Math.min( profiles.size(), org.spigotmc.SpigotConfig.playerSample ) ); // Cap the sample to n (or less) displayed players, ie: Vanilla behaviour - } - // Spigot End -- playerSample.setSample(profiles.toArray(new GameProfile[profiles.size()])); -+ playerSample.a(profiles.toArray(new GameProfile[profiles.size()])); - -- ServerStatus ping = new ServerStatus(); -+ ServerPing ping = new ServerPing(); - ping.setFavicon(event.icon.value); -- ping.setDescription(CraftChatMessage.fromString(event.getMotd(), true)[0]); -- ping.setPlayers(playerSample); -- int version = SharedConstants.getCurrentVersion().getProtocolVersion(); -- ping.setVersion(new ServerStatus.Version(server.getServerModName() + " " + server.getServerVersion(), version)); -- -- this.connection.send(new ClientboundStatusResponsePacket(ping)); -+ ping.setMOTD(CraftChatMessage.fromString(event.getMotd(), true)[0]); -+ ping.setPlayerSample(playerSample); -+ int version = SharedConstants.getGameVersion().getProtocolVersion(); -+ ping.setServerInfo(new ServerPing.ServerData(minecraftServer.getServerModName() + " " + minecraftServer.getVersion(), version)); -+ -+ this.networkManager.sendPacket(new PacketStatusOutServerInfo(ping)); + this.connection.send(new ClientboundStatusResponsePacket(ping)); + */ + com.destroystokyo.paper.network.StandardPaperServerListPingEventImpl.processRequest(this.server, this.connection); + // Paper end @@ -364,15 +236,15 @@ index 223df8d27c2ff1cbff634bca3dbde5cc24de7f98..f74e3cbdff8c2d83809f04f42717501d // CraftBukkit end } diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java -index 3981ba5957fdc2929d54515f2b98bb7a4611e938..652b820a4c0bbf7b6bbb8200927a663665583606 100644 +index e7586c325290ceb8669f9f9d430c73080a37dd05..314fa148fe783a0558ba00b068e0bf69a91577e1 100644 --- a/src/main/java/org/spigotmc/SpigotConfig.java +++ b/src/main/java/org/spigotmc/SpigotConfig.java @@ -289,7 +289,7 @@ public class SpigotConfig public static int playerSample; private static void playerSample() { -- playerSample = getInt( "settings.sample-count", 12 ); -+ playerSample = Math.max( getInt( "settings.sample-count", 12 ), 0 ); // Paper - Avoid negative counts +- SpigotConfig.playerSample = SpigotConfig.getInt( "settings.sample-count", 12 ); ++ SpigotConfig.playerSample = Math.max( SpigotConfig.getInt( "settings.sample-count", 12 ), 0 ); // Paper - Avoid negative counts Bukkit.getLogger().log( Level.INFO, "Server Ping Player Sample Count: {0}", playerSample ); // Paper - Use logger } diff --git a/patches/server-remapped/0199-Improved-Async-Task-Scheduler.patch b/patches/server/0182-Improved-Async-Task-Scheduler.patch similarity index 91% rename from patches/server-remapped/0199-Improved-Async-Task-Scheduler.patch rename to patches/server/0182-Improved-Async-Task-Scheduler.patch index b0ae823221..ad66d97e35 100644 --- a/patches/server-remapped/0199-Improved-Async-Task-Scheduler.patch +++ b/patches/server/0182-Improved-Async-Task-Scheduler.patch @@ -159,7 +159,7 @@ index 0000000000000000000000000000000000000000..3c1992e212a6d6f1db4d5b807b38d719 + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java -index 0e0f361c3af363539d5d1d865603114bdb84fd67..ca90237a53c9a026919d28adaedf483ca3c7c2a8 100644 +index 6435d53dcddc1a43420f1ea66fa08e154b82586d..dd1e8b170e87bff2089f642f41dcf7442a8ccd16 100644 --- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java +++ b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java @@ -63,7 +63,7 @@ public class CraftScheduler implements BukkitScheduler { @@ -190,7 +190,7 @@ index 0e0f361c3af363539d5d1d865603114bdb84fd67..ca90237a53c9a026919d28adaedf483c @@ -94,12 +95,31 @@ public class CraftScheduler implements BukkitScheduler { } }; - private CraftAsyncDebugger debugTail = debugHead; + private CraftAsyncDebugger debugTail = this.debugHead; + + */ // Paper end private static final int RECENT_TICKS; @@ -223,8 +223,8 @@ index 0e0f361c3af363539d5d1d865603114bdb84fd67..ca90237a53c9a026919d28adaedf483c } else if (period < CraftTask.NO_REPEATING) { period = CraftTask.NO_REPEATING; } -- return handle(new CraftAsyncTask(runners, plugin, runnable, nextId(), period), delay); -+ return handle(new CraftAsyncTask(this.asyncScheduler.runners, plugin, runnable, nextId(), period), delay); // Paper +- return this.handle(new CraftAsyncTask(this.runners, plugin, runnable, this.nextId(), period), delay); ++ return this.handle(new CraftAsyncTask(this.asyncScheduler.runners, plugin, runnable, this.nextId(), period), delay); // Paper } @Override @@ -237,7 +237,7 @@ index 0e0f361c3af363539d5d1d865603114bdb84fd67..ca90237a53c9a026919d28adaedf483c + this.asyncScheduler.cancelTask(taskId); + } + // Paper end - CraftTask task = runners.get(taskId); + CraftTask task = this.runners.get(taskId); if (task != null) { task.cancel0(); @@ -280,6 +305,11 @@ public class CraftScheduler implements BukkitScheduler { @@ -257,13 +257,13 @@ index 0e0f361c3af363539d5d1d865603114bdb84fd67..ca90237a53c9a026919d28adaedf483c @Override public boolean isCurrentlyRunning(final int taskId) { + // Paper start -+ if (!isAsyncScheduler) { ++ if (!this.isAsyncScheduler) { + if (this.asyncScheduler.isCurrentlyRunning(taskId)) { + return true; + } + } + // Paper end - final CraftTask task = runners.get(taskId); + final CraftTask task = this.runners.get(taskId); if (task == null) { return false; @@ -337,6 +374,11 @@ public class CraftScheduler implements BukkitScheduler { @@ -275,7 +275,7 @@ index 0e0f361c3af363539d5d1d865603114bdb84fd67..ca90237a53c9a026919d28adaedf483c + return true; + } + // Paper end - for (CraftTask task = head.getNext(); task != null; task = task.getNext()) { + for (CraftTask task = this.head.getNext(); task != null; task = task.getNext()) { if (task.getTaskId() == taskId) { return task.getPeriod() >= CraftTask.NO_REPEATING; // The task will run @@ -348,6 +390,12 @@ public class CraftScheduler implements BukkitScheduler { @@ -289,7 +289,7 @@ index 0e0f361c3af363539d5d1d865603114bdb84fd67..ca90237a53c9a026919d28adaedf483c + } + // Paper end final ArrayList workers = new ArrayList(); - for (final CraftTask taskObj : runners.values()) { + for (final CraftTask taskObj : this.runners.values()) { // Iterator will be a best-effort (may fail to grab very new values) if called from an async thread @@ -385,6 +433,11 @@ public class CraftScheduler implements BukkitScheduler { pending.add(task); @@ -314,18 +314,18 @@ index 0e0f361c3af363539d5d1d865603114bdb84fd67..ca90237a53c9a026919d28adaedf483c + // Paper end this.currentTick = currentTick; final List temp = this.temp; - parsePending(); + this.parsePending(); @@ -431,7 +489,7 @@ public class CraftScheduler implements BukkitScheduler { - parsePending(); + this.parsePending(); } else { - //debugTail = debugTail.setNext(new CraftAsyncDebugger(currentTick + RECENT_TICKS, task.getOwner(), task.getTaskClass())); // Paper -- executor.execute(new ServerSchedulerReportingWrapper(task)); // Paper + //this.debugTail = this.debugTail.setNext(new CraftAsyncDebugger(currentTick + CraftScheduler.RECENT_TICKS, task.getOwner(), task.getTaskClass())); // Paper +- this.executor.execute(new ServerSchedulerReportingWrapper(task)); // Paper + task.getOwner().getLogger().log(Level.SEVERE, "Unexpected Async Task in the Sync Scheduler. Report this to Paper"); // Paper // We don't need to parse pending // (async tasks must live with race-conditions if they attempt to cancel between these few lines of code) } @@ -450,7 +508,7 @@ public class CraftScheduler implements BukkitScheduler { - //debugHead = debugHead.getNextHead(currentTick); // Paper + //this.debugHead = this.debugHead.getNextHead(currentTick); // Paper } - private void addTask(final CraftTask task) { @@ -345,11 +345,11 @@ index 0e0f361c3af363539d5d1d865603114bdb84fd67..ca90237a53c9a026919d28adaedf483c + return task; + } + // Paper end - task.setNextRun(currentTick + delay); - addTask(task); + task.setNextRun(this.currentTick + delay); + this.addTask(task); return task; @@ -478,8 +542,8 @@ public class CraftScheduler implements BukkitScheduler { - return ids.incrementAndGet(); + return this.ids.incrementAndGet(); } - private void parsePending() { diff --git a/patches/server-remapped/0200-Ability-to-change-PlayerProfile-in-AsyncPreLoginEven.patch b/patches/server/0183-Ability-to-change-PlayerProfile-in-AsyncPreLoginEven.patch similarity index 88% rename from patches/server-remapped/0200-Ability-to-change-PlayerProfile-in-AsyncPreLoginEven.patch rename to patches/server/0183-Ability-to-change-PlayerProfile-in-AsyncPreLoginEven.patch index f400637138..6cbe99f5ad 100644 --- a/patches/server-remapped/0200-Ability-to-change-PlayerProfile-in-AsyncPreLoginEven.patch +++ b/patches/server/0183-Ability-to-change-PlayerProfile-in-AsyncPreLoginEven.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Ability to change PlayerProfile in AsyncPreLoginEvent This will allow you to change the players name or skin on login. diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -index ff83fb15d0d0adb62c630fc7aafc134972bf15fc..e5be45ac86907c1f8cc154bd38fd624a2320180f 100644 +index 7923078a4235a6169eb94b7c0ce85e4cd51eb593..f39ccd15c037138a933eb529bec17d49349c0264 100644 --- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java @@ -1,5 +1,7 @@ @@ -17,7 +17,7 @@ index ff83fb15d0d0adb62c630fc7aafc134972bf15fc..e5be45ac86907c1f8cc154bd38fd624a import com.mojang.authlib.GameProfile; import com.mojang.authlib.exceptions.AuthenticationUnavailableException; import java.math.BigInteger; -@@ -36,6 +38,7 @@ import org.apache.commons.lang3.Validate; +@@ -37,6 +39,7 @@ import org.apache.commons.lang3.Validate; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import io.papermc.paper.adventure.PaperAdventure; // Paper @@ -25,8 +25,8 @@ index ff83fb15d0d0adb62c630fc7aafc134972bf15fc..e5be45ac86907c1f8cc154bd38fd624a import org.bukkit.craftbukkit.util.Waitable; import org.bukkit.event.player.AsyncPlayerPreLoginEvent; import org.bukkit.event.player.PlayerPreLoginEvent; -@@ -314,8 +317,16 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener - java.util.UUID uniqueId = gameProfile.getId(); +@@ -336,8 +339,16 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener + java.util.UUID uniqueId = ServerLoginPacketListenerImpl.this.gameProfile.getId(); final org.bukkit.craftbukkit.CraftServer server = ServerLoginPacketListenerImpl.this.server.server; - AsyncPlayerPreLoginEvent asyncEvent = new AsyncPlayerPreLoginEvent(playerName, address, uniqueId); diff --git a/patches/server-remapped/0201-Player.setPlayerProfile-API.patch b/patches/server/0184-Player.setPlayerProfile-API.patch similarity index 72% rename from patches/server-remapped/0201-Player.setPlayerProfile-API.patch rename to patches/server/0184-Player.setPlayerProfile-API.patch index f35f170d57..7ebc1c188e 100644 --- a/patches/server-remapped/0201-Player.setPlayerProfile-API.patch +++ b/patches/server/0184-Player.setPlayerProfile-API.patch @@ -6,61 +6,52 @@ Subject: [PATCH] Player.setPlayerProfile API This can be useful for changing name or skins after a player has logged in. diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -index e5be45ac86907c1f8cc154bd38fd624a2320180f..0aa3a154d68f00edcc09b947a24b2b59b1e135e6 100644 +index f39ccd15c037138a933eb529bec17d49349c0264..1d05725374bdffad6a8ab1502ee732775345024d 100644 --- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -@@ -54,7 +54,7 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener - public final Connection connection; - private ServerLoginPacketListenerImpl.State state; - private int tick; -- private GameProfile gameProfile; -+ private GameProfile gameProfile; private void setGameProfile(final GameProfile profile) { this.gameProfile = profile; } private GameProfile getGameProfile() { return this.gameProfile; } // Paper - OBFHELPER - private final String serverId; - private SecretKey secretKey; - private ServerPlayer delayedAcceptPlayer; -@@ -318,12 +318,12 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener +@@ -340,12 +340,12 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener final org.bukkit.craftbukkit.CraftServer server = ServerLoginPacketListenerImpl.this.server.server; // Paper start - PlayerProfile profile = Bukkit.createProfile(uniqueId, playerName); -+ PlayerProfile profile = CraftPlayerProfile.asBukkitMirror(getGameProfile()); ++ PlayerProfile profile = CraftPlayerProfile.asBukkitMirror(ServerLoginPacketListenerImpl.this.gameProfile); AsyncPlayerPreLoginEvent asyncEvent = new AsyncPlayerPreLoginEvent(playerName, address, uniqueId, profile); server.getPluginManager().callEvent(asyncEvent); profile = asyncEvent.getPlayerProfile(); - profile.complete(); - gameProfile = CraftPlayerProfile.asAuthlibCopy(profile); + profile.complete(true); -+ setGameProfile(CraftPlayerProfile.asAuthlib(profile)); ++ ServerLoginPacketListenerImpl.this.gameProfile = CraftPlayerProfile.asAuthlib(profile); playerName = gameProfile.getName(); uniqueId = gameProfile.getId(); // Paper end diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java -index 63871a3a1981b2e8c7ad74214196e35684acb584..c4aa824d03de952fe6b306e539baa47af979add1 100644 +index 4e8d38a6379d3dc1b7167b27479e6a27ea19ea19..3c0aca2b90521da83cf494d9fff953a17a57701d 100644 --- a/src/main/java/net/minecraft/world/entity/player/Player.java +++ b/src/main/java/net/minecraft/world/entity/player/Player.java -@@ -159,7 +159,7 @@ public abstract class Player extends LivingEntity { +@@ -173,7 +173,7 @@ public abstract class Player extends LivingEntity { protected int enchantmentSeed; protected final float defaultFlySpeed = 0.02F; private int lastLevelUpTime; - private final GameProfile gameProfile; -+ private GameProfile gameProfile; public final void setProfile(final GameProfile profile) { this.gameProfile = profile; } // Paper - OBFHELPER ++ public GameProfile gameProfile; // Paper - private->public + private boolean reducedDebugInfo; private ItemStack lastItemInMainHand; private final ItemCooldowns cooldowns; - @Nullable diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index efdcb8dac8db15c4bbaed84a7861ce98339e516a..9d853733ff9054cc48925e22c8bb3c8d9b898808 100644 +index 75963a28b39f8835f1daba3d1b44655603124bf3..8bf0c74ee32e8cb7c0f48bc964552811ad6ee468 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -@@ -67,6 +67,7 @@ import net.minecraft.world.inventory.AbstractContainerMenu; - import net.minecraft.world.item.enchantment.EnchantmentHelper; +@@ -71,6 +71,7 @@ import net.minecraft.world.item.enchantment.EnchantmentHelper; import net.minecraft.world.item.enchantment.Enchantments; import net.minecraft.world.level.GameType; + import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.biome.BiomeManager; import net.minecraft.world.level.block.entity.SignBlockEntity; import net.minecraft.world.level.saveddata.maps.MapDecoration; - import net.minecraft.world.phys.Vec3; -@@ -1307,8 +1308,13 @@ public class CraftPlayer extends CraftHumanEntity implements Player { - hiddenPlayers.put(player.getUniqueId(), hidingPlugins); + import net.minecraft.world.level.saveddata.maps.MapItemSavedData; +@@ -1320,8 +1321,13 @@ public class CraftPlayer extends CraftHumanEntity implements Player { + this.hiddenPlayers.put(player.getUniqueId(), hidingPlugins); // Remove this player from the hidden player's EntityTrackerEntry - ChunkMap tracker = ((ServerLevel) entity.level).getChunkSource().chunkMap; @@ -73,10 +64,10 @@ index efdcb8dac8db15c4bbaed84a7861ce98339e516a..9d853733ff9054cc48925e22c8bb3c8d + // Paper end ChunkMap.TrackedEntity entry = tracker.entityMap.get(other.getId()); if (entry != null) { - entry.removePlayer(getHandle()); -@@ -1349,8 +1355,13 @@ public class CraftPlayer extends CraftHumanEntity implements Player { + entry.removePlayer(this.getHandle()); +@@ -1362,8 +1368,13 @@ public class CraftPlayer extends CraftHumanEntity implements Player { } - hiddenPlayers.remove(player.getUniqueId()); + this.hiddenPlayers.remove(player.getUniqueId()); - ChunkMap tracker = ((ServerLevel) entity.level).getChunkSource().chunkMap; + // Paper start @@ -87,10 +78,10 @@ index efdcb8dac8db15c4bbaed84a7861ce98339e516a..9d853733ff9054cc48925e22c8bb3c8d + ChunkMap tracker = ((ServerLevel) entity.level).getChunkSource().chunkMap; + // Paper end - getHandle().connection.send(new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.ADD_PLAYER, other)); + this.getHandle().connection.send(new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.ADD_PLAYER, other)); -@@ -1359,6 +1370,50 @@ public class CraftPlayer extends CraftHumanEntity implements Player { - entry.updatePlayer(getHandle()); +@@ -1372,6 +1383,50 @@ public class CraftPlayer extends CraftHumanEntity implements Player { + entry.updatePlayer(this.getHandle()); } } + // Paper start @@ -102,7 +93,7 @@ index efdcb8dac8db15c4bbaed84a7861ce98339e516a..9d853733ff9054cc48925e22c8bb3c8d + } + public void setPlayerProfile(com.destroystokyo.paper.profile.PlayerProfile profile) { + ServerPlayer self = getHandle(); -+ self.setProfile(com.destroystokyo.paper.profile.CraftPlayerProfile.asAuthlibCopy(profile)); ++ self.gameProfile = com.destroystokyo.paper.profile.CraftPlayerProfile.asAuthlibCopy(profile); + if (!self.sentListPacket) { + return; + } @@ -128,7 +119,7 @@ index efdcb8dac8db15c4bbaed84a7861ce98339e516a..9d853733ff9054cc48925e22c8bb3c8d + ServerLevel worldserver = handle.getLevel(); + connection.send(new net.minecraft.network.protocol.game.ClientboundRespawnPacket(worldserver.dimensionType(), worldserver.dimension(), BiomeManager.obfuscateSeed(worldserver.getSeed()), handle.gameMode.getGameModeForPlayer(), handle.gameMode.getPreviousGameModeForPlayer(), worldserver.isDebug(), worldserver.isFlat(), true)); + handle.onUpdateAbilities(); -+ connection.send(new net.minecraft.network.protocol.game.ClientboundPlayerPositionPacket(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch(), new HashSet<>(), 0)); ++ connection.send(new net.minecraft.network.protocol.game.ClientboundPlayerPositionPacket(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch(), java.util.Collections.emptySet(), 0, false)); + net.minecraft.server.MinecraftServer.getServer().getPlayerList().sendAllPlayerInfo(handle); + + if (this.isOp()) { @@ -139,4 +130,4 @@ index efdcb8dac8db15c4bbaed84a7861ce98339e516a..9d853733ff9054cc48925e22c8bb3c8d + // Paper end public void removeDisconnectingPlayer(Player player) { - hiddenPlayers.remove(player.getUniqueId()); + this.hiddenPlayers.remove(player.getUniqueId());