Posted January 31, 20223 yr I'm new to Forge, but I thought injecting some AI into Villagers would be relatively simple— just create a class that extends Goal, and use targetSelector (or goalSelector).addGoal inside an EntityJoinWorldEvent listener. But during testing, I discovered that all running and available goals are always empty for Villagers. Below is the test code— running near an established Village just returns empty lists. @SubscribeEvent public void test(EntityEvent event) { if (event.getEntity() instanceof Villager) { Villager villager = (Villager) event.getEntity(); if (villager.goalSelector != null) { LOGGER.info("available goals: {}", villager.goalSelector.getAvailableGoals() .stream() .map(goal -> new Object[]{goal.getGoal(), goal.getFlags(), goal.getPriority()}) .toList() ); LOGGER.info("current goals: {}", villager.goalSelector.getRunningGoals() .map(goal -> new Object[]{goal.getGoal(), goal.getFlags(), goal.getPriority()}) .toList() ); } if (villager.targetSelector != null) { LOGGER.info("available target goals: {}", villager.targetSelector.getAvailableGoals() .stream() .map(goal -> new Object[]{goal.getGoal(), goal.getFlags(), goal.getPriority()}) .toList() ); LOGGER.info("current target goals: {}", villager.targetSelector.getRunningGoals() .map(goal -> new Object[]{goal.getGoal(), goal.getFlags(), goal.getPriority()}) .toList() ); } } } Why is this the case, and how will it affect Goals that I add myself?
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.