Jump to content

[1.12.2] What's wrong with EntityAINearestAttackableTarget?


Recommended Posts

Posted

I'm trying to make a mob (extends EntityMob) and am basically copying tasks from existing mobs, but EntityAINearestAttackableTarget is giving me warnings that it's generic.

This is the default code, in any given mob class with a big yellow underline in Eclipse:

this.targetTasks.addTask(1, new EntityAINearestAttackableTarget(this, EntityPlayer.class, true));
this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityVillager.class, false));
this.targetTasks.addTask(3, new EntityAINearestAttackableTarget(this, EntityIronGolem.class, true));

 

Yet if I apply the suggested fix, it doesn't show a warning:

this.targetTasks.addTask(1, new EntityAINearestAttackableTarget<EntityPlayer>(this, EntityPlayer.class, true));
this.targetTasks.addTask(2, new EntityAINearestAttackableTarget<EntityVillager>(this, EntityVillager.class, false));
this.targetTasks.addTask(3, new EntityAINearestAttackableTarget<EntityIronGolem>(this, EntityIronGolem.class, true));

 

My question is, why? Why does it give me a warning if it's the Vanilla code that obviously works?

Is it going to be problematic if I ignore the warning? Or if I fix the warning?

  • Like 1
Posted
1 hour ago, SapphireSky said:

I'm trying to make a mob (extends EntityMob) and am basically copying tasks from existing mobs, but EntityAINearestAttackableTarget is giving me warnings that it's generic.

This is the default code, in any given mob class with a big yellow underline in Eclipse:


this.targetTasks.addTask(1, new EntityAINearestAttackableTarget(this, EntityPlayer.class, true));
this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityVillager.class, false));
this.targetTasks.addTask(3, new EntityAINearestAttackableTarget(this, EntityIronGolem.class, true));

 

Yet if I apply the suggested fix, it doesn't show a warning:


this.targetTasks.addTask(1, new EntityAINearestAttackableTarget<EntityPlayer>(this, EntityPlayer.class, true));
this.targetTasks.addTask(2, new EntityAINearestAttackableTarget<EntityVillager>(this, EntityVillager.class, false));
this.targetTasks.addTask(3, new EntityAINearestAttackableTarget<EntityIronGolem>(this, EntityIronGolem.class, true));

 

My question is, why? Why does it give me a warning if it's the Vanilla code that obviously works?

Is it going to be problematic if I ignore the warning? Or if I fix the warning?

No it's completely fine if you leave it with the yellow underline. It just wants you to specify a type argument.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

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.

Announcements



×
×
  • Create New...

Important Information

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