mirror of
https://github.com/architectury/architectury-api.git
synced 2026-03-28 03:56:59 -05:00
@@ -21,6 +21,7 @@ package dev.architectury.mixin.fabric;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
import com.mojang.brigadier.ParseResults;
|
||||
import com.mojang.brigadier.context.ContextChain;
|
||||
import dev.architectury.event.events.common.CommandPerformEvent;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
@@ -28,13 +29,13 @@ 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.ModifyVariable;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(Commands.class)
|
||||
public class MixinCommands {
|
||||
@ModifyVariable(method = "performCommand",
|
||||
@ModifyVariable(method = "finishParsing",
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/commands/Commands;validateParseResults(Lcom/mojang/brigadier/ParseResults;)V", remap = false), argsOnly = true)
|
||||
private ParseResults<CommandSourceStack> performCommand(ParseResults<CommandSourceStack> results) {
|
||||
private static ParseResults<CommandSourceStack> finishParsing(ParseResults<CommandSourceStack> results) {
|
||||
var event = new CommandPerformEvent(results, null);
|
||||
if (CommandPerformEvent.EVENT.invoker().act(event).isPresent()) {
|
||||
if (event.getThrowable() != null) {
|
||||
@@ -45,9 +46,9 @@ public class MixinCommands {
|
||||
return event.getResults();
|
||||
}
|
||||
|
||||
@Inject(method = "performCommand",
|
||||
@Inject(method = "finishParsing",
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/commands/Commands;validateParseResults(Lcom/mojang/brigadier/ParseResults;)V", remap = false), cancellable = true)
|
||||
private void performCommand(ParseResults<CommandSourceStack> results, String command, CallbackInfo ci) {
|
||||
if (results == null) ci.cancel();
|
||||
private static void finishParsing(ParseResults<CommandSourceStack> results, String command, CommandSourceStack stack, CallbackInfoReturnable<ContextChain<CommandSourceStack>> cir) {
|
||||
if (results == null) cir.setReturnValue(null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@ org.gradle.daemon=false
|
||||
|
||||
platforms=fabric
|
||||
|
||||
minecraft_version=23w41a
|
||||
supported_version=23w41a
|
||||
minecraft_version=23w42a
|
||||
supported_version=23w42a
|
||||
|
||||
artifact_type=beta
|
||||
|
||||
@@ -14,7 +14,7 @@ base_version=11.0
|
||||
maven_group=dev.architectury
|
||||
|
||||
fabric_loader_version=0.14.23
|
||||
fabric_api_version=0.90.1+1.20.3
|
||||
fabric_api_version=0.90.3+1.20.3
|
||||
mod_menu_version=7.0.0
|
||||
|
||||
forge_version=48.0.1
|
||||
|
||||
Reference in New Issue
Block a user