Skip to content
This repository has been archived by the owner on Feb 28, 2021. It is now read-only.

Commit

Permalink
Update to 1.14-pre5, Loader 0.4, bump version to 0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Juuxel committed Apr 21, 2019
1 parent b475689 commit 5173083
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 29 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
Expand Down
10 changes: 5 additions & 5 deletions project.gradle
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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<Consumer<CommandDispatcher<CommandSource>>> commands = new HashSet<>();

public static Collection<Consumer<CommandDispatcher<CommandSource>>> getCommands() {
Expand All @@ -27,12 +24,6 @@ public static Collection<Consumer<CommandDispatcher<CommandSource>>> getCommands
*/
public static void registerCommand(Consumer<CommandDispatcher<CommandSource>> 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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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));
}
Expand Down
18 changes: 10 additions & 8 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
@@ -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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"required": true,
"package": "io.github.cottonmc.clientcommands.mixin",
"compatibilityLevel": "JAVA_8",
"mixins": [
"client": [
"PlayerMixin", "NetworkHandlerMixin"
],
"injectors": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 -> {
Expand Down

0 comments on commit 5173083

Please sign in to comment.