chore: moved cmdpatch into cmdpatch class
This commit is contained in:
parent
a456396f8f
commit
8baa0f2a64
3 changed files with 14 additions and 26 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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"
|
||||
));
|
||||
|
|
Loading…
Reference in a new issue