From 6a0c3c3efc11e7b559412d4e4afb17095eca6afe Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Mon, 16 Dec 2024 11:54:00 +0100 Subject: [PATCH] Fix tests --- .../gametest/framework/GameTestInfo.java.patch | 11 +++++++++++ .../gametest/framework/StructureUtils.java.patch | 11 +++++++++++ .../gametest/framework/TestCommand.java.patch | 11 +++++++++++ .../java/org/bukkit/event/EntityRemoveEventTest.java | 3 +++ 4 files changed, 36 insertions(+) create mode 100644 paper-server/patches/sources/net/minecraft/gametest/framework/GameTestInfo.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/gametest/framework/StructureUtils.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/gametest/framework/TestCommand.java.patch diff --git a/paper-server/patches/sources/net/minecraft/gametest/framework/GameTestInfo.java.patch b/paper-server/patches/sources/net/minecraft/gametest/framework/GameTestInfo.java.patch new file mode 100644 index 0000000000..91fda07c6b --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/gametest/framework/GameTestInfo.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/gametest/framework/GameTestInfo.java ++++ b/net/minecraft/gametest/framework/GameTestInfo.java +@@ -241,7 +_,7 @@ + AABB structureBounds = this.getStructureBounds(); + List entitiesOfClass = this.getLevel() + .getEntitiesOfClass(Entity.class, structureBounds.inflate(1.0), entity -> !(entity instanceof Player)); +- entitiesOfClass.forEach(entity -> entity.remove(Entity.RemovalReason.DISCARDED)); ++ entitiesOfClass.forEach(entity -> entity.remove(Entity.RemovalReason.DISCARDED, org.bukkit.event.entity.EntityRemoveEvent.Cause.DISCARD)); // Paper + } + } + diff --git a/paper-server/patches/sources/net/minecraft/gametest/framework/StructureUtils.java.patch b/paper-server/patches/sources/net/minecraft/gametest/framework/StructureUtils.java.patch new file mode 100644 index 0000000000..23eeabf7b9 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/gametest/framework/StructureUtils.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/gametest/framework/StructureUtils.java ++++ b/net/minecraft/gametest/framework/StructureUtils.java +@@ -187,7 +_,7 @@ + level.clearBlockEvents(boundingBox1); + AABB aabb = AABB.of(boundingBox1); + List entitiesOfClass = level.getEntitiesOfClass(Entity.class, aabb, entity -> !(entity instanceof Player)); +- entitiesOfClass.forEach(Entity::discard); ++ entitiesOfClass.forEach(entity -> entity.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DISCARD)); // Paper + } + + public static BlockPos getTransformedFarCorner(BlockPos pos, Vec3i offset, Rotation rotation) { diff --git a/paper-server/patches/sources/net/minecraft/gametest/framework/TestCommand.java.patch b/paper-server/patches/sources/net/minecraft/gametest/framework/TestCommand.java.patch new file mode 100644 index 0000000000..6ca1c0d342 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/gametest/framework/TestCommand.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/gametest/framework/TestCommand.java ++++ b/net/minecraft/gametest/framework/TestCommand.java +@@ -278,7 +_,7 @@ + } + + private static int resetGameTestInfo(GameTestInfo gameTestInfo) { +- gameTestInfo.getLevel().getEntities(null, gameTestInfo.getStructureBounds()).stream().forEach(entity -> entity.remove(Entity.RemovalReason.DISCARDED)); ++ gameTestInfo.getLevel().getEntities(null, gameTestInfo.getStructureBounds()).stream().forEach(entity -> entity.remove(Entity.RemovalReason.DISCARDED, org.bukkit.event.entity.EntityRemoveEvent.Cause.DISCARD)); // Paper + gameTestInfo.getStructureBlockEntity().placeStructure(gameTestInfo.getLevel()); + StructureUtils.removeBarriers(gameTestInfo.getStructureBounds(), gameTestInfo.getLevel()); + say(gameTestInfo.getLevel(), "Reset succeded for: " + gameTestInfo.getTestName(), ChatFormatting.GREEN); diff --git a/paper-server/src/test/java/org/bukkit/event/EntityRemoveEventTest.java b/paper-server/src/test/java/org/bukkit/event/EntityRemoveEventTest.java index 56d2eb4b92..0d198f2592 100644 --- a/paper-server/src/test/java/org/bukkit/event/EntityRemoveEventTest.java +++ b/paper-server/src/test/java/org/bukkit/event/EntityRemoveEventTest.java @@ -103,6 +103,9 @@ public class EntityRemoveEventTest { } Class ownerClass = Class.forName(owner.replace('/', '.'), false, this.getClass().getClassLoader()); + if (ownerClass == EntityAccess.class) { + return false; + } // Found missing discard, remove or setRemoved method call return EntityAccess.class.isAssignableFrom(ownerClass);