From 464cc81633f36fd5e73c95593e4460b1249e6bc1 Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Fri, 26 Apr 2024 16:17:13 -0700 Subject: fix custom potion mixes --- patches/api/0345-Custom-Potion-Mixes.patch | 72 +++--- patches/server/0005-Paper-config-files.patch | 2 +- patches/server/0006-MC-Dev-fixes.patch | 2 +- patches/server/0009-MC-Utils.patch | 2 +- patches/server/0010-Adventure.patch | 2 +- ...lConsoleAppender-for-console-improvements.patch | 2 +- patches/server/0020-Plugin-remapping.patch | 2 +- patches/server/0025-Timings-v2.patch | 2 +- .../0027-Further-improve-server-tick-loop.patch | 2 +- ...in-client-crashes-server-lists-and-Mojang.patch | 2 +- patches/server/0049-Optimize-explosions.patch | 2 +- ...s-BlockPhysicsEvent-if-a-plugin-has-a-lis.patch | 2 +- .../0095-Configurable-Player-Collision.patch | 2 +- ...-null-possibility-for-getServer-singleton.patch | 2 +- .../0104-Async-GameProfileCache-saving.patch | 2 +- ...-handle-async-calls-to-restart-the-server.patch | 2 +- ...plement-extended-PaperServerListPingEvent.patch | 2 +- ...234-Add-Early-Warning-Feature-to-WatchDog.patch | 2 +- ...-Server-Thread-Pool-and-Thread-Priorities.patch | 2 +- .../server/0271-Optimize-World-Time-Updates.patch | 2 +- .../server/0284-Async-command-map-building.patch | 2 +- patches/server/0293-Server-Tick-Events.patch | 2 +- .../0336-Add-tick-times-API-and-mspt-command.patch | 2 +- patches/server/0363-misc-debugging-dumps.patch | 2 +- ...0371-Wait-for-Async-Tasks-during-shutdown.patch | 2 +- ...r-World-Difficulty-Remembering-Difficulty.patch | 2 +- patches/server/0422-Cache-block-data-strings.patch | 2 +- ...cking-non-whitelisted-player-when-white-l.patch | 2 +- .../0478-Add-ServerResourcesReloadedEvent.patch | 2 +- patches/server/0502-Add-EntityMoveEvent.patch | 2 +- ...d-whitelist-use-configurable-kick-message.patch | 2 +- .../server/0562-Add-PlayerKickEvent-causes.patch | 2 +- ...pose-vanilla-BiomeProvider-from-WorldInfo.patch | 2 +- ...nk-tasks-fairly-for-worlds-while-waiting-.patch | 2 +- ...ave-default-CustomSpawners-in-custom-worl.patch | 2 +- ...d-into-worldlist-before-initing-the-world.patch | 2 +- patches/server/0694-Custom-Potion-Mixes.patch | 276 ++++++++++++--------- .../server/0705-Fix-saving-in-unloadWorld.patch | 2 +- .../server/0717-WorldCreator-keepSpawnLoaded.patch | 2 +- ...eption-on-world-create-while-being-ticked.patch | 4 +- ...on-t-broadcast-messages-to-command-blocks.patch | 2 +- .../0756-Add-Velocity-IP-Forwarding-Support.patch | 2 +- ...758-Fix-plugin-loggers-on-server-shutdown.patch | 2 +- ...99-Fix-premature-player-kicks-on-shutdown.patch | 2 +- ...ce-icanhasbukkit-default-if-alias-block-e.patch | 2 +- ...0874-Folia-scheduler-and-owned-region-API.patch | 6 +- .../0876-API-for-updating-recipes-on-clients.patch | 2 +- .../0881-Use-correct-seed-on-api-world-load.patch | 2 +- ...nd-replace-methods-with-old-StructureType.patch | 2 +- .../server/0957-Add-Lifecycle-Event-system.patch | 2 +- patches/server/0962-improve-BanList-types.patch | 2 +- ...boarding-message-for-initial-server-start.patch | 2 +- patches/server/0985-Rewrite-chunk-system.patch | 4 +- .../0986-incremental-chunk-and-player-saving.patch | 2 +- patches/server/0996-Anti-Xray.patch | 2 +- .../server/1001-Improved-Watchdog-Support.patch | 2 +- .../server/1013-Execute-chunk-tasks-mid-tick.patch | 2 +- patches/server/1025-Optimize-Hoppers.patch | 2 +- patches/server/1029-Lag-compensation-ticks.patch | 2 +- ...34-Fix-and-optimise-world-force-upgrading.patch | 4 +- 60 files changed, 256 insertions(+), 218 deletions(-) diff --git a/patches/api/0345-Custom-Potion-Mixes.patch b/patches/api/0345-Custom-Potion-Mixes.patch index bc46738ce1..b6a28f8917 100644 --- a/patches/api/0345-Custom-Potion-Mixes.patch +++ b/patches/api/0345-Custom-Potion-Mixes.patch @@ -192,74 +192,80 @@ index 43b049b68a8af548cd05c67dafc23dabd07bab27..6da6c20b684eba64b85d67db2482b4a9 // Paper end } diff --git a/src/main/java/org/bukkit/potion/PotionBrewer.java b/src/main/java/org/bukkit/potion/PotionBrewer.java -index 2072f048e10eba829cef047d854b5a22c8f055a3..f81bbaa6d4a991f265e630dc9a3d3945bac78fff 100644 +index 2072f048e10eba829cef047d854b5a22c8f055a3..c1bcbeef9cb634e6cb8c4b58bf06883c37cc028b 100644 --- a/src/main/java/org/bukkit/potion/PotionBrewer.java +++ b/src/main/java/org/bukkit/potion/PotionBrewer.java -@@ -7,7 +7,7 @@ import org.jetbrains.annotations.NotNull; - * Represents a brewer that can create {@link PotionEffect}s. +@@ -4,10 +4,31 @@ import java.util.Collection; + import org.jetbrains.annotations.NotNull; + + /** +- * Represents a brewer that can create {@link PotionEffect}s. ++ * Used to manage custom {@link io.papermc.paper.potion.PotionMix}s. */ public interface PotionBrewer { -- -+ // Paper start - keep old spigot methods, removal in 1.20.6 + ++ // Paper start ++ /** ++ * Adds a new potion mix recipe. ++ * ++ * @param potionMix the potion mix to add ++ */ ++ void addPotionMix(@NotNull io.papermc.paper.potion.PotionMix potionMix); ++ ++ /** ++ * Removes a potion mix recipe. ++ * ++ * @param key the key of the mix to remove ++ */ ++ void removePotionMix(@NotNull org.bukkit.NamespacedKey key); ++ ++ /** ++ * Resets potion mixes to their default, removing all custom ones. ++ */ ++ void resetPotionMixes(); ++ // Paper end ++ /** * Creates a {@link PotionEffect} from the given {@link PotionEffectType}, * applying duration modifiers and checks. -@@ -16,9 +16,13 @@ public interface PotionBrewer { +@@ -16,9 +37,15 @@ public interface PotionBrewer { * @param duration The duration in ticks * @param amplifier The amplifier of the effect * @return The resulting potion effect + * @deprecated use {@link PotionEffectType#createEffect(int, int)} instead. */ -+ @Deprecated(forRemoval = true, since = "1.20.5") ++ @Deprecated(forRemoval = true, since = "1.20.5") // Paper @NotNull - public PotionEffect createEffect(@NotNull PotionEffectType potion, int duration, int amplifier); ++ // Paper start - make default + default PotionEffect createEffect(@NotNull PotionEffectType potion, int duration, int amplifier) { + return potion.createEffect(duration, amplifier); + } ++ // Paper end /** * Returns a collection of {@link PotionEffect} that would be applied from -@@ -28,9 +32,12 @@ public interface PotionBrewer { +@@ -28,9 +55,13 @@ public interface PotionBrewer { * @return The list of effects * @deprecated Non-Functional */ - @Deprecated -+ @Deprecated(forRemoval = true, since = "1.20.5") ++ @Deprecated(forRemoval = true, since = "1.20.5") // Paper @NotNull - public Collection getEffectsFromDamage(int damage); ++ // Paper start - make default + default Collection getEffectsFromDamage(final int damage) { + return new java.util.ArrayList<>(); + } -+ // Paper start - keep old spigot methods, removal in 1.20.6 ++ // Paper end /** * Returns a collection of {@link PotionEffect} that would be applied from -@@ -43,6 +50,27 @@ public interface PotionBrewer { +@@ -43,6 +74,6 @@ public interface PotionBrewer { * @deprecated Upgraded / extended potions are now their own {@link PotionType} use {@link PotionType#getPotionEffects()} instead */ @NotNull - @Deprecated -+ @Deprecated(forRemoval = true, since = "1.20.5") ++ @Deprecated(forRemoval = true, since = "1.20.5") // Paper public Collection getEffects(@NotNull PotionType type, boolean upgraded, boolean extended); -+ -+ // Paper start -+ /** -+ * Adds a new potion mix recipe. -+ * -+ * @param potionMix the potion mix to add -+ */ -+ void addPotionMix(@NotNull io.papermc.paper.potion.PotionMix potionMix); -+ -+ /** -+ * Removes a potion mix recipe. -+ * -+ * @param key the key of the mix to remove -+ */ -+ void removePotionMix(@NotNull org.bukkit.NamespacedKey key); -+ -+ /** -+ * Resets potion mixes to their default, removing all custom ones. -+ */ -+ void resetPotionMixes(); -+ // Paper end } diff --git a/patches/server/0005-Paper-config-files.patch b/patches/server/0005-Paper-config-files.patch index 7cfde7efef..b04a8966ef 100644 --- a/patches/server/0005-Paper-config-files.patch +++ b/patches/server/0005-Paper-config-files.patch @@ -4847,7 +4847,7 @@ index b334265d4015fec13d7fedbffba2b6c22f4c8bc8..5b4ac7b4fd0077e900e9f788963f1613 String s = (String) Optional.ofNullable((String) optionset.valueOf("world")).orElse(dedicatedserversettings.getProperties().levelName); LevelStorageSource convertable = LevelStorageSource.createDefault(file.toPath()); diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index c54979d2509ce30f2ba0d956b5c6d48342e1a0fc..254e362cd54359512285bab632dbae3cec0f03e0 100644 +index a6d495371a35195d6f841124329188107af1736f..1d241972e6f93a88c31f1276e15bae0912db5c9e 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -302,6 +302,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop Date: Thu, 7 Oct 2021 14:34:55 -0700 Subject: [PATCH] Custom Potion Mixes +== AT == +public-f net.minecraft.server.MinecraftServer potionBrewing +diff --git a/src/main/java/io/papermc/paper/potion/PaperPotionBrewer.java b/src/main/java/io/papermc/paper/potion/PaperPotionBrewer.java +new file mode 100644 +index 0000000000000000000000000000000000000000..d9390227a2bba4e03aa9ee592ca157127633c41b +--- /dev/null ++++ b/src/main/java/io/papermc/paper/potion/PaperPotionBrewer.java +@@ -0,0 +1,56 @@ ++package io.papermc.paper.potion; ++ ++import com.google.common.base.Preconditions; ++import java.util.Collection; ++import net.minecraft.server.MinecraftServer; ++import org.bukkit.NamespacedKey; ++import org.bukkit.potion.PotionBrewer; ++import org.bukkit.potion.PotionEffect; ++import org.bukkit.potion.PotionType; ++import org.checkerframework.checker.nullness.qual.NonNull; ++import org.checkerframework.framework.qual.DefaultQualifier; ++ ++@DefaultQualifier(NonNull.class) ++public class PaperPotionBrewer implements PotionBrewer { ++ ++ private final MinecraftServer minecraftServer; ++ ++ public PaperPotionBrewer(final MinecraftServer minecraftServer) { ++ this.minecraftServer = minecraftServer; ++ } ++ ++ @Override ++ @Deprecated(forRemoval = true) ++ public Collection getEffects(PotionType type, boolean upgraded, boolean extended) { ++ final org.bukkit.NamespacedKey key = type.getKey(); ++ ++ Preconditions.checkArgument(!key.getKey().startsWith("strong_"), "Strong potion type cannot be used directly, got %s", key); ++ Preconditions.checkArgument(!key.getKey().startsWith("long_"), "Extended potion type cannot be used directly, got %s", key); ++ ++ org.bukkit.NamespacedKey effectiveKey = key; ++ if (upgraded) { ++ effectiveKey = new org.bukkit.NamespacedKey(key.namespace(), "strong_" + key.key()); ++ } else if (extended) { ++ effectiveKey = new org.bukkit.NamespacedKey(key.namespace(), "long_" + key.key()); ++ } ++ ++ final org.bukkit.potion.PotionType effectivePotionType = org.bukkit.Registry.POTION.get(effectiveKey); ++ Preconditions.checkNotNull(type, "Unknown potion type from data " + effectiveKey.asMinimalString()); // Legacy error message in 1.20.4 ++ return effectivePotionType.getPotionEffects(); ++ } ++ ++ @Override ++ public void addPotionMix(final PotionMix potionMix) { ++ this.minecraftServer.potionBrewing().addPotionMix(potionMix); ++ } ++ ++ @Override ++ public void removePotionMix(final NamespacedKey key) { ++ this.minecraftServer.potionBrewing.removePotionMix(key); ++ } ++ ++ @Override ++ public void resetPotionMixes() { ++ this.minecraftServer.potionBrewing = this.minecraftServer.potionBrewing().reload(this.minecraftServer.getWorldData().enabledFeatures()); ++ } ++} diff --git a/src/main/java/io/papermc/paper/potion/PaperPotionMix.java b/src/main/java/io/papermc/paper/potion/PaperPotionMix.java new file mode 100644 index 0000000000000000000000000000000000000000..7ea357ac2f3a93db4ebdf24b5072be7d1cad3e33 @@ -32,18 +96,9 @@ index 0000000000000000000000000000000000000000..7ea357ac2f3a93db4ebdf24b5072be7d + } +} diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index ea442883eda28e5673cef9470145d5c40ac66159..25ce1b9dbaa77e2c8541d995a2c28f894cee9d38 100644 +index af5c6893859530f65724869d18b6677e6f556dc2..18a73cc12615ecc7e61e8f96e6d8a3aa2ffe6e1f 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -291,7 +291,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop public (remove final) - private volatile boolean isSaving; - - // CraftBukkit start @@ -2141,6 +2141,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop containers; private final List> potionMixes; private final List> containerMixes; -+ private static final it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap CUSTOM_MIXES = new it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap<>(); // Paper - Custom Potion Mixes ++ private final it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap customMixes = new it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap<>(); // Paper - Custom Potion Mixes PotionBrewing(List potionTypes, List> potionRecipes, List> itemRecipes) { this.containers = potionTypes; @@ -82,7 +181,7 @@ index 50e81e3babd331077eda8daa769eb2b3f99e8ca2..3469ddcf70a75e2bbfa7fcfc210f3160 public boolean isIngredient(ItemStack stack) { - return this.isContainerIngredient(stack) || this.isPotionIngredient(stack); -+ return this.isContainerIngredient(stack) || this.isPotionIngredient(stack) || isCustomIngredient(stack); // Paper - Custom Potion Mixes ++ return this.isContainerIngredient(stack) || this.isPotionIngredient(stack) || this.isCustomIngredient(stack); // Paper - Custom Potion Mixes } private boolean isContainer(ItemStack stack) { @@ -91,34 +190,34 @@ index 50e81e3babd331077eda8daa769eb2b3f99e8ca2..3469ddcf70a75e2bbfa7fcfc210f3160 public boolean hasMix(ItemStack input, ItemStack ingredient) { + // Paper start - Custom Potion Mixes -+ if (hasCustomMix(input, ingredient)) { ++ if (this.hasCustomMix(input, ingredient)) { + return true; + } + // Paper end - Custom Potion Mixes return this.isContainer(input) && (this.hasContainerMix(input, ingredient) || this.hasPotionMix(input, ingredient)); } -@@ -107,6 +113,13 @@ public class PotionBrewing { +@@ -103,6 +109,13 @@ public class PotionBrewing { + if (input.isEmpty()) { + return input; + } else { ++ // Paper start - Custom Potion Mixes ++ for (io.papermc.paper.potion.PaperPotionMix mix : this.customMixes.values()) { ++ if (mix.input().test(input) && mix.ingredient().test(ingredient)) { ++ return mix.result().copy(); ++ } ++ } ++ // Paper end - Custom Potion Mixes + Optional> optional = input.getOrDefault(DataComponents.POTION_CONTENTS, PotionContents.EMPTY).potion(); if (optional.isEmpty()) { return input; - } else { -+ // Paper start - Custom Potion Mixes -+ for (var mix : CUSTOM_MIXES.values()) { -+ if (mix.input().test(input) && mix.ingredient().test(ingredient)) { -+ return mix.result().copy(); -+ } -+ } -+ // Paper end - Custom Potion Mixes - for (PotionBrewing.Mix mix : this.containerMixes) { - if (input.is(mix.from) && mix.ingredient.test(ingredient)) { - return PotionContents.createItemStack(mix.to.value(), optional.get()); @@ -190,6 +203,50 @@ public class PotionBrewing { builder.addMix(Potions.SLOW_FALLING, Items.REDSTONE, Potions.LONG_SLOW_FALLING); } + // Paper start - Custom Potion Mixes -+ public static boolean isCustomIngredient(ItemStack stack) { -+ for (var mix : CUSTOM_MIXES.values()) { ++ public boolean isCustomIngredient(ItemStack stack) { ++ for (io.papermc.paper.potion.PaperPotionMix mix : this.customMixes.values()) { + if (mix.ingredient().test(stack)) { + return true; + } @@ -126,8 +225,8 @@ index 50e81e3babd331077eda8daa769eb2b3f99e8ca2..3469ddcf70a75e2bbfa7fcfc210f3160 + return false; + } + -+ public static boolean isCustomInput(ItemStack stack) { -+ for (var mix : CUSTOM_MIXES.values()) { ++ public boolean isCustomInput(ItemStack stack) { ++ for (io.papermc.paper.potion.PaperPotionMix mix : this.customMixes.values()) { + if (mix.input().test(stack)) { + return true; + } @@ -135,8 +234,8 @@ index 50e81e3babd331077eda8daa769eb2b3f99e8ca2..3469ddcf70a75e2bbfa7fcfc210f3160 + return false; + } + -+ private static boolean hasCustomMix(ItemStack input, ItemStack ingredient) { -+ for (var mix : CUSTOM_MIXES.values()) { ++ private boolean hasCustomMix(ItemStack input, ItemStack ingredient) { ++ for (io.papermc.paper.potion.PaperPotionMix mix : this.customMixes.values()) { + if (mix.input().test(input) && mix.ingredient().test(ingredient)) { + return true; + } @@ -144,15 +243,15 @@ index 50e81e3babd331077eda8daa769eb2b3f99e8ca2..3469ddcf70a75e2bbfa7fcfc210f3160 + return false; + } + -+ public static void addPotionMix(io.papermc.paper.potion.PotionMix mix) { -+ if (CUSTOM_MIXES.containsKey(mix.getKey())) { ++ public void addPotionMix(io.papermc.paper.potion.PotionMix mix) { ++ if (this.customMixes.containsKey(mix.getKey())) { + throw new IllegalArgumentException("Duplicate recipe ignored with ID " + mix.getKey()); + } -+ CUSTOM_MIXES.putAndMoveToFirst(mix.getKey(), new io.papermc.paper.potion.PaperPotionMix(mix)); ++ this.customMixes.putAndMoveToFirst(mix.getKey(), new io.papermc.paper.potion.PaperPotionMix(mix)); + } + -+ public static boolean removePotionMix(org.bukkit.NamespacedKey key) { -+ return CUSTOM_MIXES.remove(key) != null; ++ public boolean removePotionMix(org.bukkit.NamespacedKey key) { ++ return this.customMixes.remove(key) != null; + } + + public PotionBrewing reload(FeatureFlagSet flags) { @@ -164,27 +263,33 @@ index 50e81e3babd331077eda8daa769eb2b3f99e8ca2..3469ddcf70a75e2bbfa7fcfc210f3160 private final List containers = new ArrayList<>(); private final List> potionMixes = new ArrayList<>(); diff --git a/src/main/java/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java -index 3ebfd564d4bbf00da5919e966f3d047285845640..c1254088fc65fe46101c82cf2629cf0269711d39 100644 +index 3ebfd564d4bbf00da5919e966f3d047285845640..887957ce1ddc2f32569405642f35df468c08271f 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java -@@ -316,7 +316,7 @@ public class BrewingStandBlockEntity extends BaseContainerBlockEntity implements +@@ -311,12 +311,12 @@ public class BrewingStandBlockEntity extends BaseContainerBlockEntity implements + + @Override + public boolean canPlaceItem(int slot, ItemStack stack) { ++ PotionBrewing potionbrewer = this.level != null ? this.level.potionBrewing() : PotionBrewing.EMPTY; // Paper - move up + if (slot == 3) { +- PotionBrewing potionbrewer = this.level != null ? this.level.potionBrewing() : PotionBrewing.EMPTY; return potionbrewer.isIngredient(stack); } else { - return slot == 4 ? stack.is(Items.BLAZE_POWDER) : (stack.is(Items.POTION) || stack.is(Items.SPLASH_POTION) || stack.is(Items.LINGERING_POTION) || stack.is(Items.GLASS_BOTTLE)) && this.getItem(slot).isEmpty(); -+ return slot == 4 ? stack.is(Items.BLAZE_POWDER) : (stack.is(Items.POTION) || stack.is(Items.SPLASH_POTION) || stack.is(Items.LINGERING_POTION) || stack.is(Items.GLASS_BOTTLE) || PotionBrewing.isCustomInput(stack)) && this.getItem(slot).isEmpty(); // Paper - Custom Potion Mixes ++ return slot == 4 ? stack.is(Items.BLAZE_POWDER) : (stack.is(Items.POTION) || stack.is(Items.SPLASH_POTION) || stack.is(Items.LINGERING_POTION) || stack.is(Items.GLASS_BOTTLE) || potionbrewer.isCustomInput(stack)) && this.getItem(slot).isEmpty(); // Paper - Custom Potion Mixes } } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index e25dc948bfd59b8d0a9350c0ffe496f53d042ab8..e1903d551e2183cc92dfb4fc832ec5bf961475d1 100644 +index e25dc948bfd59b8d0a9350c0ffe496f53d042ab8..7c4ee28eb7c40e4b629cf355cfaa95fe93d66bc2 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -308,6 +308,7 @@ public final class CraftServer implements Server { private final io.papermc.paper.datapack.PaperDatapackManager datapackManager; // Paper public static Exception excessiveVelEx; // Paper - Velocity warnings private final io.papermc.paper.logging.SysoutCatcher sysoutCatcher = new io.papermc.paper.logging.SysoutCatcher(); // Paper -+ private final org.bukkit.craftbukkit.potion.CraftPotionBrewer potionBrewer; // Paper - Custom Potion Mixes ++ private final io.papermc.paper.potion.PaperPotionBrewer potionBrewer; // Paper - Custom Potion Mixes static { ConfigurationSerialization.registerClass(CraftOfflinePlayer.class); @@ -192,19 +297,18 @@ index e25dc948bfd59b8d0a9350c0ffe496f53d042ab8..e1903d551e2183cc92dfb4fc832ec5bf if (this.configuration.getBoolean("settings.use-map-color-cache")) { MapPalette.setMapColorCache(new CraftMapColorCache(this.logger)); } -+ this.potionBrewer = new org.bukkit.craftbukkit.potion.CraftPotionBrewer(playerList.getServer()); // Paper - custom potion mixes ++ this.potionBrewer = new io.papermc.paper.potion.PaperPotionBrewer(console); // Paper - custom potion mixes datapackManager = new io.papermc.paper.datapack.PaperDatapackManager(console.getPackRepository()); // Paper } -@@ -3100,5 +3102,10 @@ public final class CraftServer implements Server { +@@ -3100,5 +3102,9 @@ public final class CraftServer implements Server { return datapackManager; } + @Override -+ public org.bukkit.craftbukkit.potion.CraftPotionBrewer getPotionBrewer() { ++ public io.papermc.paper.potion.PaperPotionBrewer getPotionBrewer() { + return this.potionBrewer; + } -+ // Paper end } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftRecipe.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftRecipe.java @@ -223,75 +327,3 @@ index 139dff90561ac6c51954c6289918a07aeea13a1b..6ba29875d78ede4aa7978ff689e588f7 Ingredient stack; if (bukkit == null) { -diff --git a/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionBrewer.java b/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionBrewer.java -new file mode 100644 -index 0000000000000000000000000000000000000000..bb47c776cf1d92ef85a5a10d1c42f120457d21c1 ---- /dev/null -+++ b/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionBrewer.java -@@ -0,0 +1,66 @@ -+package org.bukkit.craftbukkit.potion; -+ -+import com.google.common.base.Preconditions; -+import java.util.ArrayList; -+import java.util.Collection; -+import org.bukkit.potion.PotionBrewer; -+import org.bukkit.potion.PotionEffect; -+import org.bukkit.potion.PotionEffectType; -+import org.bukkit.potion.PotionType; -+ -+public class CraftPotionBrewer implements PotionBrewer { -+ -+ private final net.minecraft.server.MinecraftServer minecraftServer; -+ -+ public CraftPotionBrewer(net.minecraft.server.MinecraftServer minecraftServer) { -+ this.minecraftServer = minecraftServer; -+ } -+ -+ // Paper start - keep old spigot methods, removal in 1.20.6 -+ @Override -+ public Collection getEffects(PotionType type, boolean upgraded, boolean extended) { -+ final org.bukkit.NamespacedKey key = type.getKey(); -+ -+ Preconditions.checkArgument(!key.getKey().startsWith("strong_"), "Strong potion type cannot be used directly, got %s", key); -+ Preconditions.checkArgument(!key.getKey().startsWith("long_"), "Extended potion type cannot be used directly, got %s", key); -+ -+ org.bukkit.NamespacedKey effectiveKey = key; -+ if (upgraded) { -+ effectiveKey = new org.bukkit.NamespacedKey(key.namespace(), "strong_" + key.key()); -+ } else if (extended) { -+ effectiveKey = new org.bukkit.NamespacedKey(key.namespace(), "long_" + key.key()); -+ } -+ -+ final org.bukkit.potion.PotionType effectivePotionType = org.bukkit.Registry.POTION.get(effectiveKey); -+ Preconditions.checkNotNull(type, "Unknown potion type from data " + effectiveKey.asMinimalString()); // Legacy error message in 1.20.4 -+ return effectivePotionType.getPotionEffects(); -+ } -+ -+ @Override -+ public Collection getEffectsFromDamage(int damage) { -+ return new ArrayList<>(); -+ } -+ -+ @Override -+ public PotionEffect createEffect(PotionEffectType potion, int duration, int amplifier) { -+ return new PotionEffect(potion, potion.isInstant() ? 1 : duration, amplifier); -+ } -+ // Paper end - keep old spigot methods, removal in 1.20.6 -+ -+ // Paper start -+ @Override -+ public void addPotionMix(io.papermc.paper.potion.PotionMix potionMix) { -+ net.minecraft.world.item.alchemy.PotionBrewing.addPotionMix(potionMix); -+ } -+ -+ @Override -+ public void removePotionMix(org.bukkit.NamespacedKey key) { -+ net.minecraft.world.item.alchemy.PotionBrewing.removePotionMix(key); -+ } -+ -+ @Override -+ public void resetPotionMixes() { -+ this.minecraftServer.potionBrewing = this.minecraftServer.potionBrewing().reload(this.minecraftServer.getWorldData().enabledFeatures()); -+ } -+ // Paper end -+} diff --git a/patches/server/0705-Fix-saving-in-unloadWorld.patch b/patches/server/0705-Fix-saving-in-unloadWorld.patch index 28eec1151a..604e791aaa 100644 --- a/patches/server/0705-Fix-saving-in-unloadWorld.patch +++ b/patches/server/0705-Fix-saving-in-unloadWorld.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Fix saving in unloadWorld Change savingDisabled to false to ensure ServerLevel's saving logic gets called when unloadWorld is called with save = true diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index e1903d551e2183cc92dfb4fc832ec5bf961475d1..4f7df8765254bcac61d769e87eef946bc5eab682 100644 +index 7c4ee28eb7c40e4b629cf355cfaa95fe93d66bc2..e52461063786b65802838588d68233b33b67b173 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -1350,7 +1350,7 @@ public final class CraftServer implements Server { diff --git a/patches/server/0717-WorldCreator-keepSpawnLoaded.patch b/patches/server/0717-WorldCreator-keepSpawnLoaded.patch index 02a1c0f1b0..9e358f7c85 100644 --- a/patches/server/0717-WorldCreator-keepSpawnLoaded.patch +++ b/patches/server/0717-WorldCreator-keepSpawnLoaded.patch @@ -5,7 +5,7 @@ Subject: [PATCH] WorldCreator#keepSpawnLoaded diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index 4f7df8765254bcac61d769e87eef946bc5eab682..778d08b3fba2e33af661ffaadd60c108be0127e0 100644 +index e52461063786b65802838588d68233b33b67b173..b0628876e4a6885e966f1839b7804af77a4b8d71 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -1293,7 +1293,7 @@ public final class CraftServer implements Server { diff --git a/patches/server/0732-Throw-exception-on-world-create-while-being-ticked.patch b/patches/server/0732-Throw-exception-on-world-create-while-being-ticked.patch index 691b83c5a4..73a4b424a0 100644 --- a/patches/server/0732-Throw-exception-on-world-create-while-being-ticked.patch +++ b/patches/server/0732-Throw-exception-on-world-create-while-being-ticked.patch @@ -7,7 +7,7 @@ There are no plans to support creating worlds while worlds are being ticked themselvess. diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 25ce1b9dbaa77e2c8541d995a2c28f894cee9d38..928798903a70a641626dd74faf2c2e628db28d0f 100644 +index 18a73cc12615ecc7e61e8f96e6d8a3aa2ffe6e1f..0775e9259c5b465306adf6b9d7ffc404da14be54 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -314,6 +314,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop