Redo all Industrial Grinder recipes, and move them to a separate class (Here starts the great recipe cleanup of 2017!)

This commit is contained in:
ProfessorProspector 2016-12-30 23:45:42 -08:00
parent 9b73f20ad0
commit c24116e259
8 changed files with 270 additions and 1056 deletions

View file

@ -13,11 +13,12 @@ import java.util.List;
*/ */
public abstract class BaseRecipe implements IBaseRecipeType, Cloneable { public abstract class BaseRecipe implements IBaseRecipeType, Cloneable {
private ArrayList<ItemStack> inputs;
public String name; public String name;
public int tickTime; public int tickTime;
public int euPerTick; public int euPerTick;
private ArrayList<ItemStack> inputs;
private ArrayList<ItemStack> outputs; private ArrayList<ItemStack> outputs;
private boolean oreDict = true;
public BaseRecipe(String name, int tickTime, int euPerTick) { public BaseRecipe(String name, int tickTime, int euPerTick) {
inputs = new ArrayList<>(); inputs = new ArrayList<>();
@ -39,7 +40,7 @@ public abstract class BaseRecipe implements IBaseRecipeType, Cloneable {
} }
public void addOutput(ItemStack stack) { public void addOutput(ItemStack stack) {
if(stack == null || stack.isEmpty()){ if (stack == null || stack.isEmpty()) {
throw new InvalidParameterException("output is invalid!"); throw new InvalidParameterException("output is invalid!");
} }
outputs.add(stack); outputs.add(stack);
@ -86,9 +87,13 @@ public abstract class BaseRecipe implements IBaseRecipeType, Cloneable {
return super.clone(); return super.clone();
} }
public void setOreDict(boolean oreDict) {
this.oreDict = oreDict;
}
@Override @Override
public boolean useOreDic() { public boolean useOreDic() {
return true; return oreDict;
} }
@Override @Override
@ -96,8 +101,8 @@ public abstract class BaseRecipe implements IBaseRecipeType, Cloneable {
return outputs; return outputs;
} }
public void addInput(ItemStack inuput){ public void addInput(ItemStack inuput) {
if(inuput == null || inuput.isEmpty()){ if (inuput == null || inuput.isEmpty()) {
throw new InvalidParameterException("input is invalid!"); throw new InvalidParameterException("input is invalid!");
} }
inputs.add(inuput); inputs.add(inuput);

View file

@ -8,6 +8,7 @@ import techreborn.api.recipe.BaseRecipe;
public class IndustrialGrinderRecipe extends BaseRecipe { public class IndustrialGrinderRecipe extends BaseRecipe {
public FluidStack fluidStack; public FluidStack fluidStack;
boolean useOreDic = true;
public IndustrialGrinderRecipe(ItemStack input1, FluidStack fluidStack, ItemStack output1, public IndustrialGrinderRecipe(ItemStack input1, FluidStack fluidStack, ItemStack output1,
ItemStack output2, ItemStack output3, ItemStack output4, int tickTime, int euPerTick) { ItemStack output2, ItemStack output3, ItemStack output4, int tickTime, int euPerTick) {
@ -25,8 +26,19 @@ public class IndustrialGrinderRecipe extends BaseRecipe {
this.fluidStack = fluidStack; this.fluidStack = fluidStack;
} }
public IndustrialGrinderRecipe(ItemStack input1, FluidStack fluidStack, ItemStack output1,
ItemStack output2, ItemStack output3, ItemStack output4, int tickTime, int euPerTick, boolean useOreDict) {
this(input1, fluidStack, output1, output2, output3, output4, tickTime, euPerTick);
this.useOreDic = useOreDict;
}
@Override @Override
public String getUserFreindlyName() { public String getUserFreindlyName() {
return "IndustrialGrinder"; return "IndustrialGrinder";
} }
@Override
public boolean useOreDic() {
return useOreDic;
}
} }

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,177 @@
package techreborn.init.recipes;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import org.apache.logging.log4j.Level;
import reborncore.api.recipe.RecipeHandler;
import techreborn.Core;
import techreborn.api.recipe.machines.IndustrialGrinderRecipe;
import techreborn.blocks.BlockOre;
import techreborn.init.ModFluids;
/**
* Created by Prospector
*/
public class IndustrialGrinderRecipes extends RecipeMethods {
static FluidStack WATER = new FluidStack(FluidRegistry.WATER, 1000);
static FluidStack MERCURY = new FluidStack(ModFluids.fluidMercury, 1000);
static FluidStack SODIUM_PERSULFATE = new FluidStack(ModFluids.fluidSodiumpersulfate, 1000);
public static void init() {
register(new ItemStack(Blocks.NETHERRACK, 16), WATER, 1600, 128, getMaterial("netherrack", 16, Type.DUST), new ItemStack(Items.GOLD_NUGGET));
register(new ItemStack(Blocks.NETHERRACK, 8), MERCURY, 800, 128, getMaterial("netherrack", 8, Type.DUST), new ItemStack(Items.GOLD_NUGGET));
register(getOre("oreCopper"), WATER, 100, 128, getMaterial("copper", 2, Type.DUST), getMaterial("gold", Type.SMALL_DUST), getMaterial("nickel", Type.SMALL_DUST));
register(getOre("oreCopper"), SODIUM_PERSULFATE, 100, 128, getMaterial("copper", 3, Type.DUST), getMaterial("gold", Type.SMALL_DUST), getMaterial("nickel", Type.SMALL_DUST));
register(getOre("oreCopper"), MERCURY, 100, 128, getMaterial("copper", 3, Type.DUST), getMaterial("gold", Type.DUST));
register(getOre("oreTin"), WATER, 100, 128, getMaterial("tin", 2, Type.DUST), getMaterial("iron", Type.SMALL_DUST), getMaterial("zinc", Type.SMALL_DUST));
register(getOre("oreTin"), SODIUM_PERSULFATE, 100, 128, getMaterial("tin", 2, Type.DUST), getMaterial("iron", Type.SMALL_DUST), getMaterial("zinc", Type.DUST));
if (oresExist("oreUranium", "dustUranium", "smallDustPlutonium")) {
register(getOre("oreUranium"), WATER, 100, 128, getOre("dustUranium", 2), getOre("smallDustPlutonium"));
}
if (oresExist("dustSmallThorium")) {
register(getOre("oreCoal"), WATER, 100, 128, getMaterial("coal", 2, Type.DUST), getOre("dustSmallThorium"));
} else {
register(getOre("oreCoal"), WATER, 100, 128, getMaterial("coal", 2, Type.DUST));
}
register(getOre("oreIron"), WATER, 100, 128, getMaterial("iron", 2, Type.DUST), getMaterial("tin", Type.SMALL_DUST), getMaterial("nickel", 1, Type.DUST));
register(getOre("oreLapis"), WATER, 100, 128, new ItemStack(Items.DYE, 12, 4), getMaterial("lazurite", 3, Type.DUST));
register(getOre("oreRedstone"), WATER, 100, 128, new ItemStack(Items.REDSTONE, 10), getMaterial("glowstone", 2, Type.SMALL_DUST));
register(getOre("oreGold"), WATER, 100, 128, getMaterial("gold", 2, Type.DUST), getMaterial("copper", Type.SMALL_DUST), getMaterial("nickel", Type.SMALL_DUST));
register(getOre("oreGold"), MERCURY, 100, 128, getMaterial("gold", 3, Type.DUST), getMaterial("copper", Type.SMALL_DUST), getMaterial("nickel", Type.SMALL_DUST));
register(getOre("oreGold"), SODIUM_PERSULFATE, 100, 128, getMaterial("gold", 2, Type.DUST), getMaterial("copper", Type.DUST), getMaterial("nickel", Type.SMALL_DUST));
register(getOre("oreDiamond"), WATER, 100, 128, new ItemStack(Items.DIAMOND), getMaterial("diamond", 6, Type.SMALL_DUST), getMaterial("coal", Type.DUST));
register(getOre("oreEmerald"), WATER, 100, 128, new ItemStack(Items.EMERALD), getMaterial("emerald", 6, Type.SMALL_DUST));
register(getOre("oreGalena"), WATER, 100, 128, getMaterial("galena", 2, Type.DUST), getMaterial("sulfur", Type.DUST));
register(getOre("oreGalena"), MERCURY, 100, 128, getMaterial("galena", 2, Type.DUST), getMaterial("sulfur", Type.DUST), getMaterial("silver", Type.DUST));
register(getOre("oreLead"), WATER, 100, 128, getMaterial("lead", 2, Type.DUST), getMaterial("galena", 2, Type.SMALL_DUST));
register(getOre("oreSilver"), WATER, 100, 128, getMaterial("silver", 2, Type.DUST), getMaterial("galena", 2, Type.SMALL_DUST));
register(getOre("oreIridium"), WATER, 100, 128, getMaterial("iridium", Type.INGOT), getMaterial("platinum", 2, Type.SMALL_DUST));
register(getOre("oreIridium"), MERCURY, 100, 128, getMaterial("iridium", Type.INGOT), getMaterial("platinum", Type.DUST));
register(getOre("oreRuby"), WATER, 100, 128, getMaterial("ruby", Type.GEM), getMaterial("ruby", 6, Type.SMALL_DUST), getMaterial("red_garnet", 2, Type.SMALL_DUST));
register(getOre("oreSapphire"), WATER, 100, 128, getMaterial("sapphire", Type.GEM), getMaterial("sapphire", 6, Type.SMALL_DUST), getMaterial("peridot", 2, Type.SMALL_DUST));
register(BlockOre.getOreByName("bauxite"), WATER, 100, 128, getMaterial("bauxite", 4, Type.DUST), getMaterial("aluminum", Type.DUST));
register(getOre("oreQuartz"), WATER, 100, 128, new ItemStack(Items.QUARTZ, 2), getMaterial("sulfur", 2, Type.SMALL_DUST));
register(getOre("orePyrite"), WATER, 100, 128, getMaterial("pyrite", 5, Type.DUST), getMaterial("sulfur", 2, Type.DUST));
register(getOre("oreCinnabar"), WATER, 100, 128, getMaterial("cinnabar", 5, Type.DUST), getMaterial("redstone", 2, Type.SMALL_DUST), getMaterial("glowstone", Type.SMALL_DUST));
register(getOre("oreSphalerite"), WATER, 100, 128, getMaterial("sphalerite", 5, Type.DUST), getMaterial("zinc", Type.DUST), getMaterial("yellow_garnet", Type.SMALL_DUST));
register(getOre("oreSphalerite"), SODIUM_PERSULFATE, 100, 128, getMaterial("sphalerite", 5, Type.DUST), getMaterial("zinc", 3, Type.DUST), getMaterial("yellow_garnet", Type.SMALL_DUST));
register(getOre("oreTungsten"), WATER, 100, 128, getMaterial("tungsten", 2, Type.DUST), getMaterial("iron", 3, Type.SMALL_DUST), getMaterial("manganese", 3, Type.SMALL_DUST));
register(getOre("oreSheldonite"), WATER, 100, 128, getMaterial("platinum", 2, Type.DUST), getMaterial("nickel", Type.DUST), getMaterial("iridium", 2, Type.NUGGET));
register(getOre("oreSheldonite"), MERCURY, 100, 128, getMaterial("platinum", 3, Type.DUST), getMaterial("nickel", Type.DUST), getMaterial("iridium", 2, Type.NUGGET));
register(getOre("orePeridot"), WATER, 100, 128, getMaterial("peridot", Type.GEM), getMaterial("peridot", 6, Type.SMALL_DUST), getMaterial("emerald", 2, Type.SMALL_DUST));
register(getOre("oreSodalite"), WATER, 100, 128, getMaterial("sodalite", 12, Type.DUST), getMaterial("aluminum", 3, Type.DUST));
if (oresExist("oreApatite", "gemApatite")) {
register(getOre("oreApatite"), WATER, 100, 128, getOre("gemApatite", 8), getMaterial("phosphorous", 2, Type.SMALL_DUST));
}
if (oresExist("oreCertusQuartz", "crystalCertusQuartz", "dustCertusQuartz")) {
register(getOre("oreCertusQuartz"), WATER, 100, 128, getOre("crystalCertusQuartz", 2), getOre("dustCertusQuartz"));
}
if (oresExist("oreChargedCertusQuartz", "crystalChargedCertusQuartz", "dustCertusQuartz")) {
register(getOre("oreChargedCertusQuartz"), WATER, 100, 128, getOre("crystalChargedCertusQuartz", 2), getOre("dustCertusQuartz", 2));
}
if (oresExist("oreNickel")) {
register(getOre("oreNickel"), WATER, 100, 128, getMaterial("nickel", 2, Type.DUST), getMaterial("iron", Type.SMALL_DUST), getMaterial("platinum", Type.SMALL_DUST));
register(getOre("oreNickel"), MERCURY, 100, 128, getMaterial("nickel", 3, Type.DUST), getMaterial("iron", Type.SMALL_DUST), getMaterial("platinum", Type.DUST));
register(getOre("oreNickel"), SODIUM_PERSULFATE, 100, 128, getMaterial("nickel", 3, Type.DUST), getMaterial("iron", Type.SMALL_DUST), getMaterial("platinum", Type.SMALL_DUST));
}
if (oresExist("oreZinc")) {
register(getOre("oreZinc"), WATER, 100, 128, getMaterial("zinc", 2, Type.DUST), getMaterial("iron", 2, Type.SMALL_DUST), getMaterial("tin", Type.SMALL_DUST));
register(getOre("oreZinc"), SODIUM_PERSULFATE, 100, 128, getMaterial("zinc", 2, Type.DUST), getMaterial("iron", Type.DUST), getMaterial("tin", Type.SMALL_DUST));
}
if (oresExist("oreAmethyst", "gemAmethyst")) {
register(getOre("oreAmethyst"), WATER, 100, 128, getOre("gemAmethyst", 2));
}
if (oresExist("oreTopaz", "gemTopaz")) {
register(getOre("oreTopaz"), WATER, 100, 128, getOre("gemTopaz", 2));
}
if (oresExist("oreTanzanite", "gemTanzanite")) {
register(getOre("oreTanzanite"), WATER, 100, 128, getOre("gemTanzanite", 2));
}
if (oresExist("oreMalachite", "gemMalachite")) {
register(getOre("oreMalachite"), WATER, 100, 128, getOre("gemMalachite", 2));
}
if (oresExist("oreUranium", "uran238", "smallUran235")) {
register(getOre("oreUranium"), WATER, 100, 128, getOre("uran238", 8), getOre("smallUran235", 2));
}
if (oresExist("orePitchblende", "uran238", "uran235")) {
register(getOre("orePitchblende"), WATER, 100, 128, getOre("uran238", 8), getOre("smallUran235", 2));
}
if (oresExist("oreAluminum")) {
register(getOre("oreAluminum"), WATER, 100, 128, getMaterial("aluminum", 2, Type.DUST), getMaterial("bauxite", 2, Type.SMALL_DUST));
}
if (oresExist("oreArdite", "dustArdite")) {
register(getOre("oreArdite"), WATER, 100, 128, getOre("dustArdite", 2), getMaterial("sulfur", 2, Type.SMALL_DUST));
}
if (oresExist("oreCobalt", "dustCobalt")) {
register(getOre("oreCobalt"), WATER, 100, 128, getOre("dustCobalt", 2), getMaterial("sulfur", 2, Type.SMALL_DUST));
}
if (oresExist("oreOsmium", "dustOsmium")) {
register(getOre("oreOsmium"), WATER, 100, 128, getOre("dustOsmium", 2), getMaterial("platinum", 2, Type.SMALL_DUST), getMaterial("iron", 1, Type.SMALL_DUST));
}
if (oresExist("oreTeslatite", "dustTeslatite")) {
register(getOre("oreTeslatite"), WATER, 100, 128, getOre("dustTeslatite", 2), getMaterial("redstone", 3, Type.SMALL_DUST));
}
if (oresExist("oreSulfur")) {
register(getOre("oreSulfur"), WATER, 100, 128, getMaterial("sulfur", 2, Type.DUST), getMaterial("sulfur", Type.SMALL_DUST));
}
if (oresExist("oreSaltpeter")) {
register(getOre("oreSaltpeter"), WATER, 100, 128, getMaterial("saltpeter", 2, Type.DUST), getMaterial("saltpeter", Type.SMALL_DUST));
}
}
static void register(ItemStack output, FluidStack fluid, int ticks, int euPerTick, ItemStack... inputs) {
if (inputs.length == 3)
RecipeHandler.addRecipe(new IndustrialGrinderRecipe(output,
fluid, inputs[0], inputs[1], inputs[2], null, ticks, euPerTick));
else if (inputs.length == 2)
RecipeHandler.addRecipe(new IndustrialGrinderRecipe(output,
fluid, inputs[0], inputs[1], null, null, ticks, euPerTick));
else if (inputs.length == 1)
RecipeHandler.addRecipe(new IndustrialGrinderRecipe(output,
fluid, inputs[0], null, null, null, ticks, euPerTick));
else if (inputs.length == 4) {
RecipeHandler.addRecipe(new IndustrialGrinderRecipe(output,
fluid, inputs[0], inputs[1], inputs[2], inputs[3], ticks, euPerTick));
} else {
Core.logHelper.log(Level.ERROR, "Invalid industrial grinder recipe. Too many or too few inputs.");
}
}
}

View file

@ -0,0 +1,58 @@
package techreborn.init.recipes;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
import reborncore.common.util.OreUtil;
import techreborn.items.*;
/**
* Created by Prospector
*/
public class RecipeMethods {
static ItemStack getMaterial(String name, int count, Type type) {
if (type == Type.DUST) {
return ItemDusts.getDustByName(name, count);
}
if (type == Type.SMALL_DUST) {
return ItemDustsSmall.getSmallDustByName(name, count);
}
if (type == Type.INGOT) {
return ItemIngots.getIngotByName(name, count);
}
if (type == Type.GEM) {
return ItemGems.getGemByName(name, count);
}
if (type == Type.PLATE) {
return ItemPlates.getPlateByName(name, count);
}
if (type == Type.NUGGET) {
return ItemNuggets.getNuggetByName(name, count);
}
return ItemStack.EMPTY;
}
static ItemStack getMaterial(String name, Type type) {
return getMaterial(name, 1, type);
}
static ItemStack getOre(String name, int count) {
return OreUtil.getStackFromName(name, count);
}
static ItemStack getOre(String name) {
return getOre(name, 1);
}
static boolean oresExist(String... names) {
for (String name : names) {
if (!OreDictionary.doesOreNameExist(name)) {
return false;
}
}
return true;
}
enum Type {
DUST, SMALL_DUST, INGOT, NUGGET, PLATE, GEM
}
}

View file

@ -19,7 +19,7 @@ public class ItemDusts extends ItemTRNoDestroy {
"nickel", "obsidian", "peridot", "phosphorous", "platinum", "pyrite", "pyrope", "red_garnet", ModItems.META_PLACEHOLDER, "nickel", "obsidian", "peridot", "phosphorous", "platinum", "pyrite", "pyrope", "red_garnet", ModItems.META_PLACEHOLDER,
"ruby", "saltpeter", "sapphire", "saw_dust", "silver", "sodalite", "spessartine", "sphalerite", "steel", "ruby", "saltpeter", "sapphire", "saw_dust", "silver", "sodalite", "spessartine", "sphalerite", "steel",
"sulfur", "tin", "titanium", "tungsten", "uvarovite", ModItems.META_PLACEHOLDER, "yellow_garnet", "zinc", "sulfur", "tin", "titanium", "tungsten", "uvarovite", ModItems.META_PLACEHOLDER, "yellow_garnet", "zinc",
"olivine", "andesite", "diorite", "granite" }; ModItems.META_PLACEHOLDER, "andesite", "diorite", "granite" };
public ItemDusts() { public ItemDusts() {
setUnlocalizedName("techreborn.dust"); setUnlocalizedName("techreborn.dust");

View file

@ -19,7 +19,7 @@ public class ItemDustsSmall extends ItemTRNoDestroy {
"nickel", "obsidian", "peridot", "phosphorous", "platinum", "pyrite", "pyrope", "red_garnet", ModItems.META_PLACEHOLDER, "nickel", "obsidian", "peridot", "phosphorous", "platinum", "pyrite", "pyrope", "red_garnet", ModItems.META_PLACEHOLDER,
"ruby", "saltpeter", "sapphire", "saw_dust", "silver", "sodalite", "spessartine", "sphalerite", "steel", "ruby", "saltpeter", "sapphire", "saw_dust", "silver", "sodalite", "spessartine", "sphalerite", "steel",
"sulfur", "tin", "titanium", "tungsten", "uvarovite", ModItems.META_PLACEHOLDER, "yellow_garnet", "zinc", "sulfur", "tin", "titanium", "tungsten", "uvarovite", ModItems.META_PLACEHOLDER, "yellow_garnet", "zinc",
"olivine", "redstone", "glowstone", "andesite", "diorite", "granite" }; ModItems.META_PLACEHOLDER, "redstone", "glowstone", "andesite", "diorite", "granite" };
public ItemDustsSmall() { public ItemDustsSmall() {
setUnlocalizedName("techreborn.dustsmall"); setUnlocalizedName("techreborn.dustsmall");

View file

@ -15,7 +15,7 @@ public class ItemPlates extends ItemTRNoDestroy {
//Vanilla plates or plates not from ingots or gems //Vanilla plates or plates not from ingots or gems
public static String[] types = new String[] { public static String[] types = new String[] {
"iron", "gold", "carbon", "wood", "redstone", "diamond", "emerald", "lapis", "coal", "obsidian", "lazurite" "iron", "gold", "carbon", "wood", "redstone", "diamond", "emerald", ModItems.META_PLACEHOLDER, "coal", "obsidian", "lazurite"
}; };
public ItemPlates() { public ItemPlates() {
@ -28,6 +28,9 @@ public class ItemPlates extends ItemTRNoDestroy {
name = CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, name); name = CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, name);
for (int i = 0; i < types.length; i++) { for (int i = 0; i < types.length; i++) {
if (types[i].equalsIgnoreCase(name)) { if (types[i].equalsIgnoreCase(name)) {
if (types[i].equals(ModItems.META_PLACEHOLDER)) {
throw new InvalidParameterException("The dust " + name + " could not be found.");
}
return new ItemStack(ModItems.plate, count, i); return new ItemStack(ModItems.plate, count, i);
} }
} }
@ -66,7 +69,9 @@ public class ItemPlates extends ItemTRNoDestroy {
// Adds Dusts SubItems To Creative Tab // Adds Dusts SubItems To Creative Tab
public void getSubItems(Item item, CreativeTabs creativeTabs, NonNullList list) { public void getSubItems(Item item, CreativeTabs creativeTabs, NonNullList list) {
for (int meta = 0; meta < types.length; ++meta) { for (int meta = 0; meta < types.length; ++meta) {
list.add(new ItemStack(item, 1, meta)); if (!types[meta].equals(ModItems.META_PLACEHOLDER)) {
list.add(new ItemStack(item, 1, meta));
}
} }
} }
} }