From e57441254dc93fa70782c10f9a22c87dc98ca0b6 Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Tue, 28 Feb 2023 08:36:01 -0800 Subject: [PATCH] Replace ConfiguredStructure api with Structure (#8642) --- patches/api/0249-Add-PaperRegistry.patch | 20 -- .../api/0250-Add-StructuresLocateEvent.patch | 106 ++++++-- patches/api/0269-Expand-world-key-API.patch | 8 +- patches/api/0270-Item-Rarity-API.patch | 4 +- .../api/0271-Expose-protocol-version.patch | 4 +- .../api/0289-ItemStack-repair-check-API.patch | 4 +- ...294-Attributes-API-for-item-defaults.patch | 4 +- .../0321-Get-entity-default-attributes.patch | 4 +- ...Collidable-methods-to-various-places.patch | 4 +- .../api/0351-More-PotionEffectType-API.patch | 7 +- ...0380-Add-NamespacedKey-biome-methods.patch | 4 +- patches/server/0009-MC-Utils.patch | 9 +- .../server/0018-Rewrite-chunk-system.patch | 10 +- .../server/0143-Basic-PlayerProfile-API.patch | 8 +- ...arseException-in-Entity-and-TE-names.patch | 6 +- patches/server/0548-Add-PaperRegistry.patch | 242 ------------------ .../0548-TODO-Registry-Modification-API.patch | 18 ++ .../0549-Add-StructuresLocateEvent.patch | 97 +++---- patches/server/0562-EntityMoveEvent.patch | 2 +- ...pport-for-hex-color-codes-in-console.patch | 2 +- ...0576-fix-converting-txt-to-json-file.patch | 2 +- .../server/0583-Expand-world-key-API.patch | 16 +- patches/server/0585-Item-Rarity-API.patch | 4 +- ...ed-item-when-player-has-disconnected.patch | 2 +- ...telist-use-configurable-kick-message.patch | 4 +- .../server/0591-Expose-protocol-version.patch | 4 +- ...wn-acting-as-a-bed-respawn-from-the-.patch | 2 +- ...d-RespawnFlags-to-PlayerRespawnEvent.patch | 2 +- .../server/0617-Add-basic-Datapack-API.patch | 6 +- .../0620-ItemStack-repair-check-API.patch | 4 +- ...x-and-optimise-world-force-upgrading.patch | 8 +- ...627-Attributes-API-for-item-defaults.patch | 4 +- .../0631-Add-PlayerKickEvent-causes.patch | 6 +- .../0647-Missing-Entity-Behavior-API.patch | 2 +- ...k-event-leave-message-not-being-sent.patch | 2 +- .../0661-Add-System.out-err-catcher.patch | 2 +- .../server/0667-Add-PlayerSetSpawnEvent.patch | 2 +- .../0684-Get-entity-default-attributes.patch | 4 +- ...Collidable-methods-to-various-places.patch | 4 +- ...93-Add-Raw-Byte-Entity-Serialization.patch | 2 +- ...aper-mobcaps-and-paper-playermobcaps.patch | 4 +- .../0703-Execute-chunk-tasks-mid-tick.patch | 4 +- ...ocity-compression-and-cipher-natives.patch | 2 +- ...-Fix-upstreams-block-state-factories.patch | 2 +- ...tion-for-logging-player-ip-addresses.patch | 2 +- .../0743-Configurable-feature-seeds.patch | 4 +- ...llow-delegation-to-vanilla-chunk-gen.patch | 4 +- ...single-and-multi-AABB-VoxelShapes-an.patch | 2 +- patches/server/0777-Validate-usernames.patch | 2 +- ...vanilla-BiomeProvider-from-WorldInfo.patch | 6 +- ...-command-sender-which-forwards-feedb.patch | 4 +- ...d-missing-structure-set-seed-configs.patch | 4 +- ...date-calls-to-CraftServer-getSpawnLi.patch | 4 +- patches/server/0799-Add-GameEvent-tags.patch | 6 +- ...sks-fairly-for-worlds-while-waiting-.patch | 2 +- ...efault-CustomSpawners-in-custom-worl.patch | 2 +- ...o-worldlist-before-initing-the-world.patch | 6 +- patches/server/0807-Custom-Potion-Mixes.patch | 12 +- ...808-Force-close-world-loading-screen.patch | 2 +- .../0818-Fix-saving-in-unloadWorld.patch | 4 +- ...tead-of-display-name-in-PlayerList-g.patch | 2 +- .../0834-WorldCreator-keepSpawnLoaded.patch | 4 +- ...-snow-cauldrons-not-turning-to-water.patch | 2 +- .../0844-Add-support-for-Proxy-Protocol.patch | 2 +- .../0847-Sanitize-Sent-BlockEntity-NBT.patch | 2 +- ...n-on-world-create-while-being-ticked.patch | 10 +- ...broadcast-messages-to-command-blocks.patch | 4 +- ...9-Add-Velocity-IP-Forwarding-Support.patch | 4 +- ...0881-Add-NamespacedKey-biome-methods.patch | 4 +- ...ix-plugin-loggers-on-server-shutdown.patch | 2 +- .../0899-Fix-a-bunch-of-vanilla-bugs.patch | 2 +- .../0934-Properly-resend-entities.patch | 2 +- ...le-player-info-update-packet-on-join.patch | 2 +- ...-Add-missing-isFuel-Material-entries.patch | 2 +- ...mp-fix-for-EntityType.translationKey.patch | 2 +- 75 files changed, 283 insertions(+), 486 deletions(-) delete mode 100644 patches/server/0548-Add-PaperRegistry.patch create mode 100644 patches/server/0548-TODO-Registry-Modification-API.patch diff --git a/patches/api/0249-Add-PaperRegistry.patch b/patches/api/0249-Add-PaperRegistry.patch index c4c2b84949..8cc1e1b931 100644 --- a/patches/api/0249-Add-PaperRegistry.patch +++ b/patches/api/0249-Add-PaperRegistry.patch @@ -90,23 +90,3 @@ index 0000000000000000000000000000000000000000..f29e76a6b66ddfec12ddf8db6dcb2df6 + return this.key; + } +} -diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java -index 1f89a3c1c3b73a939c2653102fc1dc8b630672a8..e5e91f4b4492fa1e709d81f313aac80761ab9e07 100644 ---- a/src/main/java/org/bukkit/UnsafeValues.java -+++ b/src/main/java/org/bukkit/UnsafeValues.java -@@ -132,5 +132,15 @@ public interface UnsafeValues { - * Use this when sending custom packets, so that there are no collisions on the client or server. - */ - public int nextEntityId(); -+ -+ /** -+ * Gets the server-backed registry for a type. -+ * -+ * @param classOfT type -+ * @param type -+ * @return the server-backed registry -+ * @throws IllegalArgumentException if there isn't a registry for that type -+ */ -+ @org.jetbrains.annotations.NotNull Registry registryFor(Class classOfT); - // Paper end - } diff --git a/patches/api/0250-Add-StructuresLocateEvent.patch b/patches/api/0250-Add-StructuresLocateEvent.patch index 9f5a511014..4000811de1 100644 --- a/patches/api/0250-Add-StructuresLocateEvent.patch +++ b/patches/api/0250-Add-StructuresLocateEvent.patch @@ -170,23 +170,27 @@ index 0000000000000000000000000000000000000000..0c83a02059d65672ff191c42932d8509 +} diff --git a/src/main/java/io/papermc/paper/event/world/StructuresLocateEvent.java b/src/main/java/io/papermc/paper/event/world/StructuresLocateEvent.java new file mode 100644 -index 0000000000000000000000000000000000000000..566f9df8f615142e14330965f3491f4e83846783 +index 0000000000000000000000000000000000000000..1648ed317145eb73c0cca431823449b2adc43e04 --- /dev/null +++ b/src/main/java/io/papermc/paper/event/world/StructuresLocateEvent.java -@@ -0,0 +1,164 @@ +@@ -0,0 +1,208 @@ +package io.papermc.paper.event.world; + ++import io.papermc.paper.math.Position; ++import io.papermc.paper.util.TransformingRandomAccessList; +import io.papermc.paper.world.structure.ConfiguredStructure; ++import java.util.Collections; ++import java.util.List; ++import java.util.Objects; +import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import org.bukkit.event.world.WorldEvent; ++import org.bukkit.generator.structure.Structure; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; -+ -+import java.util.ArrayList; -+import java.util.List; ++import org.jetbrains.annotations.UnmodifiableView; + +/** + * Called before a set of configured structures is located. @@ -206,15 +210,16 @@ index 0000000000000000000000000000000000000000..566f9df8f615142e14330965f3491f4e + + private final Location origin; + private Result result; -+ private List configuredStructures; ++ private List structures; ++ private List legacy$structures; + private int radius; + private boolean findUnexplored; + private boolean cancelled; + -+ public StructuresLocateEvent(@NotNull World world, @NotNull Location origin, @NotNull List configuredStructures, int radius, boolean findUnexplored) { ++ public StructuresLocateEvent(@NotNull World world, @NotNull Location origin, @NotNull List structures, int radius, boolean findUnexplored) { + super(world); + this.origin = origin; -+ this.configuredStructures = configuredStructures; ++ this.setStructures(structures); + this.radius = radius; + this.findUnexplored = findUnexplored; + } @@ -229,23 +234,23 @@ index 0000000000000000000000000000000000000000..566f9df8f615142e14330965f3491f4e + } + + /** -+ * Gets the {@link Location} and {@link ConfiguredStructure} set as the result, if it was defined. ++ * Gets the {@link Location} and {@link Structure} set as the result, if it was defined. + *

+ * Returns {@code null} if it has not been set by {@link StructuresLocateEvent#setResult(Result)}. + * Since this event fires before the search is done, the actual result is unknown at this point. + * + * @return The result location and structure, if it has been set. null if it has not. -+ * @see World#locateNearestStructure(Location, org.bukkit.StructureType, int, boolean) ++ * @see World#locateNearestStructure(Location, org.bukkit.generator.structure.StructureType, int, boolean) + */ + public @Nullable Result getResult() { + return this.result; + } + + /** -+ * Sets the result {@link Location} and {@link ConfiguredStructure}. This causes the search to be ++ * Sets the result {@link Location} and {@link Structure}. This causes the search to be + * skipped, and the result object passed here to be used as the result. + * -+ * @param result the {@link Location} and {@link ConfiguredStructure} of the search. ++ * @param result the {@link Location} and {@link Structure} of the search. + */ + public void setResult(@Nullable Result result) { + this.result = result; @@ -255,18 +260,41 @@ index 0000000000000000000000000000000000000000..566f9df8f615142e14330965f3491f4e + * Gets a mutable list of ConfiguredStructures that are valid targets for the search. + * + * @return a mutable list of ConfiguredStructures ++ * @deprecated use {@link #getStructures()} + */ ++ @Deprecated(forRemoval = true) + public @NotNull List getConfiguredStructures() { -+ return this.configuredStructures; ++ return this.legacy$structures; + } + + /** + * Sets the list of ConfiguredStructures that are valid targets for the search. + * + * @param configuredStructures a list of ConfiguredStructure targets ++ * @deprecated use {@link #setStructures(List)} + */ ++ @Deprecated(forRemoval = true) + public void setConfiguredStructures(@NotNull List configuredStructures) { -+ this.configuredStructures = new ArrayList<>(configuredStructures); ++ this.setStructures(configuredStructures.stream().map(ConfiguredStructure::toModern).toList()); ++ } ++ ++ /** ++ * Gets an unmodifiable list of Structures that are valid targets for the search. ++ * ++ * @return an unmodifiable list of Structures ++ */ ++ public @NotNull @UnmodifiableView List getStructures() { ++ return Collections.unmodifiableList(this.structures); ++ } ++ ++ /** ++ * Sets the list of Structures that are valid targets for the search. ++ * ++ * @param structures a list of Structures targets ++ */ ++ public void setStructures(final @NotNull List structures) { ++ this.structures = structures; ++ this.legacy$structures = new TransformingRandomAccessList<>(this.structures, ConfiguredStructure::fromModern, ConfiguredStructure::toModern); + } + + /** @@ -274,7 +302,7 @@ index 0000000000000000000000000000000000000000..566f9df8f615142e14330965f3491f4e + *

+ * This radius may not always be obeyed during the structure search! + * -+ * @return the search radius. ++ * @return the search radius (in chunks) + */ + public int getRadius() { + return this.radius; @@ -285,7 +313,7 @@ index 0000000000000000000000000000000000000000..566f9df8f615142e14330965f3491f4e + *

+ * This radius may not always be obeyed during the structure search! + * -+ * @param radius the search radius. ++ * @param radius the search radius (in chunks) + */ + public void setRadius(int radius) { + this.radius = radius; @@ -335,31 +363,51 @@ index 0000000000000000000000000000000000000000..566f9df8f615142e14330965f3491f4e + /** + * Result for {@link StructuresLocateEvent}. + */ -+ public record Result(@NotNull Location position, @NotNull ConfiguredStructure configuredStructure) { ++ public record Result(@NotNull Position pos, @NotNull Structure structure) { ++ ++ @Deprecated(forRemoval = true) ++ public Result(final @NotNull Location position, @NotNull ConfiguredStructure configuredStructure) { ++ this(position, configuredStructure.toModern()); ++ } ++ ++ @Deprecated(forRemoval = true) ++ public @NotNull ConfiguredStructure configuredStructure() { ++ return Objects.requireNonNull(ConfiguredStructure.fromModern(this.structure), "Please use the newer Structure API"); ++ } ++ ++ @Deprecated(forRemoval = true) ++ public @NotNull Location position() { ++ //noinspection DataFlowIssue ++ return this.pos.toLocation(null); ++ } + } +} diff --git a/src/main/java/io/papermc/paper/world/structure/ConfiguredStructure.java b/src/main/java/io/papermc/paper/world/structure/ConfiguredStructure.java new file mode 100644 -index 0000000000000000000000000000000000000000..5a43e40b7311ed2acb51f6ba8b12d1f34569ff2e +index 0000000000000000000000000000000000000000..b9a98f3c89cf847afd510bd1588d3a6d4b7eac0e --- /dev/null +++ b/src/main/java/io/papermc/paper/world/structure/ConfiguredStructure.java -@@ -0,0 +1,98 @@ +@@ -0,0 +1,112 @@ +package io.papermc.paper.world.structure; + +import io.papermc.paper.registry.Reference; ++import java.util.Objects; +import org.bukkit.Keyed; +import org.bukkit.NamespacedKey; +import org.bukkit.Registry; +import org.bukkit.StructureType; ++import org.bukkit.generator.structure.Structure; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; -+ -+import java.util.Objects; ++import org.jetbrains.annotations.Nullable; + +/** + * Represents a configured structure each with a + * {@link StructureType}. Multiple ConfiguredStructures can have + * the same {@link StructureType}. ++ * @deprecated use {@link Structure} + */ ++@Deprecated(forRemoval = true) +public final class ConfiguredStructure implements Keyed { + + public static final Reference PILLAGER_OUTPOST = create("pillager_outpost"); @@ -441,12 +489,22 @@ index 0000000000000000000000000000000000000000..5a43e40b7311ed2acb51f6ba8b12d1f3 + private static @NotNull Reference create(@NotNull String name) { + return Reference.create(Registry.CONFIGURED_STRUCTURE, NamespacedKey.minecraft(name)); + } ++ ++ @ApiStatus.Internal ++ public @NotNull Structure toModern() { ++ return Objects.requireNonNull(Registry.STRUCTURE.get(this.key)); ++ } ++ ++ @ApiStatus.Internal ++ public static @Nullable ConfiguredStructure fromModern(@NotNull Structure structure) { ++ return Registry.CONFIGURED_STRUCTURE.get(structure.getKey()); ++ } +} diff --git a/src/main/java/org/bukkit/Registry.java b/src/main/java/org/bukkit/Registry.java -index ff1fcdaccbca81602278a0b52670f7b895ba22b7..9e39c028b3d7bea4f2998d6ed8d53d88361ccfcd 100644 +index ff1fcdaccbca81602278a0b52670f7b895ba22b7..c0655a7c29e113297484a53d72cc5ea0affbe8ce 100644 --- a/src/main/java/org/bukkit/Registry.java +++ b/src/main/java/org/bukkit/Registry.java -@@ -211,6 +211,13 @@ public interface Registry extends Iterable { +@@ -211,6 +211,15 @@ public interface Registry extends Iterable { return GameEvent.getByKey(key); } }; @@ -454,7 +512,9 @@ index ff1fcdaccbca81602278a0b52670f7b895ba22b7..9e39c028b3d7bea4f2998d6ed8d53d88 + /** + * Configured structures. + * @see io.papermc.paper.world.structure.ConfiguredStructure ++ * @deprecated use {@link #STRUCTURE} + */ ++ @Deprecated(forRemoval = true) + Registry CONFIGURED_STRUCTURE = Bukkit.getRegistry(io.papermc.paper.world.structure.ConfiguredStructure.class); + // Paper end diff --git a/patches/api/0269-Expand-world-key-API.patch b/patches/api/0269-Expand-world-key-API.patch index e78eb2a0e5..c3176669fa 100644 --- a/patches/api/0269-Expand-world-key-API.patch +++ b/patches/api/0269-Expand-world-key-API.patch @@ -78,13 +78,13 @@ index 02b898d441c42771903d5839c3cde544b1a25778..1a3b4f20c7126caf8a34040028f73508 * Create a new virtual {@link WorldBorder}. *

diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java -index e5e91f4b4492fa1e709d81f313aac80761ab9e07..3545313f1c592e29d0bb5d055fc4e5c71c8a6fca 100644 +index 1f89a3c1c3b73a939c2653102fc1dc8b630672a8..6c45841538f2f073691331f975741a62b03a6637 100644 --- a/src/main/java/org/bukkit/UnsafeValues.java +++ b/src/main/java/org/bukkit/UnsafeValues.java -@@ -142,5 +142,10 @@ public interface UnsafeValues { - * @throws IllegalArgumentException if there isn't a registry for that type +@@ -132,5 +132,10 @@ public interface UnsafeValues { + * Use this when sending custom packets, so that there are no collisions on the client or server. */ - @org.jetbrains.annotations.NotNull Registry registryFor(Class classOfT); + public int nextEntityId(); + + /** + * Just don't use it. diff --git a/patches/api/0270-Item-Rarity-API.patch b/patches/api/0270-Item-Rarity-API.patch index 2558d2aed0..5739e52d61 100644 --- a/patches/api/0270-Item-Rarity-API.patch +++ b/patches/api/0270-Item-Rarity-API.patch @@ -61,10 +61,10 @@ index 7e447f8be7dc9768df487e1f7f4b9aafedb33e2d..eb8aa093148eea3b2fcafe06e8f1277e /** diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java -index 3545313f1c592e29d0bb5d055fc4e5c71c8a6fca..aa6d4e0ea2a1e2b96cc94d5a1d2223caecfea7a4 100644 +index 6c45841538f2f073691331f975741a62b03a6637..e87cbaf9c1ea1330ab1597f98c8864d0c5b8bdcd 100644 --- a/src/main/java/org/bukkit/UnsafeValues.java +++ b/src/main/java/org/bukkit/UnsafeValues.java -@@ -147,5 +147,22 @@ public interface UnsafeValues { +@@ -137,5 +137,22 @@ public interface UnsafeValues { * Just don't use it. */ @org.jetbrains.annotations.NotNull String getMainLevelName(); diff --git a/patches/api/0271-Expose-protocol-version.patch b/patches/api/0271-Expose-protocol-version.patch index fc59754077..5e7493cad9 100644 --- a/patches/api/0271-Expose-protocol-version.patch +++ b/patches/api/0271-Expose-protocol-version.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Expose protocol version diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java -index aa6d4e0ea2a1e2b96cc94d5a1d2223caecfea7a4..c876f95989d5bb64e745f8f62b4874422156d49c 100644 +index e87cbaf9c1ea1330ab1597f98c8864d0c5b8bdcd..906f313d8c91e65ce934143208ed281ce02f5354 100644 --- a/src/main/java/org/bukkit/UnsafeValues.java +++ b/src/main/java/org/bukkit/UnsafeValues.java -@@ -164,5 +164,12 @@ public interface UnsafeValues { +@@ -154,5 +154,12 @@ public interface UnsafeValues { * @return the itemstack rarity */ public io.papermc.paper.inventory.ItemRarity getItemStackRarity(ItemStack itemStack); diff --git a/patches/api/0289-ItemStack-repair-check-API.patch b/patches/api/0289-ItemStack-repair-check-API.patch index 6e16f41651..5641bba3a7 100644 --- a/patches/api/0289-ItemStack-repair-check-API.patch +++ b/patches/api/0289-ItemStack-repair-check-API.patch @@ -5,10 +5,10 @@ Subject: [PATCH] ItemStack repair check API diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java -index c876f95989d5bb64e745f8f62b4874422156d49c..52e0bee77f10965932c67333e7d22cbbcdc08048 100644 +index 906f313d8c91e65ce934143208ed281ce02f5354..29a91ec8e97ce66383a1dd1fc3dcbcdcca7cfc41 100644 --- a/src/main/java/org/bukkit/UnsafeValues.java +++ b/src/main/java/org/bukkit/UnsafeValues.java -@@ -165,6 +165,16 @@ public interface UnsafeValues { +@@ -155,6 +155,16 @@ public interface UnsafeValues { */ public io.papermc.paper.inventory.ItemRarity getItemStackRarity(ItemStack itemStack); diff --git a/patches/api/0294-Attributes-API-for-item-defaults.patch b/patches/api/0294-Attributes-API-for-item-defaults.patch index 804d636cec..3f96334e6f 100644 --- a/patches/api/0294-Attributes-API-for-item-defaults.patch +++ b/patches/api/0294-Attributes-API-for-item-defaults.patch @@ -31,10 +31,10 @@ index eb8aa093148eea3b2fcafe06e8f1277ebbe2f275..9c6291531d3081bf601364815fdd0a9b /** diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java -index 52e0bee77f10965932c67333e7d22cbbcdc08048..3388f31c2f287c8dcf4bfd157a04d9383cbe41e3 100644 +index 29a91ec8e97ce66383a1dd1fc3dcbcdcca7cfc41..0d47278d68cdf015cb980721c234a3abee39646a 100644 --- a/src/main/java/org/bukkit/UnsafeValues.java +++ b/src/main/java/org/bukkit/UnsafeValues.java -@@ -175,6 +175,18 @@ public interface UnsafeValues { +@@ -165,6 +165,18 @@ public interface UnsafeValues { */ public boolean isValidRepairItemStack(@org.jetbrains.annotations.NotNull ItemStack itemToBeRepaired, @org.jetbrains.annotations.NotNull ItemStack repairMaterial); diff --git a/patches/api/0321-Get-entity-default-attributes.patch b/patches/api/0321-Get-entity-default-attributes.patch index 0d8ae058a8..78cb2ccbe1 100644 --- a/patches/api/0321-Get-entity-default-attributes.patch +++ b/patches/api/0321-Get-entity-default-attributes.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Get entity default attributes diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java -index 3388f31c2f287c8dcf4bfd157a04d9383cbe41e3..393e0e9bacb30cdae4154ec2573e000a82cc89e7 100644 +index 0d47278d68cdf015cb980721c234a3abee39646a..29ccd90e2733b528ef0866f93053adf66dd9ddf3 100644 --- a/src/main/java/org/bukkit/UnsafeValues.java +++ b/src/main/java/org/bukkit/UnsafeValues.java -@@ -193,5 +193,22 @@ public interface UnsafeValues { +@@ -183,5 +183,22 @@ public interface UnsafeValues { * @return the server's protocol version */ int getProtocolVersion(); diff --git a/patches/api/0327-Add-isCollidable-methods-to-various-places.patch b/patches/api/0327-Add-isCollidable-methods-to-various-places.patch index 5923e618bf..07f73f6caa 100644 --- a/patches/api/0327-Add-isCollidable-methods-to-various-places.patch +++ b/patches/api/0327-Add-isCollidable-methods-to-various-places.patch @@ -26,10 +26,10 @@ index 9c6291531d3081bf601364815fdd0a9b801eee50..33371518fc8c5d97625f3d528ba8fee2 /** diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java -index 393e0e9bacb30cdae4154ec2573e000a82cc89e7..aa5fff8704fa002af0cffb09049311edaef19339 100644 +index 29ccd90e2733b528ef0866f93053adf66dd9ddf3..2a23e93d9e308c5eba0a2b658f11f571a0c01e26 100644 --- a/src/main/java/org/bukkit/UnsafeValues.java +++ b/src/main/java/org/bukkit/UnsafeValues.java -@@ -210,5 +210,14 @@ public interface UnsafeValues { +@@ -200,5 +200,14 @@ public interface UnsafeValues { * @throws IllegalArgumentException if the entity does not exist of have default attributes (use {@link #hasDefaultEntityAttributes(NamespacedKey)} first) */ @org.jetbrains.annotations.NotNull org.bukkit.attribute.Attributable getDefaultEntityAttributes(@org.jetbrains.annotations.NotNull NamespacedKey entityKey); diff --git a/patches/api/0351-More-PotionEffectType-API.patch b/patches/api/0351-More-PotionEffectType-API.patch index 81fe72fe80..fbbaaee341 100644 --- a/patches/api/0351-More-PotionEffectType-API.patch +++ b/patches/api/0351-More-PotionEffectType-API.patch @@ -5,13 +5,14 @@ Subject: [PATCH] More PotionEffectType API diff --git a/src/main/java/org/bukkit/Registry.java b/src/main/java/org/bukkit/Registry.java -index 9e39c028b3d7bea4f2998d6ed8d53d88361ccfcd..3dc747080b7bfea4b04b5a47cc7ae4698c758802 100644 +index c0655a7c29e113297484a53d72cc5ea0affbe8ce..0a3a41ae4c488b148266129d3663be3f8830d509 100644 --- a/src/main/java/org/bukkit/Registry.java +++ b/src/main/java/org/bukkit/Registry.java -@@ -217,6 +217,25 @@ public interface Registry extends Iterable { - * @see io.papermc.paper.world.structure.ConfiguredStructure +@@ -219,6 +219,26 @@ public interface Registry extends Iterable { */ + @Deprecated(forRemoval = true) Registry CONFIGURED_STRUCTURE = Bukkit.getRegistry(io.papermc.paper.world.structure.ConfiguredStructure.class); ++ + /** + * Potion effect types. + * diff --git a/patches/api/0380-Add-NamespacedKey-biome-methods.patch b/patches/api/0380-Add-NamespacedKey-biome-methods.patch index 72e349941b..29c18d7554 100644 --- a/patches/api/0380-Add-NamespacedKey-biome-methods.patch +++ b/patches/api/0380-Add-NamespacedKey-biome-methods.patch @@ -6,10 +6,10 @@ Subject: [PATCH] Add NamespacedKey biome methods Co-authored-by: Thonk <30448663+ExcessiveAmountsOfZombies@users.noreply.github.com> diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java -index 80314e6dabadcd290841c792f3a5fafecd6ea036..7cf5223d3f66783e05767e16000bf51925064d66 100644 +index b8ca571f8e88e7b676c5d1e1d90f6e5cb8538147..b92255a9c87620f46adb140689b1cd328a476d61 100644 --- a/src/main/java/org/bukkit/UnsafeValues.java +++ b/src/main/java/org/bukkit/UnsafeValues.java -@@ -227,5 +227,32 @@ public interface UnsafeValues { +@@ -217,5 +217,32 @@ public interface UnsafeValues { * @throws IllegalArgumentException if {@link Material#isBlock()} is false */ boolean isCollidable(@org.jetbrains.annotations.NotNull Material material); diff --git a/patches/server/0009-MC-Utils.patch b/patches/server/0009-MC-Utils.patch index a5906d2d00..aebe143be4 100644 --- a/patches/server/0009-MC-Utils.patch +++ b/patches/server/0009-MC-Utils.patch @@ -3463,13 +3463,14 @@ index 0000000000000000000000000000000000000000..cea9c098ade00ee87b8efc8164ab72f5 +} diff --git a/src/main/java/io/papermc/paper/util/MCUtil.java b/src/main/java/io/papermc/paper/util/MCUtil.java new file mode 100644 -index 0000000000000000000000000000000000000000..9798a1010120125039cbf226a0e3679cc92f92c7 +index 0000000000000000000000000000000000000000..902317d2dc198a1cbfc679810bcb2173644354cb --- /dev/null +++ b/src/main/java/io/papermc/paper/util/MCUtil.java -@@ -0,0 +1,512 @@ +@@ -0,0 +1,517 @@ +package io.papermc.paper.util; + +import com.google.common.util.concurrent.ThreadFactoryBuilder; ++import io.papermc.paper.math.Position; +import it.unimi.dsi.fastutil.objects.ObjectRBTreeSet; +import java.lang.ref.Cleaner; +import net.minecraft.core.BlockPos; @@ -3933,6 +3934,10 @@ index 0000000000000000000000000000000000000000..9798a1010120125039cbf226a0e3679c + return new BlockPos(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()); + } + ++ public static BlockPos toBlockPos(Position pos) { ++ return new BlockPos(pos.blockX(), pos.blockY(), pos.blockZ()); ++ } ++ + public static boolean isEdgeOfChunk(BlockPos pos) { + final int modX = pos.getX() & 15; + final int modZ = pos.getZ() & 15; diff --git a/patches/server/0018-Rewrite-chunk-system.patch b/patches/server/0018-Rewrite-chunk-system.patch index 6e61c635ae..bfed2ef66c 100644 --- a/patches/server/0018-Rewrite-chunk-system.patch +++ b/patches/server/0018-Rewrite-chunk-system.patch @@ -11844,13 +11844,13 @@ index 0000000000000000000000000000000000000000..a6fb7ae77d7cad2243e28a33718e4631 + +} diff --git a/src/main/java/io/papermc/paper/util/MCUtil.java b/src/main/java/io/papermc/paper/util/MCUtil.java -index 9798a1010120125039cbf226a0e3679cc92f92c7..cf3e083c2ada3275a52c303de16a62576696e83f 100644 +index 902317d2dc198a1cbfc679810bcb2173644354cb..d58d44faa40be2421f4cb54740a3abdbad72875c 100644 --- a/src/main/java/io/papermc/paper/util/MCUtil.java +++ b/src/main/java/io/papermc/paper/util/MCUtil.java -@@ -1,16 +1,29 @@ - package io.papermc.paper.util; +@@ -2,16 +2,29 @@ package io.papermc.paper.util; import com.google.common.util.concurrent.ThreadFactoryBuilder; + import io.papermc.paper.math.Position; +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; +import com.google.gson.internal.Streams; @@ -11877,7 +11877,7 @@ index 9798a1010120125039cbf226a0e3679cc92f92c7..cf3e083c2ada3275a52c303de16a6257 import org.apache.commons.lang.exception.ExceptionUtils; import org.bukkit.Location; import org.bukkit.block.BlockFace; -@@ -20,8 +33,11 @@ import org.spigotmc.AsyncCatcher; +@@ -21,8 +34,11 @@ import org.spigotmc.AsyncCatcher; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -11889,7 +11889,7 @@ index 9798a1010120125039cbf226a0e3679cc92f92c7..cf3e083c2ada3275a52c303de16a6257 import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; import java.util.concurrent.LinkedBlockingQueue; -@@ -506,6 +522,100 @@ public final class MCUtil { +@@ -511,6 +527,100 @@ public final class MCUtil { } } diff --git a/patches/server/0143-Basic-PlayerProfile-API.patch b/patches/server/0143-Basic-PlayerProfile-API.patch index 40b39a0963..ecadae1158 100644 --- a/patches/server/0143-Basic-PlayerProfile-API.patch +++ b/patches/server/0143-Basic-PlayerProfile-API.patch @@ -565,7 +565,7 @@ index 0000000000000000000000000000000000000000..7ac27392a8647ef7d0dc78efe78703e9 + @NotNull GameProfile buildGameProfile(); +} diff --git a/src/main/java/io/papermc/paper/util/MCUtil.java b/src/main/java/io/papermc/paper/util/MCUtil.java -index cf3e083c2ada3275a52c303de16a62576696e83f..b19850ae31f6c796cb3491dd5070d28e0ffd242c 100644 +index d58d44faa40be2421f4cb54740a3abdbad72875c..9ee4dc54039cbe6b8c9bd3018044c73f923a736e 100644 --- a/src/main/java/io/papermc/paper/util/MCUtil.java +++ b/src/main/java/io/papermc/paper/util/MCUtil.java @@ -1,5 +1,7 @@ @@ -574,9 +574,9 @@ index cf3e083c2ada3275a52c303de16a62576696e83f..b19850ae31f6c796cb3491dd5070d28e +import com.destroystokyo.paper.profile.CraftPlayerProfile; +import com.destroystokyo.paper.profile.PlayerProfile; import com.google.common.util.concurrent.ThreadFactoryBuilder; + import io.papermc.paper.math.Position; import com.google.gson.JsonArray; - import com.google.gson.JsonObject; -@@ -25,6 +27,7 @@ import net.minecraft.world.level.Level; +@@ -26,6 +28,7 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.chunk.ChunkAccess; import net.minecraft.world.level.chunk.ChunkStatus; import org.apache.commons.lang.exception.ExceptionUtils; @@ -584,7 +584,7 @@ index cf3e083c2ada3275a52c303de16a62576696e83f..b19850ae31f6c796cb3491dd5070d28e import org.bukkit.Location; import org.bukkit.block.BlockFace; import org.bukkit.craftbukkit.CraftWorld; -@@ -372,6 +375,10 @@ public final class MCUtil { +@@ -373,6 +376,10 @@ public final class MCUtil { return run.get(); } diff --git a/patches/server/0263-Catch-JsonParseException-in-Entity-and-TE-names.patch b/patches/server/0263-Catch-JsonParseException-in-Entity-and-TE-names.patch index 3d055bcbaf..da983a9a4b 100644 --- a/patches/server/0263-Catch-JsonParseException-in-Entity-and-TE-names.patch +++ b/patches/server/0263-Catch-JsonParseException-in-Entity-and-TE-names.patch @@ -13,10 +13,10 @@ Shulkers) may need to be changed in order for it to re-save properly No more crashing though. diff --git a/src/main/java/io/papermc/paper/util/MCUtil.java b/src/main/java/io/papermc/paper/util/MCUtil.java -index b19850ae31f6c796cb3491dd5070d28e0ffd242c..d1a59c2af0557a816c094983ec60097fb4de060c 100644 +index 9ee4dc54039cbe6b8c9bd3018044c73f923a736e..6efb8b10f17c70b05128039376d254e6beda3841 100644 --- a/src/main/java/io/papermc/paper/util/MCUtil.java +++ b/src/main/java/io/papermc/paper/util/MCUtil.java -@@ -14,6 +14,8 @@ import it.unimi.dsi.fastutil.objects.ReferenceArrayList; +@@ -15,6 +15,8 @@ import it.unimi.dsi.fastutil.objects.ReferenceArrayList; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.server.MinecraftServer; @@ -25,7 +25,7 @@ index b19850ae31f6c796cb3491dd5070d28e0ffd242c..d1a59c2af0557a816c094983ec60097f import net.minecraft.server.level.ChunkHolder; import net.minecraft.server.level.ChunkMap; import net.minecraft.server.level.DistanceManager; -@@ -529,6 +531,21 @@ public final class MCUtil { +@@ -534,6 +536,21 @@ public final class MCUtil { } } diff --git a/patches/server/0548-Add-PaperRegistry.patch b/patches/server/0548-Add-PaperRegistry.patch deleted file mode 100644 index b5474d9bb7..0000000000 --- a/patches/server/0548-Add-PaperRegistry.patch +++ /dev/null @@ -1,242 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jake Potrebic -Date: Wed, 2 Mar 2022 13:33:08 -0800 -Subject: [PATCH] Add PaperRegistry - -PaperRegistry is a server-backed impl of bukkit's Registry interface - -diff --git a/src/main/java/io/papermc/paper/registry/PaperRegistry.java b/src/main/java/io/papermc/paper/registry/PaperRegistry.java -new file mode 100644 -index 0000000000000000000000000000000000000000..7c265d27da034986be73921d35bf08ae250b42f3 ---- /dev/null -+++ b/src/main/java/io/papermc/paper/registry/PaperRegistry.java -@@ -0,0 +1,167 @@ -+package io.papermc.paper.registry; -+ -+import com.google.common.base.Preconditions; -+import com.google.common.base.Suppliers; -+import net.minecraft.core.Holder; -+import net.minecraft.core.Registry; -+import net.minecraft.core.RegistryAccess; -+import net.minecraft.resources.ResourceKey; -+import net.minecraft.resources.ResourceLocation; -+import net.minecraft.server.MinecraftServer; -+import org.bukkit.Keyed; -+import org.bukkit.NamespacedKey; -+import org.bukkit.craftbukkit.util.CraftNamespacedKey; -+import org.checkerframework.checker.nullness.qual.NonNull; -+import org.checkerframework.checker.nullness.qual.Nullable; -+import org.checkerframework.framework.qual.DefaultQualifier; -+ -+import java.util.Collections; -+import java.util.HashMap; -+import java.util.Iterator; -+import java.util.Map; -+import java.util.Objects; -+import java.util.Optional; -+import java.util.concurrent.ConcurrentHashMap; -+import java.util.function.Consumer; -+import java.util.function.Supplier; -+ -+@DefaultQualifier(NonNull.class) -+public abstract class PaperRegistry implements org.bukkit.Registry { -+ -+ @SuppressWarnings("FieldMayBeFinal") // non-final for testing -+ private static Supplier REGISTRY_ACCESS = Suppliers.memoize(() -> MinecraftServer.getServer().registryAccess()); -+ private static final Map, PaperRegistry> INTERNAL_REGISTRIES = new HashMap<>(); -+ public static final Map, PaperRegistry> REGISTRIES = Collections.unmodifiableMap(INTERNAL_REGISTRIES); -+ private static final Map, PaperRegistry> REGISTRY_BY_API_CLASS = new HashMap<>(); -+ private static final Map>, PaperRegistry> REGISTRY_BY_RES_KEY = new HashMap<>(); -+ -+ private boolean registered; -+ private final RegistryKey registryKey; -+ private final Supplier> registry; -+ private final Map cache = new ConcurrentHashMap<>(); -+ private final Map> resourceKeyCache = new ConcurrentHashMap<>(); -+ -+ public PaperRegistry(RegistryKey registryKey) { -+ this.registryKey = registryKey; -+ this.registry = Suppliers.memoize(() -> REGISTRY_ACCESS.get().registryOrThrow(this.registryKey.resourceKey())); -+ } -+ -+ @Override -+ public @Nullable API get(NamespacedKey key) { -+ return this.cache.computeIfAbsent(key, k -> { -+ final @Nullable MINECRAFT nms = this.registry.get().get(CraftNamespacedKey.toMinecraft(k)); -+ if (nms != null) { -+ return this.convertToApi(k, nms); -+ } -+ return null; -+ }); -+ } -+ -+ public abstract @Nullable API convertToApi(NamespacedKey key, MINECRAFT nms); -+ -+ public API convertToApiOrThrow(ResourceLocation resourceLocation, MINECRAFT nms) { -+ return Objects.requireNonNull(this.convertToApi(resourceLocation, nms), resourceLocation + " has a null api representation"); -+ } -+ -+ public @Nullable API convertToApi(ResourceLocation resourceLocation, MINECRAFT nms) { -+ return this.convertToApi(CraftNamespacedKey.fromMinecraft(resourceLocation), nms); -+ } -+ -+ public API convertToApiOrThrow(Holder nmsHolder) { -+ return Objects.requireNonNull(this.convertToApi(nmsHolder), nmsHolder + " has a null api representation"); -+ } -+ -+ public @Nullable API convertToApi(Holder nmsHolder) { -+ final Optional> key = nmsHolder.unwrapKey(); -+ if (nmsHolder.isBound() && key.isPresent()) { -+ return this.convertToApi(key.get().location(), nmsHolder.value()); -+ } else if (!nmsHolder.isBound() && key.isPresent()) { -+ return this.convertToApi(key.get().location(), this.registry.get().getOrThrow(key.get())); -+ } else if (nmsHolder.isBound() && key.isEmpty()) { -+ final @Nullable ResourceLocation loc = this.registry.get().getKey(nmsHolder.value()); -+ if (loc != null) { -+ return this.convertToApi(loc, nmsHolder.value()); -+ } -+ } -+ throw new IllegalStateException("Cannot convert " + nmsHolder + " to an API type in: " + this.registryKey); -+ } -+ -+ public void convertToApi(Iterable> holders, Consumer apiConsumer, boolean throwOnNull) { -+ for (Holder holder : holders) { -+ final @Nullable API api = this.convertToApi(holder); -+ if (api == null && throwOnNull) { -+ throw new NullPointerException(holder + " has a null api representation"); -+ } else if (api != null) { -+ apiConsumer.accept(api); -+ } -+ } -+ } -+ -+ public MINECRAFT getMinecraftValue(API apiValue) { -+ return this.registry.get().getOptional(CraftNamespacedKey.toMinecraft(apiValue.getKey())).orElseThrow(); -+ } -+ -+ public Holder getMinecraftHolder(API apiValue) { -+ return this.registry.get().getHolderOrThrow(this.resourceKeyCache.computeIfAbsent(apiValue.getKey(), key -> ResourceKey.create(this.registryKey.resourceKey(), CraftNamespacedKey.toMinecraft(key)))); -+ } -+ -+ @Override -+ public Iterator iterator() { -+ return this.registry.get().keySet().stream().map(key -> this.get(CraftNamespacedKey.fromMinecraft(key))).iterator(); -+ } -+ -+ public void clearCache() { -+ this.cache.clear(); -+ } -+ -+ public void register() { -+ if (this.registered) { -+ throw new IllegalStateException("Already registered: " + this.registryKey.apiClass()); -+ } -+ INTERNAL_REGISTRIES.put(this.registryKey, this); -+ REGISTRY_BY_API_CLASS.put(this.registryKey.apiClass(), this); -+ REGISTRY_BY_RES_KEY.put(this.registryKey.resourceKey(), this); -+ this.registered = true; -+ } -+ -+ @Override -+ public boolean equals(@Nullable Object o) { -+ if (this == o) return true; -+ if (o == null || !PaperRegistry.class.isAssignableFrom(o.getClass())) return false; -+ PaperRegistry that = (PaperRegistry) o; -+ return this.registryKey.equals(that.registryKey); -+ } -+ -+ @Override -+ public int hashCode() { -+ return Objects.hash(this.registryKey); -+ } -+ -+ protected static Supplier> registryFor(ResourceKey> registryKey) { -+ return Suppliers.memoize(() -> REGISTRY_ACCESS.get().registryOrThrow(registryKey)); -+ } -+ -+ public static void clearCaches() { -+ for (PaperRegistry registry : INTERNAL_REGISTRIES.values()) { -+ registry.clearCache(); -+ } -+ } -+ -+ @SuppressWarnings("unchecked") -+ public static PaperRegistry getRegistry(Class classOfT) { -+ Preconditions.checkArgument(REGISTRY_BY_API_CLASS.containsKey(classOfT), "No registry for that type"); -+ return (PaperRegistry) REGISTRY_BY_API_CLASS.get(classOfT); -+ } -+ -+ @SuppressWarnings("unchecked") -+ public static PaperRegistry getRegistry(ResourceKey> resourceKey) { -+ Preconditions.checkArgument(REGISTRY_BY_RES_KEY.containsKey(resourceKey)); -+ return (PaperRegistry) REGISTRY_BY_RES_KEY.get(resourceKey); -+ } -+ -+ @SuppressWarnings("unchecked") -+ public static PaperRegistry getRegistry(RegistryKey registryKey) { -+ Preconditions.checkArgument(INTERNAL_REGISTRIES.containsKey(registryKey)); -+ return (PaperRegistry) INTERNAL_REGISTRIES.get(registryKey); -+ } -+} -diff --git a/src/main/java/io/papermc/paper/registry/RegistryKey.java b/src/main/java/io/papermc/paper/registry/RegistryKey.java -new file mode 100644 -index 0000000000000000000000000000000000000000..6f39e343147803e15e7681c993b8797a629702e7 ---- /dev/null -+++ b/src/main/java/io/papermc/paper/registry/RegistryKey.java -@@ -0,0 +1,8 @@ -+package io.papermc.paper.registry; -+ -+import net.minecraft.core.Registry; -+import net.minecraft.resources.ResourceKey; -+import org.bukkit.Keyed; -+ -+public record RegistryKey(Class apiClass, ResourceKey> resourceKey) { -+} -diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 04137173ca7034b9dff37a68518e8b6fb0330188..9b1bde95e8303e5d4adfe92f09240df8e6323dac 100644 ---- a/src/main/java/net/minecraft/server/MinecraftServer.java -+++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -2016,6 +2016,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop Registry registryFor(Class classOfT) { -+ return io.papermc.paper.registry.PaperRegistry.getRegistry(classOfT); -+ } - // Paper end - - /** -diff --git a/src/test/java/org/bukkit/support/AbstractTestingBase.java b/src/test/java/org/bukkit/support/AbstractTestingBase.java -index 1caa4ce02cd396160f0d9d5461de8290e7c078bb..a19c1e8253b0dd0da77008f892b68187acd17c4a 100644 ---- a/src/test/java/org/bukkit/support/AbstractTestingBase.java -+++ b/src/test/java/org/bukkit/support/AbstractTestingBase.java -@@ -49,6 +49,15 @@ public abstract class AbstractTestingBase { - layers = WorldLoader.loadAndReplaceLayer(resourceManager, layers, RegistryLayer.WORLDGEN, RegistryDataLoader.WORLDGEN_REGISTRIES); - REGISTRY_CUSTOM = layers.compositeAccess().freeze(); - io.papermc.paper.testing.DummyServer.setup(); // Paper -+ // Paper start -+ try { -+ java.lang.reflect.Field field = io.papermc.paper.registry.PaperRegistry.class.getDeclaredField("REGISTRY_ACCESS"); -+ field.trySetAccessible(); -+ field.set(null, com.google.common.base.Suppliers.ofInstance(REGISTRY_CUSTOM)); -+ } catch (ReflectiveOperationException ex) { -+ throw new IllegalStateException("Could not reflectively set RegistryAccess in PaperRegistry", ex); -+ } -+ // Paper end - // Register vanilla pack - DATA_PACK = ReloadableServerResources.loadResources(resourceManager, REGISTRY_CUSTOM, FeatureFlags.REGISTRY.allFlags(), Commands.CommandSelection.DEDICATED, 0, MoreExecutors.directExecutor(), MoreExecutors.directExecutor()).join(); - // Bind tags diff --git a/patches/server/0548-TODO-Registry-Modification-API.patch b/patches/server/0548-TODO-Registry-Modification-API.patch new file mode 100644 index 0000000000..8c74989e13 --- /dev/null +++ b/patches/server/0548-TODO-Registry-Modification-API.patch @@ -0,0 +1,18 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Jake Potrebic +Date: Mon, 27 Feb 2023 18:28:39 -0800 +Subject: [PATCH] TODO Registry Modification API + + +diff --git a/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java b/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java +index 763f9d4740429840e78d3462277eb577d2d9f66a..2ab8919bddfb286255041351b55fc6d70a1bc76f 100644 +--- a/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java ++++ b/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java +@@ -26,6 +26,7 @@ public class CraftRegistry implements Registry { + if (bukkitClass == StructureType.class) { + return new CraftRegistry<>(BuiltInRegistries.STRUCTURE_TYPE, CraftStructureType::new); + } ++ // TODO registry modification API + + return null; + } diff --git a/patches/server/0549-Add-StructuresLocateEvent.patch b/patches/server/0549-Add-StructuresLocateEvent.patch index 92bb68348d..8fa34302df 100644 --- a/patches/server/0549-Add-StructuresLocateEvent.patch +++ b/patches/server/0549-Add-StructuresLocateEvent.patch @@ -5,69 +5,41 @@ Subject: [PATCH] Add StructuresLocateEvent Co-authored-by: Jake Potrebic -diff --git a/src/main/java/io/papermc/paper/registry/RegistryKey.java b/src/main/java/io/papermc/paper/registry/RegistryKey.java -index 6f39e343147803e15e7681c993b8797a629702e7..3a643d57b646c83974b5157b9cbb2a9f42e9bd59 100644 ---- a/src/main/java/io/papermc/paper/registry/RegistryKey.java -+++ b/src/main/java/io/papermc/paper/registry/RegistryKey.java -@@ -1,8 +1,14 @@ - package io.papermc.paper.registry; - -+import io.papermc.paper.world.structure.ConfiguredStructure; - import net.minecraft.core.Registry; -+import net.minecraft.core.registries.Registries; - import net.minecraft.resources.ResourceKey; -+import net.minecraft.world.level.levelgen.structure.Structure; - import org.bukkit.Keyed; - - public record RegistryKey(Class apiClass, ResourceKey> resourceKey) { -+ -+ public static final RegistryKey CONFIGURED_STRUCTURE_REGISTRY = new RegistryKey<>(ConfiguredStructure.class, Registries.STRUCTURE); -+ - } diff --git a/src/main/java/io/papermc/paper/world/structure/PaperConfiguredStructure.java b/src/main/java/io/papermc/paper/world/structure/PaperConfiguredStructure.java new file mode 100644 -index 0000000000000000000000000000000000000000..16996c743b169e625ec810523c1d59a305e1d159 +index 0000000000000000000000000000000000000000..09837f6e6c6ab8a1df2aacdb86646993123dd424 --- /dev/null +++ b/src/main/java/io/papermc/paper/world/structure/PaperConfiguredStructure.java -@@ -0,0 +1,44 @@ +@@ -0,0 +1,35 @@ +package io.papermc.paper.world.structure; + -+import io.papermc.paper.registry.PaperRegistry; -+import io.papermc.paper.registry.RegistryKey; ++import java.util.Objects; +import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; -+import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.levelgen.structure.Structure; +import org.bukkit.NamespacedKey; +import org.bukkit.StructureType; ++import org.bukkit.craftbukkit.CraftRegistry; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.framework.qual.DefaultQualifier; + -+import java.util.Objects; -+import java.util.function.Supplier; -+ +@DefaultQualifier(NonNull.class) ++@Deprecated(forRemoval = true) +public final class PaperConfiguredStructure { + + private PaperConfiguredStructure() { + } + -+ public static void init() { -+ new ConfiguredStructureRegistry().register(); -+ } ++ @Deprecated(forRemoval = true) ++ public static final class LegacyRegistry extends CraftRegistry { + -+ static final class ConfiguredStructureRegistry extends PaperRegistry { -+ -+ private static final Supplier> STRUCTURE_FEATURE_REGISTRY = registryFor(Registries.STRUCTURE); -+ -+ public ConfiguredStructureRegistry() { -+ super(RegistryKey.CONFIGURED_STRUCTURE_REGISTRY); ++ public LegacyRegistry(final Registry minecraftRegistry) { ++ super(minecraftRegistry, LegacyRegistry::minecraftToBukkit); + } + -+ @Override -+ public @Nullable ConfiguredStructure convertToApi(NamespacedKey key, Structure nms) { ++ private static @Nullable ConfiguredStructure minecraftToBukkit(NamespacedKey key, Structure nms) { + final ResourceLocation structureTypeLoc = Objects.requireNonNull(BuiltInRegistries.STRUCTURE_TYPE.getKey(nms.type()), "unexpected structure type " + nms.type()); + final @Nullable StructureType structureType = StructureType.getStructureTypes().get(structureTypeLoc.getPath()); + return structureType == null ? null : new ConfiguredStructure(key, structureType); @@ -75,54 +47,56 @@ index 0000000000000000000000000000000000000000..16996c743b169e625ec810523c1d59a3 + } +} diff --git a/src/main/java/net/minecraft/world/level/chunk/ChunkGenerator.java b/src/main/java/net/minecraft/world/level/chunk/ChunkGenerator.java -index b6df6077107759963ee8205dddb90501d5ccb4d6..29032374f0e71a41a2de260d402b6fbff68288cc 100644 +index b6df6077107759963ee8205dddb90501d5ccb4d6..aecdbbcc688aad308f81f48d50773a9866ded7b2 100644 --- a/src/main/java/net/minecraft/world/level/chunk/ChunkGenerator.java +++ b/src/main/java/net/minecraft/world/level/chunk/ChunkGenerator.java -@@ -121,6 +121,26 @@ public abstract class ChunkGenerator { +@@ -121,6 +121,24 @@ public abstract class ChunkGenerator { @Nullable public Pair> findNearestMapStructure(ServerLevel world, HolderSet structures, BlockPos center, int radius, boolean skipReferencedStructures) { -+ // Paper start - StructureLocateEvent ++ // Paper start - StructuresLocateEvent + final org.bukkit.World bukkitWorld = world.getWorld(); + final org.bukkit.Location origin = io.papermc.paper.util.MCUtil.toLocation(world, center); -+ final var paperRegistry = io.papermc.paper.registry.PaperRegistry.getRegistry(io.papermc.paper.registry.RegistryKey.CONFIGURED_STRUCTURE_REGISTRY); -+ final List configuredStructures = new ArrayList<>(); -+ paperRegistry.convertToApi(structures, configuredStructures::add, false); // gracefully handle missing api, use tests to check (or exclude) -+ if (!configuredStructures.isEmpty()) { -+ final io.papermc.paper.event.world.StructuresLocateEvent event = new io.papermc.paper.event.world.StructuresLocateEvent(bukkitWorld, origin, configuredStructures, radius, skipReferencedStructures); ++ final List apiStructures = structures.stream().map(Holder::value).map(nms -> org.bukkit.craftbukkit.generator.strucutre.CraftStructure.minecraftToBukkit(nms, world.registryAccess())).toList(); ++ if (!apiStructures.isEmpty()) { ++ final io.papermc.paper.event.world.StructuresLocateEvent event = new io.papermc.paper.event.world.StructuresLocateEvent(bukkitWorld, origin, apiStructures, radius, skipReferencedStructures); + if (!event.callEvent()) { + return null; + } + if (event.getResult() != null) { -+ return Pair.of(io.papermc.paper.util.MCUtil.toBlockPosition(event.getResult().position()), paperRegistry.getMinecraftHolder(event.getResult().configuredStructure())); ++ return Pair.of(io.papermc.paper.util.MCUtil.toBlockPos(event.getResult().pos()), world.registryAccess().registryOrThrow(Registries.STRUCTURE).wrapAsHolder(org.bukkit.craftbukkit.generator.strucutre.CraftStructure.bukkitToMinecraft(event.getResult().structure()))); + } + center = io.papermc.paper.util.MCUtil.toBlockPosition(event.getOrigin()); + radius = event.getRadius(); + skipReferencedStructures = event.shouldFindUnexplored(); -+ structures = HolderSet.direct(paperRegistry::getMinecraftHolder, event.getConfiguredStructures()); ++ structures = HolderSet.direct(api -> world.registryAccess().registryOrThrow(Registries.STRUCTURE).wrapAsHolder(org.bukkit.craftbukkit.generator.strucutre.CraftStructure.bukkitToMinecraft(api)), event.getStructures()); + } + // Paper end ChunkGeneratorStructureState chunkgeneratorstructurestate = world.getChunkSource().getGeneratorState(); Map>> map = new Object2ObjectArrayMap(); Iterator iterator = structures.iterator(); -diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index fed01c7ed32a0207216fd902976902b223cc3518..5b48102ad1c9940a5f41ba8084be0804b7536d30 100644 ---- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java -+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -318,6 +318,7 @@ public final class CraftServer implements Server { - this.structureManager = new CraftStructureManager(console.getStructureManager()); +diff --git a/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java b/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java +index 2ab8919bddfb286255041351b55fc6d70a1bc76f..34888b525fd35ac64e6e5e66036ad965a6769959 100644 +--- a/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java ++++ b/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java +@@ -27,6 +27,11 @@ public class CraftRegistry implements Registry { + return new CraftRegistry<>(BuiltInRegistries.STRUCTURE_TYPE, CraftStructureType::new); + } + // TODO registry modification API ++ // Paper start - remove this after a while along with all ConfiguredStructure stuff ++ if (bukkitClass == io.papermc.paper.world.structure.ConfiguredStructure.class) { ++ return new io.papermc.paper.world.structure.PaperConfiguredStructure.LegacyRegistry(registryHolder.registryOrThrow(Registries.STRUCTURE)); ++ } ++ // Paper end - Bukkit.setServer(this); -+ io.papermc.paper.world.structure.PaperConfiguredStructure.init(); // Paper - - // Register all the Enchantments and PotionTypes now so we can stop new registration immediately after - Enchantments.SHARPNESS.getClass(); + return null; + } diff --git a/src/test/java/io/papermc/paper/world/structure/ConfiguredStructureTest.java b/src/test/java/io/papermc/paper/world/structure/ConfiguredStructureTest.java new file mode 100644 -index 0000000000000000000000000000000000000000..cb077ac5e24d6632c46927fef8ecd20f150d3596 +index 0000000000000000000000000000000000000000..0d5306abdc72f139acdf3038ec155f853e371e7f --- /dev/null +++ b/src/test/java/io/papermc/paper/world/structure/ConfiguredStructureTest.java -@@ -0,0 +1,95 @@ +@@ -0,0 +1,96 @@ +package io.papermc.paper.world.structure; + +import io.papermc.paper.registry.Reference; @@ -151,6 +125,7 @@ index 0000000000000000000000000000000000000000..cb077ac5e24d6632c46927fef8ecd20f +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + ++@Deprecated(forRemoval = true) +public class ConfiguredStructureTest extends AbstractTestingBase { + + private static final Map BUILT_IN_STRUCTURES = new LinkedHashMap<>(); diff --git a/patches/server/0562-EntityMoveEvent.patch b/patches/server/0562-EntityMoveEvent.patch index e17f65e411..48f1ff6234 100644 --- a/patches/server/0562-EntityMoveEvent.patch +++ b/patches/server/0562-EntityMoveEvent.patch @@ -5,7 +5,7 @@ Subject: [PATCH] EntityMoveEvent diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 9b1bde95e8303e5d4adfe92f09240df8e6323dac..c22db75f87424e9b1dd2ae017619c0e2faee6901 100644 +index 04137173ca7034b9dff37a68518e8b6fb0330188..cd9022186351fa398bb8ab590ee8108b8ff1c9d3 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -1496,6 +1496,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop Registry registryFor(Class classOfT) { - return io.papermc.paper.registry.PaperRegistry.getRegistry(classOfT); +@@ -516,6 +516,11 @@ public final class CraftMagicNumbers implements UnsafeValues { + public int nextEntityId() { + return net.minecraft.world.entity.Entity.nextEntityId(); } + + @Override diff --git a/patches/server/0585-Item-Rarity-API.patch b/patches/server/0585-Item-Rarity-API.patch index fe64a97d4d..a481dc1afb 100644 --- a/patches/server/0585-Item-Rarity-API.patch +++ b/patches/server/0585-Item-Rarity-API.patch @@ -7,10 +7,10 @@ Subject: [PATCH] Item Rarity API public net.minecraft.world.item.Item rarity diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java -index 73334710407574124ad289bbd3379dccb3417755..f8bf5b0770e1e6b54d50e8063208083ea0b953a9 100644 +index 88074c487de90a7adc86c2345830147ac9f3ae77..9c24c1f163fe6dd71239e6fb888d66a130e4596b 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java -@@ -526,6 +526,20 @@ public final class CraftMagicNumbers implements UnsafeValues { +@@ -521,6 +521,20 @@ public final class CraftMagicNumbers implements UnsafeValues { public String getMainLevelName() { return ((net.minecraft.server.dedicated.DedicatedServer) net.minecraft.server.MinecraftServer.getServer()).getProperties().levelName; } diff --git a/patches/server/0587-Drop-carried-item-when-player-has-disconnected.patch b/patches/server/0587-Drop-carried-item-when-player-has-disconnected.patch index 135372a1ba..623a8dc520 100644 --- a/patches/server/0587-Drop-carried-item-when-player-has-disconnected.patch +++ b/patches/server/0587-Drop-carried-item-when-player-has-disconnected.patch @@ -7,7 +7,7 @@ Fixes disappearance of held items, when a player gets disconnected and PlayerDro Closes #5036 diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java -index 437e78adcc4838a9887887858afe883c8f928fef..17dc86f7cb383bda18f28576113d1af0d5fb288a 100644 +index 480af67431b567b29c76f949a429f619164b8391..d97ef7df5b4b98af95b8fff9ed541bbe8a43dfa8 100644 --- a/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java @@ -570,6 +570,14 @@ public abstract class PlayerList { diff --git a/patches/server/0588-forced-whitelist-use-configurable-kick-message.patch b/patches/server/0588-forced-whitelist-use-configurable-kick-message.patch index 937ad223b2..fcab90966a 100644 --- a/patches/server/0588-forced-whitelist-use-configurable-kick-message.patch +++ b/patches/server/0588-forced-whitelist-use-configurable-kick-message.patch @@ -5,10 +5,10 @@ Subject: [PATCH] forced whitelist: use configurable kick message diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 194f00dac49c54809d7a1dcccc9c2844399c5b0a..d5cd8d540438638268cc26e2fc9be8415950ee22 100644 +index 7cb5fba71a7a3eb46917ff744cede12e3c42069e..40f78babdcf6fcb3ec5dd00ed36186bf61a98c6c 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -2122,7 +2122,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop 0.0F) { diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java -index 12d65c3dfe2aa95d2aa80ba6bc4383f51e8cfc4a..565a75e5e775edf604cdb4b991b17fb3ca3423ab 100644 +index a4b35d42d6e0e24b29e647f7a1e5735f8f07ef38..aa069752df2e54cf6ef7fb4a7b82d91b219ba2ae 100644 --- a/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java @@ -748,6 +748,12 @@ public abstract class PlayerList { diff --git a/patches/server/0617-Add-basic-Datapack-API.patch b/patches/server/0617-Add-basic-Datapack-API.patch index 975c2fb651..497fbaeb9d 100644 --- a/patches/server/0617-Add-basic-Datapack-API.patch +++ b/patches/server/0617-Add-basic-Datapack-API.patch @@ -92,7 +92,7 @@ index 0000000000000000000000000000000000000000..cf4374493c11057451a62a655514415c + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index 5fbfc4b44c21ae9137e513972726ddddd2f64aa2..59f9e2c09e72acedde901790f87432e53e8a4b70 100644 +index 3135b7254776a96c581a5f8008c9712e996a27af..c58e8e36a2526272e7fa26dffbb4c5bd362692e1 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -296,6 +296,7 @@ public final class CraftServer implements Server { @@ -103,7 +103,7 @@ index 5fbfc4b44c21ae9137e513972726ddddd2f64aa2..59f9e2c09e72acedde901790f87432e5 public static Exception excessiveVelEx; // Paper - Velocity warnings static { -@@ -383,6 +384,7 @@ public final class CraftServer implements Server { +@@ -382,6 +383,7 @@ public final class CraftServer implements Server { if (this.configuration.getBoolean("settings.use-map-color-cache")) { MapPalette.setMapColorCache(new CraftMapColorCache(this.logger)); } @@ -111,7 +111,7 @@ index 5fbfc4b44c21ae9137e513972726ddddd2f64aa2..59f9e2c09e72acedde901790f87432e5 } public boolean getCommandBlockOverride(String command) { -@@ -2781,5 +2783,11 @@ public final class CraftServer implements Server { +@@ -2780,5 +2782,11 @@ public final class CraftServer implements Server { public com.destroystokyo.paper.entity.ai.MobGoals getMobGoals() { return mobGoals; } diff --git a/patches/server/0620-ItemStack-repair-check-API.patch b/patches/server/0620-ItemStack-repair-check-API.patch index 51ef504b30..85b3141e7e 100644 --- a/patches/server/0620-ItemStack-repair-check-API.patch +++ b/patches/server/0620-ItemStack-repair-check-API.patch @@ -5,10 +5,10 @@ Subject: [PATCH] ItemStack repair check API diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java -index 21648628856e425dd68d44bd81ac17ce4b4bff47..12ad9ccac400159af9b6597811fec7d362be5906 100644 +index 9efcc26d49204255831a14115af09a8db7ad4636..73fa833ecf2e783f25f24de48b00829a813c1d19 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java -@@ -541,6 +541,14 @@ public final class CraftMagicNumbers implements UnsafeValues { +@@ -536,6 +536,14 @@ public final class CraftMagicNumbers implements UnsafeValues { return io.papermc.paper.inventory.ItemRarity.values()[getItem(itemStack.getType()).getRarity(CraftItemStack.asNMSCopy(itemStack)).ordinal()]; } diff --git a/patches/server/0623-Fix-and-optimise-world-force-upgrading.patch b/patches/server/0623-Fix-and-optimise-world-force-upgrading.patch index e09b8016ee..d77cda96a9 100644 --- a/patches/server/0623-Fix-and-optimise-world-force-upgrading.patch +++ b/patches/server/0623-Fix-and-optimise-world-force-upgrading.patch @@ -275,7 +275,7 @@ index bf19d95d9b48310de10ef6819b83035ee63a165c..e24b23461c592fae07697d3b2a1929cb Main.LOGGER.info("Forcing world upgrade! {}", session.getLevelId()); // CraftBukkit WorldUpgrader worldupgrader = new WorldUpgrader(session, dataFixer, dimensionOptionsRegistry, eraseCache); diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index d5cd8d540438638268cc26e2fc9be8415950ee22..13f8b4699c5b3a99715fada2d774469fb5c17363 100644 +index 40f78babdcf6fcb3ec5dd00ed36186bf61a98c6c..b6e7b86bcb874ddf56a14334d30f95aadc9887ce 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -551,11 +551,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop list = ImmutableList.of(new PhantomSpawner(), new PatrolSpawner(), new CatSpawner(), new VillageSiege(), new WanderingTraderSpawner(worlddata)); -@@ -1232,6 +1227,13 @@ public final class CraftServer implements Server { +@@ -1231,6 +1226,13 @@ public final class CraftServer implements Server { biomeProvider = generator.getDefaultBiomeProvider(worldInfo); } diff --git a/patches/server/0627-Attributes-API-for-item-defaults.patch b/patches/server/0627-Attributes-API-for-item-defaults.patch index bd9c621984..96a30561d7 100644 --- a/patches/server/0627-Attributes-API-for-item-defaults.patch +++ b/patches/server/0627-Attributes-API-for-item-defaults.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Attributes API for item defaults diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java -index 12ad9ccac400159af9b6597811fec7d362be5906..6c39b620e9909759ab37d659c93e426c9f33ba95 100644 +index 73fa833ecf2e783f25f24de48b00829a813c1d19..23b322f077312ad6b40964b12dff1ac03ad1a2b8 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java -@@ -549,6 +549,19 @@ public final class CraftMagicNumbers implements UnsafeValues { +@@ -544,6 +544,19 @@ public final class CraftMagicNumbers implements UnsafeValues { return CraftMagicNumbers.getItem(itemToBeRepaired.getType()).isValidRepairItem(CraftItemStack.asNMSCopy(itemToBeRepaired), CraftItemStack.asNMSCopy(repairMaterial)); } diff --git a/patches/server/0631-Add-PlayerKickEvent-causes.patch b/patches/server/0631-Add-PlayerKickEvent-causes.patch index 01db5ba7e1..a570f6eff8 100644 --- a/patches/server/0631-Add-PlayerKickEvent-causes.patch +++ b/patches/server/0631-Add-PlayerKickEvent-causes.patch @@ -36,10 +36,10 @@ index b5f54ee82905e3e6ab5bfde35ab625f5feeb1393..c0a80824a0307ea673805015119cc834 public boolean shouldDisconnect() { diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 13f8b4699c5b3a99715fada2d774469fb5c17363..213033a59be4239f1225286764be83dcc6fbf973 100644 +index b6e7b86bcb874ddf56a14334d30f95aadc9887ce..34619d107231fe188d2b4c8eeefba8b6eaf4d3a5 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -2125,7 +2125,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop chunkDataPacket) { diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java -index a1ea893c4af69bdbbca9bee2760016e8c8a17bb3..892db3baaf2936d5db9b073faf7537b6a97ededf 100644 +index 8dd9066868fd9a61936aabe2336c804c20b8bbc5..c646570cfa543d56011733af984345f73dc63cb9 100644 --- a/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java @@ -833,13 +833,13 @@ public abstract class PlayerList { diff --git a/patches/server/0684-Get-entity-default-attributes.patch b/patches/server/0684-Get-entity-default-attributes.patch index 564fc23423..a11e6eebe5 100644 --- a/patches/server/0684-Get-entity-default-attributes.patch +++ b/patches/server/0684-Get-entity-default-attributes.patch @@ -81,10 +81,10 @@ index 0000000000000000000000000000000000000000..cf9d28ea97d93cec05c9fb768d59e283 + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java -index 6c39b620e9909759ab37d659c93e426c9f33ba95..72ce08862419ce5b6da6decb39d8c36adc1eaaf0 100644 +index 23b322f077312ad6b40964b12dff1ac03ad1a2b8..c18829fb68db70296ddf546a903ed38cb12a593e 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java -@@ -566,6 +566,18 @@ public final class CraftMagicNumbers implements UnsafeValues { +@@ -561,6 +561,18 @@ public final class CraftMagicNumbers implements UnsafeValues { public int getProtocolVersion() { return net.minecraft.SharedConstants.getCurrentVersion().getProtocolVersion(); } diff --git a/patches/server/0690-Add-isCollidable-methods-to-various-places.patch b/patches/server/0690-Add-isCollidable-methods-to-various-places.patch index 57cf599be2..1ece66e444 100644 --- a/patches/server/0690-Add-isCollidable-methods-to-various-places.patch +++ b/patches/server/0690-Add-isCollidable-methods-to-various-places.patch @@ -39,10 +39,10 @@ index 7b9e943b391c061782fccd2b8d705ceec8db50fe..966ac60daebb7bb211ab8096fc0c5f33 + // Paper end } diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java -index 72ce08862419ce5b6da6decb39d8c36adc1eaaf0..dea05265776f2b57115f36e8a31ed7720cce2cd0 100644 +index c18829fb68db70296ddf546a903ed38cb12a593e..368693d93700390915f538de37409b5a37f916b7 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java -@@ -578,6 +578,12 @@ public final class CraftMagicNumbers implements UnsafeValues { +@@ -573,6 +573,12 @@ public final class CraftMagicNumbers implements UnsafeValues { var supplier = net.minecraft.world.entity.ai.attributes.DefaultAttributes.getSupplier((net.minecraft.world.entity.EntityType) net.minecraft.core.registries.BuiltInRegistries.ENTITY_TYPE.get(CraftNamespacedKey.toMinecraft(bukkitEntityKey))); return new io.papermc.paper.attribute.UnmodifiableAttributeMap(supplier); } diff --git a/patches/server/0693-Add-Raw-Byte-Entity-Serialization.patch b/patches/server/0693-Add-Raw-Byte-Entity-Serialization.patch index 2b5211da2b..31523bbd5f 100644 --- a/patches/server/0693-Add-Raw-Byte-Entity-Serialization.patch +++ b/patches/server/0693-Add-Raw-Byte-Entity-Serialization.patch @@ -45,7 +45,7 @@ index f1ee89047e8cd916c762b91162842e3f981856b3..726a4ae7ab928eda3ae1c1e98f342157 // Paper end } diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java -index dea05265776f2b57115f36e8a31ed7720cce2cd0..109f36e8892cc2e50d88054459321007ea00cf93 100644 +index 368693d93700390915f538de37409b5a37f916b7..57a1b4f0e179deec31bcda23a1ebafe2c745df11 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java @@ -484,6 +484,29 @@ public final class CraftMagicNumbers implements UnsafeValues { diff --git a/patches/server/0698-Add-paper-mobcaps-and-paper-playermobcaps.patch b/patches/server/0698-Add-paper-mobcaps-and-paper-playermobcaps.patch index 33f9ec9aab..55f32e2070 100644 --- a/patches/server/0698-Add-paper-mobcaps-and-paper-playermobcaps.patch +++ b/patches/server/0698-Add-paper-mobcaps-and-paper-playermobcaps.patch @@ -286,10 +286,10 @@ index bf3fb416d36a19958033cdbf5cc313556fa0201b..0a49769bfa83d0b9c435e3ab4bba8597 // Paper start - add parameters and int ret type spawnCategoryForChunk(group, world, chunk, checker, runner, Integer.MAX_VALUE, null); diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index 0aead1e438c4c2c8c138697e9afbf52323ebf6ca..8c592dcae27b91edd6ca9374643097cf73f12750 100644 +index 049861abd721a964c965177719fe5bc2d04214a0..a6e5333c6e339a3a1853a6023a2e68c046811a4d 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -2167,6 +2167,11 @@ public final class CraftServer implements Server { +@@ -2166,6 +2166,11 @@ public final class CraftServer implements Server { @Override public int getSpawnLimit(SpawnCategory spawnCategory) { diff --git a/patches/server/0703-Execute-chunk-tasks-mid-tick.patch b/patches/server/0703-Execute-chunk-tasks-mid-tick.patch index ea9e14db38..3701b69afc 100644 --- a/patches/server/0703-Execute-chunk-tasks-mid-tick.patch +++ b/patches/server/0703-Execute-chunk-tasks-mid-tick.patch @@ -19,7 +19,7 @@ index 23e564b05ba438924180c91f9b19a60731eedd1b..5ec241d49ff5e3a161a39006f05823a5 private MinecraftTimings() {} diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 213033a59be4239f1225286764be83dcc6fbf973..0868805c78d991c602d8f1d1b5aeb5c790c13384 100644 +index 34619d107231fe188d2b4c8eeefba8b6eaf4d3a5..4fb05a2be3ff06ceddae37e1592db548c727a056 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -1305,6 +1305,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop list = ImmutableList.of(new PhantomSpawner(), new PatrolSpawner(), new CatSpawner(), new VillageSiege(), new WanderingTraderSpawner(worlddata)); LevelStem worlddimension = iregistry.get(actualDimension); diff --git a/patches/server/0794-API-for-creating-command-sender-which-forwards-feedb.patch b/patches/server/0794-API-for-creating-command-sender-which-forwards-feedb.patch index 183e135734..a29e0b80b7 100644 --- a/patches/server/0794-API-for-creating-command-sender-which-forwards-feedb.patch +++ b/patches/server/0794-API-for-creating-command-sender-which-forwards-feedb.patch @@ -122,10 +122,10 @@ index 0000000000000000000000000000000000000000..e3a5f1ec376319bdfda87fa27ae217bf + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index c41954c1c96c5b9e0ee49237e9dc6831a75c635e..82099415303e91016ed02b0ca75f1437206704c1 100644 +index 759d091593b75419e275e79eaa3afbfbef6aee10..11f133dccb7bb837d369b2b41f96b26875dc6967 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -2001,6 +2001,13 @@ public final class CraftServer implements Server { +@@ -2000,6 +2000,13 @@ public final class CraftServer implements Server { return console.console; } diff --git a/patches/server/0795-Add-missing-structure-set-seed-configs.patch b/patches/server/0795-Add-missing-structure-set-seed-configs.patch index d07c11c2f7..4c87ea9fcb 100644 --- a/patches/server/0795-Add-missing-structure-set-seed-configs.patch +++ b/patches/server/0795-Add-missing-structure-set-seed-configs.patch @@ -20,10 +20,10 @@ seeds/salts to the frequency reducer which has a similar effect. Co-authored-by: William Blake Galbreath diff --git a/src/main/java/net/minecraft/world/level/chunk/ChunkGenerator.java b/src/main/java/net/minecraft/world/level/chunk/ChunkGenerator.java -index 95dd058fca280a1e16f3d327be2aabeab91be534..7e9c388179c75a233d9b179ea1e00428ac65ee99 100644 +index 9ef0937b7292ec118d2b65e9b098f5538410dbac..130ac7164c63374120ca2cdfbb1f6c3eefb4b7a5 100644 --- a/src/main/java/net/minecraft/world/level/chunk/ChunkGenerator.java +++ b/src/main/java/net/minecraft/world/level/chunk/ChunkGenerator.java -@@ -570,7 +570,7 @@ public abstract class ChunkGenerator { +@@ -568,7 +568,7 @@ public abstract class ChunkGenerator { } } diff --git a/patches/server/0798-Add-missing-Validate-calls-to-CraftServer-getSpawnLi.patch b/patches/server/0798-Add-missing-Validate-calls-to-CraftServer-getSpawnLi.patch index f635342837..4cfeaf7217 100644 --- a/patches/server/0798-Add-missing-Validate-calls-to-CraftServer-getSpawnLi.patch +++ b/patches/server/0798-Add-missing-Validate-calls-to-CraftServer-getSpawnLi.patch @@ -6,10 +6,10 @@ Subject: [PATCH] Add missing Validate calls to CraftServer#getSpawnLimit Copies appropriate checks from CraftWorld#getSpawnLimit diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index 82099415303e91016ed02b0ca75f1437206704c1..6a5ee59bada7922217a21f1130d329af259eb5c7 100644 +index 11f133dccb7bb837d369b2b41f96b26875dc6967..93f6b4ebf1ad238248b201878cfb3cdeee2515f9 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -2175,6 +2175,8 @@ public final class CraftServer implements Server { +@@ -2174,6 +2174,8 @@ public final class CraftServer implements Server { @Override public int getSpawnLimit(SpawnCategory spawnCategory) { // Paper start diff --git a/patches/server/0799-Add-GameEvent-tags.patch b/patches/server/0799-Add-GameEvent-tags.patch index 7e1526ecfe..b5efd3a733 100644 --- a/patches/server/0799-Add-GameEvent-tags.patch +++ b/patches/server/0799-Add-GameEvent-tags.patch @@ -46,10 +46,10 @@ index 0000000000000000000000000000000000000000..e7d9fd2702a1ce96596580fff8f5ee4f + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index 6a5ee59bada7922217a21f1130d329af259eb5c7..8ad83861bd928500b206fdff341671d773efc223 100644 +index 93f6b4ebf1ad238248b201878cfb3cdeee2515f9..1e38084012b576fcd26c1d432fd8b275d1054d7f 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -2586,6 +2586,15 @@ public final class CraftServer implements Server { +@@ -2585,6 +2585,15 @@ public final class CraftServer implements Server { return (org.bukkit.Tag) new CraftEntityTag(BuiltInRegistries.ENTITY_TYPE, entityTagKey); } } @@ -65,7 +65,7 @@ index 6a5ee59bada7922217a21f1130d329af259eb5c7..8ad83861bd928500b206fdff341671d7 default -> throw new IllegalArgumentException(); } -@@ -2618,6 +2627,13 @@ public final class CraftServer implements Server { +@@ -2617,6 +2626,13 @@ public final class CraftServer implements Server { net.minecraft.core.Registry> entityTags = BuiltInRegistries.ENTITY_TYPE; return entityTags.getTags().map(pair -> (org.bukkit.Tag) new CraftEntityTag(entityTags, pair.getFirst())).collect(ImmutableList.toImmutableList()); } diff --git a/patches/server/0800-Execute-chunk-tasks-fairly-for-worlds-while-waiting-.patch b/patches/server/0800-Execute-chunk-tasks-fairly-for-worlds-while-waiting-.patch index e0c24f58e2..46b999bc98 100644 --- a/patches/server/0800-Execute-chunk-tasks-fairly-for-worlds-while-waiting-.patch +++ b/patches/server/0800-Execute-chunk-tasks-fairly-for-worlds-while-waiting-.patch @@ -9,7 +9,7 @@ This might result in chunks loading far slower in the nether, for example. diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 6986d5475b090bca60b5ae892512fd5e55ae9b07..fa28023738fc50ac6c28e12bb7bbe249ddfc9a4a 100644 +index 1b1b7560b7ae59c5da7ad0e3dfae32cbcaeedcbd..d0eedbf2970bd839422f2c911abf20d2c90c0177 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -1308,6 +1308,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop(this.worlds.values()); } @@ -60,7 +60,7 @@ index 6dcbc6993a2462bc13820d3f8a77c188705fb6c2..bb0b7081c400b3928677d3c41e398053 public DedicatedPlayerList getHandle() { return this.playerList; } -@@ -1136,6 +1141,7 @@ public final class CraftServer implements Server { +@@ -1135,6 +1140,7 @@ public final class CraftServer implements Server { @Override public World createWorld(WorldCreator creator) { Preconditions.checkState(this.console.getAllLevels().iterator().hasNext(), "Cannot create additional worlds on STARTUP"); @@ -68,7 +68,7 @@ index 6dcbc6993a2462bc13820d3f8a77c188705fb6c2..bb0b7081c400b3928677d3c41e398053 Validate.notNull(creator, "Creator may not be null"); String name = creator.name(); -@@ -1274,6 +1280,7 @@ public final class CraftServer implements Server { +@@ -1273,6 +1279,7 @@ public final class CraftServer implements Server { @Override public boolean unloadWorld(World world, boolean save) { diff --git a/patches/server/0857-Don-t-broadcast-messages-to-command-blocks.patch b/patches/server/0857-Don-t-broadcast-messages-to-command-blocks.patch index 0ba2da5073..dc14955f0b 100644 --- a/patches/server/0857-Don-t-broadcast-messages-to-command-blocks.patch +++ b/patches/server/0857-Don-t-broadcast-messages-to-command-blocks.patch @@ -20,10 +20,10 @@ index 7c7e5f3c0f9cd1f16192a8fc8163da9b2d9519d5..888936385196a178ab8b730fd5e4fff4 Date date = new Date(); diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index bb0b7081c400b3928677d3c41e398053acd301d9..d275ca28f145f3e9bbf21e591129e6108efac57d 100644 +index c51f9a26c6a41158ebdc83adfb495a5412a1197b..52dec44a061b773c4467279c766f504d079dd1a4 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -1774,7 +1774,7 @@ public final class CraftServer implements Server { +@@ -1773,7 +1773,7 @@ public final class CraftServer implements Server { // Paper end Set recipients = new HashSet<>(); for (Permissible permissible : this.getPluginManager().getPermissionSubscriptions(permission)) { diff --git a/patches/server/0879-Add-Velocity-IP-Forwarding-Support.patch b/patches/server/0879-Add-Velocity-IP-Forwarding-Support.patch index 57ecf1f666..12033da59a 100644 --- a/patches/server/0879-Add-Velocity-IP-Forwarding-Support.patch +++ b/patches/server/0879-Add-Velocity-IP-Forwarding-Support.patch @@ -213,10 +213,10 @@ index 0bedd9eadbfe1ce290f22d6c648571e25e3ae0e9..093822a5256e8e919350a000239a3e92 } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index 9c97e31a00bf226c7298242a6e0d4c0b35a49817..621919a4a45caa73a43020fdca24764d95d89fd2 100644 +index 52dec44a061b773c4467279c766f504d079dd1a4..bbb8335dae0a3e2761e6bbb8dc723bcf28cd82ba 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -780,7 +780,7 @@ public final class CraftServer implements Server { +@@ -779,7 +779,7 @@ public final class CraftServer implements Server { @Override public long getConnectionThrottle() { // Spigot Start - Automatically set connection throttle for bungee configurations diff --git a/patches/server/0881-Add-NamespacedKey-biome-methods.patch b/patches/server/0881-Add-NamespacedKey-biome-methods.patch index 60d181b0f7..81bbcfdda0 100644 --- a/patches/server/0881-Add-NamespacedKey-biome-methods.patch +++ b/patches/server/0881-Add-NamespacedKey-biome-methods.patch @@ -6,10 +6,10 @@ Subject: [PATCH] Add NamespacedKey biome methods Co-authored-by: Thonk <30448663+ExcessiveAmountsOfZombies@users.noreply.github.com> diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java -index 109f36e8892cc2e50d88054459321007ea00cf93..adde9b49bf043112765734716f01b0d29456e46c 100644 +index 57a1b4f0e179deec31bcda23a1ebafe2c745df11..2d5c4d4170e9a7cae9200280de3706e4be317413 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java -@@ -607,6 +607,19 @@ public final class CraftMagicNumbers implements UnsafeValues { +@@ -602,6 +602,19 @@ public final class CraftMagicNumbers implements UnsafeValues { Preconditions.checkArgument(material.isBlock(), material + " is not a block"); return getBlock(material).hasCollision; } diff --git a/patches/server/0882-Fix-plugin-loggers-on-server-shutdown.patch b/patches/server/0882-Fix-plugin-loggers-on-server-shutdown.patch index f974636c1c..6ed34a73da 100644 --- a/patches/server/0882-Fix-plugin-loggers-on-server-shutdown.patch +++ b/patches/server/0882-Fix-plugin-loggers-on-server-shutdown.patch @@ -37,7 +37,7 @@ index 0000000000000000000000000000000000000000..c1d3bac79bb8b4796c013ff4472f75dc + } +} diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 0e04083ff0598451c66731b1518b2eb6367ae36c..710ca7d3a5659953f64bc6dccdd93b43300961cc 100644 +index 1b56bb2869d3cf22670b508133968e66493a5bec..753a917d34a1e1c1521a8916bc8e44a6acd90a46 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -998,6 +998,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop