Add/Remove added for AlchemyTable
Add added for Altar. Working on remove.
This commit is contained in:
parent
b4dc3201d9
commit
c6bbf28d4b
5 changed files with 155 additions and 2 deletions
|
@ -1,6 +1,8 @@
|
||||||
package modtweaker.mods.bloodmagic;
|
package modtweaker.mods.bloodmagic;
|
||||||
|
|
||||||
import minetweaker.MineTweakerAPI;
|
import minetweaker.MineTweakerAPI;
|
||||||
|
import modtweaker.mods.bloodmagic.handlers.AlchemyTable;
|
||||||
|
import modtweaker.mods.bloodmagic.handlers.Altar;
|
||||||
import modtweaker.mods.bloodmagic.handlers.SoulForge;
|
import modtweaker.mods.bloodmagic.handlers.SoulForge;
|
||||||
|
|
||||||
public class BloodMagic
|
public class BloodMagic
|
||||||
|
@ -8,5 +10,7 @@ public class BloodMagic
|
||||||
public BloodMagic()
|
public BloodMagic()
|
||||||
{
|
{
|
||||||
MineTweakerAPI.registerClass(SoulForge.class);
|
MineTweakerAPI.registerClass(SoulForge.class);
|
||||||
|
MineTweakerAPI.registerClass(AlchemyTable.class);
|
||||||
|
MineTweakerAPI.registerClass(Altar.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,12 @@
|
||||||
package modtweaker.mods.bloodmagic;
|
package modtweaker.mods.bloodmagic;
|
||||||
|
|
||||||
|
import WayofTime.bloodmagic.api.ItemStackWrapper;
|
||||||
|
import WayofTime.bloodmagic.api.recipe.AlchemyTableRecipe;
|
||||||
import WayofTime.bloodmagic.api.recipe.TartaricForgeRecipe;
|
import WayofTime.bloodmagic.api.recipe.TartaricForgeRecipe;
|
||||||
|
import WayofTime.bloodmagic.api.registry.AlchemyTableRecipeRegistry;
|
||||||
|
import WayofTime.bloodmagic.api.registry.AltarRecipeRegistry;
|
||||||
import WayofTime.bloodmagic.api.registry.TartaricForgeRecipeRegistry;
|
import WayofTime.bloodmagic.api.registry.TartaricForgeRecipeRegistry;
|
||||||
|
import com.google.common.collect.BiMap;
|
||||||
import modtweaker.helpers.ReflectionHelper;
|
import modtweaker.helpers.ReflectionHelper;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -9,11 +14,15 @@ import java.util.List;
|
||||||
public class BloodMagicHelper
|
public class BloodMagicHelper
|
||||||
{
|
{
|
||||||
public static List<TartaricForgeRecipe> soulForgeList = null;
|
public static List<TartaricForgeRecipe> soulForgeList = null;
|
||||||
|
public static List<AlchemyTableRecipe> alchemyTableList = null;
|
||||||
|
public static BiMap<List<ItemStackWrapper>, AltarRecipeRegistry.AltarRecipe> altarBiMap = null;
|
||||||
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
try {
|
try {
|
||||||
soulForgeList = ReflectionHelper.getStaticObject(TartaricForgeRecipeRegistry.class, "recipeList");
|
soulForgeList = ReflectionHelper.getStaticObject(TartaricForgeRecipeRegistry.class, "recipeList");
|
||||||
|
alchemyTableList = ReflectionHelper.getStaticObject(AlchemyTableRecipeRegistry.class, "recipeList");
|
||||||
|
altarBiMap = ReflectionHelper.getStaticObject(AltarRecipeRegistry.class, "recipes");
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
|
|
@ -0,0 +1,85 @@
|
||||||
|
package modtweaker.mods.bloodmagic.handlers;
|
||||||
|
|
||||||
|
import WayofTime.bloodmagic.api.recipe.AlchemyTableRecipe;
|
||||||
|
import minetweaker.MineTweakerAPI;
|
||||||
|
import minetweaker.api.item.IIngredient;
|
||||||
|
import minetweaker.api.item.IItemStack;
|
||||||
|
import modtweaker.helpers.LogHelper;
|
||||||
|
import modtweaker.mods.bloodmagic.BloodMagicHelper;
|
||||||
|
import modtweaker.utils.BaseListAddition;
|
||||||
|
import modtweaker.utils.BaseListRemoval;
|
||||||
|
import stanhebben.zenscript.annotations.ZenClass;
|
||||||
|
import stanhebben.zenscript.annotations.ZenMethod;
|
||||||
|
|
||||||
|
import static modtweaker.helpers.InputHelper.*;
|
||||||
|
import static modtweaker.helpers.StackHelper.matches;
|
||||||
|
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@ZenClass("mods.bloodmagic.AlchemyTable")
|
||||||
|
public class AlchemyTable
|
||||||
|
{
|
||||||
|
protected static final String name = "Blood Magic Alchemy Table";
|
||||||
|
|
||||||
|
@ZenMethod
|
||||||
|
public static void addRecipe(IItemStack output, int lpDrained, int ticksRequired, int tierRequired, IIngredient[] input)
|
||||||
|
{
|
||||||
|
MineTweakerAPI.apply(new Add(new AlchemyTableRecipe(toStack(output), lpDrained, ticksRequired, tierRequired, toObjects(input)), BloodMagicHelper.alchemyTableList));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class Add extends BaseListAddition<AlchemyTableRecipe> {
|
||||||
|
public Add(AlchemyTableRecipe recipe, List<AlchemyTableRecipe> list) {
|
||||||
|
super(SoulForge.name, list);
|
||||||
|
this.recipes.add(recipe);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getRecipeInfo(AlchemyTableRecipe recipe)
|
||||||
|
{
|
||||||
|
return LogHelper.getStackDescription(recipe.getRecipeOutput(null));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ZenMethod
|
||||||
|
public static void removeRecipe(IIngredient output)
|
||||||
|
{
|
||||||
|
remove(output, BloodMagicHelper.alchemyTableList);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void remove(IIngredient output, List<AlchemyTableRecipe> list) {
|
||||||
|
if (output == null) {
|
||||||
|
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<AlchemyTableRecipe> recipes = new LinkedList<AlchemyTableRecipe>();
|
||||||
|
|
||||||
|
for(AlchemyTableRecipe recipe : list)
|
||||||
|
{
|
||||||
|
if(matches(output, toIItemStack(recipe.getRecipeOutput(null))))
|
||||||
|
recipes.add(recipe);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!recipes.isEmpty())
|
||||||
|
{
|
||||||
|
MineTweakerAPI.apply(new Remove(list, recipes));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LogHelper.logWarning(String.format("No %s Recipe found for output %s. Command ignored!", SoulForge.name, output.toString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class Remove extends BaseListRemoval<AlchemyTableRecipe> {
|
||||||
|
public Remove(List<AlchemyTableRecipe> list, List<AlchemyTableRecipe> recipes) {
|
||||||
|
super(SoulForge.name, list, recipes);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getRecipeInfo(AlchemyTableRecipe recipe) {
|
||||||
|
return LogHelper.getStackDescription(recipe.getRecipeOutput(null));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
56
src/main/java/modtweaker/mods/bloodmagic/handlers/Altar.java
Normal file
56
src/main/java/modtweaker/mods/bloodmagic/handlers/Altar.java
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
package modtweaker.mods.bloodmagic.handlers;
|
||||||
|
|
||||||
|
import WayofTime.bloodmagic.api.ItemStackWrapper;
|
||||||
|
import WayofTime.bloodmagic.api.altar.EnumAltarTier;
|
||||||
|
import WayofTime.bloodmagic.api.registry.AltarRecipeRegistry;
|
||||||
|
import minetweaker.MineTweakerAPI;
|
||||||
|
import minetweaker.api.item.IIngredient;
|
||||||
|
import minetweaker.api.item.IItemStack;
|
||||||
|
import modtweaker.helpers.LogHelper;
|
||||||
|
import modtweaker.helpers.ReflectionHelper;
|
||||||
|
import modtweaker.mods.bloodmagic.BloodMagicHelper;
|
||||||
|
import modtweaker.utils.BaseMapAddition;
|
||||||
|
import stanhebben.zenscript.annotations.ZenClass;
|
||||||
|
import stanhebben.zenscript.annotations.ZenMethod;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
|
import static modtweaker.helpers.InputHelper.*;
|
||||||
|
import static modtweaker.helpers.StackHelper.matches;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
@ZenClass("mods.bloodmagic.Altar")
|
||||||
|
public class Altar
|
||||||
|
{
|
||||||
|
protected static final String name = "Blood Magic Altar";
|
||||||
|
|
||||||
|
private static final EnumAltarTier[] altarTiers = EnumAltarTier.values();
|
||||||
|
|
||||||
|
@ZenMethod
|
||||||
|
public static void addRecipe(IItemStack output, int minTier, int syphon, int consumeRate, int drainRate, IItemStack[] input)
|
||||||
|
{
|
||||||
|
List<ItemStack> inputs = Arrays.asList(toStacks(input));
|
||||||
|
AltarRecipeRegistry.AltarRecipe temp = new AltarRecipeRegistry.AltarRecipe(inputs, toStack(output), altarTiers[minTier-1], syphon, consumeRate, drainRate);
|
||||||
|
MineTweakerAPI.apply(new Add(temp.getInput(), temp, BloodMagicHelper.altarBiMap));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class Add extends BaseMapAddition<List<ItemStackWrapper>, AltarRecipeRegistry.AltarRecipe>
|
||||||
|
{
|
||||||
|
public Add(List<ItemStackWrapper> inputs, AltarRecipeRegistry.AltarRecipe altarRecipe, Map<List<ItemStackWrapper>, AltarRecipeRegistry.AltarRecipe> list)
|
||||||
|
{
|
||||||
|
super(Altar.name, list);
|
||||||
|
this.recipes.put(inputs, altarRecipe);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getRecipeInfo(Entry<List<ItemStackWrapper>, AltarRecipeRegistry.AltarRecipe> recipe)
|
||||||
|
{
|
||||||
|
ItemStack output = ReflectionHelper.getFinalObject(recipe.getValue(), "output");
|
||||||
|
return LogHelper.getStackDescription(output);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,5 @@
|
||||||
package modtweaker.mods.bloodmagic.handlers;
|
package modtweaker.mods.bloodmagic.handlers;
|
||||||
|
|
||||||
import WayofTime.bloodmagic.api.registry.TartaricForgeRecipeRegistry;
|
|
||||||
import minetweaker.MineTweakerAPI;
|
import minetweaker.MineTweakerAPI;
|
||||||
import minetweaker.api.item.IIngredient;
|
import minetweaker.api.item.IIngredient;
|
||||||
import minetweaker.api.item.IItemStack;
|
import minetweaker.api.item.IItemStack;
|
||||||
|
@ -21,7 +20,7 @@ import java.util.List;
|
||||||
@ZenClass("mods.bloodmagic.SoulForge")
|
@ZenClass("mods.bloodmagic.SoulForge")
|
||||||
public class SoulForge
|
public class SoulForge
|
||||||
{
|
{
|
||||||
protected static final String name = "BloodMagic Soul Forge";
|
protected static final String name = "Blood Magic Soul Forge";
|
||||||
|
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
public static void addRecipe(IItemStack output, double minimumSouls, double drain, IIngredient[] input)
|
public static void addRecipe(IItemStack output, double minimumSouls, double drain, IIngredient[] input)
|
||||||
|
|
Loading…
Reference in a new issue