diff --git a/patches/api/Missing-Entity-API.patch b/patches/api/Missing-Entity-API.patch index 846586e113..6765204415 100644 --- a/patches/api/Missing-Entity-API.patch +++ b/patches/api/Missing-Entity-API.patch @@ -76,6 +76,62 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + SchoolableFish getSchoolLeader(); + +} +diff --git a/src/main/java/io/papermc/paper/potion/SuspiciousEffectEntry.java b/src/main/java/io/papermc/paper/potion/SuspiciousEffectEntry.java +new file mode 100644 +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 +--- /dev/null ++++ b/src/main/java/io/papermc/paper/potion/SuspiciousEffectEntry.java +@@ -0,0 +0,0 @@ ++package io.papermc.paper.potion; ++ ++import org.bukkit.potion.PotionEffectType; ++import org.jetbrains.annotations.Contract; ++import org.jetbrains.annotations.NotNull; ++ ++/** ++ * Represents a {@link PotionEffectType} paired with a duration. ++ */ ++public sealed interface SuspiciousEffectEntry permits SuspiciousEffectEntryImpl { ++ ++ /** ++ * Gets the effect type. ++ * ++ * @return type ++ */ ++ @NotNull PotionEffectType effect(); ++ ++ /** ++ * Gets the duration for this effect instance. ++ * ++ * @return duration (in ticks) ++ */ ++ int duration(); ++ ++ /** ++ * Creates a new instance of SuspiciousEffectEntry. ++ * ++ * @param effectType effect type ++ * @param duration duration (in ticks) ++ * @return new instance of an entry ++ */ ++ @Contract(value = "_, _ -> new", pure = true) ++ static @NotNull SuspiciousEffectEntry create(final @NotNull PotionEffectType effectType, final int duration) { ++ return new SuspiciousEffectEntryImpl(effectType, duration); ++ } ++} +diff --git a/src/main/java/io/papermc/paper/potion/SuspiciousEffectEntryImpl.java b/src/main/java/io/papermc/paper/potion/SuspiciousEffectEntryImpl.java +new file mode 100644 +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 +--- /dev/null ++++ b/src/main/java/io/papermc/paper/potion/SuspiciousEffectEntryImpl.java +@@ -0,0 +0,0 @@ ++package io.papermc.paper.potion; ++ ++import org.bukkit.potion.PotionEffectType; ++import org.jetbrains.annotations.NotNull; ++ ++record SuspiciousEffectEntryImpl(@NotNull PotionEffectType effect, int duration) implements SuspiciousEffectEntry { ++} diff --git a/src/main/java/org/bukkit/entity/AbstractHorse.java b/src/main/java/org/bukkit/entity/AbstractHorse.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/entity/AbstractHorse.java @@ -687,31 +743,45 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 BROWN; } + // Paper start -+ + /** + * Gets how long the effect applied to stew + * from this mushroom cow is. + * + * @return duration of the effect (in ticks) ++ * @deprecated Mushroom cows can now hold multiple effects, use {@link #getStewEffects()} + */ -+ int getStewEffectDuration(); ++ @Deprecated(forRemoval = true) ++ @org.jetbrains.annotations.Contract("-> fail") ++ default int getStewEffectDuration() { ++ throw new UnsupportedOperationException("Mushroom cows can now hold multiple effects. Use #getStewEffects"); ++ } + + /** + * Sets how long the effect applied to stew + * from this mushroom cow is. + * + * @param duration duration of the effect (in ticks) ++ * @deprecated Mushroom cows can now hold multiple effects, use {@link #setStewEffects(java.util.List)} + */ -+ void setStewEffectDuration(int duration); ++ @Deprecated(forRemoval = true) ++ @org.jetbrains.annotations.Contract("_ -> fail") ++ default void setStewEffectDuration(int duration) { ++ throw new UnsupportedOperationException("Mushroom cows can now hold multiple effects. Use #setStewEffects"); ++ } + + /** + * Gets the type of effect applied to stew + * from this mushroom cow is. + * + * @return effect type, or null if an effect is currently not set ++ * @deprecated Mushroom cows can now hold multiple effects, use {@link #getStewEffects()} ++ * @throws UnsupportedOperationException + */ -+ @org.jetbrains.annotations.Nullable -+ org.bukkit.potion.PotionEffectType getStewEffectType(); ++ @Deprecated(forRemoval = true) ++ @org.jetbrains.annotations.Contract("-> fail") ++ default org.bukkit.potion.PotionEffectType getStewEffectType() { ++ throw new UnsupportedOperationException("Mushroom cows can now hold multiple effects. Use #getStewEffects"); ++ } + + /** + * Sets the type of effect applied to stew @@ -719,8 +789,29 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * + * @param type new effect type + * or null if this cow does not give effects ++ * @deprecated Mushroom cows can now hold multiple effects, use {@link #setStewEffects(java.util.List)} ++ * @throws UnsupportedOperationException + */ -+ void setStewEffect(@org.jetbrains.annotations.Nullable org.bukkit.potion.PotionEffectType type); ++ @Deprecated(forRemoval = true) ++ @org.jetbrains.annotations.Contract("_ -> fail") ++ default void setStewEffect(@org.jetbrains.annotations.Nullable org.bukkit.potion.PotionEffectType type) { ++ throw new UnsupportedOperationException("Mushroom cows can now hold multiple effects. Use #setStewEffects"); ++ } ++ ++ /** ++ * Returns an immutable collection of the effects applied to stew ++ * items for this mushroom cow. ++ * ++ * @return immutable effect entry collection ++ */ ++ java.util.@NotNull @org.jetbrains.annotations.Unmodifiable List getStewEffects(); ++ ++ /** ++ * Sets effects applied to stew items for this mushroom cow. ++ * ++ * @param effects effect entry list ++ */ ++ void setStewEffects(java.util.@NotNull List effects); + // Paper end } diff --git a/src/main/java/org/bukkit/entity/Panda.java b/src/main/java/org/bukkit/entity/Panda.java diff --git a/patches/server/Missing-Entity-API.patch b/patches/server/Missing-Entity-API.patch index 8f8286291d..a8af25c679 100644 --- a/patches/server/Missing-Entity-API.patch +++ b/patches/server/Missing-Entity-API.patch @@ -28,6 +28,7 @@ public net.minecraft.world.entity.animal.AbstractSchoolingFish leader public net.minecraft.world.entity.animal.AbstractSchoolingFish schoolSize public net.minecraft.world.entity.animal.Rabbit moreCarrotTicks public net.minecraft.world.entity.AreaEffectCloud ownerUUID +public net.minecraft.world.entity.animal.MushroomCow stewEffects Co-authored-by: Nassim Jahnke Co-authored-by: Jake Potrebic @@ -137,6 +138,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 this.setFlag(2, nearTarget); } +diff --git a/src/main/java/net/minecraft/world/entity/animal/MushroomCow.java b/src/main/java/net/minecraft/world/entity/animal/MushroomCow.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/entity/animal/MushroomCow.java ++++ b/src/main/java/net/minecraft/world/entity/animal/MushroomCow.java +@@ -0,0 +0,0 @@ public class MushroomCow extends Cow implements Shearable, VariantHolder stewEffects; ++ public List stewEffects; // Paper - private -> public (AT does not seem to work for this field) + @Nullable + private UUID lastLightningBoltUUID; + diff --git a/src/main/java/net/minecraft/world/entity/animal/frog/Tadpole.java b/src/main/java/net/minecraft/world/entity/animal/frog/Tadpole.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/entity/animal/frog/Tadpole.java @@ -870,23 +884,38 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper start + @Override -+ public int getStewEffectDuration() { -+ throw new UnsupportedOperationException(); // TODO https://github.com/PaperMC/Paper/issues/9742 ++ public java.util.List getStewEffects() { ++ if (this.getHandle().stewEffects == null) { ++ return java.util.List.of(); ++ } ++ ++ java.util.List nmsPairs = new java.util.ArrayList<>(this.getHandle().stewEffects.size()); ++ for (final net.minecraft.world.level.block.SuspiciousEffectHolder.EffectEntry effect : this.getHandle().stewEffects) { ++ nmsPairs.add(io.papermc.paper.potion.SuspiciousEffectEntry.create( ++ org.bukkit.craftbukkit.potion.CraftPotionEffectType.minecraftToBukkit(effect.effect()), ++ effect.duration() ++ )); ++ } ++ ++ return java.util.Collections.unmodifiableList(nmsPairs); + } + + @Override -+ public void setStewEffectDuration(int duration) { -+ throw new UnsupportedOperationException(); // TODO https://github.com/PaperMC/Paper/issues/9742 -+ } ++ public void setStewEffects(final java.util.List effects) { ++ if (effects.isEmpty()) { ++ this.getHandle().stewEffects = null; ++ return; ++ } + -+ @Override -+ public org.bukkit.potion.PotionEffectType getStewEffectType() { -+ throw new UnsupportedOperationException(); // TODO https://github.com/PaperMC/Paper/issues/9742 -+ } ++ java.util.List nmsPairs = new java.util.ArrayList<>(effects.size()); ++ for (final io.papermc.paper.potion.SuspiciousEffectEntry effect : effects) { ++ nmsPairs.add(new net.minecraft.world.level.block.SuspiciousEffectHolder.EffectEntry( ++ org.bukkit.craftbukkit.potion.CraftPotionEffectType.bukkitToMinecraft(effect.effect()), ++ effect.duration() ++ )); ++ } + -+ @Override -+ public void setStewEffect(org.bukkit.potion.PotionEffectType type) { -+ throw new UnsupportedOperationException(); // TODO https://github.com/PaperMC/Paper/issues/9742 ++ this.getHandle().stewEffects = nmsPairs; + } + // Paper end +