Fix Mushroom cow stew api (#9934)
This commit is contained in:
		
					parent
					
						
							
								c93b73ddaa
							
						
					
				
			
			
				commit
				
					
						00c5568532
					
				
			
		
					 2 changed files with 138 additions and 18 deletions
				
			
		| 
						 | 
					@ -76,6 +76,62 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 | 
				
			||||||
+    SchoolableFish getSchoolLeader();
 | 
					+    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
 | 
					diff --git a/src/main/java/org/bukkit/entity/AbstractHorse.java b/src/main/java/org/bukkit/entity/AbstractHorse.java
 | 
				
			||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
 | 
					index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
 | 
				
			||||||
--- a/src/main/java/org/bukkit/entity/AbstractHorse.java
 | 
					--- a/src/main/java/org/bukkit/entity/AbstractHorse.java
 | 
				
			||||||
| 
						 | 
					@ -687,31 +743,45 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 | 
				
			||||||
         BROWN;
 | 
					         BROWN;
 | 
				
			||||||
     }
 | 
					     }
 | 
				
			||||||
+    // Paper start
 | 
					+    // Paper start
 | 
				
			||||||
+
 | 
					 | 
				
			||||||
+    /**
 | 
					+    /**
 | 
				
			||||||
+     * Gets how long the effect applied to stew
 | 
					+     * Gets how long the effect applied to stew
 | 
				
			||||||
+     * from this mushroom cow is.
 | 
					+     * from this mushroom cow is.
 | 
				
			||||||
+     *
 | 
					+     *
 | 
				
			||||||
+     * @return duration of the effect (in ticks)
 | 
					+     * @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
 | 
					+     * Sets how long the effect applied to stew
 | 
				
			||||||
+     * from this mushroom cow is.
 | 
					+     * from this mushroom cow is.
 | 
				
			||||||
+     *
 | 
					+     *
 | 
				
			||||||
+     * @param duration duration of the effect (in ticks)
 | 
					+     * @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
 | 
					+     * Gets the type of effect applied to stew
 | 
				
			||||||
+     * from this mushroom cow is.
 | 
					+     * from this mushroom cow is.
 | 
				
			||||||
+     *
 | 
					+     *
 | 
				
			||||||
+     * @return effect type, or null if an effect is currently not set
 | 
					+     * @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
 | 
					+    @Deprecated(forRemoval = true)
 | 
				
			||||||
+    org.bukkit.potion.PotionEffectType getStewEffectType();
 | 
					+    @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
 | 
					+     * Sets the type of effect applied to stew
 | 
				
			||||||
| 
						 | 
					@ -719,8 +789,29 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 | 
				
			||||||
+     *
 | 
					+     *
 | 
				
			||||||
+     * @param type new effect type
 | 
					+     * @param type new effect type
 | 
				
			||||||
+     *             or null if this cow does not give effects
 | 
					+     *             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<io.papermc.paper.potion.SuspiciousEffectEntry> getStewEffects();
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+    /**
 | 
				
			||||||
 | 
					+     * Sets effects applied to stew items for this mushroom cow.
 | 
				
			||||||
 | 
					+     *
 | 
				
			||||||
 | 
					+     * @param effects effect entry list
 | 
				
			||||||
 | 
					+     */
 | 
				
			||||||
 | 
					+    void setStewEffects(java.util.@NotNull List<io.papermc.paper.potion.SuspiciousEffectEntry> effects);
 | 
				
			||||||
+    // Paper end
 | 
					+    // 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/src/main/java/org/bukkit/entity/Panda.java b/src/main/java/org/bukkit/entity/Panda.java
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -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.AbstractSchoolingFish schoolSize
 | 
				
			||||||
public net.minecraft.world.entity.animal.Rabbit moreCarrotTicks
 | 
					public net.minecraft.world.entity.animal.Rabbit moreCarrotTicks
 | 
				
			||||||
public net.minecraft.world.entity.AreaEffectCloud ownerUUID
 | 
					public net.minecraft.world.entity.AreaEffectCloud ownerUUID
 | 
				
			||||||
 | 
					public net.minecraft.world.entity.animal.MushroomCow stewEffects
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Co-authored-by: Nassim Jahnke <nassim@njahnke.dev>
 | 
					Co-authored-by: Nassim Jahnke <nassim@njahnke.dev>
 | 
				
			||||||
Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
 | 
					Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
 | 
				
			||||||
| 
						 | 
					@ -137,6 +138,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 | 
				
			||||||
         this.setFlag(2, nearTarget);
 | 
					         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<Mushroo
 | 
				
			||||||
 | 
					     private static final int MUTATE_CHANCE = 1024;
 | 
				
			||||||
 | 
					     private static final String TAG_STEW_EFFECTS = "stew_effects";
 | 
				
			||||||
 | 
					     @Nullable
 | 
				
			||||||
 | 
					-    private List<SuspiciousEffectHolder.EffectEntry> stewEffects;
 | 
				
			||||||
 | 
					+    public List<SuspiciousEffectHolder.EffectEntry> 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
 | 
					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
 | 
					index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
 | 
				
			||||||
--- a/src/main/java/net/minecraft/world/entity/animal/frog/Tadpole.java
 | 
					--- a/src/main/java/net/minecraft/world/entity/animal/frog/Tadpole.java
 | 
				
			||||||
| 
						 | 
					@ -870,23 +884,38 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 | 
				
			||||||
 
 | 
					 
 | 
				
			||||||
+    // Paper start
 | 
					+    // Paper start
 | 
				
			||||||
+    @Override
 | 
					+    @Override
 | 
				
			||||||
+    public int getStewEffectDuration() {
 | 
					+    public java.util.List<io.papermc.paper.potion.SuspiciousEffectEntry> getStewEffects() {
 | 
				
			||||||
+        throw new UnsupportedOperationException(); // TODO https://github.com/PaperMC/Paper/issues/9742
 | 
					+        if (this.getHandle().stewEffects == null) {
 | 
				
			||||||
 | 
					+            return java.util.List.of();
 | 
				
			||||||
 | 
					+        }
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					+        java.util.List<io.papermc.paper.potion.SuspiciousEffectEntry> 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
 | 
					+    @Override
 | 
				
			||||||
+    public void setStewEffectDuration(int duration) {
 | 
					+    public void setStewEffects(final java.util.List<io.papermc.paper.potion.SuspiciousEffectEntry> effects) {
 | 
				
			||||||
+        throw new UnsupportedOperationException(); // TODO https://github.com/PaperMC/Paper/issues/9742
 | 
					+        if (effects.isEmpty()) {
 | 
				
			||||||
 | 
					+            this.getHandle().stewEffects = null;
 | 
				
			||||||
 | 
					+            return;
 | 
				
			||||||
+        }
 | 
					+        }
 | 
				
			||||||
+
 | 
					+
 | 
				
			||||||
+    @Override
 | 
					+        java.util.List<net.minecraft.world.level.block.SuspiciousEffectHolder.EffectEntry> nmsPairs = new java.util.ArrayList<>(effects.size());
 | 
				
			||||||
+    public org.bukkit.potion.PotionEffectType getStewEffectType() {
 | 
					+        for (final io.papermc.paper.potion.SuspiciousEffectEntry effect : effects) {
 | 
				
			||||||
+        throw new UnsupportedOperationException(); // TODO https://github.com/PaperMC/Paper/issues/9742
 | 
					+            nmsPairs.add(new net.minecraft.world.level.block.SuspiciousEffectHolder.EffectEntry(
 | 
				
			||||||
 | 
					+                org.bukkit.craftbukkit.potion.CraftPotionEffectType.bukkitToMinecraft(effect.effect()),
 | 
				
			||||||
 | 
					+                effect.duration()
 | 
				
			||||||
 | 
					+            ));
 | 
				
			||||||
+        }
 | 
					+        }
 | 
				
			||||||
+
 | 
					+
 | 
				
			||||||
+    @Override
 | 
					+        this.getHandle().stewEffects = nmsPairs;
 | 
				
			||||||
+    public void setStewEffect(org.bukkit.potion.PotionEffectType type) {
 | 
					 | 
				
			||||||
+        throw new UnsupportedOperationException(); // TODO https://github.com/PaperMC/Paper/issues/9742
 | 
					 | 
				
			||||||
+    }
 | 
					+    }
 | 
				
			||||||
+    // Paper end
 | 
					+    // Paper end
 | 
				
			||||||
+
 | 
					+
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue