FINALLY got stuff working, lol
This commit is contained in:
parent
9aed953f22
commit
49130736df
8 changed files with 114 additions and 97 deletions
|
@ -1,25 +1,27 @@
|
|||
package net.saltymc.eaa;
|
||||
|
||||
import com.mojang.brigadier.arguments.DoubleArgumentType;
|
||||
import net.saltymc.eaa.handler.commands.EchoCommand;
|
||||
import net.saltymc.eaa.commands.*;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
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();
|
||||
|
||||
public static Logger getLogger() {
|
||||
return LOGGER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInitializeClient() {
|
||||
ClientCommandManager.DISPATCHER.register(literal("test_client_command_with_arg").then(
|
||||
ClientCommandManager.argument("nachricht", DoubleArgumentType.doubleArg())).executes(EchoCommand::run));
|
||||
|
||||
//Register Commands
|
||||
new EchoCommand();
|
||||
new TagCommand();
|
||||
|
||||
}
|
||||
}
|
||||
|
|
25
src/main/java/net/saltymc/eaa/commands/EaaModCommand.java
Normal file
25
src/main/java/net/saltymc/eaa/commands/EaaModCommand.java
Normal file
|
@ -0,0 +1,25 @@
|
|||
package net.saltymc.eaa.commands;
|
||||
|
||||
import com.mojang.brigadier.Command;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import net.fabricmc.fabric.api.client.command.v1.ClientCommandManager;
|
||||
import net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource;
|
||||
|
||||
public abstract class EaaModCommand implements Command<FabricClientCommandSource> {
|
||||
|
||||
public EaaModCommand() {
|
||||
this(ClientCommandManager.DISPATCHER);
|
||||
}
|
||||
|
||||
public EaaModCommand(CommandDispatcher<FabricClientCommandSource> dispatcher) {
|
||||
this.register(dispatcher);
|
||||
}
|
||||
|
||||
public void register(CommandDispatcher<FabricClientCommandSource> dispatcher){
|
||||
dispatcher.register(this.getCommandSpecification());
|
||||
}
|
||||
|
||||
public abstract LiteralArgumentBuilder<FabricClientCommandSource> getCommandSpecification();
|
||||
|
||||
}
|
38
src/main/java/net/saltymc/eaa/commands/EchoCommand.java
Normal file
38
src/main/java/net/saltymc/eaa/commands/EchoCommand.java
Normal file
|
@ -0,0 +1,38 @@
|
|||
package net.saltymc.eaa.commands;
|
||||
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource;
|
||||
import net.minecraft.client.toast.*;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Formatting;
|
||||
|
||||
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 extends EaaModCommand{
|
||||
|
||||
public int run(CommandContext<FabricClientCommandSource> context) { // throws CommandSyntaxException
|
||||
FabricClientCommandSource source = context.getSource();
|
||||
|
||||
String nachricht = StringArgumentType.getString(context,"nachricht");
|
||||
|
||||
SystemToast.add(source.getClient().getToastManager(), SystemToast.Type.TUTORIAL_HINT, Text.of("ECHO"), Text.of(nachricht));
|
||||
|
||||
source.sendFeedback(
|
||||
new LiteralText("You said: ")
|
||||
.formatted(Formatting.RED)
|
||||
.append(new LiteralText(nachricht + ""))
|
||||
);
|
||||
return 1;
|
||||
}
|
||||
|
||||
public LiteralArgumentBuilder<FabricClientCommandSource> getCommandSpecification() {
|
||||
return literal("/echo").then(
|
||||
argument("nachricht", StringArgumentType.greedyString())
|
||||
.executes(this)
|
||||
);
|
||||
}
|
||||
}
|
39
src/main/java/net/saltymc/eaa/commands/TagCommand.java
Normal file
39
src/main/java/net/saltymc/eaa/commands/TagCommand.java
Normal file
|
@ -0,0 +1,39 @@
|
|||
package net.saltymc.eaa.commands;
|
||||
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource;
|
||||
import net.minecraft.client.toast.SystemToast;
|
||||
import net.minecraft.command.argument.EntityArgumentType;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Formatting;
|
||||
|
||||
import static net.fabricmc.fabric.api.client.command.v1.ClientCommandManager.argument;
|
||||
import static net.fabricmc.fabric.api.client.command.v1.ClientCommandManager.literal;
|
||||
|
||||
public class TagCommand extends EaaModCommand{
|
||||
@Override
|
||||
public int run(CommandContext<FabricClientCommandSource> context) throws CommandSyntaxException {
|
||||
FabricClientCommandSource source = context.getSource();
|
||||
|
||||
String player = StringArgumentType.getString(context,"player");
|
||||
String tag = StringArgumentType.getString(context,"tag");
|
||||
|
||||
SystemToast.add(source.getClient().getToastManager(), SystemToast.Type.TUTORIAL_HINT, Text.of(tag), Text.of(player));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LiteralArgumentBuilder<FabricClientCommandSource> getCommandSpecification() {
|
||||
return literal("/tag").then(
|
||||
argument("player", EntityArgumentType.player())
|
||||
.then(argument("tag", StringArgumentType.word())
|
||||
.executes(this)
|
||||
));
|
||||
}
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
package net.saltymc.eaa.handler.commands;
|
||||
|
||||
import com.mojang.brigadier.Command;
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource;
|
||||
|
||||
public abstract class EaaModCommand implements Command<FabricClientCommandSource> {
|
||||
|
||||
public LiteralArgumentBuilder<FabricClientCommandSource> register(){
|
||||
return this.getCommandSpecification().executes(this);
|
||||
}
|
||||
|
||||
public abstract LiteralArgumentBuilder<FabricClientCommandSource> getCommandSpecification();
|
||||
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
package net.saltymc.eaa.handler.commands;
|
||||
|
||||
|
||||
import com.mojang.brigadier.Command;
|
||||
import com.mojang.brigadier.arguments.DoubleArgumentType;
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import net.fabricmc.fabric.api.client.command.v1.ClientCommandManager;
|
||||
import net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource;
|
||||
import net.minecraft.client.toast.SystemToast;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Formatting;
|
||||
|
||||
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 static int run(CommandContext<FabricClientCommandSource> context) { // throws CommandSyntaxException
|
||||
FabricClientCommandSource source = context.getSource();
|
||||
|
||||
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(
|
||||
new LiteralText("You said input: ")
|
||||
.formatted(Formatting.RED)
|
||||
.append(new LiteralText(nachricht + ""))
|
||||
);
|
||||
return 1;
|
||||
}
|
||||
|
||||
public LiteralArgumentBuilder<FabricClientCommandSource> register() {
|
||||
return this.getCommandSpecification().executes(context -> this.run(context));
|
||||
}
|
||||
|
||||
public LiteralArgumentBuilder<FabricClientCommandSource> getCommandSpecification() {
|
||||
//return literal("echo").then(argument("nachricht", DoubleArgumentType.doubleArg()));
|
||||
return literal("test_client_command_with_arg").then(
|
||||
ClientCommandManager.argument("nachricht", DoubleArgumentType.doubleArg()));
|
||||
}
|
||||
}
|
|
@ -6,10 +6,12 @@ import org.spongepowered.asm.mixin.injection.At;
|
|||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import static net.saltymc.eaa.EaaMod.getLogger;
|
||||
|
||||
@Mixin(TitleScreen.class)
|
||||
public class ExampleMixin {
|
||||
@Inject(at = @At("HEAD"), method = "init()V")
|
||||
private void init(CallbackInfo info) {
|
||||
System.out.println("This line is printed by EAA MOD!");
|
||||
getLogger().info("This line is printed by EAA MOD!");
|
||||
}
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
package net.saltymc.eaa.util;
|
||||
|
||||
public class ResponseEntity {
|
||||
|
||||
private boolean interceptEvent;
|
||||
private final boolean wasHandled;
|
||||
|
||||
public ResponseEntity(boolean wasHandled){
|
||||
this.wasHandled = wasHandled;
|
||||
}
|
||||
|
||||
public ResponseEntity(boolean wasHandled, boolean interceptEvent){
|
||||
this.wasHandled = wasHandled;
|
||||
this.interceptEvent = interceptEvent;
|
||||
}
|
||||
|
||||
|
||||
public boolean isInterceptEvent() {
|
||||
return interceptEvent;
|
||||
}
|
||||
|
||||
public void setInterceptEvent(boolean interceptEvent) {
|
||||
this.interceptEvent = interceptEvent;
|
||||
}
|
||||
|
||||
public boolean isWasHandled() {
|
||||
return wasHandled;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue