SpongePowered / Sponge

The SpongeAPI implementation targeting vanilla Minecraft and 3rd party platforms.
MIT License
384 stars 211 forks source link

Some AI Goal methods are throwing exceptions #1933

Open Xenmai opened 6 years ago

Xenmai commented 6 years ago

Hi there, I'm using spongevanilla-1.12.2-7.1.0-BETA-48.jar and I've encountered some problems when using AI Tasks. The main issues are related to Goal methods throwing exceptions. Goal#getTasksByType(AITaskType type) and Goal#removeTasks(AITaskType type) are the specific methods in this case. Here is a gist of the exception thrown by the former when given AITaskTypes.WANDER as an argument: https://gist.github.com/Xenmai/e84d41388f7e8bcbdb5ea33bbf7db33e I can test the other method again and paste its exception as well if needed, just let me know.

Note: I've also seen the API is lacking some AI Task Types in its catalog. There are actually more types of working AI Tasks than it's shown here: https://jd.spongepowered.org/7.1.0-SNAPSHOT/org/spongepowered/api/entity/ai/task/AITaskTypes.html Should I create an API issue for that?

Thanks a lot for your time.

liach commented 6 years ago

https://github.com/SpongePowered/SpongeCommon/blob/c96a2d8c2b7a3ab8bb2d1c61cdea47a55ba3a8a9/src/main/java/org/spongepowered/common/mixin/core/entity/ai/MixinEntityAITasks.java#L110-L122

liach commented 6 years ago

So do some tasks not have types?

Xenmai commented 6 years ago

If I remember my prior testing correctly, Sponge.getRegistry.getAllOf(AITaskType.class) returns all of them, but if you try to Sponge.getRegistry.getType(AITaskType.class, string) one of them, it only works with the ones listed in the API. Not sure if that makes sense. I can test again later today just to make sure.

ST-DDT commented 6 years ago

GetbyId and getAll use the same dataset. See https://github.com/SpongePowered/SpongeCommon/blob/bleeding/src/main/java/org/spongepowered/common/registry/type/entity/AITaskTypeModule.java

Xenmai commented 6 years ago

You are right, my bad. Two task types are missing from the catalog though: LookIdleAITask and RangeAgentAITask.