mirror of
https://github.com/GTNewHorizons/BloodMagic.git
synced 2026-11-17 10:55:10 +00:00
Update MineTweaker integration to handle delayed run of additions/removals to main recipe registry.
This commit is contained in:
1 parent
40d0b5e228
commit
b4db1b05c8
6 files changed
+40
-14
No files matched your search
@@ -4,6 +4,7 @@ import static WayofTime.alchemicalWizardry.common.tweaker.MTHelper.toObjects;
|
||||
import static WayofTime.alchemicalWizardry.common.tweaker.MTHelper.toShapedObjects;
|
||||
import static WayofTime.alchemicalWizardry.common.tweaker.MTHelper.toStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import WayofTime.alchemicalWizardry.api.items.ShapelessBloodOrbRecipe;
|
||||
@@ -24,16 +25,30 @@ import WayofTime.alchemicalWizardry.api.items.ShapedBloodOrbRecipe;
|
||||
@ZenClass("mods.bloodmagic.BloodOrb")
|
||||
public class BloodOrb
|
||||
{
|
||||
public static List<IUndoableAction> lateAdditions = new ArrayList<>();
|
||||
public static List<IUndoableAction> lateRemovals = new ArrayList<>();
|
||||
|
||||
public static void applyAdditionsAndRemovals() {
|
||||
for (IUndoableAction toRemove : lateRemovals) {
|
||||
MineTweakerAPI.apply(toRemove);
|
||||
}
|
||||
for (IUndoableAction toAdd : lateAdditions) {
|
||||
MineTweakerAPI.apply(toAdd);
|
||||
}
|
||||
|
||||
lateAdditions.clear();
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void addShaped(IItemStack output, IIngredient[][] ingredients)
|
||||
{
|
||||
MineTweakerAPI.apply(new Add(false, toStack(output), toShapedObjects(ingredients)));
|
||||
lateAdditions.add(new Add(false, toStack(output), toShapedObjects(ingredients)));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void addShapeless(IItemStack output, IIngredient[] ingredients)
|
||||
{
|
||||
MineTweakerAPI.apply(new Add(true, toStack(output), toObjects(ingredients)));
|
||||
lateAdditions.add((new Add(true, toStack(output), toObjects(ingredients))));
|
||||
}
|
||||
|
||||
private static class Add implements IUndoableAction {
|
||||
@@ -89,7 +104,7 @@ public class BloodOrb
|
||||
|
||||
@ZenMethod
|
||||
public static void removeRecipe(IItemStack output) {
|
||||
MineTweakerAPI.apply(new Remove(toStack(output)));
|
||||
lateRemovals.add(new Remove(toStack(output)));
|
||||
}
|
||||
|
||||
private static class Remove implements IUndoableAction {
|
||||
@@ -111,7 +126,6 @@ public class BloodOrb
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
CraftingManager.getInstance().getRecipeList().remove(iRecipe);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package WayofTime.alchemicalWizardry.common.tweaker;
|
||||
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.MineTweakerImplementationAPI;
|
||||
import minetweaker.util.IEventHandler;
|
||||
|
||||
/**
|
||||
* MineTweaker3 Integration by joshie *
|
||||
@@ -15,5 +17,18 @@ public class MineTweakerIntegration
|
||||
MineTweakerAPI.registerClass(BloodOrb.class);
|
||||
MineTweakerAPI.registerClass(FallingTower.class);
|
||||
MineTweakerAPI.registerClass(HarvestMoon.class);
|
||||
|
||||
MineTweakerImplementationAPI.onRollbackEvent(new HandleLateAdditionsAndRemovals());
|
||||
MineTweakerImplementationAPI.onPostReload(new HandleLateAdditionsAndRemovals());
|
||||
}
|
||||
public static class HandleLateAdditionsAndRemovals implements IEventHandler<MineTweakerImplementationAPI.ReloadEvent>
|
||||
{
|
||||
@Override
|
||||
public void handle(MineTweakerImplementationAPI.ReloadEvent event)
|
||||
{
|
||||
BloodOrb.applyAdditionsAndRemovals();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user