From e19f48475db512e0b6f699c7a930434ea36cb753 Mon Sep 17 00:00:00 2001 From: Bjarne Koll Date: Fri, 25 Oct 2024 19:15:40 +0200 Subject: [PATCH] Test compile fixes --- .../0457-Fix-SpawnerEntry-Equipment-API.patch | 4 ++-- patches/server/0004-Test-changes.patch | 4 ++-- .../0156-Add-PlayerArmorChangeEvent.patch | 22 +++++++++---------- ...-Add-methods-to-get-translation-keys.patch | 16 +++++++++----- ...gistryAccess-for-managing-Registries.patch | 4 ++-- ...d-missing-structure-set-seed-configs.patch | 6 ++--- .../0957-Fix-issues-with-Recipe-API.patch | 4 ++-- patches/server/0979-Anti-Xray.patch | 11 +++++++++- .../0993-Registry-Modification-API.patch | 4 ++-- ...0994-Add-registry-entry-and-builders.patch | 2 +- 10 files changed, 45 insertions(+), 32 deletions(-) diff --git a/patches/api/0457-Fix-SpawnerEntry-Equipment-API.patch b/patches/api/0457-Fix-SpawnerEntry-Equipment-API.patch index 201dc87c42..e170eabd17 100644 --- a/patches/api/0457-Fix-SpawnerEntry-Equipment-API.patch +++ b/patches/api/0457-Fix-SpawnerEntry-Equipment-API.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Fix SpawnerEntry$Equipment API diff --git a/src/main/java/org/bukkit/block/spawner/SpawnerEntry.java b/src/main/java/org/bukkit/block/spawner/SpawnerEntry.java -index fc1c0435dfea121923eb1fe0182880752f321143..e167003cdf014e1ef4c475d1138c4462153fbc85 100644 +index fc1c0435dfea121923eb1fe0182880752f321143..bc8ccd139df6072f9744cfb85ad0070369600aa1 100644 --- a/src/main/java/org/bukkit/block/spawner/SpawnerEntry.java +++ b/src/main/java/org/bukkit/block/spawner/SpawnerEntry.java @@ -120,27 +120,29 @@ public class SpawnerEntry { @@ -22,7 +22,7 @@ index fc1c0435dfea121923eb1fe0182880752f321143..e167003cdf014e1ef4c475d1138c4462 + * Set the loot table for the spawned entity's equipment slots. *
- * To remove a loot table use null. -+ * To remove a loot table use {@link org.bukkit.loot.LootTables#EMPTY}. ++ * To remove a loot table use the empty loot table. * * @param table this {@link org.bukkit.entity.Mob} will have. */ diff --git a/patches/server/0004-Test-changes.patch b/patches/server/0004-Test-changes.patch index adf6660553..2bf3cdb566 100644 --- a/patches/server/0004-Test-changes.patch +++ b/patches/server/0004-Test-changes.patch @@ -32,7 +32,7 @@ index d4a5229b4df544ff60cdaee80c8ae301faf2a235..41b000aaa71dca3fb392ae657be16e05 } diff --git a/src/test/java/io/papermc/paper/registry/RegistryKeyTest.java b/src/test/java/io/papermc/paper/registry/RegistryKeyTest.java new file mode 100644 -index 0000000000000000000000000000000000000000..fe52d229c31526cc32f6422328efe92edf75a7ff +index 0000000000000000000000000000000000000000..d8857a05858585113bc7efde3416748effb53d01 --- /dev/null +++ b/src/test/java/io/papermc/paper/registry/RegistryKeyTest.java @@ -0,0 +1,34 @@ @@ -65,7 +65,7 @@ index 0000000000000000000000000000000000000000..fe52d229c31526cc32f6422328efe92e + @ParameterizedTest + @MethodSource("data") + void testApiRegistryKeysExist(final RegistryKey key) { -+ final Optional> registry = RegistryHelper.getRegistry().registry(ResourceKey.createRegistryKey(ResourceLocation.parse(key.key().asString()))); ++ final Optional> registry = RegistryHelper.getRegistry().lookup(ResourceKey.createRegistryKey(ResourceLocation.parse(key.key().asString()))); + assertTrue(registry.isPresent(), "Missing vanilla registry for " + key.key().asString()); + + } diff --git a/patches/server/0156-Add-PlayerArmorChangeEvent.patch b/patches/server/0156-Add-PlayerArmorChangeEvent.patch index cd684e2357..3655d4701a 100644 --- a/patches/server/0156-Add-PlayerArmorChangeEvent.patch +++ b/patches/server/0156-Add-PlayerArmorChangeEvent.patch @@ -24,7 +24,7 @@ index f2f8fbc8a8cf32bcba0ad7ac9b6cdd75468e062a..76b71af07a311bc415b36f517afab315 } diff --git a/src/test/java/io/papermc/paper/inventory/item/ArmorSlotTypeMaterialTest.java b/src/test/java/io/papermc/paper/inventory/item/ArmorSlotTypeMaterialTest.java new file mode 100644 -index 0000000000000000000000000000000000000000..8943cef5cdb8269080b9f0e2edbad5d5ea8b421d +index 0000000000000000000000000000000000000000..1431b3faf081dc3ee5b33639bdc90c5057ae7027 --- /dev/null +++ b/src/test/java/io/papermc/paper/inventory/item/ArmorSlotTypeMaterialTest.java @@ -0,0 +1,75 @@ @@ -34,10 +34,10 @@ index 0000000000000000000000000000000000000000..8943cef5cdb8269080b9f0e2edbad5d5 +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Stream; ++import net.minecraft.core.component.DataComponents; +import net.minecraft.world.entity.EquipmentSlot; -+import net.minecraft.world.item.Equipable; +import net.minecraft.world.item.Item; -+import net.minecraft.world.item.ItemStack; ++import net.minecraft.world.item.equipment.Equippable; +import org.bukkit.Material; +import org.bukkit.craftbukkit.util.CraftMagicNumbers; +import org.bukkit.support.environment.AllFeatures; @@ -65,23 +65,23 @@ index 0000000000000000000000000000000000000000..8943cef5cdb8269080b9f0e2edbad5d5 + @MethodSource("slotTypeParams") + public void testSlotType(PlayerArmorChangeEvent.SlotType slotType, Material item) { + final Item nmsItem = CraftMagicNumbers.getItem(item); -+ final Equipable equipable = Equipable.get(new ItemStack(nmsItem)); -+ assertNotNull(equipable, item + " isn't equipable"); ++ final Equippable equippable = nmsItem.components().get(DataComponents.EQUIPPABLE); ++ assertNotNull(equippable, item + " isn't equipable"); + final EquipmentSlot slot = switch (slotType) { + case HEAD -> EquipmentSlot.HEAD; + case CHEST -> EquipmentSlot.CHEST; + case LEGS -> EquipmentSlot.LEGS; + case FEET -> EquipmentSlot.FEET; + }; -+ assertEquals(equipable.getEquipmentSlot(), slot, item + " isn't set to the right slot"); ++ assertEquals(equippable.slot(), slot, item + " isn't set to the right slot"); + } + + public static Stream equipableParams() { + final List parameters = new ArrayList<>(); + for (final Item item : net.minecraft.core.registries.BuiltInRegistries.ITEM) { -+ final Equipable equipable = Equipable.get(new ItemStack(item)); -+ if (equipable != null) { -+ parameters.add(new Object[]{equipable, item}); ++ final Equippable equippable = item.components().get(DataComponents.EQUIPPABLE); ++ if (equippable != null) { ++ parameters.add(new Object[]{equippable, item}); + } + } + return parameters.stream(); @@ -89,8 +89,8 @@ index 0000000000000000000000000000000000000000..8943cef5cdb8269080b9f0e2edbad5d5 + + @ParameterizedTest(name = "{argumentsWithNames}") + @MethodSource("equipableParams") -+ public void testEquipable(Equipable equipable, Item item) { -+ final EquipmentSlot equipmentSlot = equipable.getEquipmentSlot(); ++ public void testEquipable(Equippable equipable, Item item) { ++ final EquipmentSlot equipmentSlot = equipable.slot(); + PlayerArmorChangeEvent.SlotType slotType = switch (equipmentSlot) { + case HEAD -> PlayerArmorChangeEvent.SlotType.HEAD; + case CHEST -> PlayerArmorChangeEvent.SlotType.CHEST; diff --git a/patches/server/0401-Add-methods-to-get-translation-keys.patch b/patches/server/0401-Add-methods-to-get-translation-keys.patch index bc50b97d02..8ff2f02eb9 100644 --- a/patches/server/0401-Add-methods-to-get-translation-keys.patch +++ b/patches/server/0401-Add-methods-to-get-translation-keys.patch @@ -93,20 +93,22 @@ index 4921fc085c9d60c74028ef390325e26c598e8df1..4941e0afff8df5f10f06c715b54bf58e case BALL: return FireworkExplosion.Shape.SMALL_BALL; diff --git a/src/test/java/io/papermc/paper/world/TranslationKeyTest.java b/src/test/java/io/papermc/paper/world/TranslationKeyTest.java -index 7f8b6462d2a1bbd39a870d2543bebc135f7eb45b..4001c73e833ebf17baa22463dd197cee8ad67266 100644 +index 7f8b6462d2a1bbd39a870d2543bebc135f7eb45b..e8d5c3eb8ad98b2082bdd33d96bfb1d7124ea186 100644 --- a/src/test/java/io/papermc/paper/world/TranslationKeyTest.java +++ b/src/test/java/io/papermc/paper/world/TranslationKeyTest.java -@@ -1,11 +1,29 @@ +@@ -1,11 +1,32 @@ package io.papermc.paper.world; import com.destroystokyo.paper.ClientOption; +import java.util.Locale; +import java.util.Map; -+import net.minecraft.core.registries.BuiltInRegistries; ++import net.minecraft.core.registries.Registries; +import net.minecraft.network.chat.contents.TranslatableContents; +import net.minecraft.resources.ResourceKey; +import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.player.ChatVisiblity; ++import net.minecraft.world.flag.FeatureFlags; ++import net.minecraft.world.level.GameRules; +import net.minecraft.world.level.GameType; +import net.minecraft.world.level.biome.Biome; import org.bukkit.Difficulty; @@ -115,6 +117,7 @@ index 7f8b6462d2a1bbd39a870d2543bebc135f7eb45b..4001c73e833ebf17baa22463dd197cee +import org.bukkit.GameRule; +import org.bukkit.MusicInstrument; +import org.bukkit.attribute.Attribute; ++import org.bukkit.craftbukkit.CraftWorld; +import org.bukkit.craftbukkit.util.CraftNamespacedKey; +import org.bukkit.support.RegistryHelper; +import org.bukkit.support.environment.AllFeatures; @@ -126,7 +129,7 @@ index 7f8b6462d2a1bbd39a870d2543bebc135f7eb45b..4001c73e833ebf17baa22463dd197cee public class TranslationKeyTest { @Test -@@ -15,4 +33,69 @@ public class TranslationKeyTest { +@@ -15,4 +36,70 @@ public class TranslationKeyTest { Assertions.assertEquals(ChatVisiblity.valueOf(chatVisibility.name()).getKey(), chatVisibility.translationKey(), chatVisibility + "'s translation key doesn't match"); } } @@ -140,8 +143,9 @@ index 7f8b6462d2a1bbd39a870d2543bebc135f7eb45b..4001c73e833ebf17baa22463dd197cee + + @Test + public void testGameruleKeys() { ++ final Map> gameRules = CraftWorld.getGameRulesNMS(new GameRules(FeatureFlags.REGISTRY.allFlags())); + for (GameRule rule : GameRule.values()) { -+ Assertions.assertEquals(org.bukkit.craftbukkit.CraftWorld.getGameRulesNMS().get(rule.getName()).getDescriptionId(), rule.translationKey(), rule.getName() + "'s translation doesn't match"); ++ Assertions.assertEquals(gameRules.get(rule.getName()).getDescriptionId(), rule.translationKey(), rule.getName() + "'s translation doesn't match"); + } + } + @@ -189,7 +193,7 @@ index 7f8b6462d2a1bbd39a870d2543bebc135f7eb45b..4001c73e833ebf17baa22463dd197cee + + @Test + public void testMusicInstrument() { -+ for (final ResourceLocation nms : BuiltInRegistries.INSTRUMENT.keySet()) { ++ for (final ResourceLocation nms : RegistryHelper.getRegistry().lookupOrThrow(Registries.INSTRUMENT).keySet()) { + final MusicInstrument bukkit = MusicInstrument.getByKey(CraftNamespacedKey.fromMinecraft(nms)); + Assertions.assertNotNull(bukkit, "Missing bukkit instrument for " + nms); + Assertions.assertEquals(nms.toLanguageKey("instrument"), bukkit.translationKey(), "translation key mismatch for " + bukkit); diff --git a/patches/server/0467-Add-RegistryAccess-for-managing-Registries.patch b/patches/server/0467-Add-RegistryAccess-for-managing-Registries.patch index 5c38218948..2f3085960e 100644 --- a/patches/server/0467-Add-RegistryAccess-for-managing-Registries.patch +++ b/patches/server/0467-Add-RegistryAccess-for-managing-Registries.patch @@ -1004,7 +1004,7 @@ index 0000000000000000000000000000000000000000..a80b0ded74c0be657e734de61cbf5e32 + } +} diff --git a/src/test/java/io/papermc/paper/registry/RegistryKeyTest.java b/src/test/java/io/papermc/paper/registry/RegistryKeyTest.java -index fe52d229c31526cc32f6422328efe92edf75a7ff..67dadb1765a5ef9a391a459224e233f38201f5d5 100644 +index d8857a05858585113bc7efde3416748effb53d01..41c38b1b6d25c7a7ed08d70b19f5f4a70fc2df94 100644 --- a/src/test/java/io/papermc/paper/registry/RegistryKeyTest.java +++ b/src/test/java/io/papermc/paper/registry/RegistryKeyTest.java @@ -1,15 +1,19 @@ @@ -1030,7 +1030,7 @@ index fe52d229c31526cc32f6422328efe92edf75a7ff..67dadb1765a5ef9a391a459224e233f3 @AllFeatures @@ -29,6 +33,12 @@ class RegistryKeyTest { void testApiRegistryKeysExist(final RegistryKey key) { - final Optional> registry = RegistryHelper.getRegistry().registry(ResourceKey.createRegistryKey(ResourceLocation.parse(key.key().asString()))); + final Optional> registry = RegistryHelper.getRegistry().lookup(ResourceKey.createRegistryKey(ResourceLocation.parse(key.key().asString()))); assertTrue(registry.isPresent(), "Missing vanilla registry for " + key.key().asString()); + } diff --git a/patches/server/0655-Add-missing-structure-set-seed-configs.patch b/patches/server/0655-Add-missing-structure-set-seed-configs.patch index 42bd7f0c4b..8677197bdc 100644 --- a/patches/server/0655-Add-missing-structure-set-seed-configs.patch +++ b/patches/server/0655-Add-missing-structure-set-seed-configs.patch @@ -316,7 +316,7 @@ index e76f96a5c48d1eda2f9bbb3e11dd79f23f9ab75c..2b263246135c85aa225120519e9702a6 } diff --git a/src/test/java/io/papermc/paper/world/structure/StructureSeedConfigTest.java b/src/test/java/io/papermc/paper/world/structure/StructureSeedConfigTest.java new file mode 100644 -index 0000000000000000000000000000000000000000..c77345f7e0c9bf179b8b35a8b300085f31fd45af +index 0000000000000000000000000000000000000000..cc1fb5ae9e0898735771c6163c9b90658fb61eed --- /dev/null +++ b/src/test/java/io/papermc/paper/world/structure/StructureSeedConfigTest.java @@ -0,0 +1,77 @@ @@ -356,10 +356,10 @@ index 0000000000000000000000000000000000000000..c77345f7e0c9bf179b8b35a8b300085f + final SpigotWorldConfig config = PaperConfigurations.SPIGOT_WORLD_DEFAULTS.get(); + + -+ final Registry structureSets = RegistryHelper.getRegistry().registryOrThrow(Registries.STRUCTURE_SET); ++ final Registry structureSets = RegistryHelper.getRegistry().lookupOrThrow(Registries.STRUCTURE_SET); + for (final ResourceKey setKey : structureSets.registryKeySet()) { + assertEquals(ResourceLocation.DEFAULT_NAMESPACE, setKey.location().getNamespace()); -+ final StructureSet set = structureSets.getOrThrow(setKey); ++ final StructureSet set = structureSets.getValueOrThrow(setKey); + if (setKey == BuiltinStructureSets.STRONGHOLDS) { // special case due to seed matching world seed + assertEquals(0, set.placement().salt); + continue; diff --git a/patches/server/0957-Fix-issues-with-Recipe-API.patch b/patches/server/0957-Fix-issues-with-Recipe-API.patch index ab2b6a47ef..17a8c00f64 100644 --- a/patches/server/0957-Fix-issues-with-Recipe-API.patch +++ b/patches/server/0957-Fix-issues-with-Recipe-API.patch @@ -73,7 +73,7 @@ index 0000000000000000000000000000000000000000..45ab2b6d32b29cb663df848534e1aa68 + } +} diff --git a/src/test/java/org/bukkit/support/DummyServerHelper.java b/src/test/java/org/bukkit/support/DummyServerHelper.java -index 55c05c16a80c489cdda2fd03c943921d38d978e9..6855816ec5fd232b53622c316e45b3c081297085 100644 +index 55c05c16a80c489cdda2fd03c943921d38d978e9..309d371247adcddf0a1b370cc5faff3e6e01cb0f 100644 --- a/src/test/java/org/bukkit/support/DummyServerHelper.java +++ b/src/test/java/org/bukkit/support/DummyServerHelper.java @@ -92,6 +92,15 @@ public final class DummyServerHelper { @@ -84,7 +84,7 @@ index 55c05c16a80c489cdda2fd03c943921d38d978e9..6855816ec5fd232b53622c316e45b3c0 + // Paper start - add test for recipe conversion + when(instance.recipeIterator()).thenAnswer(ignored -> + com.google.common.collect.Iterators.transform( -+ RegistryHelper.getDataPack().getRecipeManager().byType.entries().iterator(), ++ RegistryHelper.getDataPack().getRecipeManager().recipes.byType.entries().iterator(), + input -> input.getValue().toBukkitRecipe() + ) + ); diff --git a/patches/server/0979-Anti-Xray.patch b/patches/server/0979-Anti-Xray.patch index 88fd107647..3a140d851c 100644 --- a/patches/server/0979-Anti-Xray.patch +++ b/patches/server/0979-Anti-Xray.patch @@ -1519,9 +1519,18 @@ index 303e59be721d0e16e8822cf4e407595348ee7abf..51f74dd7b276e858889803d7f341d735 int getSerializedSize(); diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/SerializableChunkData.java b/src/main/java/net/minecraft/world/level/chunk/storage/SerializableChunkData.java -index b86b3bf713668999a21c4120b1d16c295531b2ad..f6c42532d4921628072d44313404696890087b9f 100644 +index b86b3bf713668999a21c4120b1d16c295531b2ad..eba3e34e5b129050bf6eaed6ce4e690357a3de20 100644 --- a/src/main/java/net/minecraft/world/level/chunk/storage/SerializableChunkData.java +++ b/src/main/java/net/minecraft/world/level/chunk/storage/SerializableChunkData.java +@@ -79,7 +79,7 @@ import org.slf4j.Logger; + // CraftBukkit - persistentDataContainer + public record SerializableChunkData(Registry biomeRegistry, ChunkPos chunkPos, int minSectionY, long lastUpdateTime, long inhabitedTime, ChunkStatus chunkStatus, @Nullable BlendingData.Packed blendingData, @Nullable BelowZeroRetrogen belowZeroRetrogen, UpgradeData upgradeData, @Nullable long[] carvingMask, Map heightmaps, ChunkAccess.PackedTicks packedTicks, ShortList[] postProcessingSections, boolean lightCorrect, List sectionData, List entities, List blockEntities, CompoundTag structureData, @Nullable Tag persistentDataContainer) { + +- public static final Codec> BLOCK_STATE_CODEC = PalettedContainer.codecRW(Block.BLOCK_STATE_REGISTRY, BlockState.CODEC, PalettedContainer.Strategy.SECTION_STATES, Blocks.AIR.defaultBlockState()); ++ public static final Codec> BLOCK_STATE_CODEC = PalettedContainer.codecRW(Block.BLOCK_STATE_REGISTRY, BlockState.CODEC, PalettedContainer.Strategy.SECTION_STATES, Blocks.AIR.defaultBlockState(), null); // Paper start - Anti-Xray + private static final Logger LOGGER = LogUtils.getLogger(); + private static final String TAG_UPGRADE_DATA = "UpgradeData"; + private static final String BLOCK_TICKS_TAG = "block_ticks"; @@ -111,6 +111,7 @@ public record SerializableChunkData(Registry biomeRegistry, ChunkPos chun @Nullable diff --git a/patches/server/0993-Registry-Modification-API.patch b/patches/server/0993-Registry-Modification-API.patch index d61a98a7a4..9568730b7f 100644 --- a/patches/server/0993-Registry-Modification-API.patch +++ b/patches/server/0993-Registry-Modification-API.patch @@ -1393,7 +1393,7 @@ index 0000000000000000000000000000000000000000..8bee1a5ed877a04e4d027593df1f42ce +io.papermc.paper.registry.event.RegistryEventTypeProviderImpl diff --git a/src/test/java/io/papermc/paper/registry/RegistryBuilderTest.java b/src/test/java/io/papermc/paper/registry/RegistryBuilderTest.java new file mode 100644 -index 0000000000000000000000000000000000000000..47b8ebac8496179008b8932c5ca2aadc274e24e0 +index 0000000000000000000000000000000000000000..ceef7b5864deb1d7c6aa5630febe86ba9427bdc4 --- /dev/null +++ b/src/test/java/io/papermc/paper/registry/RegistryBuilderTest.java @@ -0,0 +1,36 @@ @@ -1426,7 +1426,7 @@ index 0000000000000000000000000000000000000000..47b8ebac8496179008b8932c5ca2aadc + @ParameterizedTest + @MethodSource("registries") + void testEquality(final ResourceKey> resourceKey, final PaperRegistryBuilder.Filler filler) { -+ final Registry registry = RegistryHelper.getRegistry().registryOrThrow(resourceKey); ++ final Registry registry = RegistryHelper.getRegistry().lookupOrThrow(resourceKey); + for (final Map.Entry, M> entry : registry.entrySet()) { + final M built = filler.fill(new Conversions(new RegistryOps.HolderLookupAdapter(RegistryHelper.getRegistry())), PaperRegistries.fromNms(entry.getKey()), entry.getValue()).build(); + assertEquals(entry.getValue(), built); diff --git a/patches/server/0994-Add-registry-entry-and-builders.patch b/patches/server/0994-Add-registry-entry-and-builders.patch index 8f2663ac94..0355a6b299 100644 --- a/patches/server/0994-Add-registry-entry-and-builders.patch +++ b/patches/server/0994-Add-registry-entry-and-builders.patch @@ -442,7 +442,7 @@ index ac9b4328cd55a68664a3f71186bc9a7be7cd9658..ea9fe1f8b1a1685ea975eba0ca418a83 @Override public NamespacedKey getKey() { diff --git a/src/test/java/io/papermc/paper/registry/RegistryBuilderTest.java b/src/test/java/io/papermc/paper/registry/RegistryBuilderTest.java -index 47b8ebac8496179008b8932c5ca2aadc274e24e0..814675bf67fd02e8cd2311dce60eeef651ef16f1 100644 +index ceef7b5864deb1d7c6aa5630febe86ba9427bdc4..4d4632da6bf1bde85115dde2e2f7e353bd392176 100644 --- a/src/test/java/io/papermc/paper/registry/RegistryBuilderTest.java +++ b/src/test/java/io/papermc/paper/registry/RegistryBuilderTest.java @@ -1,11 +1,16 @@