Commit 29db3e51 by Jonathan Thomas

Adding more logs in EntityBehaviorManager

parent a41071fa
Pipeline #11927 passed with stage
in 19 seconds
......@@ -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();
if (followGoals.containsKey(entityId)) {
FollowPlayerGoal goal = followGoals.remove(entityId);
if (goal != null) {
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);
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment