diff --git a/fabric-1.20.1/src/main/java/net/william278/uniform/fabric/mixins/ArgumentNodeMixin.java b/fabric-1.20.1/src/main/java/net/william278/uniform/fabric/mixins/ArgumentNodeMixin.java index 309b4dc..e76f3da 100644 --- a/fabric-1.20.1/src/main/java/net/william278/uniform/fabric/mixins/ArgumentNodeMixin.java +++ b/fabric-1.20.1/src/main/java/net/william278/uniform/fabric/mixins/ArgumentNodeMixin.java @@ -21,43 +21,33 @@ package net.william278.uniform.fabric.mixins; +import com.mojang.brigadier.arguments.ArgumentType; import com.mojang.brigadier.arguments.StringArgumentType; -import com.mojang.brigadier.tree.ArgumentCommandNode; -import net.minecraft.command.CommandSource; import net.minecraft.command.argument.ArgumentTypes; import net.minecraft.command.argument.serialize.ArgumentSerializer; -import net.minecraft.command.suggestion.SuggestionProviders; import net.minecraft.network.packet.s2c.play.CommandTreeS2CPacket.ArgumentNode; -import net.minecraft.util.Identifier; -import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Invoker; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; @Mixin(ArgumentNode.class) public class ArgumentNodeMixin { - @Invoker("") - private static ArgumentNode createArgumentNode(String name, ArgumentSerializer.ArgumentTypeProperties properties, - @Nullable Identifier id) { - throw new AssertionError(); - } - - @Redirect(method = "(Lcom/mojang/brigadier/tree/ArgumentCommandNode;)V", at = @At("HEAD")) - private static ArgumentNode onConstruct(ArgumentCommandNode node) { + @Redirect( + method = "(Lcom/mojang/brigadier/tree/ArgumentCommandNode;)V", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/command/argument/ArgumentTypes;getArgumentTypeProperties(Lcom/mojang/brigadier/arguments/ArgumentType;)Lnet/minecraft/command/argument/serialize/ArgumentSerializer$ArgumentTypeProperties;" + ) + ) + private static ArgumentSerializer.ArgumentTypeProperties onConstruct(ArgumentType type) { ArgumentSerializer.ArgumentTypeProperties properties; try { - properties = ArgumentTypes.getArgumentTypeProperties(node.getType()); + properties = ArgumentTypes.getArgumentTypeProperties(type); } catch (IllegalArgumentException e) { properties = ArgumentTypes.getArgumentTypeProperties(StringArgumentType.string()); } - - return createArgumentNode( - node.getName(), - properties, - node.getCustomSuggestions() != null ? SuggestionProviders.computeId(node.getCustomSuggestions()) : null - ); + return properties; } } diff --git a/fabric-1.20.6/src/main/java/net/william278/uniform/fabric/mixins/ArgumentNodeMixin.java b/fabric-1.20.6/src/main/java/net/william278/uniform/fabric/mixins/ArgumentNodeMixin.java index 309b4dc..e76f3da 100644 --- a/fabric-1.20.6/src/main/java/net/william278/uniform/fabric/mixins/ArgumentNodeMixin.java +++ b/fabric-1.20.6/src/main/java/net/william278/uniform/fabric/mixins/ArgumentNodeMixin.java @@ -21,43 +21,33 @@ package net.william278.uniform.fabric.mixins; +import com.mojang.brigadier.arguments.ArgumentType; import com.mojang.brigadier.arguments.StringArgumentType; -import com.mojang.brigadier.tree.ArgumentCommandNode; -import net.minecraft.command.CommandSource; import net.minecraft.command.argument.ArgumentTypes; import net.minecraft.command.argument.serialize.ArgumentSerializer; -import net.minecraft.command.suggestion.SuggestionProviders; import net.minecraft.network.packet.s2c.play.CommandTreeS2CPacket.ArgumentNode; -import net.minecraft.util.Identifier; -import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Invoker; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; @Mixin(ArgumentNode.class) public class ArgumentNodeMixin { - @Invoker("") - private static ArgumentNode createArgumentNode(String name, ArgumentSerializer.ArgumentTypeProperties properties, - @Nullable Identifier id) { - throw new AssertionError(); - } - - @Redirect(method = "(Lcom/mojang/brigadier/tree/ArgumentCommandNode;)V", at = @At("HEAD")) - private static ArgumentNode onConstruct(ArgumentCommandNode node) { + @Redirect( + method = "(Lcom/mojang/brigadier/tree/ArgumentCommandNode;)V", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/command/argument/ArgumentTypes;getArgumentTypeProperties(Lcom/mojang/brigadier/arguments/ArgumentType;)Lnet/minecraft/command/argument/serialize/ArgumentSerializer$ArgumentTypeProperties;" + ) + ) + private static ArgumentSerializer.ArgumentTypeProperties onConstruct(ArgumentType type) { ArgumentSerializer.ArgumentTypeProperties properties; try { - properties = ArgumentTypes.getArgumentTypeProperties(node.getType()); + properties = ArgumentTypes.getArgumentTypeProperties(type); } catch (IllegalArgumentException e) { properties = ArgumentTypes.getArgumentTypeProperties(StringArgumentType.string()); } - - return createArgumentNode( - node.getName(), - properties, - node.getCustomSuggestions() != null ? SuggestionProviders.computeId(node.getCustomSuggestions()) : null - ); + return properties; } } diff --git a/gradle.properties b/gradle.properties index b3c6038..015e27d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,6 +3,6 @@ javaVersion=17 org.gradle.jvmargs='-Dfile.encoding=UTF-8' org.gradle.daemon=true -library_version=1.0.12 +library_version=1.0.13 library_archive=uniform library_description=Cross-platform wrapper for making Brigadier commands, based on BrigadierWrapper by Tofaa2, itself inspired by emortalmcs command system. \ No newline at end of file