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
...
@@ -15,6 +15,7 @@ All notable changes to **CreatureChat** are documented in this file. The format
### Changed
### Changed
-
Chat Bubble rendering & interacting is now dependent on whitelist / blacklist config
-
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 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)
-
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
-
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 {
...
@@ -47,6 +47,8 @@ public class BubbleRenderer {
public
static
int
overlay
=
OverlayTexture
.
DEFAULT_UV
;
public
static
int
overlay
=
OverlayTexture
.
DEFAULT_UV
;
public
static
List
<
String
>
whitelist
=
new
ArrayList
<>();
public
static
List
<
String
>
whitelist
=
new
ArrayList
<>();
public
static
List
<
String
>
blacklist
=
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
)
{
public
static
void
drawTextBubbleBackground
(
String
base_name
,
MatrixStack
matrices
,
float
x
,
float
y
,
float
width
,
float
height
,
int
friendship
)
{
// Set shader & texture
// Set shader & texture
...
@@ -351,26 +353,35 @@ public class BubbleRenderer {
...
@@ -351,26 +353,35 @@ public class BubbleRenderer {
// Get camera position
// Get camera position
Vec3d
interpolatedCameraPos
=
new
Vec3d
(
camera
.
getPos
().
x
,
camera
.
getPos
().
y
,
camera
.
getPos
().
z
);
Vec3d
interpolatedCameraPos
=
new
Vec3d
(
camera
.
getPos
().
x
,
camera
.
getPos
().
y
,
camera
.
getPos
().
z
);
// Get all entities
// Increment query counter
List
<
Entity
>
nearbyEntities
=
world
.
getOtherEntities
(
null
,
area
);
queryEntityDataCount
++;
// Filter to include only MobEntity & PlayerEntity but exclude any camera 1st person entity and any entities with passengers
// This query count helps us cache the list of relevant entities. We can refresh
List
<
Entity
>
relevantEntities
=
nearbyEntities
.
stream
()
// the list every 3rd call to this render function
.
filter
(
entity
->
(
entity
instanceof
MobEntity
||
entity
instanceof
PlayerEntity
))
if
(
queryEntityDataCount
%
3
==
0
||
relevantEntities
==
null
)
{
.
filter
(
entity
->
!
entity
.
hasPassengers
())
// Get all entities
.
filter
(
entity
->
!(
entity
.
equals
(
cameraEntity
)
&&
!
camera
.
isThirdPerson
()))
List
<
Entity
>
nearbyEntities
=
world
.
getOtherEntities
(
null
,
area
);
.
filter
(
entity
->
!(
entity
.
equals
(
cameraEntity
)
&&
entity
.
isSpectator
()))
.
filter
(
entity
->
{
// Filter to include only MobEntity & PlayerEntity but exclude any camera 1st person entity and any entities with passengers
Identifier
entityId
=
Registries
.
ENTITY_TYPE
.
getId
(
entity
.
getType
());
relevantEntities
=
nearbyEntities
.
stream
()
String
entityIdString
=
entityId
.
toString
();
.
filter
(
entity
->
(
entity
instanceof
MobEntity
||
entity
instanceof
PlayerEntity
))
// Check blacklist first
.
filter
(
entity
->
!
entity
.
hasPassengers
())
if
(
blacklist
.
contains
(
entityIdString
))
{
.
filter
(
entity
->
!(
entity
.
equals
(
cameraEntity
)
&&
!
camera
.
isThirdPerson
()))
return
false
;
.
filter
(
entity
->
!(
entity
.
equals
(
cameraEntity
)
&&
entity
.
isSpectator
()))
}
.
filter
(
entity
->
{
// If whitelist is not empty, only include entities in the whitelist
Identifier
entityId
=
Registries
.
ENTITY_TYPE
.
getId
(
entity
.
getType
());
return
whitelist
.
isEmpty
()
||
whitelist
.
contains
(
entityIdString
);
String
entityIdString
=
entityId
.
toString
();
})
// Check blacklist first
.
collect
(
Collectors
.
toList
());
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
)
{
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