Skip to content

Commit 5891d27

Browse files
committed
CancellableEvent
1 parent 65f84b1 commit 5891d27

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

build.gradle.kts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@ version = "1.0"
88

99
repositories {
1010
mavenCentral()
11+
mavenLocal()
1112
maven("https://jitpack.io")
1213
}
1314

1415
dependencies {
15-
implementation("com.github.Weave-MC:Weave-Loader:4c45210e52")
16+
implementation("com.github.Weave-MC:Weave-Loader:bf715e2b8d")
1617
}
1718

1819
minecraft {

src/main/java/com/example/mod/ExampleMod.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
22

33
import club.maxstats.weave.loader.api.ModInitializer;
44
import club.maxstats.weave.loader.api.HookManager;
5+
import club.maxstats.weave.loader.api.event.ChatReceivedEvent;
56
import club.maxstats.weave.loader.api.event.EventBus;
67
import club.maxstats.weave.loader.api.event.InputEvent;
7-
import club.maxstats.weave.loader.api.event.SubscribeEvent;
8-
import club.maxstats.weave.loader.util.ExtensionsKt;
9-
import kotlin.Unit;
108
import net.minecraft.client.Minecraft;
119
import net.minecraft.util.ChatComponentText;
1210
import org.jetbrains.annotations.NotNull;
@@ -37,6 +35,13 @@ public void preinit(@NotNull HookManager hookManager) {
3735
new ChatComponentText("Pressed: " + Keyboard.getKeyName(e.getKeyCode()))
3836
);
3937
});
38+
39+
EventBus.INSTANCE.subscribe(ChatReceivedEvent.class, e -> {
40+
if (e.getMessage().getUnformattedText().contains("Hello Computer")) {
41+
e.setCancelled(true);
42+
Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("Hello Player"));
43+
}
44+
});
4045
}
4146
public static void onStart() {
4247
System.out.println("Hello World from Minecraft#startGame");

0 commit comments

Comments
 (0)