diff --git a/fabric-1.20.1/build.gradle b/fabric-1.20.1/build.gradle index 993f765..85e257e 100644 --- a/fabric-1.20.1/build.gradle +++ b/fabric-1.20.1/build.gradle @@ -18,10 +18,16 @@ dependencies { annotationProcessor 'org.projectlombok:lombok:1.18.32' } +loom { + accessWidenerPath = file("src/main/resources/uniform.accesswidener") +} + shadowJar { configurations = [project.configurations.shadow] exclude('net.fabricmc:.*') exclude('net.kyori:.*') exclude '/mappings/*' -} \ No newline at end of file +} + +shadowJar.finalizedBy(remapJar) \ No newline at end of file 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 2e06334..9c64f68 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 @@ -28,41 +28,50 @@ import net.minecraft.command.argument.ArgumentTypes; import net.minecraft.command.argument.serialize.ArgumentSerializer; import net.minecraft.command.suggestion.SuggestionProviders; import net.minecraft.util.Identifier; -import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mutable; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.Redirect; @Mixin(targets = "net/minecraft/network/packet/s2c/play/CommandTreeS2CPacket$ArgumentNode") public class ArgumentNodeMixin { - + @Mutable @Final @Shadow private String name; + @Mutable @Final @Shadow private ArgumentSerializer.ArgumentTypeProperties properties; + @Mutable @Final - @Nullable @Shadow - private Identifier id; // Actually, the suggestion provider. Possibly the worst field name in the entire yarn mappings? + private Identifier id; // Worst mapping name in the entirety of yarn. Actually suggestion providers. Lmao. + + ArgumentNodeMixin(String name, ArgumentSerializer.ArgumentTypeProperties properties, Identifier id) { + this.name = name; + this.properties = properties; + this.id = id; + } - @Inject(method = "(Lcom/mojang/brigadier/tree/ArgumentCommandNode;)V", at = @At("RETURN")) - private void onConstruct(ArgumentCommandNode node, CallbackInfo ci) { - this.name = node.getName(); - this.id = node.getCustomSuggestions() != null ? SuggestionProviders.computeId(node.getCustomSuggestions()) : null; + @Redirect(method = "(Lcom/mojang/brigadier/tree/ArgumentCommandNode;)V", at = @At("HEAD")) + private static ArgumentNodeMixin onConstruct(ArgumentCommandNode node) { + ArgumentSerializer.ArgumentTypeProperties properties; try { - this.properties = ArgumentTypes.get(node.getType()).getArgumentTypeProperties(node.getType()); + properties = ArgumentTypes.get(node.getType()).getArgumentTypeProperties(node.getType()); } catch (IllegalArgumentException e) { - this.properties = ArgumentTypes.get(StringArgumentType.string()).getArgumentTypeProperties(StringArgumentType.string()); + properties = ArgumentTypes.get(StringArgumentType.string()).getArgumentTypeProperties(StringArgumentType.string()); } + return new ArgumentNodeMixin( + node.getName(), + properties, + node.getCustomSuggestions() != null ? SuggestionProviders.computeId(node.getCustomSuggestions()) : null + ); } } diff --git a/fabric-1.20.1/src/main/resources/uniform.accesswidener b/fabric-1.20.1/src/main/resources/uniform.accesswidener index 75137e2..1a83124 100644 --- a/fabric-1.20.1/src/main/resources/uniform.accesswidener +++ b/fabric-1.20.1/src/main/resources/uniform.accesswidener @@ -1,3 +1,4 @@ accessWidener v2 named -accessible class net/minecraft/network/packet/s2c/play/CommandTreeS2CPacket$ArgumentNode \ No newline at end of file +extendable class net/minecraft/network/packet/s2c/play/CommandTreeS2CPacket$ArgumentNode +accessible method net/minecraft/network/packet/s2c/play/CommandTreeS2CPacket$ArgumentNode (Ljava/lang/String;Lnet/minecraft/command/argument/serialize/ArgumentSerializer$ArgumentTypeProperties;Lnet/minecraft/util/Identifier;)V \ No newline at end of file diff --git a/fabric-1.20.1/src/main/resources/uniform.mixins.json b/fabric-1.20.1/src/main/resources/uniform.mixins.json index b5c2588..a838aec 100644 --- a/fabric-1.20.1/src/main/resources/uniform.mixins.json +++ b/fabric-1.20.1/src/main/resources/uniform.mixins.json @@ -1,6 +1,13 @@ { + "required": true, + "minVersion": "0.8", "package": "net.william278.uniform.fabric.mixins", - "mixins": [ + "compatibilityLevel": "JAVA_17", + "mixins": [], + "server": [ "ArgumentNodeMixin" - ] + ], + "injectors": { + "defaultRequire": 1 + } } \ No newline at end of file diff --git a/fabric-1.20.6/build.gradle b/fabric-1.20.6/build.gradle index dbcdb99..d36a024 100644 --- a/fabric-1.20.6/build.gradle +++ b/fabric-1.20.6/build.gradle @@ -18,10 +18,16 @@ dependencies { annotationProcessor 'org.projectlombok:lombok:1.18.32' } +loom { + accessWidenerPath = file("src/main/resources/uniform.accesswidener") +} + shadowJar { configurations = [project.configurations.shadow] exclude('net.fabricmc:.*') exclude('net.kyori:.*') exclude '/mappings/*' -} \ No newline at end of file +} + +shadowJar.finalizedBy(remapJar) \ No newline at end of file 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 2e06334..9c64f68 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 @@ -28,41 +28,50 @@ import net.minecraft.command.argument.ArgumentTypes; import net.minecraft.command.argument.serialize.ArgumentSerializer; import net.minecraft.command.suggestion.SuggestionProviders; import net.minecraft.util.Identifier; -import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mutable; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.Redirect; @Mixin(targets = "net/minecraft/network/packet/s2c/play/CommandTreeS2CPacket$ArgumentNode") public class ArgumentNodeMixin { - + @Mutable @Final @Shadow private String name; + @Mutable @Final @Shadow private ArgumentSerializer.ArgumentTypeProperties properties; + @Mutable @Final - @Nullable @Shadow - private Identifier id; // Actually, the suggestion provider. Possibly the worst field name in the entire yarn mappings? + private Identifier id; // Worst mapping name in the entirety of yarn. Actually suggestion providers. Lmao. + + ArgumentNodeMixin(String name, ArgumentSerializer.ArgumentTypeProperties properties, Identifier id) { + this.name = name; + this.properties = properties; + this.id = id; + } - @Inject(method = "(Lcom/mojang/brigadier/tree/ArgumentCommandNode;)V", at = @At("RETURN")) - private void onConstruct(ArgumentCommandNode node, CallbackInfo ci) { - this.name = node.getName(); - this.id = node.getCustomSuggestions() != null ? SuggestionProviders.computeId(node.getCustomSuggestions()) : null; + @Redirect(method = "(Lcom/mojang/brigadier/tree/ArgumentCommandNode;)V", at = @At("HEAD")) + private static ArgumentNodeMixin onConstruct(ArgumentCommandNode node) { + ArgumentSerializer.ArgumentTypeProperties properties; try { - this.properties = ArgumentTypes.get(node.getType()).getArgumentTypeProperties(node.getType()); + properties = ArgumentTypes.get(node.getType()).getArgumentTypeProperties(node.getType()); } catch (IllegalArgumentException e) { - this.properties = ArgumentTypes.get(StringArgumentType.string()).getArgumentTypeProperties(StringArgumentType.string()); + properties = ArgumentTypes.get(StringArgumentType.string()).getArgumentTypeProperties(StringArgumentType.string()); } + return new ArgumentNodeMixin( + node.getName(), + properties, + node.getCustomSuggestions() != null ? SuggestionProviders.computeId(node.getCustomSuggestions()) : null + ); } } diff --git a/fabric-1.20.6/src/main/resources/uniform.accesswidener b/fabric-1.20.6/src/main/resources/uniform.accesswidener index 75137e2..1a83124 100644 --- a/fabric-1.20.6/src/main/resources/uniform.accesswidener +++ b/fabric-1.20.6/src/main/resources/uniform.accesswidener @@ -1,3 +1,4 @@ accessWidener v2 named -accessible class net/minecraft/network/packet/s2c/play/CommandTreeS2CPacket$ArgumentNode \ No newline at end of file +extendable class net/minecraft/network/packet/s2c/play/CommandTreeS2CPacket$ArgumentNode +accessible method net/minecraft/network/packet/s2c/play/CommandTreeS2CPacket$ArgumentNode (Ljava/lang/String;Lnet/minecraft/command/argument/serialize/ArgumentSerializer$ArgumentTypeProperties;Lnet/minecraft/util/Identifier;)V \ No newline at end of file diff --git a/fabric-1.20.6/src/main/resources/uniform.mixins.json b/fabric-1.20.6/src/main/resources/uniform.mixins.json index b5c2588..a838aec 100644 --- a/fabric-1.20.6/src/main/resources/uniform.mixins.json +++ b/fabric-1.20.6/src/main/resources/uniform.mixins.json @@ -1,6 +1,13 @@ { + "required": true, + "minVersion": "0.8", "package": "net.william278.uniform.fabric.mixins", - "mixins": [ + "compatibilityLevel": "JAVA_17", + "mixins": [], + "server": [ "ArgumentNodeMixin" - ] + ], + "injectors": { + "defaultRequire": 1 + } } \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 0b3b9fa..5ab072b 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.8 +library_version=1.0.9 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