-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FacetProvider requirements should be verified #4924
Comments
Hi @zhayun3233 - https://discord.gg/terasology is the place for various general support :-) If you're curious about this topic in particular check out https://github.com/Terasology/TutorialWorldGeneration and our getting started docs in this repo's wiki 👍 |
Would the WorldBuilder class (org.terasology.engine.world.generation.WorldBuilder) be a good place to perform the check if all required facet providers are available? More specifically in the determineProviderChains function where the other annotations are processed (line 178) |
Adding a link here for easier access: https://github.com/MovingBlocks/Terasology/blob/develop/engine/src/main/java/org/terasology/engine/world/generation/WorldBuilder.java#L177-L188 @MrGizmo123 Without having actively looked for alternative places, this seems like a good place to add such a check as we have easy access to both, the list of already added ("present") facets and the facet to be added to the chain. For me the question would be, what is the expected behavior if we notice that a required facet is not yet present in the chain? Should we only log something or fail entirely? Personally, I think I would favor the latter to get early feedback when developing, but I'm not sure whether I'm overlooking scenarios in which this behavior would not be favorable... what do you think? |
@jdrueckert I agree, as in I think it should fail entirely since its going to crash anyway a few moments later. I think the only time this error will come up is during development of a new world generator and so a prominent error message (after failure) will be most helpful. |
An if statement like this should be enough https://github.com/MrGizmo123/Terasology/blob/develop/engine/src/main/java/org/terasology/engine/world/generation/WorldBuilder.java#L230-L233. I'm also not sure how to exit the program properly. |
* add check for required facets in WorldBuilder * throw IllegalStateException on missing provider for required facet * adjust test cases for facet provider order * add test case for incorrect order throwing * remove .idea/kotlinc.xml Fixes #4924 Co-authored-by: jdrueckert <jd.rueckert@googlemail.com>
For example, BiomeProvider
@Requires
SeaLevelFacet, but code reaches BiomeProvider.process without a SeaLevelFacet provided: https://scans.gradle.com/s/3szw7vgxv4d2o/tests/:modules:DynamicCities:test/org.terasology.dynamicCities.settlements.SettlementEntityManagerTest/placeParcel(SettlementEntityManager,%20ModuleTestingHelper)?top-execution=1If this had been checked up-front and responded with a clear error message, it would have saved me some time in trying to figure out why my WorldGenerator wasn't working.
@tolziplohu says:
The text was updated successfully, but these errors were encountered: