fix: fix fabric mixins

dependabot/gradle/org.projectlombok-lombok-1.18.34 1.0.13
William 5 months ago
parent 187acc9195
commit 1817d12b5f
No known key found for this signature in database

@ -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 ArgumentNode onConstruct(ArgumentCommandNode<CommandSource, ?> node) { private static ArgumentSerializer.ArgumentTypeProperties<?> onConstruct(ArgumentType<?> type) {
ArgumentSerializer.ArgumentTypeProperties<?> properties; ArgumentSerializer.ArgumentTypeProperties<?> properties;
try { try {
properties = ArgumentTypes.getArgumentTypeProperties(node.getType()); 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
);
} }
} }

@ -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 ArgumentNode onConstruct(ArgumentCommandNode<CommandSource, ?> node) { private static ArgumentSerializer.ArgumentTypeProperties<?> onConstruct(ArgumentType<?> type) {
ArgumentSerializer.ArgumentTypeProperties<?> properties; ArgumentSerializer.ArgumentTypeProperties<?> properties;
try { try {
properties = ArgumentTypes.getArgumentTypeProperties(node.getType()); 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
);
} }
} }

@ -3,6 +3,6 @@ javaVersion=17
org.gradle.jvmargs='-Dfile.encoding=UTF-8' org.gradle.jvmargs='-Dfile.encoding=UTF-8'
org.gradle.daemon=true org.gradle.daemon=true
library_version=1.0.12 library_version=1.0.13
library_archive=uniform library_archive=uniform
library_description=Cross-platform wrapper for making Brigadier commands, based on BrigadierWrapper by Tofaa2, itself inspired by emortalmcs command system. library_description=Cross-platform wrapper for making Brigadier commands, based on BrigadierWrapper by Tofaa2, itself inspired by emortalmcs command system.
Loading…
Cancel
Save