summaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
author alemi <me@alemi.dev>2023-03-11 22:53:03 +0100
committer alemi <me@alemi.dev>2023-03-11 22:53:03 +0100
commit8baa0f2a64e0039d0df7d168e30c03a22c60bfb4 (patch)
tree89d3374dd1736983d4e1e0d06bfb4dacb36eb04e /src/main/java
parenta456396f8fa2dd000a22bda08bada4358e53bc30 (diff)
chore: moved cmdpatch into cmdpatch class
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/ftbsc/bscv/Boscovicino.java4
-rw-r--r--src/main/java/ftbsc/bscv/events/CommandsBuiltEvent.java19
-rw-r--r--src/main/java/ftbsc/bscv/patches/CommandsPatch.java17
3 files changed, 14 insertions, 26 deletions
diff --git a/src/main/java/ftbsc/bscv/Boscovicino.java b/src/main/java/ftbsc/bscv/Boscovicino.java
index d1f4531..90dc5b4 100644
--- a/src/main/java/ftbsc/bscv/Boscovicino.java
+++ b/src/main/java/ftbsc/bscv/Boscovicino.java
@@ -5,7 +5,7 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.mojang.brigadier.tree.CommandNode;
import ftbsc.bscv.api.IModule;
-import ftbsc.bscv.events.CommandsBuiltEvent;
+import ftbsc.bscv.patches.CommandsPatch.CommandsBuiltEvent;
import ftbsc.bscv.system.Friends;
import ftbsc.bscv.system.ModManager;
import net.minecraft.client.gui.screen.IngameMenuScreen;
@@ -86,7 +86,7 @@ public class Boscovicino implements ICommons {
@SubscribeEvent
public void onCommandSuggestionsBuilt(CommandsBuiltEvent event) {
for (CommandNode<CommandSource> child : this.dispatcher.getRoot().getChildren()) {
- event.dispatcher().getRoot().addChild(child);
+ event.dispatcher.getRoot().addChild(child);
}
}
diff --git a/src/main/java/ftbsc/bscv/events/CommandsBuiltEvent.java b/src/main/java/ftbsc/bscv/events/CommandsBuiltEvent.java
deleted file mode 100644
index 99a2dde..0000000
--- a/src/main/java/ftbsc/bscv/events/CommandsBuiltEvent.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package ftbsc.bscv.events;
-
-import com.mojang.brigadier.CommandDispatcher;
-
-import net.minecraft.command.CommandSource;
-import net.minecraft.command.ISuggestionProvider;
-import net.minecraftforge.eventbus.api.Event;
-
-public class CommandsBuiltEvent extends Event {
- private CommandDispatcher<CommandSource> dispatcher;
-
- public CommandDispatcher<CommandSource> dispatcher() {
- return this.dispatcher;
- }
-
- public CommandsBuiltEvent(CommandDispatcher<CommandSource> dispatcher) {
- this.dispatcher = dispatcher;
- }
-}
diff --git a/src/main/java/ftbsc/bscv/patches/CommandsPatch.java b/src/main/java/ftbsc/bscv/patches/CommandsPatch.java
index 410b660..0e8dd2a 100644
--- a/src/main/java/ftbsc/bscv/patches/CommandsPatch.java
+++ b/src/main/java/ftbsc/bscv/patches/CommandsPatch.java
@@ -1,6 +1,5 @@
package ftbsc.bscv.patches;
-import ftbsc.bscv.events.CommandsBuiltEvent;
import ftbsc.lll.processor.annotations.Injector;
import ftbsc.lll.processor.annotations.Patch;
import ftbsc.lll.processor.annotations.Target;
@@ -10,6 +9,8 @@ import net.minecraft.client.network.play.ClientPlayNetHandler;
import net.minecraft.command.CommandSource;
import net.minecraft.network.play.server.SCommandListPacket;
import net.minecraftforge.common.MinecraftForge;
+import net.minecraftforge.eventbus.api.Event;
+
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.*;
@@ -17,12 +18,18 @@ import com.mojang.brigadier.CommandDispatcher;
public class CommandsPatch {
- public static class CommandsHook {
- public static void cmdBuilt(CommandDispatcher<CommandSource> dispatcher) {
- MinecraftForge.EVENT_BUS.post(new CommandsBuiltEvent(dispatcher));
+ public static class CommandsBuiltEvent extends Event {
+ public final CommandDispatcher<CommandSource> dispatcher;
+
+ public CommandsBuiltEvent(CommandDispatcher<CommandSource> dispatcher) {
+ this.dispatcher = dispatcher;
}
}
+ public static void cmdBuilt(CommandDispatcher<CommandSource> dispatcher) {
+ MinecraftForge.EVENT_BUS.post(new CommandsBuiltEvent(dispatcher));
+ }
+
@Patch(value = ClientPlayNetHandler.class, reason = "add hook to insert our command suggestions")
public abstract static class CommandsDispatcherCatcher implements Opcodes {
@Target
@@ -44,7 +51,7 @@ public class CommandsPatch {
is.add(new InsnNode(DUP));
is.add(new MethodInsnNode(
INVOKESTATIC,
- "ftbsc/bscv/patches/CommandsPatch$CommandsHook",
+ "ftbsc/bscv/patches/CommandsPatch",
"cmdBuilt",
"(Lcom/mojang/brigadier/CommandDispatcher;)V"
));