jabelar Posted September 9, 2017 Share Posted September 9, 2017 (edited) I'm porting my mods to 1.12.1 and moving achievements to advancements. I understand that many advancements can be implemented just by using JSON, and there are a lot of interesting vanilla triggers, but my advancements are usually more complex. As an example, I've got mobs with their own taming system that don't extend ITameable so the vanilla tame_an_animal trigger won't fire but I want to make similar advancement (taming eagles leads to "falconer" advancement, taming a big cat leads to "lion tamer" advancement). There probably is a way to wrangle NBT to use JSON only, but it is much easier for me just to fire a trigger that doesn't need further testing... So i decided to make my own flexible custom criterion system. It works fine but I'm wondering if I'm reinventing something or if there are other side effects of my approach. My main idea is that I want to fire criteria that don't need testing. In other words, I fire the "tame_bird" using my TAME_BIRD.trigger() method and only pass it the player since that is minimum needed to attach the trigger to the player. Everytime I trigger it will test as true -- no other predicate testing. To make it flexible, I have a single criteria class which has constructor to take in the name (i.e. the "tame_bird") so that associated JSON will work. The JSON is very simple. Just has the display and parent and then associated the criteria with the single trigger. The only hurdle I faced was registering a custom criterion. As far as I could tell, there is no registry event for it and the registry field and the register method on the build-in registry (CriteriaTriggers class) are private. So I used some simple Java Reflection and it worked fine. So everything works -- trigger fires and the advancement works as expected, shows toast message, is displayed in advancement tree, so forth. But I have two questions: 1) Does forge provide a method for registering custom criteria? Any time I use reflection I assume I'm missing out on some hook that already exists... 2) Is there any side effect for not using predicates in my test method? Would it affect my (or resource packs') ability to combine criteria in a more complicated JSON? Otherwise it is really slick system. I simply register a new instance with new name, trigger it wherever I want in code, and copy a very simple JSON to hook it into the advancement tree. Edited September 9, 2017 by jabelar Quote Check out my tutorials here: http://jabelarminecraft.blogspot.com/ Link to comment Share on other sites More sharing options...
Draco18s Posted September 9, 2017 Share Posted September 9, 2017 1 hour ago, jabelar said: But I have two questions: 1) Does forge provide a method for registering custom criteria? Any time I use reflection I assume I'm missing out on some hook that already exists... 2) Is there any side effect for not using predicates in my test method? Would it affect my (or resource packs') ability to combine criteria in a more complicated JSON? Otherwise it is really slick system. I simply register a new instance with new name, trigger it wherever I want in code, and copy a very simple JSON to hook it into the advancement tree. 1) Not currently. However, this works: https://github.com/Draco18s/ReasonableRealism/blob/1.12.1/src/main/java/com/draco18s/hardlib/EasyRegistry.java#L210-L222 2) Not sure what you mean, but feel free to take a look at some of my criterionhttps://github.com/Draco18s/ReasonableRealism/tree/1.12.1/src/main/java/com/draco18s/hardlib/api/advancement Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given. Link to comment Share on other sites More sharing options...
jabelar Posted September 9, 2017 Author Share Posted September 9, 2017 Thanks, you're doing it exactly the same way I am for the reflection. So I'll consider it a reasonable approach then. Thanks for the confirmation. Quote Check out my tutorials here: http://jabelarminecraft.blogspot.com/ Link to comment Share on other sites More sharing options...
Recommended Posts
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.