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
ada10af7
Commit
ada10af7
authored
Jul 15, 2024
by
Jonathan Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improved client render performance (only query nearby entities every 3rd call)
parent
929305ad
Pipeline
#12670
passed with stages
in 2 minutes 6 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
20 deletions
+32
-20
CHANGELOG.md
CHANGELOG.md
+1
-0
BubbleRenderer.java
src/client/java/com/owlmaddie/ui/BubbleRenderer.java
+31
-20
No files found.
CHANGELOG.md
View file @
ada10af7
...
...
@@ -15,6 +15,7 @@ All notable changes to **CreatureChat** are documented in this file. The format
### Changed
-
Chat Bubble rendering & interacting is now dependent on whitelist / blacklist config
-
Improved client render performance (only query nearby entities every 3rd call)
-
Fixed a
**crash with FLEE**
when non-path aware entities (i.e. Ghast) attempted to flee.
-
Fixed certain behaviors from colliding with others (i.e. mutual exclusive ones)
-
Updated README.md with new video thumbnail, and simplified text, added spoiler to install instructions
...
...
src/client/java/com/owlmaddie/ui/BubbleRenderer.java
View file @
ada10af7
...
...
@@ -47,6 +47,8 @@ public class BubbleRenderer {
public
static
int
overlay
=
OverlayTexture
.
DEFAULT_UV
;
public
static
List
<
String
>
whitelist
=
new
ArrayList
<>();
public
static
List
<
String
>
blacklist
=
new
ArrayList
<>();
private
static
int
queryEntityDataCount
=
0
;
private
static
List
<
Entity
>
relevantEntities
;
public
static
void
drawTextBubbleBackground
(
String
base_name
,
MatrixStack
matrices
,
float
x
,
float
y
,
float
width
,
float
height
,
int
friendship
)
{
// Set shader & texture
...
...
@@ -351,26 +353,35 @@ public class BubbleRenderer {
// Get camera position
Vec3d
interpolatedCameraPos
=
new
Vec3d
(
camera
.
getPos
().
x
,
camera
.
getPos
().
y
,
camera
.
getPos
().
z
);
// Get all entities
List
<
Entity
>
nearbyEntities
=
world
.
getOtherEntities
(
null
,
area
);
// Filter to include only MobEntity & PlayerEntity but exclude any camera 1st person entity and any entities with passengers
List
<
Entity
>
relevantEntities
=
nearbyEntities
.
stream
()
.
filter
(
entity
->
(
entity
instanceof
MobEntity
||
entity
instanceof
PlayerEntity
))
.
filter
(
entity
->
!
entity
.
hasPassengers
())
.
filter
(
entity
->
!(
entity
.
equals
(
cameraEntity
)
&&
!
camera
.
isThirdPerson
()))
.
filter
(
entity
->
!(
entity
.
equals
(
cameraEntity
)
&&
entity
.
isSpectator
()))
.
filter
(
entity
->
{
Identifier
entityId
=
Registries
.
ENTITY_TYPE
.
getId
(
entity
.
getType
());
String
entityIdString
=
entityId
.
toString
();
// Check blacklist first
if
(
blacklist
.
contains
(
entityIdString
))
{
return
false
;
}
// If whitelist is not empty, only include entities in the whitelist
return
whitelist
.
isEmpty
()
||
whitelist
.
contains
(
entityIdString
);
})
.
collect
(
Collectors
.
toList
());
// Increment query counter
queryEntityDataCount
++;
// This query count helps us cache the list of relevant entities. We can refresh
// the list every 3rd call to this render function
if
(
queryEntityDataCount
%
3
==
0
||
relevantEntities
==
null
)
{
// Get all entities
List
<
Entity
>
nearbyEntities
=
world
.
getOtherEntities
(
null
,
area
);
// Filter to include only MobEntity & PlayerEntity but exclude any camera 1st person entity and any entities with passengers
relevantEntities
=
nearbyEntities
.
stream
()
.
filter
(
entity
->
(
entity
instanceof
MobEntity
||
entity
instanceof
PlayerEntity
))
.
filter
(
entity
->
!
entity
.
hasPassengers
())
.
filter
(
entity
->
!(
entity
.
equals
(
cameraEntity
)
&&
!
camera
.
isThirdPerson
()))
.
filter
(
entity
->
!(
entity
.
equals
(
cameraEntity
)
&&
entity
.
isSpectator
()))
.
filter
(
entity
->
{
Identifier
entityId
=
Registries
.
ENTITY_TYPE
.
getId
(
entity
.
getType
());
String
entityIdString
=
entityId
.
toString
();
// Check blacklist first
if
(
blacklist
.
contains
(
entityIdString
))
{
return
false
;
}
// If whitelist is not empty, only include entities in the whitelist
return
whitelist
.
isEmpty
()
||
whitelist
.
contains
(
entityIdString
);
})
.
collect
(
Collectors
.
toList
());
queryEntityDataCount
=
0
;
}
for
(
Entity
entity
:
relevantEntities
)
{
...
...
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