forked from Sinytra/ForgifiedFabricAPI
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
119 additions
and
364 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 0 additions & 50 deletions
50
...-gametest-api-v1/src/main/java/net/fabricmc/fabric/mixin/gametest/ArgumentTypesMixin.java
This file was deleted.
Oops, something went wrong.
47 changes: 0 additions & 47 deletions
47
...gametest-api-v1/src/main/java/net/fabricmc/fabric/mixin/gametest/CommandManagerMixin.java
This file was deleted.
Oops, something went wrong.
22 changes: 22 additions & 0 deletions
22
...-gametest-api-v1/src/main/java/net/fabricmc/fabric/mixin/gametest/GameTestHooksMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package net.fabricmc.fabric.mixin.gametest; | ||
|
||
import net.neoforged.neoforge.gametest.GameTestHooks; | ||
import org.sinytra.fabric.gametest_api_v1.FabricGameTestApiV1; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
import java.lang.reflect.Method; | ||
|
||
@Mixin(value = GameTestHooks.class, remap = false) | ||
public class GameTestHooksMixin { | ||
|
||
@Inject(method = "getTemplateNamespace", at = @At("TAIL"), cancellable = true) | ||
private static void provideFabricTestNamespace(Method method, CallbackInfoReturnable<String> cir) { | ||
String namespace = FabricGameTestApiV1.getGameTestNamespace(method); | ||
if (namespace != null) { | ||
cir.setReturnValue(namespace); | ||
} | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
...metest-api-v1/src/main/java/net/fabricmc/fabric/mixin/gametest/GameTestRegistryMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package net.fabricmc.fabric.mixin.gametest; | ||
|
||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation; | ||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; | ||
import net.fabricmc.fabric.api.gametest.v1.FabricGameTest; | ||
import net.minecraft.gametest.framework.GameTest; | ||
import net.minecraft.gametest.framework.GameTestHelper; | ||
import net.minecraft.gametest.framework.GameTestRegistry; | ||
import org.sinytra.fabric.gametest_api_v1.FabricGameTestApiV1; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.ModifyVariable; | ||
|
||
import java.lang.reflect.Method; | ||
|
||
@Mixin(value = GameTestRegistry.class) | ||
public class GameTestRegistryMixin { | ||
|
||
@ModifyVariable(method = "turnMethodIntoTestFunction", at = @At(value = "INVOKE", target = "Lnet/minecraft/gametest/framework/GameTest;batch()Ljava/lang/String;"), ordinal = 3) | ||
private static String provideFabricTestName(String str, Method method) { | ||
if (FabricGameTestApiV1.shouldProcess(method)) { | ||
GameTest gametest = method.getAnnotation(GameTest.class); | ||
if (gametest.templateNamespace().isEmpty() && !gametest.template().isEmpty()) { | ||
return gametest.template(); | ||
} | ||
} | ||
return str; | ||
} | ||
|
||
@WrapOperation(method = "lambda$turnMethodIntoConsumer$5(Ljava/lang/reflect/Method;Ljava/lang/Object;)V", at = @At(value = "INVOKE", target = "Ljava/lang/reflect/Method;invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;")) | ||
private static Object redirectTestInvoker(Method method, Object instance, Object[] args, Operation<Object> original) { | ||
if (instance instanceof FabricGameTest fabricGameTest && args.length > 0 && args[0] instanceof GameTestHelper ctx) { | ||
fabricGameTest.invokeTestMethod(ctx, method); | ||
return null; | ||
} | ||
return original.call(method, instance, args); | ||
} | ||
} |
46 changes: 0 additions & 46 deletions
46
...ametest-api-v1/src/main/java/net/fabricmc/fabric/mixin/gametest/MinecraftServerMixin.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.