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;
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("<init>")
private static ArgumentNode createArgumentNode(String name, ArgumentSerializer.ArgumentTypeProperties<?> properties,
@Nullable Identifier id) {
throw new AssertionError();
}
@Redirect(method = "<init>(Lcom/mojang/brigadier/tree/ArgumentCommandNode;)V", at = @At("HEAD"))
private static ArgumentNode onConstruct(ArgumentCommandNode<CommandSource, ?> node) {
@Redirect(
method = "<init>(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;
}
}

@ -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("<init>")
private static ArgumentNode createArgumentNode(String name, ArgumentSerializer.ArgumentTypeProperties<?> properties,
@Nullable Identifier id) {
throw new AssertionError();
}
@Redirect(method = "<init>(Lcom/mojang/brigadier/tree/ArgumentCommandNode;)V", at = @At("HEAD"))
private static ArgumentNode onConstruct(ArgumentCommandNode<CommandSource, ?> node) {
@Redirect(
method = "<init>(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;
}
}

@ -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.
Loading…
Cancel
Save