Skip to content

Commit

Permalink
Moved Fabric chat message hook for Corporea Index to ClientPacketList…
Browse files Browse the repository at this point in the history
…ener::sendChat

Adds support for chat messages sent through other means than the ChatScreen, e.g. "Microphone Text Input" mod or custom UI screens that also happen to allow chatting, and is closer to how the corresponding Forge event is dispatched.
  • Loading branch information
TheRealWormbo committed May 30, 2024
1 parent 968b028 commit b9f9735
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 28 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package vazkii.botania.fabric.mixin.client;

import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ClientPacketListener;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import vazkii.botania.common.block.block_entity.corporea.CorporeaIndexBlockEntity;

@Mixin(ClientPacketListener.class)
public class ClientPacketListenerMixin {
@Inject(at = @At("HEAD"), method = "sendChat", cancellable = true)
private void onChat(String message, CallbackInfo ci) {
var player = Minecraft.getInstance().player;
if (CorporeaIndexBlockEntity.ClientHandler.onChat(player, message)) {
ci.cancel();
}
}
}
2 changes: 1 addition & 1 deletion Fabric/src/main/resources/botania_fabric.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"client.AbstractTextureFabricMixin",
"client.BlockModelDeserializerFabricMixin",
"client.BossHealthOverlayFabricMixin",
"client.ChatScreenMixin",
"client.ClientPacketListenerMixin",
"client.DebugScreenOverlayFabricMixin",
"client.GuiGraphicsFabricMixin",
"client.KeyboardHandlerFabricMixin",
Expand Down

0 comments on commit b9f9735

Please sign in to comment.