tried out different shit, didnt work
This commit is contained in:
parent
865abd7c29
commit
9aed953f22
4 changed files with 40 additions and 34 deletions
|
@ -1,19 +1,25 @@
|
||||||
package net.saltymc.eaa;
|
package net.saltymc.eaa;
|
||||||
|
|
||||||
import net.fabricmc.api.ModInitializer;
|
import com.mojang.brigadier.arguments.DoubleArgumentType;
|
||||||
import net.saltymc.eaa.handler.commands.EchoCommand;
|
import net.saltymc.eaa.handler.commands.EchoCommand;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
public class EaaMod implements ModInitializer {
|
import net.fabricmc.api.ClientModInitializer;
|
||||||
|
import net.fabricmc.api.EnvType;
|
||||||
|
import net.fabricmc.api.Environment;
|
||||||
|
import net.fabricmc.fabric.api.client.command.v1.ClientCommandManager;
|
||||||
|
|
||||||
|
import static net.fabricmc.fabric.api.client.command.v1.ClientCommandManager.literal;
|
||||||
|
|
||||||
|
@Environment(EnvType.CLIENT)
|
||||||
|
public final class EaaMod implements ClientModInitializer {
|
||||||
|
private static final Logger LOGGER = LogManager.getLogger();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInitialize() {
|
public void onInitializeClient() {
|
||||||
// This code runs as soon as Minecraft is in a mod-load-ready state.
|
ClientCommandManager.DISPATCHER.register(literal("test_client_command_with_arg").then(
|
||||||
// However, some things (like resources) may still be uninitialized.
|
ClientCommandManager.argument("nachricht", DoubleArgumentType.doubleArg())).executes(EchoCommand::run));
|
||||||
// Proceed with mild caution.
|
|
||||||
|
|
||||||
System.out.println("EAA Mod initializing...");
|
|
||||||
|
|
||||||
new EchoCommand();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,18 +2,12 @@ package net.saltymc.eaa.handler.commands;
|
||||||
|
|
||||||
import com.mojang.brigadier.Command;
|
import com.mojang.brigadier.Command;
|
||||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.client.command.v1.ClientCommandManager;
|
|
||||||
import net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource;
|
import net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource;
|
||||||
|
|
||||||
public abstract class EaaModCommand implements Command<FabricClientCommandSource> {
|
public abstract class EaaModCommand implements Command<FabricClientCommandSource> {
|
||||||
|
|
||||||
public EaaModCommand() {
|
public LiteralArgumentBuilder<FabricClientCommandSource> register(){
|
||||||
this.register();
|
return this.getCommandSpecification().executes(this);
|
||||||
}
|
|
||||||
|
|
||||||
public void register(){
|
|
||||||
ClientCommandManager.DISPATCHER.register(getCommandSpecification().executes(this));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract LiteralArgumentBuilder<FabricClientCommandSource> getCommandSpecification();
|
public abstract LiteralArgumentBuilder<FabricClientCommandSource> getCommandSpecification();
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
package net.saltymc.eaa.handler.commands;
|
package net.saltymc.eaa.handler.commands;
|
||||||
|
|
||||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
|
||||||
|
import com.mojang.brigadier.Command;
|
||||||
|
import com.mojang.brigadier.arguments.DoubleArgumentType;
|
||||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||||
import com.mojang.brigadier.context.CommandContext;
|
import com.mojang.brigadier.context.CommandContext;
|
||||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
|
||||||
import net.fabricmc.fabric.api.client.command.v1.ClientCommandManager;
|
import net.fabricmc.fabric.api.client.command.v1.ClientCommandManager;
|
||||||
import net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource;
|
import net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource;
|
||||||
import net.minecraft.client.toast.SystemToast;
|
import net.minecraft.client.toast.SystemToast;
|
||||||
|
@ -11,29 +12,34 @@ import net.minecraft.text.LiteralText;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.util.Formatting;
|
import net.minecraft.util.Formatting;
|
||||||
|
|
||||||
import static com.mojang.brigadier.arguments.StringArgumentType.getString;
|
import static net.fabricmc.fabric.api.client.command.v1.ClientCommandManager.argument;
|
||||||
|
import static net.fabricmc.fabric.api.client.command.v1.ClientCommandManager.literal;
|
||||||
|
|
||||||
|
public class EchoCommand {
|
||||||
public class EchoCommand extends EaaModCommand {
|
public static int run(CommandContext<FabricClientCommandSource> context) { // throws CommandSyntaxException
|
||||||
@Override
|
FabricClientCommandSource source = context.getSource();
|
||||||
public int run(CommandContext context) throws CommandSyntaxException {
|
|
||||||
FabricClientCommandSource source = (FabricClientCommandSource) (context.getSource());
|
|
||||||
|
|
||||||
SystemToast.add(source.getClient().getToastManager(), SystemToast.Type.TUTORIAL_HINT, Text.of("ECHO"), Text.of(context.getInput()));
|
SystemToast.add(source.getClient().getToastManager(), SystemToast.Type.TUTORIAL_HINT, Text.of("ECHO"), Text.of(context.getInput()));
|
||||||
|
|
||||||
|
//String nachricht = getString(context,"nachricht");
|
||||||
|
double nachricht = DoubleArgumentType.getDouble(context, "nachricht");
|
||||||
|
System.out.println("nachricht is " + nachricht);
|
||||||
|
|
||||||
source.sendFeedback(
|
source.sendFeedback(
|
||||||
new LiteralText("You said input: ")
|
new LiteralText("You said input: ")
|
||||||
.formatted(Formatting.RED)
|
.formatted(Formatting.RED)
|
||||||
.append(new LiteralText(getString(context, "message"))
|
.append(new LiteralText(nachricht + ""))
|
||||||
.formatted(Formatting.WHITE, Formatting.ITALIC)
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
return SINGLE_SUCCESS;
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LiteralArgumentBuilder<FabricClientCommandSource> register() {
|
||||||
|
return this.getCommandSpecification().executes(context -> this.run(context));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public LiteralArgumentBuilder<FabricClientCommandSource> getCommandSpecification() {
|
public LiteralArgumentBuilder<FabricClientCommandSource> getCommandSpecification() {
|
||||||
return ClientCommandManager.literal("echo")
|
//return literal("echo").then(argument("nachricht", DoubleArgumentType.doubleArg()));
|
||||||
.then(ClientCommandManager.argument("message", StringArgumentType.greedyString()));
|
return literal("test_client_command_with_arg").then(
|
||||||
|
ClientCommandManager.argument("nachricht", DoubleArgumentType.doubleArg()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
"environment": "*",
|
"environment": "*",
|
||||||
"entrypoints": {
|
"entrypoints": {
|
||||||
"main": [
|
"client": [
|
||||||
"net.saltymc.eaa.EaaMod"
|
"net.saltymc.eaa.EaaMod"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue