Railcraft fuel handler
This commit is contained in:
parent
6fbca2547f
commit
db9b0e3c11
|
@ -17,7 +17,7 @@ buildscript {
|
|||
|
||||
apply plugin: 'forge'
|
||||
|
||||
version = "0.9.1"
|
||||
version = "0.9.2"
|
||||
group= "modtweaker" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||
archivesBaseName = "ModTweaker~2"
|
||||
|
||||
|
|
Binary file not shown.
|
@ -4,6 +4,6 @@ public class ModProps {
|
|||
|
||||
public static final String NAME = "Mod Tweaker 2", name = NAME;
|
||||
public static final String MODID = "modtweaker2", modid = MODID;
|
||||
public static final String VERSION = "0.9.1", version = VERSION;
|
||||
public static final String VERSION = "0.9.2", version = VERSION;
|
||||
public static final String DEPENDENCIES = "required-after:MineTweaker3", dependencies = DEPENDENCIES;
|
||||
}
|
||||
|
|
|
@ -19,12 +19,14 @@ public class RailcraftHelper {
|
|||
public static List<? extends ICokeOvenRecipe> oven = null;
|
||||
public static List<? extends IRockCrusherRecipe> crusher = null;
|
||||
public static List<IRecipe> rolling = null;
|
||||
public static List<ItemStack> fuels = null;
|
||||
static {
|
||||
try {
|
||||
furnace = RailcraftCraftingManager.blastFurnace.getRecipes();
|
||||
oven = RailcraftCraftingManager.cokeOven.getRecipes();
|
||||
crusher = RailcraftCraftingManager.rockCrusher.getRecipes();
|
||||
rolling = RailcraftCraftingManager.rollingMachine.getRecipeList();
|
||||
fuels = ReflectionHelper.<List<ItemStack>>getObject(RailcraftCraftingManager.blastFurnace, "fuels");
|
||||
} catch (Exception e) {}
|
||||
}
|
||||
|
||||
|
|
|
@ -11,10 +11,14 @@ import minetweaker.MineTweakerAPI;
|
|||
import minetweaker.api.item.IIngredient;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import mods.railcraft.api.crafting.IBlastFurnaceRecipe;
|
||||
import modtweaker2.helpers.InputHelper;
|
||||
import modtweaker2.helpers.LogHelper;
|
||||
import modtweaker2.helpers.StackHelper;
|
||||
import modtweaker2.mods.railcraft.RailcraftHelper;
|
||||
import modtweaker2.utils.BaseListAddition;
|
||||
import modtweaker2.utils.BaseListRemoval;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntityFurnace;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
|
@ -22,9 +26,17 @@ import stanhebben.zenscript.annotations.ZenMethod;
|
|||
public class BlastFurnace {
|
||||
|
||||
public static final String name = "Railcraft Blast Furnace";
|
||||
public static final String nameFuel = "Railcraft Blast Furnace (Fuel)";
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ZenMethod
|
||||
public static void addRecipe(IItemStack input, boolean matchDamage, boolean matchNBT, int cookTime, IItemStack output) {
|
||||
if(input == null || output == null) {
|
||||
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name));
|
||||
return;
|
||||
}
|
||||
|
||||
MineTweakerAPI.apply(new Add(RailcraftHelper.getBlastFurnaceRecipe(toStack(input), matchDamage, matchNBT, cookTime, toStack(output))));
|
||||
}
|
||||
|
||||
|
@ -40,9 +52,16 @@ public class BlastFurnace {
|
|||
return LogHelper.getStackDescription(recipe.getOutput());
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ZenMethod
|
||||
public static void removeRecipe(IIngredient output) {
|
||||
if(output == null) {
|
||||
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name));
|
||||
return;
|
||||
}
|
||||
|
||||
List<IBlastFurnaceRecipe> recipes = new LinkedList<IBlastFurnaceRecipe>();
|
||||
|
||||
for (IBlastFurnaceRecipe r : RailcraftHelper.furnace) {
|
||||
|
@ -69,4 +88,79 @@ public class BlastFurnace {
|
|||
return LogHelper.getStackDescription(recipe.getOutput());
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ZenMethod
|
||||
public static void addFuel(IIngredient itemInput) {
|
||||
if(itemInput == null) {
|
||||
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name));
|
||||
return;
|
||||
}
|
||||
|
||||
List<ItemStack> fuels = new LinkedList<ItemStack>();
|
||||
|
||||
for(IItemStack item : itemInput.getItems()) {
|
||||
|
||||
boolean match = false;
|
||||
|
||||
for(ItemStack fuel : RailcraftHelper.fuels) {
|
||||
if(StackHelper.matches(item, InputHelper.toIItemStack(fuel))) {
|
||||
match = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!match && TileEntityFurnace.isItemFuel(InputHelper.toStack(item))) {
|
||||
fuels.add(InputHelper.toStack(item));
|
||||
}
|
||||
}
|
||||
|
||||
if(!fuels.isEmpty()) {
|
||||
MineTweakerAPI.apply(new AddFuels(fuels));
|
||||
} else {
|
||||
LogHelper.logWarning(String.format("No %s added.", nameFuel));
|
||||
}
|
||||
}
|
||||
|
||||
private static class AddFuels extends BaseListAddition<ItemStack> {
|
||||
public AddFuels(List<ItemStack> fuels) {
|
||||
super(BlastFurnace.nameFuel, RailcraftHelper.fuels, fuels);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getRecipeInfo(ItemStack recipe) {
|
||||
return LogHelper.getStackDescription(recipe);
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ZenMethod
|
||||
private static void removeFuel(IIngredient itemInput) {
|
||||
List<ItemStack> fuels = new LinkedList<ItemStack>();
|
||||
|
||||
for(ItemStack fuel : RailcraftHelper.fuels) {
|
||||
if(StackHelper.matches(itemInput, InputHelper.toIItemStack(fuel))) {
|
||||
fuels.add(fuel);
|
||||
}
|
||||
}
|
||||
|
||||
if(!fuels.isEmpty()) {
|
||||
MineTweakerAPI.apply(new RemoveFuels(fuels));
|
||||
} else {
|
||||
LogHelper.logWarning(String.format("No %s found for argument %s.", nameFuel, itemInput.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
private static class RemoveFuels extends BaseListRemoval<ItemStack> {
|
||||
public RemoveFuels(List<ItemStack> fuels) {
|
||||
super(BlastFurnace.nameFuel, RailcraftHelper.fuels, fuels);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getRecipeInfo(ItemStack recipe) {
|
||||
return LogHelper.getStackDescription(recipe);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,8 @@ public class CokeOven {
|
|||
|
||||
public static final String name = "Railcraft Coke Oven";
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Adds a recipe for the Coke Oven
|
||||
*
|
||||
|
|
|
@ -23,6 +23,8 @@ public class RockCrusher {
|
|||
|
||||
public static final String name = "Railcraft Rock Crusher";
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ZenMethod
|
||||
public static void addRecipe(IItemStack input, boolean matchDamage, boolean matchNBT, IItemStack[] output, double[] chances) {
|
||||
IRockCrusherRecipe recipe = RailcraftHelper.getRockCrusherRecipe(toStack(input), matchDamage, matchNBT);
|
||||
|
|
|
@ -24,6 +24,8 @@ public class RollingMachine {
|
|||
|
||||
public static final String name = "Railcraft Rolling Machine";
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ZenMethod
|
||||
public static void addShaped(IItemStack output, IIngredient[][] ingredients) {
|
||||
MineTweakerAPI.apply(new Add(new ShapedOreRecipe(toStack(output), toShapedObjects(ingredients))));
|
||||
|
|
Loading…
Reference in a new issue