aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJake Potrebic <[email protected]>2024-06-04 13:26:40 -0700
committerGitHub <[email protected]>2024-06-04 16:26:40 -0400
commit88d76d9fe5e8980ca83a6eb2c530d33eda9725c8 (patch)
treeaa5754c64734209fcad6c25e7694812cc3e3272b
parent79c1ce184486847c614250e4e2025fd95a61cde5 (diff)
downloadPaper-88d76d9fe5e8980ca83a6eb2c530d33eda9725c8.tar.gz
Paper-88d76d9fe5e8980ca83a6eb2c530d33eda9725c8.zip
Make Bogged implement Shearable (#10844)
-rw-r--r--patches/api/0398-Add-Shearable-API.patch11
-rw-r--r--patches/server/0823-Add-Shearable-API.patch47
2 files changed, 58 insertions, 0 deletions
diff --git a/patches/api/0398-Add-Shearable-API.patch b/patches/api/0398-Add-Shearable-API.patch
index 19ef9a4a36..71b9361047 100644
--- a/patches/api/0398-Add-Shearable-API.patch
+++ b/patches/api/0398-Add-Shearable-API.patch
@@ -53,6 +53,17 @@ index 0000000000000000000000000000000000000000..0d5793790ab6a47525ad330335173612
+ */
+ boolean readyToBeSheared();
+}
+diff --git a/src/main/java/org/bukkit/entity/Bogged.java b/src/main/java/org/bukkit/entity/Bogged.java
+index 584404c6ac5f4c67a5a023f834cada0af0299447..7cd32bce7699bad7900ed137750531fd3e528020 100644
+--- a/src/main/java/org/bukkit/entity/Bogged.java
++++ b/src/main/java/org/bukkit/entity/Bogged.java
+@@ -9,5 +9,5 @@ import org.jetbrains.annotations.ApiStatus;
+ */
+ @MinecraftExperimental(Requires.UPDATE_1_21)
+ @ApiStatus.Experimental
+-public interface Bogged extends AbstractSkeleton {
++public interface Bogged extends AbstractSkeleton, io.papermc.paper.entity.Shearable { // Paper - Shear API
+ }
diff --git a/src/main/java/org/bukkit/entity/MushroomCow.java b/src/main/java/org/bukkit/entity/MushroomCow.java
index cef1700834643fe28ed5737578d91ecefbe99e2f..86c0043ef4e1288b6fe2f68a9b6d01c3de2c3454 100644
--- a/src/main/java/org/bukkit/entity/MushroomCow.java
diff --git a/patches/server/0823-Add-Shearable-API.patch b/patches/server/0823-Add-Shearable-API.patch
index 34eb025e6b..675a1bf358 100644
--- a/patches/server/0823-Add-Shearable-API.patch
+++ b/patches/server/0823-Add-Shearable-API.patch
@@ -31,6 +31,19 @@ index 0000000000000000000000000000000000000000..bcf254e3c81cf1e401bddc850fb24ad2
+ this.getHandle().shear(PaperAdventure.asVanilla(source));
+ }
+}
+diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftBogged.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftBogged.java
+index b252236369315502278e9b7c93709a347ec16636..93481e2828f945b11ae9a20a8e5286232b449fa9 100644
+--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftBogged.java
++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftBogged.java
+@@ -4,7 +4,7 @@ import org.bukkit.craftbukkit.CraftServer;
+ import org.bukkit.entity.Bogged;
+ import org.bukkit.entity.Skeleton;
+
+-public class CraftBogged extends CraftAbstractSkeleton implements Bogged {
++public class CraftBogged extends CraftAbstractSkeleton implements Bogged, io.papermc.paper.entity.PaperShearable { // Paper - Shear API
+
+ public CraftBogged(CraftServer server, net.minecraft.world.entity.monster.Bogged entity) {
+ super(server, entity);
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java
index 986f7b18112ef183de3bbff269a92bf6ac945477..9cc81bcccbf1141f66fedada1359b7c0dfa8e22a 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java
@@ -70,3 +83,37 @@ index 1e9807b8f468742d208f817e22d7625106fc1b58..4ce2373ff71c3c1b8951646e057587a3
public CraftSnowman(CraftServer server, SnowGolem entity) {
super(server, entity);
}
+diff --git a/src/test/java/io/papermc/paper/entity/ShearableTest.java b/src/test/java/io/papermc/paper/entity/ShearableTest.java
+new file mode 100644
+index 0000000000000000000000000000000000000000..fc8010c5fa0027d45d3c10d67e20631951714c40
+--- /dev/null
++++ b/src/test/java/io/papermc/paper/entity/ShearableTest.java
+@@ -0,0 +1,28 @@
++package io.papermc.paper.entity;
++
++import com.destroystokyo.paper.entity.ai.MobGoalHelper;
++import io.github.classgraph.ClassGraph;
++import io.github.classgraph.ScanResult;
++import java.util.List;
++import net.minecraft.world.entity.Mob;
++import net.minecraft.world.entity.Shearable;
++import org.junit.jupiter.api.Assertions;
++import org.junit.jupiter.params.ParameterizedTest;
++import org.junit.jupiter.params.provider.MethodSource;
++
++class ShearableTest {
++
++ static List<Class<Shearable>> nmsShearables() {
++ try (final ScanResult result = new ClassGraph().enableClassInfo().whitelistPackages("net.minecraft.world.entity").scan()) {
++ return result.getClassesImplementing(Shearable.class.getName()).loadClasses(Shearable.class);
++ }
++ }
++
++ @SuppressWarnings("unchecked")
++ @ParameterizedTest
++ @MethodSource("nmsShearables")
++ void ensureImplementsShearable(final Class<? extends Shearable> shearableNmsClass) {
++ final Class<? extends org.bukkit.entity.Mob> bukkitClass = MobGoalHelper.toBukkitClass((Class<? extends Mob>) shearableNmsClass);
++ Assertions.assertTrue(io.papermc.paper.entity.Shearable.class.isAssignableFrom(bukkitClass), bukkitClass.getName() + " does not implement Shearable");
++ }
++}