1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package com.owlmaddie.ui;
import net.minecraft.util.math.Vec3d;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
/**
* The {@code BubbleLocationManager} class is used to keep track of the currently rendered chat bubbles,
* to simplify click handling of nearby chat bubbles. This data includes the exact location of the chat
* bubbles, and their rotations (pitch, yaw).
*/
public class BubbleLocationManager {
private static final Map<UUID, BubbleData> bubbleDataMap = new ConcurrentHashMap<>();
public static void updateBubbleData(UUID entityId, Vec3d position, double width, double height, double yaw, double pitch) {
bubbleDataMap.put(entityId, new BubbleData(position, width, height, yaw, pitch));
}
public static BubbleData getBubbleData(UUID entityId) {
return bubbleDataMap.get(entityId);
}
public static class BubbleData {
public final Vec3d position;
public final double width;
public final double height;
public final double yaw;
public final double pitch;
public BubbleData(Vec3d position, double width, double height, double yaw, double pitch) {
this.position = position;
this.width = width;
this.height = height;
this.yaw = yaw;
this.pitch = pitch;
}
}
public static void performCleanup(List<UUID> activeEntityIds) {
// Retain only entries for active entities
bubbleDataMap.keySet().retainAll(activeEntityIds);
}
public static Map<UUID, BubbleData> getAllBubbleData() {
return Collections.unmodifiableMap(bubbleDataMap);
}
}