Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.