generated from FabricMC/fabric-example-mod
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor how helper is accessed in commands
- Loading branch information
Showing
9 changed files
with
135 additions
and
90 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
9 changes: 9 additions & 0 deletions
9
src/main/java/io/github/misode/packtest/PackTestSourceStack.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,9 @@ | ||
package io.github.misode.packtest; | ||
|
||
import net.minecraft.gametest.framework.GameTestHelper; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public interface PackTestSourceStack { | ||
@Nullable GameTestHelper packtest$getHelper(); | ||
void packtest$setHelper(GameTestHelper helper); | ||
} |
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
89 changes: 89 additions & 0 deletions
89
src/main/java/io/github/misode/packtest/mixin/CommandSourceStackMixin.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,89 @@ | ||
package io.github.misode.packtest.mixin; | ||
|
||
import com.llamalad7.mixinextras.injector.ModifyReturnValue; | ||
import io.github.misode.packtest.PackTestSourceStack; | ||
import net.minecraft.commands.CommandSourceStack; | ||
import net.minecraft.gametest.framework.GameTestHelper; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Unique; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
|
||
@Mixin(CommandSourceStack.class) | ||
public class CommandSourceStackMixin implements PackTestSourceStack { | ||
@Unique | ||
private GameTestHelper helper; | ||
|
||
public GameTestHelper packtest$getHelper() { | ||
return this.helper; | ||
} | ||
|
||
public void packtest$setHelper(GameTestHelper helper) { | ||
this.helper = helper; | ||
} | ||
|
||
@ModifyReturnValue(method = "withSource", at = @At("RETURN")) | ||
private CommandSourceStack withSource(CommandSourceStack original) { | ||
((CommandSourceStackMixin)(Object)original).helper = this.helper; | ||
return original; | ||
} | ||
|
||
@ModifyReturnValue(method = "withEntity", at = @At("RETURN")) | ||
private CommandSourceStack withEntity(CommandSourceStack original) { | ||
((CommandSourceStackMixin)(Object)original).helper = this.helper; | ||
return original; | ||
} | ||
|
||
@ModifyReturnValue(method = "withPosition", at = @At("RETURN")) | ||
private CommandSourceStack withPosition(CommandSourceStack original) { | ||
((CommandSourceStackMixin)(Object)original).helper = this.helper; | ||
return original; | ||
} | ||
|
||
@ModifyReturnValue(method = "withRotation", at = @At("RETURN")) | ||
private CommandSourceStack withRotation(CommandSourceStack original) { | ||
((CommandSourceStackMixin)(Object)original).helper = this.helper; | ||
return original; | ||
} | ||
|
||
@ModifyReturnValue(method = "withCallback(Lnet/minecraft/commands/CommandResultCallback;)Lnet/minecraft/commands/CommandSourceStack;", at = @At("RETURN")) | ||
private CommandSourceStack withCallback(CommandSourceStack original) { | ||
((CommandSourceStackMixin)(Object)original).helper = this.helper; | ||
return original; | ||
} | ||
|
||
@ModifyReturnValue(method = "withSuppressedOutput", at = @At("RETURN")) | ||
private CommandSourceStack withSuppressedOutput(CommandSourceStack original) { | ||
((CommandSourceStackMixin)(Object)original).helper = this.helper; | ||
return original; | ||
} | ||
|
||
@ModifyReturnValue(method = "withPermission", at = @At("RETURN")) | ||
private CommandSourceStack withPermission(CommandSourceStack original) { | ||
((CommandSourceStackMixin)(Object)original).helper = this.helper; | ||
return original; | ||
} | ||
|
||
@ModifyReturnValue(method = "withMaximumPermission", at = @At("RETURN")) | ||
private CommandSourceStack withMaximumPermission(CommandSourceStack original) { | ||
((CommandSourceStackMixin)(Object)original).helper = this.helper; | ||
return original; | ||
} | ||
|
||
@ModifyReturnValue(method = "withAnchor", at = @At("RETURN")) | ||
private CommandSourceStack withAnchor(CommandSourceStack original) { | ||
((CommandSourceStackMixin)(Object)original).helper = this.helper; | ||
return original; | ||
} | ||
|
||
@ModifyReturnValue(method = "withLevel", at = @At("RETURN")) | ||
private CommandSourceStack withLevel(CommandSourceStack original) { | ||
((CommandSourceStackMixin)(Object)original).helper = this.helper; | ||
return original; | ||
} | ||
|
||
@ModifyReturnValue(method = "withSigningContext", at = @At("RETURN")) | ||
private CommandSourceStack withSigningContext(CommandSourceStack original) { | ||
((CommandSourceStackMixin)(Object)original).helper = this.helper; | ||
return original; | ||
} | ||
} |
20 changes: 0 additions & 20 deletions
20
src/main/java/io/github/misode/packtest/mixin/GameTestInfoMixin.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
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