diff --git a/modules/gametest/src/main/java/io/github/fabricators_of_create/porting_lib/gametest/mixin/TestCommandMixin.java b/modules/gametest/src/main/java/io/github/fabricators_of_create/porting_lib/gametest/mixin/TestCommandMixin.java index 596e4091..de4bfa1b 100644 --- a/modules/gametest/src/main/java/io/github/fabricators_of_create/porting_lib/gametest/mixin/TestCommandMixin.java +++ b/modules/gametest/src/main/java/io/github/fabricators_of_create/porting_lib/gametest/mixin/TestCommandMixin.java @@ -2,6 +2,8 @@ //import io.github.fabricators_of_create.porting_lib.gametest.infrastructure.ExtendedTestFunction; +import io.github.fabricators_of_create.porting_lib.gametest.infrastructure.ExtendedTestFunction; + import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -22,24 +24,24 @@ @Mixin(TestCommand.class) public class TestCommandMixin { - // fixme port me :plead: -// @WrapOperation( -// method = "runTest(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/core/BlockPos;Lnet/minecraft/gametest/framework/MultipleTestTracker;Z)V", -// at = @At( -// value = "INVOKE", -// target = "Lnet/minecraft/gametest/framework/GameTestRegistry;findTestFunction(Ljava/lang/String;)Ljava/util/Optional;" -// ), -// require = 0 // non-critical -// ) -// private static Optional getCorrectTestFunction(String testName, Operation> original, -// ServerLevel level, BlockPos pos, @Nullable MultipleTestTracker tracker, -// @Local StructureBlockEntity structureBlock) { -// String qualifiedTestName = ((StructureBlockEntityExtensions) structureBlock).getQualifiedTestName(); -// if (qualifiedTestName == null) -// return original.call(testName); -// ExtendedTestFunction function = ExtendedTestFunction.NAMES_TO_FUNCTIONS.get(qualifiedTestName); -// if (function == null) -// throw new IllegalStateException("Could not find test function " + qualifiedTestName); -// return Optional.of(function); -// } + // FIXME, this mixin needs to be redone + @WrapOperation( + method = "runTest(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/core/BlockPos;Lnet/minecraft/gametest/framework/MultipleTestTracker;Z)V", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/gametest/framework/GameTestRegistry;findTestFunction(Ljava/lang/String;)Ljava/util/Optional;" + ), + require = 0 // non-critical + ) + private static Optional getCorrectTestFunction(String testName, Operation> original, + ServerLevel level, BlockPos pos, @Nullable MultipleTestTracker tracker, + @Local StructureBlockEntity structureBlock) { + String qualifiedTestName = ((StructureBlockEntityExtensions) structureBlock).getQualifiedTestName(); + if (qualifiedTestName == null) + return original.call(testName); + ExtendedTestFunction function = ExtendedTestFunction.NAMES_TO_FUNCTIONS.get(qualifiedTestName); + if (function == null) + throw new IllegalStateException("Could not find test function " + qualifiedTestName); + return Optional.of(function.testFunction); + } }