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
ecb58952
Commit
ecb58952
authored
Apr 12, 2024
by
Jonathan Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Custom animating the dot dot dot button
parent
8f8e5455
Pipeline
#11979
passed with stage
in 19 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
20 deletions
+22
-20
ClientInit.java
src/client/java/com/owlmaddie/ClientInit.java
+9
-2
BubbleRenderer.java
src/client/java/com/owlmaddie/ui/BubbleRenderer.java
+13
-2
button-dot-0.png.mcmeta
...sources/assets/mobgpt/textures/ui/button-dot-0.png.mcmeta
+0
-16
No files found.
src/client/java/com/owlmaddie/ClientInit.java
View file @
ecb58952
...
...
@@ -6,19 +6,26 @@ import com.owlmaddie.ui.ClickHandler;
import
net.fabricmc.api.ClientModInitializer
;
import
net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents
;
import
net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents
;
import
net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents
;
/**
* The {@code ClientInit} class initializes this mod in the client and defines all hooks into the
* render pipeline to draw chat bubbles, text, and entity icons.
*/
public
class
ClientInit
implements
ClientModInitializer
{
@Override
private
static
long
tickCounter
=
0
;
@Override
public
void
onInitializeClient
()
{
ClientTickEvents
.
END_CLIENT_TICK
.
register
(
client
->
{
tickCounter
++;
});
ClickHandler
.
register
();
// Register an event callback to render text bubbles
WorldRenderEvents
.
LAST
.
register
((
context
)
->
{
BubbleRenderer
.
drawTextAboveEntities
(
context
,
context
.
tickDelta
());
BubbleRenderer
.
drawTextAboveEntities
(
context
,
tickCounter
,
context
.
tickDelta
());
});
// Register an event callback for when the client disconnects from a server or changes worlds
...
...
src/client/java/com/owlmaddie/ui/BubbleRenderer.java
View file @
ecb58952
...
...
@@ -39,6 +39,8 @@ public class BubbleRenderer {
protected
static
TextureLoader
textures
=
new
TextureLoader
();
public
static
int
DISPLAY_NUM_LINES
=
3
;
public
static
int
DISPLAY_PADDING
=
2
;
public
static
int
animationFrame
=
0
;
public
static
long
lastTick
=
0
;
public
static
void
drawTextBubbleBackground
(
MatrixStack
matrices
,
float
x
,
float
y
,
float
width
,
float
height
,
int
friendship
)
{
RenderSystem
.
enableDepthTest
();
...
...
@@ -206,7 +208,7 @@ public class BubbleRenderer {
}
}
public
static
void
drawTextAboveEntities
(
WorldRenderContext
context
,
float
partialTicks
)
{
public
static
void
drawTextAboveEntities
(
WorldRenderContext
context
,
long
tick
,
float
partialTicks
)
{
Camera
camera
=
context
.
camera
();
Entity
cameraEntity
=
camera
.
getFocusedEntity
();
if
(
cameraEntity
==
null
)
return
;
...
...
@@ -356,7 +358,16 @@ public class BubbleRenderer {
}
else
if
(
chatData
.
status
==
ChatDataManager
.
ChatStatus
.
PENDING
)
{
// Draw 'pending' button
drawIcon
(
"button-dot-0"
,
matrices
,
-
16
,
textHeaderHeight
,
32
,
17
);
drawIcon
(
"button-dot-"
+
animationFrame
,
matrices
,
-
16
,
textHeaderHeight
,
32
,
17
);
// Calculate animation frames (0-8) every X ticks
if
(
lastTick
!=
tick
&&
tick
%
5
==
0
)
{
lastTick
=
tick
;
animationFrame
++;
}
if
(
animationFrame
>
8
)
{
animationFrame
=
0
;
}
}
else
if
(
chatData
.
sender
==
ChatDataManager
.
ChatSender
.
ASSISTANT
)
{
// Draw text background (no smaller than 50F tall)
...
...
src/main/resources/assets/mobgpt/textures/ui/button-dot-0.png.mcmeta
deleted
100644 → 0
View file @
8f8e5455
{
"animation": {
"frametime": 2,
"frames": [
{"index": 0, "time": 2},
{"index": 1, "time": 2},
{"index": 2, "time": 2},
{"index": 3, "time": 2},
{"index": 4, "time": 2},
{"index": 5, "time": 2},
{"index": 6, "time": 2},
{"index": 7, "time": 2},
{"index": 8, "time": 2}
]
}
}
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