SpongeAvoidEntityAIBuilder should use Entity as classToAvoid

Created on 2 Aug 2017  路  7Comments  路  Source: SpongePowered/Sponge

SpongeAvoidEntityAIBuilder actually use EntityCreature as second argument.

Because of that you cannot actually avoid no-creature based entity like the player.

Version: SpongeVanilla 1.12-7.0.0-BETA-306

entity

All 7 comments

Then it should be EntityLivingBase. The player isn't an EntityLiving.

Is it able to avoid non-living entities as well?

@ryantheleach After a quick look, EntityAIAvoidEntity seems to accept Entity so yeah in theory, we can use it to be able to avoid non-living entities.

I'll be dammed.

Looks like when I originally wrote this AI interface, I brought in the filter (which is fine) but completely forgot about the target class.

So really two things can be done here (give me some thoughts). One is a break, one isn't:

  • (non-break) Change the second argument to Entity.class, filter out the ones you want with the predicate. Drawback is you better make sure that your predicate impl is FAST (as there could be many entities and its hot code)
  • (break) Introduce the avoiding class and setting it in the interface. I could do this regardless but would keep it to bleeding API.

Thoughts?

I don't understand the second option.

The second option wouldn't have to be a break. It could just default to Entity.class if left unspecified.

I've elected to just allow all entities to be passed to the selector due to the generics usage, changing the target class after the task has been built gets ugly fast and allowing the target class in the builder still means the predicate in the task would be just an Entity predicate (which means you would still need to cast).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jeffreykog picture jeffreykog  路  4Comments

Rasgnarok picture Rasgnarok  路  4Comments

Eufranio picture Eufranio  路  4Comments

therealmikz picture therealmikz  路  4Comments

XakepSDK picture XakepSDK  路  5Comments