Skip to content

Commit

Permalink
uncomment test command mixin
Browse files Browse the repository at this point in the history
  • Loading branch information
IThundxr committed Aug 24, 2024
1 parent 55a25d1 commit 7cb7f05
Showing 1 changed file with 22 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<TestFunction> getCorrectTestFunction(String testName, Operation<Optional<TestFunction>> 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<TestFunction> getCorrectTestFunction(String testName, Operation<Optional<TestFunction>> 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);
}
}

0 comments on commit 7cb7f05

Please sign in to comment.