Skip to content

Commit f5904eb

Browse files
committed
Fix /assert entity showing null instead of the entity selector
1 parent 3e644a2 commit f5904eb

2 files changed

Lines changed: 9 additions & 7 deletions

File tree

src/main/java/io/github/misode/packtest/mixin/BlockPredicateArgumentMixin.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import com.mojang.brigadier.StringReader;
88
import io.github.misode.packtest.PackTestArgumentSource;
99
import net.minecraft.commands.arguments.blocks.BlockPredicateArgument;
10+
import net.minecraft.core.HolderLookup;
11+
import net.minecraft.world.level.block.Block;
1012
import org.spongepowered.asm.mixin.Mixin;
1113
import org.spongepowered.asm.mixin.injection.At;
1214
import org.spongepowered.asm.mixin.injection.Inject;
@@ -17,13 +19,13 @@
1719
*/
1820
@Mixin(BlockPredicateArgument.class)
1921
public class BlockPredicateArgumentMixin {
20-
@Inject(method = "parse(Lcom/mojang/brigadier/StringReader;)Lnet/minecraft/commands/arguments/blocks/BlockPredicateArgument$Result;", at = @At("HEAD"))
21-
private void getCursor(StringReader stringReader, CallbackInfoReturnable<BlockPredicateArgument.Result> cir, @Share("cursor") LocalIntRef cursorRef) {
22+
@Inject(method = "parse(Lnet/minecraft/core/HolderLookup;Lcom/mojang/brigadier/StringReader;)Lnet/minecraft/commands/arguments/blocks/BlockPredicateArgument$Result;", at = @At("HEAD"))
23+
private static void getCursor(HolderLookup<Block> holderLookup, StringReader stringReader, CallbackInfoReturnable<BlockPredicateArgument.Result> cir, @Share("cursor") LocalIntRef cursorRef) {
2224
cursorRef.set(stringReader.getCursor());
2325
}
2426

25-
@ModifyReturnValue(method = "parse(Lcom/mojang/brigadier/StringReader;)Lnet/minecraft/commands/arguments/blocks/BlockPredicateArgument$Result;", at = @At("RETURN"))
26-
private BlockPredicateArgument.Result returnSelector(BlockPredicateArgument.Result result, @Local StringReader reader, @Share("cursor") LocalIntRef cursorRef) {
27+
@ModifyReturnValue(method = "parse(Lnet/minecraft/core/HolderLookup;Lcom/mojang/brigadier/StringReader;)Lnet/minecraft/commands/arguments/blocks/BlockPredicateArgument$Result;", at = @At("RETURN"))
28+
private static BlockPredicateArgument.Result returnSelector(BlockPredicateArgument.Result result, @Local(argsOnly = true) StringReader reader, @Share("cursor") LocalIntRef cursorRef) {
2729
((PackTestArgumentSource)result).packtest$setSource(reader.getRead().substring(cursorRef.get()));
2830
return result;
2931
}

src/main/java/io/github/misode/packtest/mixin/EntityArgumentMixin.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919
@Mixin(EntityArgument.class)
2020
public class EntityArgumentMixin {
2121

22-
@Inject(method = "parse(Lcom/mojang/brigadier/StringReader;)Lnet/minecraft/commands/arguments/selector/EntitySelector;", at = @At("HEAD"))
23-
private void getCursor(StringReader stringReader, CallbackInfoReturnable<EntitySelector> cir, @Share("cursor") LocalIntRef cursorRef) {
22+
@Inject(method = "parse(Lcom/mojang/brigadier/StringReader;Z)Lnet/minecraft/commands/arguments/selector/EntitySelector;", at = @At("HEAD"))
23+
private void getCursor(StringReader stringReader, boolean bl, CallbackInfoReturnable<EntitySelector> cir, @Share("cursor") LocalIntRef cursorRef) {
2424
cursorRef.set(stringReader.getCursor());
2525
}
2626

27-
@ModifyReturnValue(method = "parse(Lcom/mojang/brigadier/StringReader;)Lnet/minecraft/commands/arguments/selector/EntitySelector;", at = @At("RETURN"))
27+
@ModifyReturnValue(method = "parse(Lcom/mojang/brigadier/StringReader;Z)Lnet/minecraft/commands/arguments/selector/EntitySelector;", at = @At("RETURN"))
2828
private EntitySelector returnSelector(EntitySelector selector, @Local(argsOnly = true) StringReader reader, @Share("cursor") LocalIntRef cursorRef) {
2929
((PackTestArgumentSource)selector).packtest$setSource(reader.getRead().substring(cursorRef.get()));
3030
return selector;

0 commit comments

Comments
 (0)