mirror of
https://github.com/ViaVersion/ViaFabric.git
synced 2024-12-19 15:57:37 +01:00
fabric client-side commands
This commit is contained in:
parent
cfa0c89178
commit
2b843d24b9
@ -65,8 +65,8 @@ dependencies {
|
|||||||
modImplementation("net.fabricmc.fabric-api:fabric-api:0.32.7+1.17")
|
modImplementation("net.fabricmc.fabric-api:fabric-api:0.32.7+1.17")
|
||||||
modImplementation("io.github.prospector:modmenu:1.14.5+build.30")
|
modImplementation("io.github.prospector:modmenu:1.14.5+build.30")
|
||||||
|
|
||||||
modImplementation("io.github.cottonmc:cotton-client-commands:1.0.1+1.16-rc1")
|
//modImplementation("io.github.cottonmc:cotton-client-commands:1.0.1+1.16-rc1")
|
||||||
include("io.github.cottonmc:cotton-client-commands:1.0.1+1.16-rc1")
|
//include("io.github.cottonmc:cotton-client-commands:1.0.1+1.16-rc1")
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!System.getenv()["curse_api_key"].isNullOrBlank() && branch.startsWith("mc-")) {
|
if (!System.getenv()["curse_api_key"].isNullOrBlank() && branch.startsWith("mc-")) {
|
||||||
|
@ -15,6 +15,7 @@ import com.mojang.brigadier.builder.RequiredArgumentBuilder;
|
|||||||
import io.netty.channel.DefaultEventLoop;
|
import io.netty.channel.DefaultEventLoop;
|
||||||
import io.netty.channel.EventLoop;
|
import io.netty.channel.EventLoop;
|
||||||
import net.fabricmc.api.ModInitializer;
|
import net.fabricmc.api.ModInitializer;
|
||||||
|
import net.fabricmc.fabric.api.client.command.v1.ClientCommandManager;
|
||||||
import net.fabricmc.fabric.api.command.v1.CommandRegistrationCallback;
|
import net.fabricmc.fabric.api.command.v1.CommandRegistrationCallback;
|
||||||
import net.fabricmc.fabric.api.registry.CommandRegistry;
|
import net.fabricmc.fabric.api.registry.CommandRegistry;
|
||||||
import net.fabricmc.loader.api.FabricLoader;
|
import net.fabricmc.loader.api.FabricLoader;
|
||||||
@ -99,6 +100,7 @@ public class ViaFabric implements ModInitializer {
|
|||||||
CommandRegistrationCallback.EVENT.register((dispatcher, dedicated) -> dispatcher.register(command("viaversion")));
|
CommandRegistrationCallback.EVENT.register((dispatcher, dedicated) -> dispatcher.register(command("viaversion")));
|
||||||
CommandRegistrationCallback.EVENT.register((dispatcher, dedicated) -> dispatcher.register(command("viaver")));
|
CommandRegistrationCallback.EVENT.register((dispatcher, dedicated) -> dispatcher.register(command("viaver")));
|
||||||
CommandRegistrationCallback.EVENT.register((dispatcher, dedicated) -> dispatcher.register(command("vvfabric")));
|
CommandRegistrationCallback.EVENT.register((dispatcher, dedicated) -> dispatcher.register(command("vvfabric")));
|
||||||
|
ClientCommandManager.DISPATCHER.register(command("viafabricclient"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
package com.github.creeper123123321.viafabric.commands;
|
package com.github.creeper123123321.viafabric.commands;
|
||||||
|
|
||||||
import com.github.creeper123123321.viafabric.platform.VRPlatform;
|
import com.github.creeper123123321.viafabric.platform.VRPlatform;
|
||||||
import io.github.cottonmc.clientcommands.CottonClientCommandSource;
|
import net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource;
|
||||||
import net.minecraft.client.MinecraftClient;
|
|
||||||
import net.minecraft.command.CommandSource;
|
import net.minecraft.command.CommandSource;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.server.command.ServerCommandSource;
|
import net.minecraft.server.command.ServerCommandSource;
|
||||||
@ -28,8 +27,8 @@ public class NMSCommandSender implements ViaCommandSender {
|
|||||||
public void sendMessage(String s) {
|
public void sendMessage(String s) {
|
||||||
if (source instanceof ServerCommandSource) {
|
if (source instanceof ServerCommandSource) {
|
||||||
((ServerCommandSource) source).sendFeedback(Text.Serializer.fromJson(VRPlatform.legacyToJson(s)), false);
|
((ServerCommandSource) source).sendFeedback(Text.Serializer.fromJson(VRPlatform.legacyToJson(s)), false);
|
||||||
} else if (source instanceof CottonClientCommandSource) {
|
} else if (source instanceof FabricClientCommandSource) {
|
||||||
((CottonClientCommandSource) source).sendFeedback(Text.Serializer.fromJson(VRPlatform.legacyToJson(s)), false);
|
((FabricClientCommandSource) source).sendFeedback(Text.Serializer.fromJson(VRPlatform.legacyToJson(s)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,8 +37,8 @@ public class NMSCommandSender implements ViaCommandSender {
|
|||||||
if (source instanceof ServerCommandSource) {
|
if (source instanceof ServerCommandSource) {
|
||||||
Entity entity = ((ServerCommandSource) source).getEntity();
|
Entity entity = ((ServerCommandSource) source).getEntity();
|
||||||
if (entity != null) return entity.getUuid();
|
if (entity != null) return entity.getUuid();
|
||||||
} else if (source instanceof CottonClientCommandSource) {
|
} else if (source instanceof FabricClientCommandSource) {
|
||||||
return MinecraftClient.getInstance().player.getUuid();
|
return ((FabricClientCommandSource) source).getPlayer().getUuid();
|
||||||
}
|
}
|
||||||
return UUID.fromString(getName());
|
return UUID.fromString(getName());
|
||||||
}
|
}
|
||||||
@ -48,8 +47,8 @@ public class NMSCommandSender implements ViaCommandSender {
|
|||||||
public String getName() {
|
public String getName() {
|
||||||
if (source instanceof ServerCommandSource) {
|
if (source instanceof ServerCommandSource) {
|
||||||
return ((ServerCommandSource) source).getName();
|
return ((ServerCommandSource) source).getName();
|
||||||
} else if (source instanceof CottonClientCommandSource) {
|
} else if (source instanceof FabricClientCommandSource) {
|
||||||
return MinecraftClient.getInstance().player.getEntityName();
|
return ((FabricClientCommandSource) source).getPlayer().getEntityName();
|
||||||
}
|
}
|
||||||
return "?";
|
return "?";
|
||||||
}
|
}
|
||||||
|
@ -1,13 +0,0 @@
|
|||||||
package com.github.creeper123123321.viafabric.commands;
|
|
||||||
|
|
||||||
import com.github.creeper123123321.viafabric.ViaFabric;
|
|
||||||
import com.mojang.brigadier.CommandDispatcher;
|
|
||||||
import io.github.cottonmc.clientcommands.ClientCommandPlugin;
|
|
||||||
import io.github.cottonmc.clientcommands.CottonClientCommandSource;
|
|
||||||
|
|
||||||
public class VRClientCommands implements ClientCommandPlugin {
|
|
||||||
@Override
|
|
||||||
public void registerCommands(CommandDispatcher<CottonClientCommandSource> commandDispatcher) {
|
|
||||||
commandDispatcher.register(ViaFabric.command("viafabricclient"));
|
|
||||||
}
|
|
||||||
}
|
|
@ -61,15 +61,11 @@
|
|||||||
"main": [
|
"main": [
|
||||||
"com.github.creeper123123321.viafabric.ViaFabric"
|
"com.github.creeper123123321.viafabric.ViaFabric"
|
||||||
],
|
],
|
||||||
"cotton-client-commands": [
|
|
||||||
"com.github.creeper123123321.viafabric.commands.VRClientCommands"
|
|
||||||
],
|
|
||||||
"modmenu": [
|
"modmenu": [
|
||||||
"com.github.creeper123123321.viafabric.gui.ModMenuConfig"
|
"com.github.creeper123123321.viafabric.gui.ModMenuConfig"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"depends": {
|
"depends": {
|
||||||
"cotton-client-commands": "*",
|
|
||||||
"fabricloader": ">=0.4.0",
|
"fabricloader": ">=0.4.0",
|
||||||
"fabric-resource-loader-v0": "*",
|
"fabric-resource-loader-v0": "*",
|
||||||
"minecraft": ">1.16.50",
|
"minecraft": ">1.16.50",
|
||||||
|
Loading…
Reference in New Issue
Block a user