-
-
Notifications
You must be signed in to change notification settings - Fork 512
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved Fabric chat message hook for Corporea Index to ClientPacketList…
…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
1 parent
968b028
commit b9f9735
Showing
3 changed files
with
23 additions
and
28 deletions.
There are no files selected for viewing
27 changes: 0 additions & 27 deletions
27
Fabric/src/main/java/vazkii/botania/fabric/mixin/client/ChatScreenMixin.java
This file was deleted.
Oops, something went wrong.
22 changes: 22 additions & 0 deletions
22
Fabric/src/main/java/vazkii/botania/fabric/mixin/client/ClientPacketListenerMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters