Commit 6c5fa825 by Jonathan Thomas

Fixing PACKET_S2C_MESSAGE from crashing a newly logging on player, if they…

Fixing PACKET_S2C_MESSAGE from crashing a newly logging on player, if they receive that message first.
parent 011ddb99
Pipeline #13210 passed with stages
in 2 minutes 8 seconds
......@@ -23,6 +23,7 @@ All notable changes to **CreatureChat** are documented in this file. The format
- Passive entities no longer emit damage particles when attacking, they emit custom attack particles
- Protect now auto sets friendship to 1 (if <= 0), to prevent entity from attacking and protecting at the same time
- Seperated `generateCharacter()` and `generateMessage()` functions for simplicity
- Fixing PACKET_S2C_MESSAGE from crashing a newly logging on player, if they receive that message first.
### Fixed
- Fixed a regression caused by adding a "-forge" suffix to one of our builds
......
......@@ -116,16 +116,23 @@ public class ClientPackets {
String sender_name = buffer.readString(32767);
ChatDataManager.ChatSender sender = ChatDataManager.ChatSender.valueOf(sender_name);
int friendship = buffer.readInt();
String currentPlayerName = client.player.getDisplayName().getString();
// Update the chat data manager on the client-side
client.execute(() -> { // Make sure to run on the client thread
// Ensure client.player is initialized
if (client.player == null) {
LOGGER.warn("Client player is not initialized. Dropping message for entity '{}'.", entityId);
return;
}
// Update the chat data manager on the client-side
MobEntity entity = ClientEntityFinder.getEntityByUUID(client.world, entityId);
if (entity == null) {
return;
}
// Get entity chat data for current entity & player
String currentPlayerName = client.player.getDisplayName().getString();
ChatDataManager chatDataManager = ChatDataManager.getClientInstance();
EntityChatData chatData = chatDataManager.getOrCreateChatData(entity.getUuidAsString(), currentPlayerName);
......
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