Interactio - In-World Crafting with Datapacks!

Interactio - In-World Crafting with Datapacks!

3M Downloads

chore: Event System Cleanup

MaxNeedsSnacks opened this issue · 0 comments

commented

After checking out @murapix's event system a bit more in-depth, I definitely think it's a great start, but ît may still need some refining before the initial release. Some things that immediately came to mind were:

  • I feel like RecipeTickEvent and RecipeEvent could likely be merged into one interface
  • Recipe events and predicates should have an optional additional check to find out whether they can be applied to a given recipe or not, rather than that validation happening inside the events. By default this should just be always true, but this could perhaps be used during recipe parsing to inform the user of invalid actions (like using damage_anvil on a fluid transform recipe)
  • I'm thinking maybe we should at some point forego the hardcoded values for event types and events and instead look at a more dynamic system like an interface EventType rather than an enum -- the long and short of it is I just kind of dislike these four maps here because they're a bit inexpressive (maybe this can just be a registry since these should only be loaded at startup?):
    public static Map<ResourceLocation, RecipeStartPredicate<Object, StateHolder<?, ?>, CraftingInfo>> startPredicates = new HashMap<>();
    public static Map<ResourceLocation, RecipeContinuePredicate<Object, CraftingInfo>> continuePredicates = new HashMap<>();
    public static Map<ResourceLocation, RecipeEvent<Object, CraftingInfo>> events = new HashMap<>();
    public static Map<ResourceLocation, RecipeTickEvent<Object, StateHolder<?, ?>>> tickEvents = new HashMap<>();
  • I think I want to introduce parameters for tick events that determine when and how such an event should be fired. every for instance would say that an event should fire every n ticks, while chance determines the chance of an event firing on each attempt

None of these are 100% set in stone but these were just things that came to mind after checking out the refactor a bit more thoroughly. Overall, I feel like this can be quite a robust and futureproof system and make adding more features for packmakers down the line easier for us.