Jump to content

[1.14.4] Changing Creeper's AI Goals OnEntitySpawn


max2461

Recommended Posts

So in my code for 1.8.1, I used to be able to change Creepers AI tasks like so:

	@SubscribeEvent
    public void onEntitySpawn(EntityJoinWorldEvent event) {
          if (event.entity instanceof EntityCreeper){
              EntityCreeper entity = (EntityCreeper) event.entity;
              for (Object entry : entity.targetTasks.taskEntries.toArray()){
                  EntityAIBase ai = ((EntityAITasks.EntityAITaskEntry) entry).action;
                 if (ai instanceof EntityAINearestAttackableTarget) entity.targetTasks.removeTask(ai);
              }
              for (Object entry : entity.tasks.taskEntries.toArray()){
                  EntityAIBase ai = ((EntityAITasks.EntityAITaskEntry) entry).action;
                  if (ai instanceof EntityAIAttackOnCollide) entity.tasks.removeTask(ai);
              }
              entity.tasks.addTask(1, new EntityAITempt(entity, 1.0D, Items.gunpowder, false));
              entity.tasks.addTask(2, new EntityAIPanic(entity, 1.4D));
          }
	}

 

But now, in 1.14.4, i cannot for the life of me figure out how to use the "goal" system in the AI.

I have tried different events, new registry of the mob, overriding creeperEntites... Here is a failure chunk of code I tried to rework the 1.8 function to (knowing it would fail):

(Also, if it doesn't make any sense its because it's literally me changing tiny things to see what happens after weeks of trying)

 

@SubscribeEvent
	public void onEntitySpawn(EntityJoinWorldEvent event) {
	    if (event.getEntity() instanceof CreeperEntity){
	    	CreeperEntity creeper = (CreeperEntity) event.getEntity();
	        for (Task task : creeper.goalSelector.getRunningGoals().filter(PrioritizedGoalPrioritizedGoal).getgoal()){
	        	GoalSelector ai = ((GoalSelector) entry).action;
	           if (ai instanceof EntityAINearestAttackableTarget) entity.targetTasks.removeTask(ai);
	        }
	}
}

 

The Mod in its base form is just to make creepers friendly and maybe attack other things. I just can't get the Goal system right.

Edited by max2461
Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.