ForgePatch/patches/minecraft/net/minecraft/command/Commands.java.patch

26 lines
1.3 KiB
Diff

--- a/net/minecraft/command/Commands.java
+++ b/net/minecraft/command/Commands.java
@@ -186,6 +186,7 @@
if (p_i232148_1_.field_237219_d_) {
PublishCommand.func_198581_a(this.field_197062_b);
}
+ net.minecraftforge.event.ForgeEventFactory.onCommandRegister(this.field_197062_b, p_i232148_1_);
this.field_197062_b.findAmbiguities((p_201302_1_, p_201302_2_, p_201302_3_, p_201302_4_) -> {
field_197061_a.warn("Ambiguity between arguments {} and {} with inputs: {}", this.field_197062_b.getPath(p_201302_2_), this.field_197062_b.getPath(p_201302_3_), p_201302_4_);
@@ -205,6 +206,14 @@
try {
try {
+ ParseResults<CommandSource> parse = this.field_197062_b.parse(stringreader, p_197059_1_);
+ net.minecraftforge.event.CommandEvent event = new net.minecraftforge.event.CommandEvent(parse);
+ if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event)) {
+ if (event.getException() != null) {
+ com.google.common.base.Throwables.throwIfUnchecked(event.getException());
+ }
+ return 1;
+ }
return this.field_197062_b.execute(stringreader, p_197059_1_);
} catch (CommandException commandexception) {
p_197059_1_.func_197021_a(commandexception.func_197003_a());