ChiriVulpes / soulus

A Minecraft mod. You must sift through the ashes of the dead to restore life to the world.
https://soulus.info
Other
3 stars 3 forks source link

Fixed #37 #40

Closed codetaylor closed 6 years ago

codetaylor commented 6 years ago

This change delays the processing of all Soulus specific recipe additions and removals until after CraftTweaker (CT) has processed its recipes in its PostInit phase.

A soft, order-only dependency on crafttweaker was added to the mod's @Mod annotation to ensure that if CT is available, Soulus will be loaded after it, therefore processing its PostInit event after CT.

In Soulus' PostInit handler, a call to the ZenComposer::apply() is made to apply aggregated IAction implementations in the proper order.

Creation of the recipes, specifically the resolution of oredict ingredients has been moved to the respective IAction#apply() methods to ensure that mods and CT scripts have ample time to manipulate the oredict entries before resolution.

Tested using the script provided in #37 :

import mods.soulus.Composer;
recipes.remove(<minecraft:stone:1>);
Composer.addShaped("mytest", <minecraft:stone:1>, 512, [ [<minecraft:gold_ingot>, <minecraft:gold_ingot>, <minecraft:gold_ingot>], [<minecraft:gold_ingot>, null, <minecraft:gold_ingot>], [<minecraft:gold_ingot>, <minecraft:gold_ingot>, <minecraft:gold_ingot>] ]);

The granite recipe added after the removal is not removed.

Also tested in reverse:

import mods.soulus.Composer;
Composer.addShaped("mytest", <minecraft:stone:1>, 512, [ [<minecraft:gold_ingot>, <minecraft:gold_ingot>, <minecraft:gold_ingot>], [<minecraft:gold_ingot>, null, <minecraft:gold_ingot>], [<minecraft:gold_ingot>, <minecraft:gold_ingot>, <minecraft:gold_ingot>] ]);
recipes.remove(<minecraft:stone:1>);

Again, the soulus specific granite recipe added is not removed because the removals are processed before the additions. This behavior conforms to CT behavior and the behavior of most mods that implement CT, as well as expected and accepted behavior by pack developers.

Three new entries were also added to the .gitignore to prevent project contamination by Intellij users.

ChiriVulpes commented 6 years ago

Omg! 😍

I'll test and merge this as soon as I wake up tomorrow (caught up in something else at the moment). This looks great tho!

Looks like the part that I could never figure out was the simplest part of all https://github.com/codetaylor/soulus/blob/fix-issue-37/src/main/java/yuudaari/soulus/Soulus.java#L173-L175

It's funny, seeing this similar code in ex nihilo creatio and your mods I could never wrap my head around what was happening, and looking at the changes you made to my own code, I finally understand. I also understand how simple it is. I feel kinda dumb now.