@ -21,43 +21,33 @@
package net.william278.uniform.fabric.mixins ;
package net.william278.uniform.fabric.mixins ;
import com.mojang.brigadier.arguments.ArgumentType ;
import com.mojang.brigadier.arguments.StringArgumentType ;
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.ArgumentTypes ;
import net.minecraft.command.argument.serialize.ArgumentSerializer ;
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.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.Mixin ;
import org.spongepowered.asm.mixin.gen.Invoker ;
import org.spongepowered.asm.mixin.injection.At ;
import org.spongepowered.asm.mixin.injection.At ;
import org.spongepowered.asm.mixin.injection.Redirect ;
import org.spongepowered.asm.mixin.injection.Redirect ;
@Mixin ( ArgumentNode . class )
@Mixin ( ArgumentNode . class )
public class ArgumentNodeMixin {
public class ArgumentNodeMixin {
@ Invoker( "<init>" )
@ Redirect(
private static ArgumentNode createArgumentNode ( String name , ArgumentSerializer . ArgumentTypeProperties < ? > properties ,
method = "<init>(Lcom/mojang/brigadier/tree/ArgumentCommandNode;)V" ,
@Nullable Identifier id ) {
at = @At (
throw new AssertionError ( ) ;
value = "INVOKE" ,
}
target = "Lnet/minecraft/command/argument/ArgumentTypes;getArgumentTypeProperties(Lcom/mojang/brigadier/arguments/ArgumentType;)Lnet/minecraft/command/argument/serialize/ArgumentSerializer$ArgumentTypeProperties;"
)
@Redirect ( method = "<init>(Lcom/mojang/brigadier/tree/ArgumentCommandNode;)V" , at = @At ( "HEAD" ) )
)
private static Argument Node onConstruct ( ArgumentCommandNode < CommandSource , ? > nod e) {
private static Argument Serializer. ArgumentTypeProperties < ? > onConstruct ( ArgumentType < ? > typ e) {
ArgumentSerializer . ArgumentTypeProperties < ? > properties ;
ArgumentSerializer . ArgumentTypeProperties < ? > properties ;
try {
try {
properties = ArgumentTypes . getArgumentTypeProperties ( node. ge tT ype( ) ) ;
properties = ArgumentTypes . getArgumentTypeProperties ( type) ;
} catch ( IllegalArgumentException e ) {
} catch ( IllegalArgumentException e ) {
properties = ArgumentTypes . getArgumentTypeProperties ( StringArgumentType . string ( ) ) ;
properties = ArgumentTypes . getArgumentTypeProperties ( StringArgumentType . string ( ) ) ;
}
}
return properties ;
return createArgumentNode (
node . getName ( ) ,
properties ,
node . getCustomSuggestions ( ) ! = null ? SuggestionProviders . computeId ( node . getCustomSuggestions ( ) ) : null
) ;
}
}
}
}