Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
CreatureChat
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Jobs
Commits
Open sidebar
Public
CreatureChat
Commits
d3eed475
Commit
d3eed475
authored
Nov 09, 2023
by
Jonathan Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clear client ChatDataManager when a client joins or disconnects from a world
parent
aa6a8087
Pipeline
#11654
passed with stage
in 26 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
0 deletions
+20
-0
ClientInit.java
src/client/java/com/owlmaddie/ClientInit.java
+15
-0
ChatDataManager.java
src/main/java/com/owlmaddie/ChatDataManager.java
+5
-0
No files found.
src/client/java/com/owlmaddie/ClientInit.java
View file @
d3eed475
...
@@ -2,6 +2,7 @@ package com.owlmaddie;
...
@@ -2,6 +2,7 @@ package com.owlmaddie;
import
com.mojang.blaze3d.systems.RenderSystem
;
import
com.mojang.blaze3d.systems.RenderSystem
;
import
net.fabricmc.api.ClientModInitializer
;
import
net.fabricmc.api.ClientModInitializer
;
import
net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents
;
import
net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext
;
import
net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext
;
import
net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents
;
import
net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents
;
import
net.minecraft.client.MinecraftClient
;
import
net.minecraft.client.MinecraftClient
;
...
@@ -36,9 +37,23 @@ public class ClientInit implements ClientModInitializer {
...
@@ -36,9 +37,23 @@ public class ClientInit implements ClientModInitializer {
public
void
onInitializeClient
()
{
public
void
onInitializeClient
()
{
ClickHandler
.
register
();
ClickHandler
.
register
();
// Register an event callback to render text bubbles
WorldRenderEvents
.
LAST
.
register
((
context
)
->
{
WorldRenderEvents
.
LAST
.
register
((
context
)
->
{
drawTextAboveEntities
(
context
,
context
.
tickDelta
());
drawTextAboveEntities
(
context
,
context
.
tickDelta
());
});
});
// Register an event callback for when the client disconnects from a server or changes worlds
ClientPlayConnectionEvents
.
DISCONNECT
.
register
((
handler
,
client
)
->
{
// Clear or reset the ChatDataManager
ChatDataManager
.
getClientInstance
().
clearData
();
});
// Register an event callback for when the player joins a server or world
ClientPlayConnectionEvents
.
JOIN
.
register
((
handler
,
sender
,
client
)
->
{
// Possibly re-initialize or prepare the ChatDataManager for the new session
ChatDataManager
.
getClientInstance
().
clearData
();
});
}
}
public
void
drawTextBubbleBackground
(
MatrixStack
matrices
,
Entity
entity
,
float
x
,
float
y
,
float
width
,
float
height
)
{
public
void
drawTextBubbleBackground
(
MatrixStack
matrices
,
Entity
entity
,
float
x
,
float
y
,
float
width
,
float
height
)
{
...
...
src/main/java/com/owlmaddie/ChatDataManager.java
View file @
d3eed475
...
@@ -85,6 +85,11 @@ public class ChatDataManager {
...
@@ -85,6 +85,11 @@ public class ChatDataManager {
}
}
}
}
public
void
clearData
()
{
// Clear the chat data for the previous session
entityChatDataMap
.
clear
();
}
private
ChatDataManager
()
{
private
ChatDataManager
()
{
entityChatDataMap
=
new
HashMap
<>();
entityChatDataMap
=
new
HashMap
<>();
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment