[BUG] Fix MessageBroadcastEvent using the wrong thread context (SDLink)

This commit is contained in:
2024-01-02 08:27:03 +02:00
parent 2d847afbf0
commit 921ca9a7a7
2 changed files with 8 additions and 2 deletions

View File

@@ -11,11 +11,13 @@ public class MessageBroadcastEvent extends CraterEvent {
private final Component component;
private final Function<ServerPlayer, Component> function;
private final boolean bl;
private final String threadName;
public MessageBroadcastEvent(Component component, Function<ServerPlayer, Component> function, boolean bl) {
public MessageBroadcastEvent(Component component, Function<ServerPlayer, Component> function, boolean bl, String threadName) {
this.component = component;
this.function = function;
this.bl = bl;
this.threadName = threadName;
}
public Component getComponent() {
@@ -30,6 +32,10 @@ public class MessageBroadcastEvent extends CraterEvent {
return function;
}
public String getThreadName() {
return threadName;
}
@Override
public boolean canCancel() {
return false;

View File

@@ -23,7 +23,7 @@ public class PlayerListMixin {
@Inject(method = "broadcastSystemMessage(Lnet/minecraft/network/chat/Component;Ljava/util/function/Function;Z)V", at = @At("HEAD"))
private void injectBroadcastEvent(Component component, Function<ServerPlayer, Component> function, boolean bl, CallbackInfo ci) {
MessageBroadcastEvent event = new MessageBroadcastEvent(component, function, bl);
MessageBroadcastEvent event = new MessageBroadcastEvent(component, function, bl, threadName);
CraterEventBus.INSTANCE.postEvent(event);
}