fabric client-side commands, update modmenu

This commit is contained in:
creeper123123321 2021-04-09 17:01:14 -03:00
parent cc4cc7f265
commit e683756ea2
6 changed files with 22 additions and 36 deletions

View File

@ -37,6 +37,7 @@ repositories {
maven(url = "https://server.bbkr.space/artifactory/libs-snapshot")
maven(url = "https://server.bbkr.space/artifactory/libs-release")
maven(url = "https://maven.extracraftx.com")
maven("https://maven.terraformersmc.com/releases/")
}
@ -58,15 +59,15 @@ dependencies {
// Use 1.16 snapshot, probably intermediary will make it work on further versions
// https://modmuss50.me/fabric.html?&version=1.16
minecraft("com.mojang:minecraft:1.16.3")
mappings("net.fabricmc:yarn:1.16.3+build.5:v2")
modImplementation("net.fabricmc:fabric-loader:0.9.3+build.207")
minecraft("com.mojang:minecraft:1.16.5")
mappings("net.fabricmc:yarn:1.16.5+build.6:v2")
modImplementation("net.fabricmc:fabric-loader:0.11.3")
modImplementation("net.fabricmc.fabric-api:fabric-api:0.20.2+build.402-1.16")
modImplementation("io.github.prospector:modmenu:1.14.5+build.30")
modImplementation("net.fabricmc.fabric-api:fabric-api:0.32.5+1.16")
modImplementation("com.terraformersmc:modmenu:1.16.9")
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")
//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")
}
if (!System.getenv()["curse_api_key"].isNullOrBlank() && branch.startsWith("mc-")) {

View File

@ -15,10 +15,11 @@ import com.mojang.brigadier.builder.RequiredArgumentBuilder;
import io.netty.channel.DefaultEventLoop;
import io.netty.channel.EventLoop;
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.registry.CommandRegistry;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.server.command.CommandSource;
import net.minecraft.command.CommandSource;
import org.apache.logging.log4j.LogManager;
import us.myles.ViaVersion.ViaManagerImpl;
import us.myles.ViaVersion.api.Via;
@ -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("viaver")));
CommandRegistrationCallback.EVENT.register((dispatcher, dedicated) -> dispatcher.register(command("vvfabric")));
ClientCommandManager.DISPATCHER.register(command("viafabricclient"));
}
@SuppressWarnings("deprecation")

View File

@ -1,9 +1,9 @@
package com.github.creeper123123321.viafabric.commands;
import io.github.cottonmc.clientcommands.CottonClientCommandSource;
import net.minecraft.client.MinecraftClient;
import com.github.creeper123123321.viafabric.platform.VRPlatform;
import net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource;
import net.minecraft.command.CommandSource;
import net.minecraft.entity.Entity;
import net.minecraft.server.command.CommandSource;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.text.Text;
import us.myles.ViaVersion.api.command.ViaCommandSender;
@ -28,9 +28,9 @@ public class NMSCommandSender implements ViaCommandSender {
@Override
public void sendMessage(String s) {
if (source instanceof ServerCommandSource) {
((ServerCommandSource) source).sendFeedback(Text.Serializer.fromJson(legacyToJson(s)), false);
} else if (source instanceof CottonClientCommandSource) {
((CottonClientCommandSource) source).sendFeedback(Text.Serializer.fromJson(legacyToJson(s)), false);
((ServerCommandSource) source).sendFeedback(Text.Serializer.fromJson(VRPlatform.legacyToJson(s)), false);
} else if (source instanceof FabricClientCommandSource) {
((FabricClientCommandSource) source).sendFeedback(Text.Serializer.fromJson(VRPlatform.legacyToJson(s)));
}
}
@ -43,8 +43,8 @@ public class NMSCommandSender implements ViaCommandSender {
if (source instanceof ServerCommandSource) {
Entity entity = ((ServerCommandSource) source).getEntity();
if (entity != null) return entity.getUuid();
} else if (source instanceof CottonClientCommandSource) {
return MinecraftClient.getInstance().player.getUuid();
} else if (source instanceof FabricClientCommandSource) {
return ((FabricClientCommandSource) source).getPlayer().getUuid();
}
return UUID.fromString(getName());
}
@ -53,8 +53,8 @@ public class NMSCommandSender implements ViaCommandSender {
public String getName() {
if (source instanceof ServerCommandSource) {
return ((ServerCommandSource) source).getName();
} else if (source instanceof CottonClientCommandSource) {
return MinecraftClient.getInstance().player.getEntityName();
} else if (source instanceof FabricClientCommandSource) {
return ((FabricClientCommandSource) source).getPlayer().getEntityName();
}
return "?";
}

View File

@ -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"));
}
}

View File

@ -5,7 +5,7 @@ import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.suggestion.Suggestions;
import com.mojang.brigadier.suggestion.SuggestionsBuilder;
import net.minecraft.server.command.CommandSource;
import net.minecraft.command.CommandSource;
import us.myles.ViaVersion.commands.ViaCommandHandler;
import java.util.concurrent.CompletableFuture;

View File

@ -61,15 +61,11 @@
"main": [
"com.github.creeper123123321.viafabric.ViaFabric"
],
"cotton-client-commands": [
"com.github.creeper123123321.viafabric.commands.VRClientCommands"
],
"modmenu": [
"com.github.creeper123123321.viafabric.gui.ModMenuConfig"
]
},
"depends": {
"cotton-client-commands": "*",
"fabricloader": ">=0.4.0",
"fabric-resource-loader-v0": "*",
"minecraft": "1.16.x",