mirror of
https://github.com/GTNewHorizons/ModTweaker.git
synced 2026-11-20 04:19:44 +00:00
ModTweaker2 Rework
- Revised base classes for IUndoableAction - Reordered lots of code, so stuck actions should be less frequent - Added wildcard support to many "remove" methods - Started working on exist & duplicate checks
This commit is contained in:
1 parent
f5034b04d8
commit
da33cc6fab
112 files changed
+4596
-3522
No files matched your search
@@ -1,6 +1,7 @@
|
||||
package modtweaker2.mods.tconstruct;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -9,6 +10,7 @@ import java.util.Map;
|
||||
import mantle.utils.ItemMetaWrapper;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.crafting.AlloyMix;
|
||||
@@ -16,6 +18,7 @@ import tconstruct.library.crafting.CastingRecipe;
|
||||
import tconstruct.library.crafting.DryingRackRecipes.DryingRecipe;
|
||||
import tconstruct.library.crafting.ModifyBuilder;
|
||||
import tconstruct.library.crafting.PatternBuilder.ItemKey;
|
||||
import tconstruct.library.crafting.Smeltery;
|
||||
import tconstruct.library.modifier.ItemModifier;
|
||||
import tconstruct.library.tools.ToolMaterial;
|
||||
|
||||
@@ -27,6 +30,7 @@ public class TConstructHelper {
|
||||
public static Map<ItemMetaWrapper, FluidStack> smeltingList = null;
|
||||
public static Map<ItemMetaWrapper, Integer> temperatureList = null;
|
||||
public static Map<ItemMetaWrapper, ItemStack> renderIndex = null;
|
||||
public static Map<Fluid, Integer[]> fuelList = null;
|
||||
public static List<ItemModifier> modifiers = null;
|
||||
public static List<ItemModifier> modifiers_clone = null;
|
||||
|
||||
@@ -44,7 +48,8 @@ public class TConstructHelper {
|
||||
for (Map.Entry<Integer, ToolMaterial> entry : TConstructRegistry.toolMaterials.entrySet()) {
|
||||
mappings.put(entry.getValue().materialName, entry.getKey());
|
||||
}
|
||||
|
||||
|
||||
fuelList = getFuelList();
|
||||
} catch (Exception e) {}
|
||||
}
|
||||
|
||||
@@ -55,6 +60,20 @@ public class TConstructHelper {
|
||||
return -1;
|
||||
} else return mappings.get(material);
|
||||
}
|
||||
|
||||
public static Map<Fluid, Integer[]> getFuelList() {
|
||||
Smeltery smelteryInstance = tconstruct.library.crafting.Smeltery.instance;
|
||||
|
||||
try {
|
||||
Field smelteryFuels = Smeltery.class.getDeclaredField("smelteryFuels");
|
||||
smelteryFuels.setAccessible(true);
|
||||
|
||||
return (Map<Fluid, Integer[]>)smelteryFuels.get(smelteryInstance);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new NullPointerException("Failed to instantiate smeltery fuel map");
|
||||
}
|
||||
}
|
||||
|
||||
//Returns a Drying Recipe, using reflection as the constructor is not visible
|
||||
public static DryingRecipe getDryingRecipe(ItemStack input, int time, ItemStack output) {
|
||||
|
||||
@@ -1,21 +1,23 @@
|
||||
package modtweaker2.mods.tconstruct.handlers;
|
||||
|
||||
import static modtweaker2.helpers.InputHelper.toFluid;
|
||||
import static modtweaker2.helpers.InputHelper.toIItemStack;
|
||||
import static modtweaker2.helpers.InputHelper.toILiquidStack;
|
||||
import static modtweaker2.helpers.InputHelper.toStack;
|
||||
import static modtweaker2.helpers.StackHelper.areEqual;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.api.item.IIngredient;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import minetweaker.api.liquid.ILiquidStack;
|
||||
import modtweaker2.helpers.InputHelper;
|
||||
import modtweaker2.helpers.LogHelper;
|
||||
import modtweaker2.mods.tconstruct.TConstructHelper;
|
||||
import modtweaker2.utils.BaseListAddition;
|
||||
import modtweaker2.utils.BaseListRemoval;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import stanhebben.zenscript.annotations.Optional;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
@@ -23,7 +25,11 @@ import tconstruct.library.crafting.CastingRecipe;
|
||||
|
||||
@ZenClass("mods.tconstruct.Casting")
|
||||
public class Casting {
|
||||
//Adding a TConstruct Casting recipe
|
||||
|
||||
protected static final String name = "TConstruct Casting";
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ZenMethod
|
||||
public static void addBasinRecipe(IItemStack output, ILiquidStack metal, @Optional IItemStack cast, @Optional boolean consume, int delay) {
|
||||
MineTweakerAPI.apply(new Add(new CastingRecipe(toStack(output), toFluid(metal), toStack(cast), consume, delay, null), TConstructHelper.basinCasting));
|
||||
@@ -35,98 +41,90 @@ public class Casting {
|
||||
}
|
||||
|
||||
//Passes the list to the base list implementation, and adds the recipe
|
||||
private static class Add extends BaseListAddition {
|
||||
public Add(CastingRecipe recipe, ArrayList list) {
|
||||
super("TConstruct Casting", list, recipe);
|
||||
private static class Add extends BaseListAddition<CastingRecipe> {
|
||||
public Add(CastingRecipe recipe, ArrayList<CastingRecipe> list) {
|
||||
super("TConstruct Casting", list);
|
||||
|
||||
this.recipes.add(recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeInfo() {
|
||||
return ((CastingRecipe) recipe).output.getDisplayName();
|
||||
protected String getRecipeInfo(CastingRecipe recipe) {
|
||||
return InputHelper.getStackDescription(recipe.output);
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//Removing a TConstruct Casting recipe
|
||||
@ZenMethod
|
||||
public static void removeBasinRecipe(IItemStack output) {
|
||||
MineTweakerAPI.apply(new Remove((toStack(output)), TConstructHelper.basinCasting, RecipeComponent.Output));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void removeTableRecipe(IItemStack output) {
|
||||
MineTweakerAPI.apply(new Remove((toStack(output)), TConstructHelper.tableCasting, RecipeComponent.Output));
|
||||
public static void removeTableRecipe(IIngredient output) {
|
||||
removeRecipe(output, TConstructHelper.tableCasting, RecipeComponent.Output);
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void removeBasinMaterial(ILiquidStack fluid) {
|
||||
MineTweakerAPI.apply(new Remove((toFluid(fluid)), TConstructHelper.basinCasting));
|
||||
public static void removeTableMaterial(IIngredient material) {
|
||||
removeRecipe(material, TConstructHelper.tableCasting, RecipeComponent.Material);
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void removeTableMaterial(ILiquidStack fluid) {
|
||||
MineTweakerAPI.apply(new Remove((toFluid(fluid)), TConstructHelper.tableCasting));
|
||||
public static void removeCastRecipes(IIngredient cast) {
|
||||
removeRecipe(cast, TConstructHelper.tableCasting, RecipeComponent.Cast);
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void removeCastRecipes(IItemStack cast) {
|
||||
MineTweakerAPI.apply(new Remove((toStack(cast)), TConstructHelper.tableCasting, RecipeComponent.Cast));
|
||||
public static void removeBasinRecipe(IIngredient output) {
|
||||
removeRecipe(output, TConstructHelper.basinCasting, RecipeComponent.Output);
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void removeBasinMaterial(IIngredient material) {
|
||||
removeRecipe(material, TConstructHelper.basinCasting, RecipeComponent.Material);
|
||||
}
|
||||
|
||||
// Removes all matching recipes, apply is never the same for anything, so will always need to override it
|
||||
private static class Remove extends BaseListRemoval {
|
||||
protected final RecipeComponent component;
|
||||
|
||||
public static void removeRecipe(IIngredient ingredient, List<CastingRecipe> list, RecipeComponent component) {
|
||||
|
||||
public Remove(ItemStack item, ArrayList list, RecipeComponent component) {
|
||||
super("TConstruct Casting", list, item);
|
||||
this.component = component;
|
||||
}
|
||||
List<CastingRecipe> recipes = new LinkedList<CastingRecipe>();
|
||||
|
||||
public Remove(FluidStack fluid, ArrayList list) {
|
||||
super("TConstruct Casting", list, fluid);
|
||||
this.component = RecipeComponent.Material;
|
||||
}
|
||||
|
||||
// Loops through the registry, to find all items that matches, then removes them
|
||||
@Override
|
||||
public void apply() {
|
||||
for (Iterator<CastingRecipe> iterator = ((ArrayList<CastingRecipe>)list).iterator(); iterator.hasNext();) {
|
||||
CastingRecipe r = iterator.next();
|
||||
|
||||
switch(component)
|
||||
{
|
||||
for(CastingRecipe recipe : list) {
|
||||
if(recipe != null) {
|
||||
switch(component) {
|
||||
case Cast:
|
||||
if (r.cast != null && areEqual(r.cast, stack)) {
|
||||
recipes.add(r);
|
||||
if(recipe.cast != null && ingredient.contains(toIItemStack(recipe.cast))) {
|
||||
recipes.add(recipe);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case Material:
|
||||
if (r.castingMetal != null && r.castingMetal.isFluidEqual(fluid)) {
|
||||
recipes.add(r);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case Output:
|
||||
if (r.output != null && areEqual(r.output, stack)) {
|
||||
recipes.add(r);
|
||||
if (recipe.output != null && ingredient.contains(toIItemStack(recipe.output))) {
|
||||
recipes.add(recipe);
|
||||
}
|
||||
break;
|
||||
case Material:
|
||||
if (recipe.castingMetal != null && ingredient.contains(toILiquidStack(recipe.castingMetal))) {
|
||||
// TODO: Currently broken, because MCLiquidStack equals() method always returns false
|
||||
recipes.add(recipe);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
super.apply();
|
||||
}
|
||||
|
||||
if(!recipes.isEmpty()) {
|
||||
MineTweakerAPI.apply(new Remove(list, recipes));
|
||||
} else {
|
||||
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Casting.name, ingredient.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
// Removes all matching recipes, apply is never the same for anything, so will always need to override it
|
||||
private static class Remove extends BaseListRemoval<CastingRecipe> {
|
||||
public Remove(List<CastingRecipe> list, List<CastingRecipe> recipes) {
|
||||
super(Casting.name, list, recipes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeInfo() {
|
||||
if(component == RecipeComponent.Material)
|
||||
return fluid.getLocalizedName();
|
||||
else
|
||||
return stack.getDisplayName();
|
||||
protected String getRecipeInfo(CastingRecipe recipe) {
|
||||
return InputHelper.getStackDescription(recipe.output);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,16 +1,19 @@
|
||||
package modtweaker2.mods.tconstruct.handlers;
|
||||
|
||||
import static modtweaker2.helpers.InputHelper.toIItemStack;
|
||||
import static modtweaker2.helpers.InputHelper.toStack;
|
||||
import static modtweaker2.helpers.StackHelper.areEqual;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.api.item.IIngredient;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import modtweaker2.helpers.InputHelper;
|
||||
import modtweaker2.helpers.LogHelper;
|
||||
import modtweaker2.mods.tconstruct.TConstructHelper;
|
||||
import modtweaker2.utils.BaseListAddition;
|
||||
import modtweaker2.utils.BaseListRemoval;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
import tconstruct.library.crafting.DryingRackRecipes;
|
||||
@@ -18,21 +21,26 @@ import tconstruct.library.crafting.DryingRackRecipes.DryingRecipe;
|
||||
|
||||
@ZenClass("mods.tconstruct.Drying")
|
||||
public class Drying {
|
||||
//Adding a TConstruct Drying Rack recipe
|
||||
|
||||
protected static final String name = "TConstruct Drying Rack";
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ZenMethod
|
||||
public static void addRecipe(IItemStack input, IItemStack output, int time) {
|
||||
MineTweakerAPI.apply(new Add(TConstructHelper.getDryingRecipe(toStack(input), time, toStack(output))));
|
||||
}
|
||||
|
||||
//Passes the list to the base list implementation, and adds the recipe
|
||||
private static class Add extends BaseListAddition {
|
||||
private static class Add extends BaseListAddition<DryingRecipe> {
|
||||
public Add(DryingRecipe recipe) {
|
||||
super("TConstruct Drying Rack", DryingRackRecipes.recipes, recipe);
|
||||
super(Drying.name, DryingRackRecipes.recipes);
|
||||
this.recipes.add(recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeInfo() {
|
||||
return ((DryingRecipe) recipe).result.getDisplayName();
|
||||
protected String getRecipeInfo(DryingRecipe recipe) {
|
||||
return InputHelper.getStackDescription(recipe.result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,30 +48,31 @@ public class Drying {
|
||||
|
||||
//Removing a TConstruct Drying Rack recipe
|
||||
@ZenMethod
|
||||
public static void removeRecipe(IItemStack output) {
|
||||
MineTweakerAPI.apply(new Remove((toStack(output))));
|
||||
public static void removeRecipe(IIngredient ingredient) {
|
||||
List<DryingRecipe> recipes = new LinkedList<DryingRecipe>();
|
||||
|
||||
for (DryingRecipe recipe : DryingRackRecipes.recipes) {
|
||||
if (recipe != null && recipe.result != null && ingredient.matches(toIItemStack(recipe.result))) {
|
||||
recipes.add(recipe);
|
||||
}
|
||||
}
|
||||
|
||||
if(!recipes.isEmpty()) {
|
||||
MineTweakerAPI.apply(new Remove(recipes));
|
||||
} else {
|
||||
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Drying.name, ingredient.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
//Removes a recipe, apply is never the same for anything, so will always need to override it
|
||||
private static class Remove extends BaseListRemoval {
|
||||
public Remove(ItemStack output) {
|
||||
super("TConstruct Drying Rack", DryingRackRecipes.recipes, output);
|
||||
}
|
||||
|
||||
//Loops through the registry, to find the item that matches, saves that recipe then removes it
|
||||
@Override
|
||||
public void apply() {
|
||||
for (DryingRecipe r : (ArrayList<DryingRecipe>) list) {
|
||||
if (r.result != null && areEqual(r.result, stack)) {
|
||||
recipes.add(r);
|
||||
}
|
||||
}
|
||||
super.apply();
|
||||
private static class Remove extends BaseListRemoval<DryingRecipe> {
|
||||
public Remove(List<DryingRecipe> list) {
|
||||
super(Drying.name, DryingRackRecipes.recipes, list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeInfo() {
|
||||
return stack.getDisplayName();
|
||||
protected String getRecipeInfo(DryingRecipe recipe) {
|
||||
return InputHelper.getStackDescription(recipe.result);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
package modtweaker2.mods.tconstruct.handlers;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import modtweaker2.helpers.LogHelper;
|
||||
import modtweaker2.mods.tconstruct.TConstructHelper;
|
||||
import modtweaker2.utils.BaseListRemoval;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
@@ -11,28 +13,37 @@ import tconstruct.library.modifier.ItemModifier;
|
||||
|
||||
@ZenClass("mods.tconstruct.Modifiers")
|
||||
public class Modifiers {
|
||||
|
||||
protected static final String name = "TConstruct Modifier";
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ZenMethod
|
||||
public static void remove(String mod) {
|
||||
MineTweakerAPI.apply(new Remove(mod));
|
||||
List<ItemModifier> recipes = new LinkedList<ItemModifier>();
|
||||
|
||||
for (ItemModifier recipe : TConstructHelper.modifiers) {
|
||||
if (recipe.key.equals(mod)) {
|
||||
recipes.add(recipe);
|
||||
}
|
||||
}
|
||||
|
||||
if(!recipes.isEmpty()) {
|
||||
MineTweakerAPI.apply(new Remove(recipes));
|
||||
} else {
|
||||
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Modifiers.name, mod));
|
||||
}
|
||||
}
|
||||
|
||||
//Searches through the modifiers and removes the first valid entry
|
||||
private static class Remove extends BaseListRemoval {
|
||||
private final String check;
|
||||
|
||||
public Remove(String check) {
|
||||
super("Modifier", TConstructHelper.modifiers);
|
||||
this.check = check;
|
||||
private static class Remove extends BaseListRemoval<ItemModifier>{
|
||||
public Remove(List<ItemModifier> recipes) {
|
||||
super(Modifiers.name, TConstructHelper.modifiers, recipes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
for (ItemModifier m : (List<ItemModifier>) list) {
|
||||
if (m.key.equals(check)) {
|
||||
recipes. add(m);
|
||||
}
|
||||
}
|
||||
super.apply();
|
||||
protected String getRecipeInfo(ItemModifier recipe) {
|
||||
return recipe.key;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,24 +3,34 @@ package modtweaker2.mods.tconstruct.handlers;
|
||||
import static modtweaker2.helpers.InputHelper.isABlock;
|
||||
import static modtweaker2.helpers.InputHelper.toFluid;
|
||||
import static modtweaker2.helpers.InputHelper.toFluids;
|
||||
import static modtweaker2.helpers.InputHelper.toILiquidStack;
|
||||
import static modtweaker2.helpers.InputHelper.toStack;
|
||||
import static modtweaker2.helpers.StackHelper.matches;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import mantle.utils.ItemMetaWrapper;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.api.item.IIngredient;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import minetweaker.api.liquid.ILiquidStack;
|
||||
import minetweaker.api.minecraft.MineTweakerMC;
|
||||
import minetweaker.api.oredict.IOreDictEntry;
|
||||
import modtweaker2.helpers.InputHelper;
|
||||
import modtweaker2.helpers.LogHelper;
|
||||
import modtweaker2.mods.tconstruct.TConstructHelper;
|
||||
import modtweaker2.utils.BaseDescriptionAddition;
|
||||
import modtweaker2.utils.BaseDescriptionRemoval;
|
||||
import modtweaker2.utils.BaseListAddition;
|
||||
import modtweaker2.utils.BaseListRemoval;
|
||||
import modtweaker2.utils.BaseMapAddition;
|
||||
import modtweaker2.utils.BaseMapRemoval;
|
||||
import modtweaker2.utils.BaseUndoable;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import stanhebben.zenscript.annotations.Optional;
|
||||
@@ -30,6 +40,8 @@ import tconstruct.library.crafting.AlloyMix;
|
||||
|
||||
@ZenClass("mods.tconstruct.Smeltery")
|
||||
public class Smeltery {
|
||||
|
||||
public static final String nameFuel = "TConstruct Smeltery - Fuel";
|
||||
|
||||
/********************************************** TConstruct Alloy Recipes **********************************************/
|
||||
|
||||
@@ -40,14 +52,15 @@ public class Smeltery {
|
||||
}
|
||||
|
||||
// Passes the list to the base list implementation, and adds the recipe
|
||||
private static class AddAlloy extends BaseListAddition {
|
||||
private static class AddAlloy extends BaseListAddition<AlloyMix> {
|
||||
public AddAlloy(AlloyMix recipe) {
|
||||
super("Smeltery - Alloy", TConstructHelper.alloys, recipe);
|
||||
super("TConstruct Smeltery - Alloy", TConstructHelper.alloys);
|
||||
this.recipes.add(recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeInfo() {
|
||||
return ((AlloyMix) recipe).result.getFluid().getName();
|
||||
protected String getRecipeInfo(AlloyMix recipe) {
|
||||
return InputHelper.getStackDescription(recipe.result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,27 +74,21 @@ public class Smeltery {
|
||||
|
||||
// Removes a recipe, apply is never the same for anything, so will always
|
||||
// need to override it
|
||||
private static class RemoveAlloy extends BaseListRemoval {
|
||||
private static class RemoveAlloy extends BaseListRemoval<AlloyMix> {
|
||||
public RemoveAlloy(FluidStack output) {
|
||||
super("Smeltery - Alloy", TConstructHelper.alloys, output);
|
||||
super("Smeltery - Alloy", TConstructHelper.alloys);
|
||||
|
||||
for (AlloyMix r : TConstructHelper.alloys) {
|
||||
if (r.result != null && output != null && r.result.getFluid() == output.getFluid()) {
|
||||
recipes.add(r);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Loops through the registry, to find the item that matches, saves that
|
||||
// recipe then removes it
|
||||
@Override
|
||||
public void apply() {
|
||||
for (AlloyMix r : TConstructHelper.alloys) {
|
||||
if (r.result != null && fluid != null && r.result.getFluid() == fluid.getFluid()) {
|
||||
recipes.add(r);
|
||||
}
|
||||
}
|
||||
super.apply();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeInfo() {
|
||||
return fluid.getFluid().getName();
|
||||
}
|
||||
@Override
|
||||
protected String getRecipeInfo(AlloyMix recipe) {
|
||||
return InputHelper.getStackDescription(recipe.result);
|
||||
}
|
||||
}
|
||||
|
||||
/********************************************** TConstruct Melting Recipes **********************************************/
|
||||
@@ -106,7 +113,7 @@ public class Smeltery {
|
||||
}
|
||||
|
||||
// Takes all the variables and saves them in place
|
||||
private static class AddMelting extends BaseDescriptionAddition {
|
||||
private static class AddMelting extends BaseUndoable {
|
||||
private final ItemStack input;
|
||||
private final Block block;
|
||||
private final int meta;
|
||||
@@ -136,14 +143,15 @@ public class Smeltery {
|
||||
TConstructHelper.temperatureList.remove(in);
|
||||
TConstructHelper.renderIndex.remove(in);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getRecipeInfo() {
|
||||
return input.getDisplayName();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Removing a TConstruct Melting recipe
|
||||
@ZenMethod
|
||||
@@ -160,7 +168,7 @@ public class Smeltery {
|
||||
|
||||
// Removes a recipe, apply is never the same for anything, so will always
|
||||
// need to override it
|
||||
private static class RemoveMelting extends BaseDescriptionRemoval {
|
||||
private static class RemoveMelting extends BaseUndoable {
|
||||
private final ItemStack input;
|
||||
private FluidStack fluid;
|
||||
private Integer temp;
|
||||
@@ -197,4 +205,58 @@ public class Smeltery {
|
||||
return input.getDisplayName();
|
||||
}
|
||||
}
|
||||
|
||||
/********************************************** TConstruct Fuel Recipes **********************************************/
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ZenMethod
|
||||
public static void removFuel(IIngredient input) {
|
||||
Map<Fluid, Integer[]> recipes = new HashMap<Fluid, Integer[]>();
|
||||
|
||||
for(Entry<Fluid, Integer[]> fuel : TConstructHelper.fuelList.entrySet()) {
|
||||
if(fuel != null && fuel.getKey() != null && matches(input, toILiquidStack(new FluidStack(fuel.getKey(), 1)))) {
|
||||
recipes.put(fuel.getKey(), fuel.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
if(!recipes.isEmpty()) {
|
||||
MineTweakerAPI.apply(new RemoveFuel(recipes));
|
||||
} else {
|
||||
LogHelper.logWarning(String.format("No %s Recipe for %s found. Command ignored!", Smeltery.nameFuel, input.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
public static class RemoveFuel extends BaseMapRemoval<Fluid, Integer[]> {
|
||||
public RemoveFuel(Map<Fluid, Integer[]> recipes) {
|
||||
super(Smeltery.nameFuel, TConstructHelper.fuelList, recipes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeInfo(Entry<Fluid, Integer[]> recipe) {
|
||||
return InputHelper.getStackDescription(new FluidStack(recipe.getKey(), 1));
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ZenMethod
|
||||
public static void addFuel(ILiquidStack liquid, int power, int duration) {
|
||||
Map<Fluid, Integer[]> recipes = new HashMap<Fluid, Integer[]>();
|
||||
|
||||
recipes.put(toFluid(liquid).getFluid(), new Integer[] {power, duration});
|
||||
|
||||
MineTweakerAPI.apply(new AddFuel(recipes));
|
||||
}
|
||||
|
||||
public static class AddFuel extends BaseMapAddition<Fluid, Integer[]> {
|
||||
public AddFuel(Map<Fluid, Integer[]> recipes) {
|
||||
super(Smeltery.nameFuel, TConstructHelper.fuelList, recipes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeInfo(Entry<Fluid, Integer[]> recipe) {
|
||||
return InputHelper.getStackDescription(new FluidStack(recipe.getKey(), 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,15 @@
|
||||
package modtweaker2.mods.tconstruct.handlers;
|
||||
|
||||
import static modtweaker2.helpers.InputHelper.toIItemStack;
|
||||
import static modtweaker2.helpers.InputHelper.toStack;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.api.item.IIngredient;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import modtweaker2.helpers.InputHelper;
|
||||
import modtweaker2.mods.tconstruct.TConstructHelper;
|
||||
import modtweaker2.utils.BaseListAddition;
|
||||
import modtweaker2.utils.BaseListRemoval;
|
||||
@@ -63,51 +70,49 @@ public class TiCTweaks {
|
||||
}
|
||||
|
||||
// Tweaks for setting repair materials
|
||||
private static class Add extends BaseListAddition {
|
||||
private static class Add extends BaseListAddition<ItemKey> {
|
||||
public Add(ItemKey recipe) {
|
||||
super("Repair Material", PatternBuilder.instance.materials, recipe);
|
||||
super("Repair Material", PatternBuilder.instance.materials);
|
||||
recipes.add(recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeInfo() {
|
||||
return new ItemStack(((ItemKey) recipe).item, 1, ((ItemKey) recipe).damage).getDisplayName();
|
||||
protected String getRecipeInfo(ItemKey recipe) {
|
||||
return InputHelper.getStackDescription(new ItemStack(recipe.item, 1, recipe.damage));
|
||||
}
|
||||
}
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ZenMethod
|
||||
public static void removeRepairMaterial(IItemStack output, @Optional String material) {
|
||||
MineTweakerAPI.apply(new Remove(toStack(output), material));
|
||||
public static void removeRepairMaterial(IIngredient output, @Optional String material) {
|
||||
|
||||
List<ItemKey> recipes = new LinkedList<ItemKey>();
|
||||
|
||||
for (ItemKey recipe : PatternBuilder.instance.materials) {
|
||||
IItemStack clone = toIItemStack(new ItemStack(recipe.item, 1, recipe.damage));
|
||||
if ((material != null && material.equalsIgnoreCase(recipe.key)) || (material == null)) {
|
||||
if (output.matches(clone)) {
|
||||
recipes.add(recipe);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!recipes.isEmpty()) {
|
||||
MineTweakerAPI.apply(new Remove(recipes));
|
||||
}
|
||||
}
|
||||
|
||||
// Removes a recipe, apply is never the same for anything, so will always
|
||||
// need to override it
|
||||
private static class Remove extends BaseListRemoval {
|
||||
private final String material;
|
||||
|
||||
public Remove(ItemStack stack, String material) {
|
||||
super("Repair Material", PatternBuilder.instance.materials, stack);
|
||||
this.material = material;
|
||||
}
|
||||
|
||||
// Loops through the registry, to find the item that matches, saves that
|
||||
// recipe then removes it
|
||||
@Override
|
||||
public void apply() {
|
||||
for (ItemKey r : PatternBuilder.instance.materials) {
|
||||
ItemStack clone = new ItemStack(r.item, 1, r.damage);
|
||||
if ((material != null && material.equalsIgnoreCase(r.key)) || (material == null)) {
|
||||
if (clone.isItemEqual(stack)) {
|
||||
recipes.add(r);
|
||||
}
|
||||
}
|
||||
}
|
||||
super.apply();
|
||||
private static class Remove extends BaseListRemoval<ItemKey> {
|
||||
public Remove(List<ItemKey> recipes) {
|
||||
super("Repair Material", PatternBuilder.instance.materials, recipes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeInfo() {
|
||||
return stack.getDisplayName();
|
||||
protected String getRecipeInfo(ItemKey recipe) {
|
||||
return InputHelper.getStackDescription(new ItemStack(recipe.item, 1, recipe.damage));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user