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
1
Merge Requests
1
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
29db3e51
Commit
29db3e51
authored
Apr 03, 2024
by
Jonathan Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding more logs in EntityBehaviorManager
parent
a41071fa
Pipeline
#11927
passed with stage
in 19 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
3 deletions
+15
-3
EntityBehaviorManager.java
src/main/java/com/owlmaddie/goals/EntityBehaviorManager.java
+15
-3
No files found.
src/main/java/com/owlmaddie/goals/EntityBehaviorManager.java
View file @
29db3e51
...
...
@@ -4,6 +4,8 @@ import net.minecraft.entity.ai.goal.GoalSelector;
import
net.minecraft.entity.mob.MobEntity
;
import
net.minecraft.server.network.ServerPlayerEntity
;
import
net.minecraft.server.world.ServerWorld
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.util.HashMap
;
import
java.util.Map
;
...
...
@@ -15,10 +17,14 @@ import java.util.UUID;
* entity more than once.
*/
public
class
EntityBehaviorManager
{
public
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
"mobgpt"
);
private
static
final
Map
<
UUID
,
FollowPlayerGoal
>
followGoals
=
new
HashMap
<>();
public
static
void
addFollowPlayerGoal
(
ServerPlayerEntity
player
,
MobEntity
entity
,
double
speed
)
{
if
(!(
entity
.
getWorld
()
instanceof
ServerWorld
))
return
;
if
(!(
entity
.
getWorld
()
instanceof
ServerWorld
))
{
LOGGER
.
debug
(
"Attempted to add FollowPlayerGoal in a non-server world. Aborting."
);
return
;
}
UUID
entityId
=
entity
.
getUuid
();
if
(!
followGoals
.
containsKey
(
entityId
))
{
...
...
@@ -26,15 +32,21 @@ public class EntityBehaviorManager {
GoalSelector
goalSelector
=
GoalUtils
.
getGoalSelector
(
entity
);
goalSelector
.
add
(
1
,
goal
);
// Priority 1
followGoals
.
put
(
entityId
,
goal
);
LOGGER
.
info
(
"FollowPlayerGoal added for entity UUID: {} with speed: {}"
,
entityId
,
speed
);
}
else
{
LOGGER
.
debug
(
"FollowPlayerGoal already exists for entity UUID: {}"
,
entityId
);
}
}
public
static
void
removeFollowPlayerGoal
(
MobEntity
entity
)
{
UUID
entityId
=
entity
.
getUuid
();
FollowPlayerGoal
goal
=
followGoals
.
remove
(
entityId
);
if
(
goal
!=
null
)
{
if
(
followGoals
.
containsKey
(
entityId
))
{
FollowPlayerGoal
goal
=
followGoals
.
remove
(
entityId
);
GoalSelector
goalSelector
=
GoalUtils
.
getGoalSelector
(
entity
);
goalSelector
.
remove
(
goal
);
LOGGER
.
info
(
"FollowPlayerGoal removed for entity UUID: {}"
,
entityId
);
}
else
{
LOGGER
.
debug
(
"No FollowPlayerGoal found for entity UUID: {} to remove"
,
entityId
);
}
}
}
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