mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-27 15:33:06 +00:00
Still working from recipes now.
This commit is contained in:
1 parent
cfde3bed5a
commit
44686c0c1e
7 files changed
+139
-79
No files matched your search
@@ -32,6 +32,7 @@ import crazypants.enderio.enderface.BlockEnderIO;
|
||||
import crazypants.enderio.enderface.EnderfaceRecipes;
|
||||
import crazypants.enderio.enderface.ItemEnderface;
|
||||
import crazypants.enderio.fluid.BlockFluidEio;
|
||||
import crazypants.enderio.fluid.Fluids;
|
||||
import crazypants.enderio.fluid.ItemBucketEio;
|
||||
import crazypants.enderio.item.ItemDarkSteelArmor;
|
||||
import crazypants.enderio.item.ItemDarkSteelPickaxe;
|
||||
@@ -196,7 +197,7 @@ public class EnderIO {
|
||||
blockLightNode = BlockLightNode.create();
|
||||
blockReservoir = BlockReservoir.create();
|
||||
|
||||
Fluid f = new Fluid("nutrientDistillation").setDensity(1500).setViscosity(3000);
|
||||
Fluid f = new Fluid(Fluids.NUTRIENT_DISTILLATION_UNLOCALISED_NAME).setDensity(1500).setViscosity(3000);
|
||||
FluidRegistry.registerFluid(f);
|
||||
fluidNutrientDistillation = FluidRegistry.getFluid(f.getName());
|
||||
blockNutrientDistillation = BlockFluidEio.create(fluidNutrientDistillation, new MaterialLiquid(MapColor.brownColor));
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package crazypants.enderio.fluid;
|
||||
|
||||
public class Fluids {
|
||||
|
||||
public static final String NUTRIENT_DISTILLATION_NAME = "nutrientdistillation";
|
||||
|
||||
public static final String NUTRIENT_DISTILLATION_UNLOCALISED_NAME = "nutrientDistillation";
|
||||
|
||||
}
|
||||
@@ -12,6 +12,10 @@ import javax.xml.parsers.SAXParserFactory;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
@@ -36,6 +40,7 @@ public class RecipeConfigParser extends DefaultHandler {
|
||||
public static final String ELEMENT_INPUT = "input";
|
||||
public static final String ELEMENT_OUTPUT = "output";
|
||||
public static final String ELEMENT_ITEM_STACK = "itemStack";
|
||||
public static final String ELEMENT_FLUID_STACK = "fluidStack";
|
||||
public static final String ELEMENT_DUMP_REGISTERY = "dumpRegistery";
|
||||
|
||||
public static final String AT_NAME = "name";
|
||||
@@ -47,6 +52,7 @@ public class RecipeConfigParser extends DefaultHandler {
|
||||
public static final String AT_ITEM_NAME = "itemName";
|
||||
public static final String AT_MOD_ID = "modID";
|
||||
public static final String AT_NUMBER = "number";
|
||||
public static final String AT_AMOUNT = "amount";
|
||||
public static final String AT_MULTIPLIER = "multiplier";
|
||||
public static final String AT_SLOT = "slot";
|
||||
public static final String AT_CHANCE = "chance";
|
||||
@@ -280,7 +286,8 @@ public class RecipeConfigParser extends DefaultHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
if(ELEMENT_ITEM_STACK.equals(localName)) {
|
||||
boolean isFluidStack = ELEMENT_FLUID_STACK.equals(localName);
|
||||
if(ELEMENT_ITEM_STACK.equals(localName) || isFluidStack) {
|
||||
if(!inputTagOpen && !outputTagOpen) {
|
||||
Log.warn(LP + "Encounterd an item stack outside of either an <input> or <output> tag.");
|
||||
return;
|
||||
@@ -289,10 +296,19 @@ public class RecipeConfigParser extends DefaultHandler {
|
||||
Log.warn(LP + "Encounterd an item stack within both an <input> and <output> tag.");
|
||||
return;
|
||||
}
|
||||
|
||||
if(inputTagOpen) {
|
||||
addInputStack(attributes);
|
||||
if(isFluidStack) {
|
||||
addInputFluidStack(attributes);
|
||||
} else {
|
||||
addInputStack(attributes);
|
||||
}
|
||||
} else {
|
||||
addOutputStack(attributes);
|
||||
if(isFluidStack) {
|
||||
addOutputFluidStack(attributes);
|
||||
} else {
|
||||
addOutputStack(attributes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -300,7 +316,7 @@ public class RecipeConfigParser extends DefaultHandler {
|
||||
|
||||
//TODO: What a hack!
|
||||
private boolean isElementRoot(String str) {
|
||||
return "AlloySmelterRecipes".equals(str) || "SAGMillRecipes".equals(str);
|
||||
return "AlloySmelterRecipes".equals(str) || "SAGMillRecipes".equals(str) || "StillRecipes".equals(str);
|
||||
}
|
||||
|
||||
private void addOutputStack(Attributes attributes) {
|
||||
@@ -320,6 +336,36 @@ public class RecipeConfigParser extends DefaultHandler {
|
||||
recipe.addInput(stack);
|
||||
}
|
||||
|
||||
private void addOutputFluidStack(Attributes attributes) {
|
||||
RecipeInput stack = getFluidStack(attributes);
|
||||
if(stack == null) {
|
||||
return;
|
||||
}
|
||||
recipe.addOutput(new RecipeOutput(stack.getFluidInput()));
|
||||
}
|
||||
|
||||
private void addInputFluidStack(Attributes attributes) {
|
||||
RecipeInput stack = getFluidStack(attributes);
|
||||
if(stack == null) {
|
||||
return;
|
||||
}
|
||||
recipe.addInput(stack);
|
||||
}
|
||||
|
||||
private RecipeInput getFluidStack(Attributes attributes) {
|
||||
int amount = getIntValue(AT_AMOUNT, attributes, FluidContainerRegistry.BUCKET_VOLUME);
|
||||
String name = getStringValue(AT_NAME, attributes, null);
|
||||
if(name == null) {
|
||||
return null;
|
||||
}
|
||||
Fluid fluid = FluidRegistry.getFluid(name);
|
||||
if(fluid == null) {
|
||||
Log.warn("When parsing recipes could not find fluid with name: " + name);
|
||||
return null;
|
||||
}
|
||||
return new RecipeInput(new FluidStack(fluid, amount), getFloatValue(AT_MULTIPLIER, attributes, 1));
|
||||
}
|
||||
|
||||
public static RecipeInput getItemStack(Attributes attributes) {
|
||||
|
||||
int stackSize = getIntValue(AT_NUMBER, attributes, 1);
|
||||
|
||||
@@ -8,7 +8,6 @@ import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import crazypants.enderio.machine.MachineRecipeInput;
|
||||
import crazypants.enderio.machine.recipe.IRecipe;
|
||||
import crazypants.enderio.machine.recipe.Recipe;
|
||||
import crazypants.enderio.machine.recipe.RecipeInput;
|
||||
import crazypants.enderio.machine.recipe.RecipeOutput;
|
||||
|
||||
@@ -22,7 +21,7 @@ public class StillRecipe implements IRecipe {
|
||||
protected final RecipeOutput[] output;
|
||||
protected final float energyRequired;
|
||||
|
||||
public StillRecipe(Recipe recipe) {
|
||||
public StillRecipe(IRecipe recipe) {
|
||||
List<FluidStack> fluids = recipe.getInputFluidStacks();
|
||||
if(fluids != null && !fluids.isEmpty()) {
|
||||
inputFluidStack = fluids.get(0).copy();
|
||||
@@ -49,7 +48,7 @@ public class StillRecipe implements IRecipe {
|
||||
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
return inputFluidStack != null && inputStacks != null && !inputStacks.isEmpty() && inputStacks.size() > 2 && outputFluidStack != null;
|
||||
return inputFluidStack != null && inputStacks != null && !inputStacks.isEmpty() && inputStacks.size() > 0 && outputFluidStack != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -3,11 +3,6 @@ package crazypants.enderio.machine.still;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import crazypants.enderio.Log;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.machine.MachineRecipeInput;
|
||||
@@ -15,8 +10,7 @@ import crazypants.enderio.machine.MachineRecipeRegistry;
|
||||
import crazypants.enderio.machine.recipe.IRecipe;
|
||||
import crazypants.enderio.machine.recipe.Recipe;
|
||||
import crazypants.enderio.machine.recipe.RecipeConfig;
|
||||
import crazypants.enderio.machine.recipe.RecipeInput;
|
||||
import crazypants.enderio.machine.recipe.RecipeOutput;
|
||||
import crazypants.enderio.machine.recipe.RecipeConfigParser;
|
||||
|
||||
public class StillRecipeManager {
|
||||
|
||||
@@ -35,63 +29,32 @@ public class StillRecipeManager {
|
||||
}
|
||||
|
||||
public void loadRecipesFromConfig() {
|
||||
// RecipeConfig config = RecipeConfig.loadRecipeConfig(CORE_FILE_NAME, CUSTOM_FILE_NAME, null);
|
||||
// if(config != null) {
|
||||
// processConfig(config);
|
||||
// } else {
|
||||
// Log.error("Could not load recipes for SAG Mill.");
|
||||
// }
|
||||
RecipeConfig config = RecipeConfig.loadRecipeConfig(CORE_FILE_NAME, CUSTOM_FILE_NAME, null);
|
||||
if(config != null) {
|
||||
processConfig(config);
|
||||
} else {
|
||||
Log.error("Could not load recipes for SAG Mill.");
|
||||
}
|
||||
|
||||
MachineRecipeRegistry.instance.registerRecipe(ModObject.blockStill.unlocalisedName, new StillMachineRecipe());
|
||||
|
||||
RecipeInput[] ins = new RecipeInput[] {
|
||||
new RecipeInput(new FluidStack(FluidRegistry.WATER, FluidContainerRegistry.BUCKET_VOLUME), 0.5f),
|
||||
new RecipeInput(new ItemStack(Items.rotten_flesh), true, 2, 0),
|
||||
new RecipeInput(new ItemStack(Items.beef), true, 1, 0),
|
||||
new RecipeInput(new ItemStack(Items.chicken), true, 1, 0),
|
||||
new RecipeInput(new ItemStack(Items.porkchop), true, 1, 0),
|
||||
new RecipeInput(new ItemStack(Items.skull), false, 2.5f, 0),
|
||||
|
||||
new RecipeInput(new ItemStack(Items.nether_wart), true, 1.5f, 1),
|
||||
new RecipeInput(new ItemStack(Items.sugar), true, 1f, 1)
|
||||
};
|
||||
|
||||
FluidStack resStack = FluidRegistry.getFluidStack("nutrientdistillation", FluidContainerRegistry.BUCKET_VOLUME);
|
||||
RecipeOutput[] outs = new RecipeOutput[] {
|
||||
new RecipeOutput(resStack)
|
||||
};
|
||||
|
||||
Recipe rec = new Recipe(ins, outs, 1000);
|
||||
addRecipe(new StillRecipe(rec));
|
||||
}
|
||||
|
||||
public void addCustumRecipes(String xmlDef) {
|
||||
// RecipeConfig config;
|
||||
// try {
|
||||
// config = RecipeConfigParser.parse(xmlDef, null);
|
||||
// } catch (Exception e) {
|
||||
// Log.error("Error parsing custom xml");
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// if(config == null) {
|
||||
// Log.error("Could process custom XML");
|
||||
// return;
|
||||
// }
|
||||
// processConfig(config);
|
||||
}
|
||||
RecipeConfig config;
|
||||
try {
|
||||
config = RecipeConfigParser.parse(xmlDef, null);
|
||||
} catch (Exception e) {
|
||||
Log.error("Error parsing custom xml");
|
||||
return;
|
||||
}
|
||||
|
||||
// public IRecipe getRecipeForInput(List<ItemStack> input, List<FluidStack> inputFluids) {
|
||||
// if(input == null || inputFluids == null) {
|
||||
// return null;
|
||||
// }
|
||||
// for (IRecipe recipe : recipes) {
|
||||
// if(recipe.isInputForRecipe(input, inputFluids)) {
|
||||
// return recipe;
|
||||
// }
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
if(config == null) {
|
||||
Log.error("Could process custom XML");
|
||||
return;
|
||||
}
|
||||
processConfig(config);
|
||||
}
|
||||
|
||||
public IRecipe getRecipeForInput(MachineRecipeInput[] inputs) {
|
||||
if(inputs == null || inputs.length == 0) {
|
||||
@@ -106,19 +69,13 @@ public class StillRecipeManager {
|
||||
}
|
||||
|
||||
private void processConfig(RecipeConfig config) {
|
||||
// if(config.isDumpItemRegistery()) {
|
||||
// Util.dumpModObjects(new File(Config.configDirectory, "modObjectsRegistery.txt"));
|
||||
// }
|
||||
// if(config.isDumpOreDictionary()) {
|
||||
// Util.dumpOreNames(new File(Config.configDirectory, "oreDictionaryRegistery.txt"));
|
||||
// }
|
||||
//
|
||||
// List<Recipe> newRecipes = config.getRecipes(true);
|
||||
// Log.info("Found " + newRecipes.size() + " valid SAG Mill recipes in config.");
|
||||
// for (Recipe rec : newRecipes) {
|
||||
// addRecipe(rec);
|
||||
// }
|
||||
// Log.info("Finished processing Alloy Smelter recipes. " + recipes.size() + " recipes avaliable.");
|
||||
|
||||
List<Recipe> newRecipes = config.getRecipes(false);
|
||||
Log.info("Found " + newRecipes.size() + " valid Still recipes in config.");
|
||||
for (Recipe rec : newRecipes) {
|
||||
addRecipe(rec);
|
||||
}
|
||||
Log.info("Finished processing Still recipes. " + recipes.size() + " recipes avaliable.");
|
||||
}
|
||||
|
||||
public void addRecipe(IRecipe recipe) {
|
||||
@@ -126,7 +83,7 @@ public class StillRecipeManager {
|
||||
Log.debug("Could not add invalid recipe: " + recipe);
|
||||
return;
|
||||
}
|
||||
recipes.add(recipe);
|
||||
recipes.add(new StillRecipe(recipe));
|
||||
}
|
||||
|
||||
public List<IRecipe> getRecipes() {
|
||||
|
||||
Reference in new issue
Block a user