From d333b32d4fe4bf41abfd09092ff0724f92e4fc63 Mon Sep 17 00:00:00 2001 From: Bjarne Koll Date: Fri, 25 Oct 2024 18:08:28 +0200 Subject: [PATCH] Compiler issue v5 --- .../Ability-to-apply-mending-to-XP-API.patch | 6 +++--- patches/server/Add-FeatureFlag-API.patch | 6 ++++-- patches/server/Add-GameEvent-tags.patch | 2 +- patches/server/Adventure.patch | 14 +++++++++----- patches/server/Expand-ArmorStand-API.patch | 2 +- .../Expose-furnace-minecart-push-values.patch | 10 ++++++---- patches/server/More-Teleport-API.patch | 4 +++- patches/server/Paper-config-files.patch | 12 ++++++------ patches/server/Paper-dumpitem-command.patch | 2 +- 9 files changed, 34 insertions(+), 24 deletions(-) diff --git a/patches/server/Ability-to-apply-mending-to-XP-API.patch b/patches/server/Ability-to-apply-mending-to-XP-API.patch index 3ac3247762..2ccb771d4a 100644 --- a/patches/server/Ability-to-apply-mending-to-XP-API.patch +++ b/patches/server/Ability-to-apply-mending-to-XP-API.patch @@ -22,7 +22,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override - public void giveExp(int exp) { -+ // Paper start ++ // Paper start - ability to apply mending + public int applyMending(int amount) { + ServerPlayer handle = this.getHandle(); + // Logic copied from EntityExperienceOrb and remapped to unobfuscated methods/properties @@ -31,7 +31,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + .getRandomItemWith(net.minecraft.world.item.enchantment.EnchantmentEffectComponents.REPAIR_WITH_XP, handle, net.minecraft.world.item.ItemStack::isDamaged); + final net.minecraft.world.item.ItemStack itemstack = stackEntry.map(net.minecraft.world.item.enchantment.EnchantedItemInUse::itemStack).orElse(net.minecraft.world.item.ItemStack.EMPTY); + if (!itemstack.isEmpty() && itemstack.getItem().components().has(net.minecraft.core.component.DataComponents.MAX_DAMAGE)) { -+ net.minecraft.world.entity.ExperienceOrb orb = net.minecraft.world.entity.EntityType.EXPERIENCE_ORB.create(handle.level()); ++ net.minecraft.world.entity.ExperienceOrb orb = net.minecraft.world.entity.EntityType.EXPERIENCE_ORB.create(handle.level(), net.minecraft.world.entity.EntitySpawnReason.COMMAND); + orb.value = amount; + orb.spawnReason = org.bukkit.entity.ExperienceOrb.SpawnReason.CUSTOM; + orb.setPosRaw(handle.getX(), handle.getY(), handle.getZ()); @@ -56,7 +56,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + if (applyMending) { + exp = this.applyMending(exp); + } -+ // Paper end ++ // Paper end - ability to apply mending this.getHandle().giveExperiencePoints(exp); } diff --git a/patches/server/Add-FeatureFlag-API.patch b/patches/server/Add-FeatureFlag-API.patch index 514de38bab..13471b9233 100644 --- a/patches/server/Add-FeatureFlag-API.patch +++ b/patches/server/Add-FeatureFlag-API.patch @@ -55,8 +55,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + public static final BiMap FLAGS = ImmutableBiMap.of( + FeatureFlag.VANILLA, FeatureFlags.VANILLA, -+ FeatureFlag.BUNDLE, FeatureFlags.BUNDLE, -+ FeatureFlag.TRADE_REBALANCE, FeatureFlags.TRADE_REBALANCE ++ FeatureFlag.TRADE_REBALANCE, FeatureFlags.TRADE_REBALANCE, ++ FeatureFlag.MINECART_IMPROVEMENTS, FeatureFlags.MINECART_IMPROVEMENTS, ++ FeatureFlag.REDSTONE_EXPERIMENTS, FeatureFlags.REDSTONE_EXPERIMENTS, ++ FeatureFlag.WINTER_DROP, FeatureFlags.WINTER_DROP + ); + + @Override diff --git a/patches/server/Add-GameEvent-tags.patch b/patches/server/Add-GameEvent-tags.patch index b1f15eb281..10607a0fde 100644 --- a/patches/server/Add-GameEvent-tags.patch +++ b/patches/server/Add-GameEvent-tags.patch @@ -37,7 +37,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + private static final Map> KEY_CACHE = Collections.synchronizedMap(new IdentityHashMap<>()); + @Override + public boolean isTagged(@NotNull GameEvent gameEvent) { -+ return registry.getHolderOrThrow(KEY_CACHE.computeIfAbsent(gameEvent, event -> ResourceKey.create(Registries.GAME_EVENT, CraftNamespacedKey.toMinecraft(event.getKey())))).is(tag); ++ return registry.getOrThrow(KEY_CACHE.computeIfAbsent(gameEvent, event -> ResourceKey.create(Registries.GAME_EVENT, CraftNamespacedKey.toMinecraft(event.getKey())))).is(tag); + } + + @Override diff --git a/patches/server/Adventure.patch b/patches/server/Adventure.patch index dc64632a87..a3802a51b8 100644 --- a/patches/server/Adventure.patch +++ b/patches/server/Adventure.patch @@ -61,6 +61,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import net.kyori.adventure.text.format.TextColor; +import net.kyori.adventure.text.format.TextDecoration; +import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer; ++import net.minecraft.commands.arguments.selector.SelectorPattern; +import net.minecraft.core.UUIDUtil; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.nbt.CompoundTag; @@ -146,7 +147,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @Subst("key") final String typeKey = isi.item.unwrapKey().orElseThrow().location().toString(); + return HoverEvent.ShowItem.showItem(Key.key(typeKey), isi.count, PaperAdventure.asAdventure(isi.getItemStack().getComponentsPatch())); + }, si -> { -+ final Item itemType = BuiltInRegistries.ITEM.get(PaperAdventure.asVanilla(si.item())); ++ final Item itemType = BuiltInRegistries.ITEM.getValue(PaperAdventure.asVanilla(si.item())); + final Map dataComponentsMap = si.dataComponents(); + final ItemStack stack = new ItemStack(BuiltInRegistries.ITEM.wrapAsHolder(itemType), si.count(), PaperAdventure.asVanilla(dataComponentsMap)); + return new net.minecraft.network.chat.HoverEvent.ItemStackInfo(stack); @@ -315,7 +316,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + }); + + static final MapCodec KEYBIND_COMPONENT_MAP_CODEC = KeybindContents.CODEC.xmap(k -> Component.keybind(k.getName()), k -> new KeybindContents(k.keybind())); -+ static final MapCodec SCORE_COMPONENT_INNER_MAP_CODEC = ScoreContents.INNER_CODEC.xmap(s -> Component.score(s.getName(), s.getObjective()), s -> new ScoreContents(s.name(), s.objective())); ++ static final MapCodec SCORE_COMPONENT_INNER_MAP_CODEC = ScoreContents.INNER_CODEC.xmap( ++ s -> Component.score(s.name().map(SelectorPattern::pattern, Function.identity()), s.objective()), ++ s -> new ScoreContents(SelectorPattern.parse(s.name()).>map(Either::left).result().orElse(Either.right(s.name())), s.objective()) ++ ); // TODO we might want to ask adventure for a nice way we can avoid parsing and flattening the SelectorPattern on every conversion. + static final MapCodec SCORE_COMPONENT_MAP_CODEC = SCORE_COMPONENT_INNER_MAP_CODEC.fieldOf("score"); + static final MapCodec SELECTOR_COMPONENT_MAP_CODEC = mapCodec((instance) -> { + return instance.group( @@ -1580,7 +1584,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + final DataComponentPatch.Builder builder = DataComponentPatch.builder(); + map.forEach((key, dataComponentValue) -> { -+ final DataComponentType type = requireNonNull(BuiltInRegistries.DATA_COMPONENT_TYPE.get(asVanilla(key))); ++ final DataComponentType type = requireNonNull(BuiltInRegistries.DATA_COMPONENT_TYPE.getValue(asVanilla(key))); + if (dataComponentValue instanceof DataComponentValue.Removed) { + builder.remove(type); + return; @@ -1895,7 +1899,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + GsonDataComponentValue.class, + PaperAdventure.DataComponentValueImpl.class, + (key, dataComponentValue) -> { -+ final @Nullable DataComponentType type = BuiltInRegistries.DATA_COMPONENT_TYPE.get(PaperAdventure.asVanilla(key)); ++ final @Nullable DataComponentType type = BuiltInRegistries.DATA_COMPONENT_TYPE.getValue(PaperAdventure.asVanilla(key)); + if (type == null) { + throw new IllegalArgumentException("Unknown data component type: " + key); + } @@ -1911,7 +1915,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + DataComponentValue.TagSerializable.class, + PaperAdventure.DataComponentValueImpl.class, + (key, tagSerializable) -> { -+ final @Nullable DataComponentType type = BuiltInRegistries.DATA_COMPONENT_TYPE.get(PaperAdventure.asVanilla(key)); ++ final @Nullable DataComponentType type = BuiltInRegistries.DATA_COMPONENT_TYPE.getValue(PaperAdventure.asVanilla(key)); + if (type == null) { + throw new IllegalArgumentException("Unknown data component type: " + key); + } diff --git a/patches/server/Expand-ArmorStand-API.patch b/patches/server/Expand-ArmorStand-API.patch index d748729128..5a1c1d9c1e 100644 --- a/patches/server/Expand-ArmorStand-API.patch +++ b/patches/server/Expand-ArmorStand-API.patch @@ -72,7 +72,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + for (org.bukkit.inventory.EquipmentSlot slot : slots) { + if (slot == org.bukkit.inventory.EquipmentSlot.OFF_HAND) continue; + net.minecraft.world.entity.EquipmentSlot nmsSlot = org.bukkit.craftbukkit.CraftEquipmentSlot.getNMS(slot); -+ disabled += (1 << nmsSlot.getFilterFlag()) + (1 << (nmsSlot.getFilterFlag() + 8)) + (1 << (nmsSlot.getFilterFlag() + 16)); ++ disabled += (1 << nmsSlot.getFilterBit(0)) + (1 << nmsSlot.getFilterBit(8)) + (1 << nmsSlot.getFilterBit(16)); + } + getHandle().disabledSlots = disabled; + } diff --git a/patches/server/Expose-furnace-minecart-push-values.patch b/patches/server/Expose-furnace-minecart-push-values.patch index c2beeb4bef..a979b81cca 100644 --- a/patches/server/Expose-furnace-minecart-push-values.patch +++ b/patches/server/Expose-furnace-minecart-push-values.patch @@ -16,22 +16,24 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper start + @Override + public double getPushX() { -+ return getHandle().xPush; ++ return getHandle().push.x; + } + + @Override + public double getPushZ() { -+ return getHandle().zPush; ++ return getHandle().push.z; + } + + @Override + public void setPushX(double xPush) { -+ getHandle().xPush = xPush; ++ final net.minecraft.world.phys.Vec3 push = getHandle().push; ++ getHandle().push = new net.minecraft.world.phys.Vec3(xPush, push.y, push.z); + } + + @Override + public void setPushZ(double zPush) { -+ getHandle().zPush = zPush; ++ final net.minecraft.world.phys.Vec3 push = getHandle().push; ++ getHandle().push = new net.minecraft.world.phys.Vec3(push.x, push.y, zPush); + } + // Paper end + diff --git a/patches/server/More-Teleport-API.patch b/patches/server/More-Teleport-API.patch index 70893c283d..7dca058409 100644 --- a/patches/server/More-Teleport-API.patch +++ b/patches/server/More-Teleport-API.patch @@ -263,7 +263,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + for (final io.papermc.paper.entity.TeleportFlag.Relative bukkit : relativeArguments) { + nms.add(toNmsRelativeFlag(bukkit)); + } -+ entity.connection.internalTeleport(to.getX(), to.getY(), to.getZ(), to.getYaw(), to.getPitch(), nms); ++ entity.connection.internalTeleport(new net.minecraft.world.entity.PositionMoveRotation( ++ io.papermc.paper.util.MCUtil.toVec3(to), net.minecraft.world.phys.Vec3.ZERO, to.getYaw(), to.getPitch() ++ ), nms); + // Paper end - Teleport API } else { entity.portalProcess = null; // SPIGOT-7785: there is no need to carry this over as it contains the old world/location and we might run into trouble if there is a portal in the same spot in both worlds diff --git a/patches/server/Paper-config-files.patch b/patches/server/Paper-config-files.patch index 93213fcc42..d44b5af17c 100644 --- a/patches/server/Paper-config-files.patch +++ b/patches/server/Paper-config-files.patch @@ -3178,7 +3178,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + + protected final Registry registry() { -+ return this.registryAccess.registryOrThrow(this.registryKey); ++ return this.registryAccess.lookupOrThrow(this.registryKey); + } + + protected abstract T convertFromResourceKey(ResourceKey key) throws SerializationException; @@ -3240,7 +3240,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + @Override + protected Holder convertFromResourceKey(ResourceKey key) throws SerializationException { -+ return this.registry().getHolder(key).orElseThrow(() -> new SerializationException("Missing holder in " + this.registry().key() + " with key " + key)); ++ return this.registry().get(key).orElseThrow(() -> new SerializationException("Missing holder in " + this.registry().key() + " with key " + key)); + } + + @Override @@ -3277,7 +3277,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + @Override + protected T convertFromResourceKey(ResourceKey key) throws SerializationException { -+ final T value = this.registry().get(key); ++ final T value = this.registry().getValue(key); + if (value == null) { + throw new SerializationException("Missing value in " + this.registry() + " with key " + key.location()); + } @@ -3668,7 +3668,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + final Reference2LongMap>> features = Objects.requireNonNullElseGet(featureNode.get(new TypeToken>>>() {}), Reference2LongOpenHashMap::new); + final Random random = new SecureRandom(); + AtomicInteger counter = new AtomicInteger(0); -+ MinecraftServer.getServer().registryAccess().registryOrThrow(Registries.CONFIGURED_FEATURE).holders().forEach(holder -> { ++ MinecraftServer.getServer().registryAccess().lookupOrThrow(Registries.CONFIGURED_FEATURE).listElements().forEach(holder -> { + if (features.containsKey(holder)) { + return; + } @@ -3805,7 +3805,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + ) + .addVersion(26, ConfigurationTransformation.builder().addAction(path("alt-item-despawn-rate", "items", ConfigurationTransformation.WILDCARD_OBJECT), (path, value) -> { + String itemName = path.get(path.size() - 1).toString(); -+ final Optional> item = BuiltInRegistries.ITEM.getHolder(ResourceKey.create(Registries.ITEM, ResourceLocation.parse(itemName.toLowerCase(Locale.ROOT)))); ++ final Optional> item = BuiltInRegistries.ITEM.get(ResourceKey.create(Registries.ITEM, ResourceLocation.parse(itemName.toLowerCase(Locale.ROOT)))); + if (item.isEmpty()) { + itemName = Material.valueOf(itemName).getKey().getKey(); + } @@ -3837,7 +3837,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + Map rebuild = new HashMap<>(); + value.childrenMap().forEach((key, node) -> { + String itemName = key.toString(); -+ final Optional> itemHolder = BuiltInRegistries.ITEM.getHolder(ResourceKey.create(Registries.ITEM, ResourceLocation.parse(itemName.toLowerCase(Locale.ROOT)))); ++ final Optional> itemHolder = BuiltInRegistries.ITEM.get(ResourceKey.create(Registries.ITEM, ResourceLocation.parse(itemName.toLowerCase(Locale.ROOT)))); + final @Nullable String item; + if (itemHolder.isEmpty()) { + final @Nullable Material bukkitMat = Material.matchMaterial(itemName); diff --git a/patches/server/Paper-dumpitem-command.patch b/patches/server/Paper-dumpitem-command.patch index c791136a0b..53e9e5db71 100644 --- a/patches/server/Paper-dumpitem-command.patch +++ b/patches/server/Paper-dumpitem-command.patch @@ -103,7 +103,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + final RegistryAccess.Frozen access = ((CraftServer) sender.getServer()).getServer().registryAccess(); + final RegistryOps ops = access.createSerializationContext(NbtOps.INSTANCE); -+ final Registry> registry = access.registryOrThrow(Registries.DATA_COMPONENT_TYPE); ++ final Registry> registry = access.lookupOrThrow(Registries.DATA_COMPONENT_TYPE); + final List componentComponents = new ArrayList<>(); + final List commandComponents = new ArrayList<>(); + for (final DataComponentType type : referencedComponentTypes) {