summaryrefslogtreecommitdiff
path: root/src/main/java/ftbsc/bscv/patches/CommandsPatch.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/ftbsc/bscv/patches/CommandsPatch.java')
-rw-r--r--src/main/java/ftbsc/bscv/patches/CommandsPatch.java17
1 files changed, 12 insertions, 5 deletions
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"
));