Commit d435b21a by Jonathan Thomas

Fixing another regression found during testing, user messages were breaking due…

Fixing another regression found during testing, user messages were breaking due to missing "playerName" attribute
parent 2ec4f204
Pipeline #13205 passed with stages
in 2 minutes 6 seconds
...@@ -126,7 +126,7 @@ public class ClientPackets { ...@@ -126,7 +126,7 @@ public class ClientPackets {
if (chatData.sender == ChatDataManager.ChatSender.USER) { if (chatData.sender == ChatDataManager.ChatSender.USER) {
// Add player message to queue for rendering // Add player message to queue for rendering
PlayerMessageManager.addMessage(playerId, chatData.currentMessage, ChatDataManager.TICKS_TO_DISPLAY_USER_MESSAGE); PlayerMessageManager.addMessage(playerId, playerName, chatData.currentMessage, ChatDataManager.TICKS_TO_DISPLAY_USER_MESSAGE);
} }
// Play sound with volume based on distance (from player or entity) // Play sound with volume based on distance (from player or entity)
......
...@@ -475,16 +475,22 @@ public class BubbleRenderer { ...@@ -475,16 +475,22 @@ public class BubbleRenderer {
// Get the player // Get the player
ClientPlayerEntity player = MinecraftClient.getInstance().player; ClientPlayerEntity player = MinecraftClient.getInstance().player;
// Look-up greeting (if any) // Get chat message (if any)
EntityChatData chatData = null; EntityChatData chatData = null;
PlayerData playerData = null; PlayerData playerData = null;
if (entity instanceof MobEntity) { if (entity instanceof MobEntity) {
chatData = ChatDataManager.getClientInstance().getOrCreateChatData(entity.getUuidAsString(), player.getDisplayName().getString()); chatData = ChatDataManager.getClientInstance().getOrCreateChatData(entity.getUuidAsString(), player.getDisplayName().getString());
playerData = chatData.getPlayerData(player.getDisplayName().getString());
} else if (entity instanceof PlayerEntity) { } else if (entity instanceof PlayerEntity) {
chatData = PlayerMessageManager.getMessage(entity.getUuid()); chatData = PlayerMessageManager.getMessage(entity.getUuid());
} }
// Get playerData: friendship (if any)
if (chatData != null) {
playerData = chatData.getPlayerData(player.getDisplayName().getString());
} else {
playerData = new PlayerData();
}
float minTextHeight = (ChatDataManager.DISPLAY_NUM_LINES * (fontRenderer.fontHeight + lineSpacing)) + (DISPLAY_PADDING * 2); float minTextHeight = (ChatDataManager.DISPLAY_NUM_LINES * (fontRenderer.fontHeight + lineSpacing)) + (DISPLAY_PADDING * 2);
float scaledTextHeight = 0; float scaledTextHeight = 0;
......
...@@ -13,8 +13,8 @@ import java.util.concurrent.atomic.AtomicInteger; ...@@ -13,8 +13,8 @@ import java.util.concurrent.atomic.AtomicInteger;
public class PlayerMessage extends EntityChatData { public class PlayerMessage extends EntityChatData {
public AtomicInteger tickCountdown; public AtomicInteger tickCountdown;
public PlayerMessage(String playerId, String messageText, int ticks) { public PlayerMessage(String playerId, String playerName, String messageText, int ticks) {
super("", playerId); super(playerId, playerName);
this.currentMessage = messageText; this.currentMessage = messageText;
this.currentLineNumber = 0; this.currentLineNumber = 0;
this.tickCountdown = new AtomicInteger(ticks); this.tickCountdown = new AtomicInteger(ticks);
......
...@@ -12,8 +12,8 @@ public class PlayerMessageManager { ...@@ -12,8 +12,8 @@ public class PlayerMessageManager {
private static final ConcurrentHashMap<UUID, PlayerMessage> messages = new ConcurrentHashMap<>(); private static final ConcurrentHashMap<UUID, PlayerMessage> messages = new ConcurrentHashMap<>();
private static final ConcurrentHashMap<UUID, Boolean> openChatUIs = new ConcurrentHashMap<>(); private static final ConcurrentHashMap<UUID, Boolean> openChatUIs = new ConcurrentHashMap<>();
public static void addMessage(UUID playerUUID, String messageText, int ticks) { public static void addMessage(UUID playerUUID, String playerName, String messageText, int ticks) {
messages.put(playerUUID, new PlayerMessage(playerUUID.toString(), messageText, ticks)); messages.put(playerUUID, new PlayerMessage(playerUUID.toString(), playerName, messageText, ticks));
} }
public static PlayerMessage getMessage(UUID playerId) { public static PlayerMessage getMessage(UUID playerId) {
......
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