fix return value of run not captured
This commit is contained in:
1 parent
f2b7aaf28c
commit
ca5f69a476
5 files changed
+44
-3
No files matched your search
@@ -0,0 +1,10 @@
|
||||
package carpet.fakes;
|
||||
|
||||
import net.minecraft.commands.CommandResultCallback;
|
||||
import net.minecraft.commands.CommandSigningContext;
|
||||
import net.minecraft.commands.arguments.EntityAnchorArgument;
|
||||
import net.minecraft.util.TaskChainer;
|
||||
|
||||
public interface CommandSourceStackInterface {
|
||||
void setupPrivates(boolean bl, CommandResultCallback commandResultCallback, EntityAnchorArgument.Anchor anchor, CommandSigningContext commandSigningContext, TaskChainer taskChainer);
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.fakes.CommandSourceStackInterface;
|
||||
import net.minecraft.commands.CommandResultCallback;
|
||||
import net.minecraft.commands.CommandSigningContext;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.arguments.EntityAnchorArgument;
|
||||
import net.minecraft.util.TaskChainer;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Mutable;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
@Mixin(CommandSourceStack.class)
|
||||
public class CommandSourceStack_scarpetMixin implements CommandSourceStackInterface {
|
||||
@Mutable @Shadow private boolean silent;
|
||||
@Mutable @Shadow private CommandResultCallback resultCallback;
|
||||
@Mutable @Shadow private EntityAnchorArgument.Anchor anchor;
|
||||
@Mutable @Shadow private CommandSigningContext signingContext;
|
||||
@Mutable @Shadow private TaskChainer chatMessageChainer;
|
||||
|
||||
@Override
|
||||
public void setupPrivates(boolean bl, CommandResultCallback commandResultCallback, EntityAnchorArgument.Anchor anchor, CommandSigningContext commandSigningContext, TaskChainer taskChainer) {
|
||||
this.silent = bl;
|
||||
this.resultCallback = commandResultCallback;
|
||||
this.anchor = anchor;
|
||||
this.signingContext = commandSigningContext;
|
||||
this.chatMessageChainer = taskChainer;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package carpet.script.utils;
|
||||
|
||||
import carpet.fakes.CommandSourceStackInterface;
|
||||
import carpet.script.external.Vanilla;
|
||||
import net.minecraft.commands.CommandResultCallback;
|
||||
import net.minecraft.commands.CommandSigningContext;
|
||||
@@ -66,6 +67,7 @@ public class SnoopyCommandSource extends CommandSourceStack
|
||||
this.chatOutput = chatOutput;
|
||||
this.signingContext = original.getSigningContext();
|
||||
this.taskChainer = TaskChainer.immediate(original.getServer());
|
||||
((CommandSourceStackInterface) this).setupPrivates(false, (b, i) -> returnValue[0] = OptionalLong.of(i), EntityAnchorArgument.Anchor.FEET, CommandSigningContext.ANONYMOUS, TaskChainer.immediate(original.getServer()));
|
||||
}
|
||||
|
||||
public SnoopyCommandSource(ServerPlayer player, Component[] error, List<Component> output, int [] result)
|
||||
@@ -89,6 +91,7 @@ public class SnoopyCommandSource extends CommandSourceStack
|
||||
this.chatOutput = output;
|
||||
this.signingContext = CommandSigningContext.ANONYMOUS;
|
||||
this.taskChainer = TaskChainer.immediate(player.level().getServer());
|
||||
((CommandSourceStackInterface) this).setupPrivates(false, (b, i) -> result[0] = i, EntityAnchorArgument.Anchor.FEET, CommandSigningContext.ANONYMOUS, TaskChainer.immediate(player.level().getServer()));
|
||||
}
|
||||
|
||||
private SnoopyCommandSource(CommandSource output, Vec3 pos, Vec2 rot, ServerLevel world, PermissionSet level, String simpleName, Component name, MinecraftServer server, @Nullable Entity entity, CommandResultCallback consumer, EntityAnchorArgument.Anchor entityAnchor, CommandSigningContext context, TaskChainer chainer,
|
||||
@@ -114,6 +117,7 @@ public class SnoopyCommandSource extends CommandSourceStack
|
||||
this.chatOutput = chatOutput;
|
||||
this.signingContext = context;
|
||||
this.taskChainer = chainer;
|
||||
((CommandSourceStackInterface) this).setupPrivates(false, consumer, entityAnchor, context, chainer);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user