Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-15 11:00:06 +01:00
Fix Mushroom cow stew api (#9934)
Dieser Commit ist enthalten in:
Ursprung
37bee09e3d
Commit
5cbd5352b4
@ -76,6 +76,62 @@ index 0000000000000000000000000000000000000000..39ad7d283609d7e427a2ab35b6fad839
|
|||||||
+ 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..c8446678e39e777bd2c9992d5c577f4c7606ce15
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/io/papermc/paper/potion/SuspiciousEffectEntry.java
|
||||||
|
@@ -0,0 +1,37 @@
|
||||||
|
+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..e5002ccaef9ea7a9db94296ad0d66cdae050cdd1
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/io/papermc/paper/potion/SuspiciousEffectEntryImpl.java
|
||||||
|
@@ -0,0 +1,7 @@
|
||||||
|
+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 0d88dce9978243a1f995c5fb448c5d71b01136eb..8b1048c94dffd058eb9fd9144f7f59fc9bd219ad 100644
|
index 0d88dce9978243a1f995c5fb448c5d71b01136eb..8b1048c94dffd058eb9fd9144f7f59fc9bd219ad 100644
|
||||||
--- a/src/main/java/org/bukkit/entity/AbstractHorse.java
|
--- a/src/main/java/org/bukkit/entity/AbstractHorse.java
|
||||||
@ -679,39 +735,53 @@ index 11b6d1aba7d1f6ae1f3c822193486f5a1478e105..709c8fc3dde786f45ff13d6ee6c405ff
|
|||||||
+ // Paper end
|
+ // Paper end
|
||||||
}
|
}
|
||||||
diff --git a/src/main/java/org/bukkit/entity/MushroomCow.java b/src/main/java/org/bukkit/entity/MushroomCow.java
|
diff --git a/src/main/java/org/bukkit/entity/MushroomCow.java b/src/main/java/org/bukkit/entity/MushroomCow.java
|
||||||
index 939a3dbfcf38f38e4e39d28973ef723157ce0a50..738d547d2a6966122cb2f9f6e94263ee526d9fab 100644
|
index 939a3dbfcf38f38e4e39d28973ef723157ce0a50..e14194a130ebd872bbc1eb24c7759f0388f3da97 100644
|
||||||
--- a/src/main/java/org/bukkit/entity/MushroomCow.java
|
--- a/src/main/java/org/bukkit/entity/MushroomCow.java
|
||||||
+++ b/src/main/java/org/bukkit/entity/MushroomCow.java
|
+++ b/src/main/java/org/bukkit/entity/MushroomCow.java
|
||||||
@@ -35,4 +35,40 @@ public interface MushroomCow extends Cow {
|
@@ -35,4 +35,75 @@ public interface MushroomCow extends Cow {
|
||||||
*/
|
*/
|
||||||
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 939a3dbfcf38f38e4e39d28973ef723157ce0a50..738d547d2a6966122cb2f9f6e94263ee
|
|||||||
+ *
|
+ *
|
||||||
+ * @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 41f5b4fc4a4b7d2a54b08869d4afa450f34caf91..63678ff2e40d2ba0a5e97539394b18f9
|
|||||||
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 52cc265f1663d648b6bfd03f2ac3e191b1c16d44..e42b0b19019ef74733fd19b08f882cccff920142 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/entity/animal/MushroomCow.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/entity/animal/MushroomCow.java
|
||||||
|
@@ -55,7 +55,7 @@ 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 71a08510a928d4570822282bb31f14013ec3834a..4aeab90e778629c355189dfe79c39c4b21f5f5ac 100644
|
index 71a08510a928d4570822282bb31f14013ec3834a..4aeab90e778629c355189dfe79c39c4b21f5f5ac 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
|
||||||
@ -357,7 +371,7 @@ index 61d4877b4f74362e38104bfeacb7d66534ad798e..454dd67920826b8b62c2654abfd43fc0
|
|||||||
@Override
|
@Override
|
||||||
protected EntityHitResult findHitEntity(Vec3 currentPosition, Vec3 nextPosition) {
|
protected EntityHitResult findHitEntity(Vec3 currentPosition, Vec3 nextPosition) {
|
||||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java b/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java b/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java
|
||||||
index c3a26a55f46737a470448c6554d6827b1d6fc89c..c0186224fd64d70770a0e16752d17c0870121d8f 100644
|
index b1c0baa5a535c629008960bdc94b6010a147c329..e2e5b64812ee403be59b3586bf8b0334574c011f 100644
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java
|
||||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java
|
||||||
@@ -829,14 +829,19 @@ public abstract class CraftRegionAccessor implements RegionAccessor {
|
@@ -829,14 +829,19 @@ public abstract class CraftRegionAccessor implements RegionAccessor {
|
||||||
@ -861,32 +875,47 @@ index 6152f4d3d58f4b598d5bd92dbd7c5428c5ff8bc5..a5d3845acc607f640dace05a85f00896
|
|||||||
+ // Paper end
|
+ // Paper end
|
||||||
}
|
}
|
||||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java
|
||||||
index 77cede9c565a3bc404878c9a4028cadc90f6c010..ade11598bee28fea252e3500aaa1daefc506c175 100644
|
index 77cede9c565a3bc404878c9a4028cadc90f6c010..c20f470bec5292dde7fbdbf3a6562ae12117521d 100644
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java
|
||||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java
|
||||||
@@ -27,6 +27,28 @@ public class CraftMushroomCow extends CraftCow implements MushroomCow {
|
@@ -27,6 +27,43 @@ public class CraftMushroomCow extends CraftCow implements MushroomCow {
|
||||||
this.getHandle().setVariant(net.minecraft.world.entity.animal.MushroomCow.MushroomType.values()[variant.ordinal()]);
|
this.getHandle().setVariant(net.minecraft.world.entity.animal.MushroomCow.MushroomType.values()[variant.ordinal()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
+ // 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
|
||||||
+
|
+
|
||||||
|
@ -32,7 +32,7 @@ index 0000000000000000000000000000000000000000..bcf254e3c81cf1e401bddc850fb24ad2
|
|||||||
+ }
|
+ }
|
||||||
+}
|
+}
|
||||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java
|
||||||
index ade11598bee28fea252e3500aaa1daefc506c175..7ee489da5963fd722fc2531fef14911447a16557 100644
|
index f2d5a34b39c20995243c437a7fb5e0db5ba5420d..219723dd26d600c89cd560b8fdad3783765f6179 100644
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java
|
||||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java
|
||||||
@@ -5,7 +5,7 @@ import org.bukkit.craftbukkit.CraftServer;
|
@@ -5,7 +5,7 @@ import org.bukkit.craftbukkit.CraftServer;
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren