From 5173083b5c10e6b2c5874649b3d7ecec45a73fd4 Mon Sep 17 00:00:00 2001 From: Juuxel Date: Sun, 21 Apr 2019 14:15:08 +0300 Subject: [PATCH] Update to 1.14-pre5, Loader 0.4, bump version to 0.2.0 --- build.gradle | 2 +- project.gradle | 10 +++++----- .../clientcommands/ClientCommands.java | 13 ++----------- .../mixin/NetworkHandlerMixin.java | 2 ++ src/main/resources/fabric.mod.json | 18 ++++++++++-------- ...client.json => mixins.client-commands.json} | 2 +- .../clientcommands/test/ExampleMod.java | 6 +++--- 7 files changed, 24 insertions(+), 29 deletions(-) rename src/main/resources/{mixins.client-commands.client.json => mixins.client-commands.json} (93%) diff --git a/build.gradle b/build.gradle index 75c069d..48ff868 100644 --- a/build.gradle +++ b/build.gradle @@ -13,7 +13,7 @@ buildscript { } } dependencies { - classpath "net.fabricmc:fabric-loom:0.2.0-SNAPSHOT" //Don't backdate before 0.2.0; features in this version prevent messy workarounds! + classpath "net.fabricmc:fabric-loom:0.2.1-SNAPSHOT" //Don't backdate before 0.2.0; features in this version prevent messy workarounds! classpath "com.github.jengelman.gradle.plugins:shadow:5.0.0" } } diff --git a/project.gradle b/project.gradle index d2cd766..a5c9329 100644 --- a/project.gradle +++ b/project.gradle @@ -1,13 +1,13 @@ ext { projectName = "client-commands" group = "io.github.cottonmc" - version = "0.1.0+19w12b" + version = "0.2.0+1.14-pre5" snapshot = true - minecraft = "19w12b" - mappings = "19w12b.3" - loader = "0.3.7.109" - fabricMod = "0.2.5.114" + minecraft = "1.14 Pre-Release 5" + mappings = "1.14 Pre-Release 5+build.4" + loader = "0.4.2+build.130" + fabricMod = null silkMod = null jankson = null needsShadow = false diff --git a/src/main/java/io/github/cottonmc/clientcommands/ClientCommands.java b/src/main/java/io/github/cottonmc/clientcommands/ClientCommands.java index 0a4883f..20df8dd 100644 --- a/src/main/java/io/github/cottonmc/clientcommands/ClientCommands.java +++ b/src/main/java/io/github/cottonmc/clientcommands/ClientCommands.java @@ -1,9 +1,6 @@ package io.github.cottonmc.clientcommands; import com.mojang.brigadier.CommandDispatcher; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.ModInitializer; -import net.fabricmc.loader.api.FabricLoader; import net.minecraft.server.command.CommandSource; import java.util.Collection; @@ -12,7 +9,7 @@ import java.util.Set; import java.util.function.Consumer; -public final class ClientCommands implements ModInitializer { +public final class ClientCommands { private static final Set>> commands = new HashSet<>(); public static Collection>> getCommands() { @@ -27,12 +24,6 @@ public static Collection>> getCommands */ public static void registerCommand(Consumer> command) { // TODO: (Maybe) error if a common/dedicated command with the same base is already registered - if (FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT) - commands.add(command); - } - - @Override - public void onInitialize() { - + commands.add(command); } } diff --git a/src/main/java/io/github/cottonmc/clientcommands/mixin/NetworkHandlerMixin.java b/src/main/java/io/github/cottonmc/clientcommands/mixin/NetworkHandlerMixin.java index 19a088e..f43e1be 100644 --- a/src/main/java/io/github/cottonmc/clientcommands/mixin/NetworkHandlerMixin.java +++ b/src/main/java/io/github/cottonmc/clientcommands/mixin/NetworkHandlerMixin.java @@ -11,6 +11,7 @@ import net.minecraft.server.command.CommandSource; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @@ -29,6 +30,7 @@ private void onConstruct(MinecraftClient mc, Screen screen, ClientConnection cc, addCommands(); } + @Unique private void addCommands() { ClientCommands.getCommands().forEach(c -> c.accept(commandDispatcher)); } diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index b5ff04b..e597c0d 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -1,16 +1,18 @@ { + "schemaVersion": 1, "id": "clientcommands", "name": "Client Commands", "description": "Allows purely client-side commands.", - "version": "0.1.0", - "side": "universal", - "initializers": [ - "io.github.cottonmc.clientcommands.ClientCommands" - ], + "version": "0.2.0", + "environment": "client", + "license": "MIT", "requires": { - "fabric": "*" + "fabricloader": ">=0.4.0" }, - "mixins": { - "client": "mixins.client-commands.client.json" + "mixins": [ + "mixins.client-commands.json" + ], + "custom": { + "modmenu:clientsideOnly": true } } diff --git a/src/main/resources/mixins.client-commands.client.json b/src/main/resources/mixins.client-commands.json similarity index 93% rename from src/main/resources/mixins.client-commands.client.json rename to src/main/resources/mixins.client-commands.json index 02b3530..9c49168 100644 --- a/src/main/resources/mixins.client-commands.client.json +++ b/src/main/resources/mixins.client-commands.json @@ -2,7 +2,7 @@ "required": true, "package": "io.github.cottonmc.clientcommands.mixin", "compatibilityLevel": "JAVA_8", - "mixins": [ + "client": [ "PlayerMixin", "NetworkHandlerMixin" ], "injectors": { diff --git a/src/test/java/io/github/cottonmc/clientcommands/test/ExampleMod.java b/src/test/java/io/github/cottonmc/clientcommands/test/ExampleMod.java index 9acdde8..0fe6019 100644 --- a/src/test/java/io/github/cottonmc/clientcommands/test/ExampleMod.java +++ b/src/test/java/io/github/cottonmc/clientcommands/test/ExampleMod.java @@ -3,12 +3,12 @@ import io.github.cottonmc.clientcommands.ArgumentBuilders; import io.github.cottonmc.clientcommands.ClientCommands; import io.github.cottonmc.clientcommands.Feedback; -import net.fabricmc.api.ModInitializer; +import net.fabricmc.api.ClientModInitializer; import net.minecraft.text.StringTextComponent; -public class ExampleMod implements ModInitializer { +public class ExampleMod implements ClientModInitializer { @Override - public void onInitialize() { + public void onInitializeClient() { ClientCommands.registerCommand(dispatcher -> { dispatcher.register(ArgumentBuilders.literal("client-commands").executes( source -> {