Commit b210e7c4 by Jonathan Thomas

Chat messages are now displayed in chat bubbles above players heads

parent 6b8ee14d
Pipeline #13273 passed with stages
in 2 minutes 14 seconds
......@@ -10,6 +10,7 @@ All notable changes to **CreatureChat** are documented in this file. The format
- Player Icons (custom art embedded in player skin)
- New Step-by-Step **Icon** Tutorial: [ICON.md](ICONS.md)
- New mixin to extend PlayerSkinTexture to make a copy of the NativeImage + pixel toggle to enable
- Chat messages are now displayed in chat bubbles above players heads
- Improved LLM Unit tests (to prevent rate limit issues from certain providers when running all tests)
- Check friendship direction (+ or -) in LLM unit tests (to verify friendship direction is output correctly)
......
package com.owlmaddie.mixin;
import com.owlmaddie.chat.EntityChatData;
import net.minecraft.network.packet.c2s.play.ChatMessageC2SPacket;
import net.minecraft.server.network.ServerPlayNetworkHandler;
import net.minecraft.server.network.ServerPlayerEntity;
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 static com.owlmaddie.network.ServerPackets.BroadcastPlayerMessage;
/**
* The {@code MixinOnChat} mixin class intercepts chat messages from players, and broadcasts them as chat bubbles
*/
@Mixin(ServerPlayNetworkHandler.class)
public abstract class MixinOnChat {
@Inject(method = "onChatMessage", at = @At("HEAD"), cancellable = true)
private void onChatMessage(ChatMessageC2SPacket packet, CallbackInfo ci) {
// Get the player who sent the message
ServerPlayNetworkHandler handler = (ServerPlayNetworkHandler) (Object) this;
ServerPlayerEntity player = handler.player;
// Get the chat message
String chatMessage = packet.chatMessage();
// Example: Call your broadcast function
EntityChatData chatData = new EntityChatData(player.getUuidAsString());
chatData.currentMessage = chatMessage;
BroadcastPlayerMessage(chatData, player);
// Optionally, cancel the event to prevent the default behavior
//ci.cancel();
}
}
......@@ -7,7 +7,8 @@
"MixinMobEntityAccessor",
"MixinLivingEntity",
"MixinBucketable",
"MixinVillagerEntity"
"MixinVillagerEntity",
"MixinOnChat"
],
"injectors": {
"defaultRequire": 1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment