Started with ExNihilo rework
This commit is contained in:
parent
2dd8e910f4
commit
df846585c4
6 changed files with 247 additions and 182 deletions
|
@ -14,6 +14,7 @@ import modtweaker2.mods.botania.lexicon.commands.LexiconKnowledgeTypesLogger;
|
||||||
import modtweaker2.mods.botania.lexicon.commands.LexiconPageLogger;
|
import modtweaker2.mods.botania.lexicon.commands.LexiconPageLogger;
|
||||||
import modtweaker2.mods.chisel.commands.ChiselGroupLogger;
|
import modtweaker2.mods.chisel.commands.ChiselGroupLogger;
|
||||||
import modtweaker2.mods.chisel.commands.ChiselVariationLogger;
|
import modtweaker2.mods.chisel.commands.ChiselVariationLogger;
|
||||||
|
import modtweaker2.mods.exnihilo.commands.ExNihiloLogger;
|
||||||
import modtweaker2.mods.factorization.commands.FactorizationLogger;
|
import modtweaker2.mods.factorization.commands.FactorizationLogger;
|
||||||
import modtweaker2.mods.mekanism.gas.GasLogger;
|
import modtweaker2.mods.mekanism.gas.GasLogger;
|
||||||
import modtweaker2.mods.railcraft.commands.RailcraftLogger;
|
import modtweaker2.mods.railcraft.commands.RailcraftLogger;
|
||||||
|
@ -85,6 +86,10 @@ public class Commands {
|
||||||
if (TweakerPlugin.isLoaded("Railcraft")) {
|
if (TweakerPlugin.isLoaded("Railcraft")) {
|
||||||
MineTweakerAPI.server.addMineTweakerCommand("railcraft", new String[] {"/minetweaker railcraft [FILTER]", " Outputs a list of all Railcraft recipes."}, new RailcraftLogger());
|
MineTweakerAPI.server.addMineTweakerCommand("railcraft", new String[] {"/minetweaker railcraft [FILTER]", " Outputs a list of all Railcraft recipes."}, new RailcraftLogger());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (TweakerPlugin.isLoaded("exnihilo")) {
|
||||||
|
MineTweakerAPI.server.addMineTweakerCommand("exnihilo", new String[] {"/minetweaker exnihilo [FILTER]", " Outputs a list of all ExNihilo recipes."}, new ExNihiloLogger());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
13
src/main/java/modtweaker2/mods/exnihilo/ExNihiloHelper.java
Normal file
13
src/main/java/modtweaker2/mods/exnihilo/ExNihiloHelper.java
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
package modtweaker2.mods.exnihilo;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import modtweaker2.helpers.ReflectionHelper;
|
||||||
|
import exnihilo.registries.HeatRegistry;
|
||||||
|
import exnihilo.utils.ItemInfo;
|
||||||
|
|
||||||
|
public class ExNihiloHelper {
|
||||||
|
public static Map<ItemInfo, Float> getHeatMap() {
|
||||||
|
return ReflectionHelper.<Map<ItemInfo, Float>>getStaticObject(HeatRegistry.class, "heatmap");
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,69 @@
|
||||||
|
package modtweaker2.mods.exnihilo.commands;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
import minetweaker.MineTweakerAPI;
|
||||||
|
import minetweaker.MineTweakerImplementationAPI;
|
||||||
|
import minetweaker.api.player.IPlayer;
|
||||||
|
import minetweaker.api.server.ICommandFunction;
|
||||||
|
import modtweaker2.helpers.LogHelper;
|
||||||
|
import modtweaker2.helpers.StringHelper;
|
||||||
|
import modtweaker2.mods.exnihilo.ExNihiloHelper;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
|
import exnihilo.registries.CompostRegistry;
|
||||||
|
import exnihilo.registries.CrucibleRegistry;
|
||||||
|
import exnihilo.registries.helpers.Compostable;
|
||||||
|
import exnihilo.registries.helpers.Meltable;
|
||||||
|
import exnihilo.utils.ItemInfo;
|
||||||
|
|
||||||
|
public class ExNihiloLogger implements ICommandFunction {
|
||||||
|
|
||||||
|
private static final List<String> validArguments = new LinkedList<String>();
|
||||||
|
|
||||||
|
static {
|
||||||
|
validArguments.add("compost");
|
||||||
|
validArguments.add("crucible");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(String[] arguments, IPlayer player) {
|
||||||
|
List<String> args = StringHelper.toLowerCase(Arrays.asList(arguments));
|
||||||
|
|
||||||
|
if(!validArguments.containsAll(args)) {
|
||||||
|
if(player != null) {
|
||||||
|
player.sendChat(MineTweakerImplementationAPI.platform.getMessage("Invalid arguments for command. Valid arguments: " + StringHelper.join(validArguments, ", ")));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if(args.isEmpty() || args.contains("compost")) {
|
||||||
|
for(Entry<ItemInfo, Compostable> recipe : CompostRegistry.entries.entrySet()) {
|
||||||
|
MineTweakerAPI.logCommand(String.format("mods.exnihilo.Composting.addRecipe(%s, %s, \"%s\");",
|
||||||
|
LogHelper.getStackDescription(recipe.getKey().getStack()),
|
||||||
|
recipe.getValue().value,
|
||||||
|
Integer.toHexString(recipe.getValue().color.toInt()).substring(2)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(args.isEmpty() || args.contains("crucible")) {
|
||||||
|
for(Meltable recipe : CrucibleRegistry.entries.values()) {
|
||||||
|
MineTweakerAPI.logCommand(String.format("mods.exnihilo.Crucible.addRecipe(%s, %s);",
|
||||||
|
LogHelper.getStackDescription(new ItemStack(recipe.block, 1, recipe.meta)),
|
||||||
|
LogHelper.getStackDescription(new FluidStack(recipe.fluid, (int)recipe.fluidVolume))));
|
||||||
|
}
|
||||||
|
|
||||||
|
for(Entry<ItemInfo, Float> recipe : ExNihiloHelper.getHeatMap().entrySet()) {
|
||||||
|
MineTweakerAPI.logCommand(String.format("mods.exnihilo.Crucible.addHeatSource(%s, %s);",
|
||||||
|
LogHelper.getStackDescription(recipe.getKey().getStack()),
|
||||||
|
recipe.getValue()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (player != null) {
|
||||||
|
player.sendChat(MineTweakerImplementationAPI.platform.getMessage("List generated; see minetweaker.log in your minecraft dir"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,117 +1,92 @@
|
||||||
package modtweaker2.mods.exnihilo.handlers;
|
package modtweaker2.mods.exnihilo.handlers;
|
||||||
|
|
||||||
|
import static modtweaker2.helpers.InputHelper.toIItemStack;
|
||||||
import static modtweaker2.helpers.InputHelper.toStack;
|
import static modtweaker2.helpers.InputHelper.toStack;
|
||||||
import minetweaker.IUndoableAction;
|
import static modtweaker2.helpers.StackHelper.matches;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import minetweaker.MineTweakerAPI;
|
import minetweaker.MineTweakerAPI;
|
||||||
|
import minetweaker.api.item.IIngredient;
|
||||||
import minetweaker.api.item.IItemStack;
|
import minetweaker.api.item.IItemStack;
|
||||||
import net.minecraft.item.Item;
|
import modtweaker2.helpers.LogHelper;
|
||||||
import net.minecraft.item.ItemStack;
|
import modtweaker2.utils.BaseMapAddition;
|
||||||
|
import modtweaker2.utils.BaseMapRemoval;
|
||||||
import stanhebben.zenscript.annotations.Optional;
|
import stanhebben.zenscript.annotations.Optional;
|
||||||
import stanhebben.zenscript.annotations.ZenClass;
|
import stanhebben.zenscript.annotations.ZenClass;
|
||||||
import stanhebben.zenscript.annotations.ZenMethod;
|
import stanhebben.zenscript.annotations.ZenMethod;
|
||||||
import exnihilo.registries.CompostRegistry;
|
import exnihilo.registries.CompostRegistry;
|
||||||
import exnihilo.registries.helpers.Color;
|
import exnihilo.registries.helpers.Color;
|
||||||
|
import exnihilo.registries.helpers.Compostable;
|
||||||
|
import exnihilo.utils.ItemInfo;
|
||||||
|
|
||||||
|
|
||||||
@ZenClass("mods.exnihilo.Composting")
|
@ZenClass("mods.exnihilo.Composting")
|
||||||
public class Compost {
|
public class Compost {
|
||||||
//Adding a Ex Nihilo Composting recipe
|
|
||||||
|
public static final String name = "ExNihilo Composting";
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
public static void addRecipe(IItemStack input, double value, @Optional String hex) {
|
public static void addRecipe(IItemStack input, double value, @Optional String hex) {
|
||||||
hex = (hex == null || hex.equals("")) ? "35A82A" : hex;
|
if(input == null) {
|
||||||
MineTweakerAPI.apply(new Add(toStack(input).getItem(), toStack(input).getItemDamage(), Math.min(1.0F, (float) value), new Color(hex)));
|
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name));
|
||||||
}
|
return;
|
||||||
|
|
||||||
//Passes the list to the map list implementation, and adds the recipe
|
|
||||||
private static class Add implements IUndoableAction
|
|
||||||
{
|
|
||||||
private Item item;
|
|
||||||
private int meta;
|
|
||||||
private float value;
|
|
||||||
private Color color;
|
|
||||||
|
|
||||||
public Add(Item item, int meta, float value, Color color) {
|
|
||||||
this.item = item;
|
|
||||||
this.meta = meta;
|
|
||||||
this.value = value;
|
|
||||||
this.color = color;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
hex = (hex == null || hex.equals("")) ? "35A82A" : hex;
|
||||||
public void apply() {
|
|
||||||
CompostRegistry.register(item, meta, value, color);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
Map<ItemInfo, Compostable> recipes = new HashMap<ItemInfo, Compostable>();
|
||||||
public boolean canUndo() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
recipes.put(
|
||||||
public String describe() {
|
new ItemInfo(toStack(input)),
|
||||||
return "Adding Composting Recipe using " + item.getUnlocalizedName();
|
new Compostable(Math.min(1.0F, (float)value), new Color(hex)));
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
MineTweakerAPI.apply(new Add(recipes));
|
||||||
public String describeUndo() {
|
}
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
private static class Add extends BaseMapAddition<ItemInfo, Compostable> {
|
||||||
public Object getOverrideKey() {
|
public Add(Map<ItemInfo, Compostable> recipes) {
|
||||||
return null;
|
super(Compost.name, CompostRegistry.entries, recipes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void undo() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getRecipeInfo(Entry<ItemInfo, Compostable> recipe) {
|
||||||
|
return LogHelper.getStackDescription(recipe.getKey().getStack());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
//Removing a Ex Nihilo Composting recipe
|
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
public static void removeRecipe(IItemStack input) {
|
public static void removeRecipe(IIngredient input) {
|
||||||
MineTweakerAPI.apply(new Remove(toStack(input)));
|
Map<ItemInfo, Compostable> recipes = new HashMap<ItemInfo, Compostable>();
|
||||||
}
|
|
||||||
|
|
||||||
//Removes a recipe, will always remove the key, so all should be good
|
for(Entry<ItemInfo, Compostable> recipe : CompostRegistry.entries.entrySet()) {
|
||||||
private static class Remove implements IUndoableAction
|
if(matches(input, toIItemStack(recipe.getKey().getStack()))) {
|
||||||
{
|
recipes.put(recipe.getKey(), recipe.getValue());
|
||||||
private ItemStack stack;
|
}
|
||||||
|
|
||||||
public Remove(ItemStack stack) {
|
|
||||||
this.stack = stack;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
if(!recipes.isEmpty()) {
|
||||||
public void apply() {
|
MineTweakerAPI.apply(new Remove(recipes));
|
||||||
CompostRegistry.unregister(stack.getItem(), stack.getItemDamage());
|
} else {
|
||||||
}
|
LogHelper.logWarning(String.format("No %s recipes found for %s. Command ignored!", Compost.name, input.toString()));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
}
|
||||||
public boolean canUndo() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
private static class Remove extends BaseMapRemoval<ItemInfo, Compostable> {
|
||||||
public String describe() {
|
public Remove(Map<ItemInfo, Compostable> recipes) {
|
||||||
return "Removing Composting Recipe using " + stack.getUnlocalizedName();
|
super(Compost.name, CompostRegistry.entries, recipes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String describeUndo() {
|
protected String getRecipeInfo(Entry<ItemInfo, Compostable> recipe) {
|
||||||
return null;
|
return LogHelper.getStackDescription(recipe.getKey().getStack());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getOverrideKey() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void undo() {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,45 +2,69 @@ package modtweaker2.mods.exnihilo.handlers;
|
||||||
|
|
||||||
import static modtweaker2.helpers.InputHelper.isABlock;
|
import static modtweaker2.helpers.InputHelper.isABlock;
|
||||||
import static modtweaker2.helpers.InputHelper.toFluid;
|
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.InputHelper.toStack;
|
||||||
|
import static modtweaker2.helpers.StackHelper.matches;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import minetweaker.IUndoableAction;
|
|
||||||
import minetweaker.MineTweakerAPI;
|
import minetweaker.MineTweakerAPI;
|
||||||
|
import minetweaker.api.item.IIngredient;
|
||||||
import minetweaker.api.item.IItemStack;
|
import minetweaker.api.item.IItemStack;
|
||||||
import minetweaker.api.liquid.ILiquidStack;
|
import minetweaker.api.liquid.ILiquidStack;
|
||||||
import modtweaker2.helpers.LogHelper;
|
import modtweaker2.helpers.LogHelper;
|
||||||
|
import modtweaker2.mods.exnihilo.ExNihiloHelper;
|
||||||
import modtweaker2.utils.BaseMapAddition;
|
import modtweaker2.utils.BaseMapAddition;
|
||||||
import modtweaker2.utils.BaseMapRemoval;
|
import modtweaker2.utils.BaseMapRemoval;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
import stanhebben.zenscript.annotations.ZenClass;
|
import stanhebben.zenscript.annotations.ZenClass;
|
||||||
import stanhebben.zenscript.annotations.ZenMethod;
|
import stanhebben.zenscript.annotations.ZenMethod;
|
||||||
import exnihilo.registries.CrucibleRegistry;
|
import exnihilo.registries.CrucibleRegistry;
|
||||||
import exnihilo.registries.HeatRegistry;
|
|
||||||
import exnihilo.registries.helpers.Meltable;
|
import exnihilo.registries.helpers.Meltable;
|
||||||
|
import exnihilo.utils.ItemInfo;
|
||||||
|
|
||||||
@ZenClass("mods.exnihilo.Crucible")
|
@ZenClass("mods.exnihilo.Crucible")
|
||||||
public class Crucible {
|
public class Crucible {
|
||||||
|
|
||||||
|
public static final String nameMelting = "ExNihilo Crucible (Melting)";
|
||||||
|
public static final String nameHeatSource = "ExNihilo Crucible (Heat source)";
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
/************************************************ Crucible Melting ************************************************/
|
/************************************************ Crucible Melting ************************************************/
|
||||||
//Adding a Ex Nihilo Crucible recipe
|
//Adding a Ex Nihilo Crucible recipe
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
public static void addRecipe(IItemStack input, ILiquidStack fluid) {
|
public static void addRecipe(IItemStack input, ILiquidStack fluid) {
|
||||||
if (isABlock(input)) {
|
if(input == null || fluid == null) {
|
||||||
Block theBlock = Block.getBlockFromItem(toStack(input).getItem());
|
LogHelper.logError(String.format("Required parameters missing for %s recipe.", nameMelting));
|
||||||
int theMeta = toStack(input).getItemDamage();
|
return;
|
||||||
MineTweakerAPI.apply(new AddRecipe(new Meltable(theBlock, theMeta, 2000, toFluid(fluid).getFluid(), toFluid(fluid).amount, theBlock)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!isABlock(input)) {
|
||||||
|
LogHelper.logError(String.format("Input item for %s recipe must be a block.", nameMelting));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, Meltable> recipes = new HashMap<String, Meltable>();
|
||||||
|
Block theBlock = Block.getBlockFromItem(toStack(input).getItem());
|
||||||
|
int theMeta = toStack(input).getItemDamage();
|
||||||
|
|
||||||
|
recipes.put(
|
||||||
|
theBlock + ":" + theMeta,
|
||||||
|
new Meltable(theBlock, theMeta, 2000, toFluid(fluid).getFluid(), toFluid(fluid).amount, theBlock));
|
||||||
|
|
||||||
|
MineTweakerAPI.apply(new AddRecipe(recipes));
|
||||||
}
|
}
|
||||||
|
|
||||||
//Passes the list to the map list implementation, and adds the recipe
|
//Passes the list to the map list implementation, and adds the recipe
|
||||||
private static class AddRecipe extends BaseMapAddition<String, Meltable> {
|
private static class AddRecipe extends BaseMapAddition<String, Meltable> {
|
||||||
public AddRecipe(Meltable recipe) {
|
public AddRecipe(Map<String, Meltable> recipes) {
|
||||||
super("ExNihilo Crucible", CrucibleRegistry.entries);
|
super(nameMelting, CrucibleRegistry.entries, recipes);
|
||||||
recipes.put(recipe.block + ":" + recipe.meta, recipe);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -53,23 +77,27 @@ public class Crucible {
|
||||||
|
|
||||||
//Removing a Ex Nihilo Crucible recipe
|
//Removing a Ex Nihilo Crucible recipe
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
public static void removeRecipe(IItemStack output) {
|
public static void removeRecipe(IIngredient output) {
|
||||||
if (isABlock(output)) {
|
Map<String, Meltable> recipes = new HashMap<String, Meltable>();
|
||||||
MineTweakerAPI.apply(new RemoveRecipe(toStack(output)));
|
|
||||||
|
for(Entry<String, Meltable> entry : CrucibleRegistry.entries.entrySet()) {
|
||||||
|
FluidStack fluid = new FluidStack(entry.getValue().fluid, (int)entry.getValue().fluidVolume);
|
||||||
|
if(matches(output, toILiquidStack(fluid))) {
|
||||||
|
recipes.put(entry.getKey(), entry.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!recipes.isEmpty()) {
|
||||||
|
MineTweakerAPI.apply(new RemoveRecipe(recipes));
|
||||||
|
} else {
|
||||||
|
LogHelper.logWarning(String.format("No %s recipe found for %s. Command ignored!", Crucible.nameMelting, output.toString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Removes a recipe, will always remove the key, so all should be good
|
//Removes a recipe, will always remove the key, so all should be good
|
||||||
private static class RemoveRecipe extends BaseMapRemoval<String, Meltable> {
|
private static class RemoveRecipe extends BaseMapRemoval<String, Meltable> {
|
||||||
public RemoveRecipe(ItemStack stack) {
|
public RemoveRecipe(Map<String, Meltable> recipes) {
|
||||||
super("ExNihilo Crucible", CrucibleRegistry.entries);
|
super(nameMelting, CrucibleRegistry.entries, recipes);
|
||||||
|
|
||||||
String key = Block.getBlockFromItem(stack.getItem()) + ":" + stack.getItemDamage();
|
|
||||||
|
|
||||||
for(Entry<String, Meltable> entry : map.entrySet()) {
|
|
||||||
if(entry.getKey().equals(key))
|
|
||||||
recipes.put(entry.getKey(), entry.getValue());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -82,92 +110,67 @@ public class Crucible {
|
||||||
//Adding a Ex Nihilo Crucible heat source
|
//Adding a Ex Nihilo Crucible heat source
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
public static void addHeatSource(IItemStack input, double value) {
|
public static void addHeatSource(IItemStack input, double value) {
|
||||||
if (isABlock(input)) {
|
if(input == null) {
|
||||||
Block theBlock = Block.getBlockFromItem(toStack(input).getItem());
|
LogHelper.logError(String.format("Required parameters missing for %s recipe.", nameMelting));
|
||||||
int theMeta = toStack(input).getItemDamage();
|
return;
|
||||||
MineTweakerAPI.apply(new AddHeatSource(theBlock, theMeta, (float) value));
|
}
|
||||||
|
|
||||||
|
if(!isABlock(input)) {
|
||||||
|
LogHelper.logError(String.format("Input item for %s recipe must be a block.", nameMelting));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<ItemInfo, Float> recipes = new HashMap<ItemInfo, Float>();
|
||||||
|
recipes.put(new ItemInfo(toStack(input)), (float)value);
|
||||||
|
|
||||||
|
if(!recipes.isEmpty()) {
|
||||||
|
MineTweakerAPI.apply(new AddHeatSource(recipes));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Passes the list to the base map implementation, and adds the recipe
|
//Passes the list to the base map implementation, and adds the recipe
|
||||||
private static class AddHeatSource implements IUndoableAction
|
private static class AddHeatSource extends BaseMapAddition<ItemInfo, Float>
|
||||||
{
|
{
|
||||||
Block source;
|
public AddHeatSource(Map<ItemInfo, Float> recipes) {
|
||||||
int sourceMeta;
|
super(Crucible.nameHeatSource, ExNihiloHelper.getHeatMap(), recipes);
|
||||||
float value;
|
|
||||||
|
|
||||||
public AddHeatSource(Block source, int sourceMeta, float value) {
|
|
||||||
this.source = source;
|
|
||||||
this.sourceMeta = sourceMeta;
|
|
||||||
this.value = value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void apply() {
|
@Override
|
||||||
HeatRegistry.register(source, sourceMeta, value);
|
protected String getRecipeInfo(Entry<ItemInfo, Float> recipe) {
|
||||||
}
|
return LogHelper.getStackDescription(recipe.getKey().getStack());
|
||||||
|
|
||||||
public boolean canUndo() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String describe() {
|
|
||||||
return "Adding ExNihilo Heat source of " + source.getLocalizedName();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String describeUndo() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object getOverrideKey() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void undo() {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
//Removing a Ex Nihilo Crucible heat source
|
//Removing a Ex Nihilo Crucible heat source
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
public static void removeHeatSource(IItemStack output) {
|
public static void removeHeatSource(IIngredient output) {
|
||||||
if (isABlock(output)) {
|
Map<ItemInfo, Float> recipes = new HashMap<ItemInfo, Float>();
|
||||||
Block block = Block.getBlockFromItem(toStack(output).getItem());
|
|
||||||
MineTweakerAPI.apply(new RemoveHeatSource(block));
|
for(Entry<ItemInfo, Float> entry : ExNihiloHelper.getHeatMap().entrySet()) {
|
||||||
|
if(matches(output, toIItemStack(entry.getKey().getStack()))) {
|
||||||
|
recipes.put(entry.getKey(), entry.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!recipes.isEmpty()) {
|
||||||
|
MineTweakerAPI.apply(new RemoveHeatSource(recipes));
|
||||||
|
} else {
|
||||||
|
LogHelper.logWarning(String.format("No %s recipe found for %s. Command ignored!", Crucible.nameMelting, output.toString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Removes a recipe, will always remove the key, so all should be good
|
//Removes a recipe, will always remove the key, so all should be good
|
||||||
private static class RemoveHeatSource implements IUndoableAction
|
private static class RemoveHeatSource extends BaseMapAddition<ItemInfo, Float>
|
||||||
{
|
{
|
||||||
Block block;
|
public RemoveHeatSource(Map<ItemInfo, Float> recipes) {
|
||||||
|
super(Crucible.nameHeatSource, ExNihiloHelper.getHeatMap(), recipes);
|
||||||
public RemoveHeatSource(Block block) {
|
|
||||||
this.block = block;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void apply() {
|
@Override
|
||||||
HeatRegistry.unregister(block);
|
protected String getRecipeInfo(Entry<ItemInfo, Float> recipe) {
|
||||||
}
|
return LogHelper.getStackDescription(recipe.getKey().getStack());
|
||||||
|
}
|
||||||
public boolean canUndo() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String describe() {
|
|
||||||
return "Removing ExNihilo Heat source of " + block.getLocalizedName();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String describeUndo() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object getOverrideKey() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void undo() {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,9 +13,9 @@ import tconstruct.library.TConstructRegistry;
|
||||||
import tconstruct.library.tools.ToolMaterial;
|
import tconstruct.library.tools.ToolMaterial;
|
||||||
|
|
||||||
public class MaterialLogger implements ICommandFunction {
|
public class MaterialLogger implements ICommandFunction {
|
||||||
private static ArrayList<String> materials = new ArrayList();
|
private static ArrayList<String> materials = new ArrayList<String>();
|
||||||
static {
|
static {
|
||||||
materials = new ArrayList();
|
materials = new ArrayList<String>();
|
||||||
for (Map.Entry<String, ToolMaterial> entry : TConstructRegistry.toolMaterialStrings.entrySet()) {
|
for (Map.Entry<String, ToolMaterial> entry : TConstructRegistry.toolMaterialStrings.entrySet()) {
|
||||||
materials.add(entry.getKey());
|
materials.add(entry.getKey());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue