More recipes ported

This commit is contained in:
modmuss50 2019-07-30 21:16:44 +01:00
parent 3c29c06d39
commit a1674cb8a8
100 changed files with 2139 additions and 405 deletions

View file

@ -21,6 +21,8 @@ import net.minecraft.text.LiteralText;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.Validate;
import techreborn.items.ItemDynamicCell;
import java.io.File;
import java.io.IOException;
@ -229,7 +231,7 @@ public class RecipeTemplate {
Function<ItemStack, JsonObject> toIngredient = stack -> {
JsonObject jsonObject = new JsonObject();
if(stack.getItem() == TRContent.CELL){
if(stack.getItem() == TRContent.CELL && TRContent.CELL.getFluid(stack) != Fluids.EMPTY){
jsonObject.addProperty("fluid", Registry.FLUID.getId(TRContent.CELL.getFluid(stack)).toString());
jsonObject.addProperty("holder", "techreborn:cell");
} else {
@ -237,10 +239,14 @@ public class RecipeTemplate {
if(stack.getCount() > 1){
jsonObject.addProperty("count", stack.getCount());
}
if(stack.getItem() instanceof ItemDynamicCell){
//Force it to be an empty cell
jsonObject.addProperty("nbt", "null");
}
}
return jsonObject;
};
inputs.forEach(stack -> ingredients.add(toIngredient.apply(stack)));
inputs.stream().peek(Validate::notNull).forEach(stack -> ingredients.add(toIngredient.apply(stack)));
object.add("ingredients", ingredients);
}
@ -275,6 +281,9 @@ public class RecipeTemplate {
String name = Registry.ITEM.getId(outputs.get(0).getItem()).getPath();
if(outputs.get(0).getItem() == TRContent.CELL){
name = Registry.FLUID.getId(TRContent.CELL.getFluid(outputs.get(0))).getPath();
if(name.equals("empty")){
name = "empty_cell";
}
}
String extraPath = auto ? "/auto/" : "/";

View file

@ -1,105 +0,0 @@
/*
* This file is part of TechReborn, licensed under the MIT License (MIT).
*
* Copyright (c) 2018 TechReborn
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package techreborn.init.recipes;
import net.minecraft.item.ItemStack;
import techreborn.init.ModFluids;
import techreborn.items.ItemDynamicCell;
import java.security.InvalidParameterException;
/**
* @author drcrazy
*
*/
public class DistillationTowerRecipes extends RecipeMethods {
public static void init() {
register(ItemDynamicCell.getCellWithFluid(ModFluids.OIL.getFluid(), 16), 1400, 13, getMaterial("diesel", 16, Type.CELL), getMaterial("sulfuricAcid", 16, Type.CELL), getMaterial("glyceryl", Type.CELL));
}
static void register(ItemStack input, int ticks, int euPerTick, boolean oreDict, ItemStack... outputs) {
ItemStack output1;
ItemStack output2 = null;
ItemStack output3 = null;
ItemStack output4 = null;
if (outputs.length == 3) {
output1 = outputs[0];
output2 = outputs[1];
output3 = outputs[2];
} else if (outputs.length == 2) {
output1 = outputs[0];
output2 = outputs[1];
} else if (outputs.length == 1) {
output1 = outputs[0];
} else if (outputs.length == 4) {
output1 = outputs[0];
output2 = outputs[1];
output3 = outputs[2];
output4 = outputs[3];
} else {
throw new InvalidParameterException("Invalid number of Distillation tower outputs: " + outputs);
}
int cellCount = 0;
for (ItemStack stack : outputs) {
if (stack.getItem() instanceof ItemDynamicCell) {
cellCount += stack.getCount();
}
}
if (input.getItem() instanceof ItemDynamicCell) {
int inputCount = input.getCount();
if (cellCount < inputCount) {
if (output2 == null) {
output2 = ItemDynamicCell.getEmptyCell(inputCount - cellCount);
} else if (output3 == null) {
output3 = ItemDynamicCell.getEmptyCell(inputCount - cellCount);
} else if (output4 == null) {
output4 = ItemDynamicCell.getEmptyCell(inputCount - cellCount);
}
}
cellCount -= inputCount;
}
if (cellCount < 0) { cellCount = 0; }
ItemStack cells = null;
if (cellCount > 0) {
if (cellCount > 64) {
throw new InvalidParameterException("Invalid Distillation tower outputs: " + outputs + "(Recipe requires > 64 cells)");
}
cells = ItemDynamicCell.getEmptyCell(cellCount);
}
// RecipeHandler.addRecipe(Reference.DistiLLATION_TOWER_RECIPE, new DistillationTowerRecipe(input, cells, output1, output2, output3, output4, ticks, euPerTick, oreDict));
}
static void register(ItemStack input, int ticks, int euPerTick, ItemStack... outputs) {
register(input, ticks, euPerTick, true, outputs);
}
}

View file

@ -1,70 +0,0 @@
/*
* This file is part of TechReborn, licensed under the MIT License (MIT).
*
* Copyright (c) 2018 TechReborn
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package techreborn.init.recipes;
/**
* Created by Prospector
*/
public class ExtractorRecipes extends RecipeMethods {
/* TODO 1.13 :D
public static void init() {
register(getStack(TRContent.RUBBER_SAPLING), TRContent.Parts.RUBBER.getStack(), false);
register(getStack(TRContent.RUBBER_LOG), TRContent.Parts.RUBBER.getStack(), false);
register(getStack(Items.SLIME_BALL), TRContent.Parts.RUBBER.getStack(2), false);
register(TRContent.Parts.SAP.getStack(), TRContent.Parts.RUBBER.getStack(3), false);
register(getStack(Blocks.RED_TULIP), getStack(Items.ROSE_RED, 2), false);
register(getStack(Blocks.POPPY), getStack(Items.ROSE_RED, 2), false);
register(getStack(Blocks.ROSE_BUSH), getStack(Items.ROSE_RED, 4), false);
register(getStack(Blocks.BLUE_ORCHID), getStack(Items.LIGHT_BLUE_DYE, 2), false);
register(getStack(Blocks.AZURE_BLUET), getStack(Items.LIGHT_GRAY_DYE, 2), false);
register(getStack(Blocks.OXEYE_DAISY), getStack(Items.LIGHT_GRAY_DYE, 2), false);
register(getStack(Blocks.WHITE_TULIP), getStack(Items.LIGHT_GRAY_DYE, 2), false);
register(getStack(Blocks.ALLIUM), getStack(Items.MAGENTA_DYE, 2), false);
register(getStack(Blocks.LILAC), getStack(Items.MAGENTA_DYE, 4), false);
register(getStack(Blocks.ORANGE_TULIP), getStack(Items.ORANGE_DYE, 2), false);
register(getStack(Blocks.PINK_TULIP), getStack(Items.PINK_DYE, 2), false);
register(getStack(Blocks.PEONY), getStack(Items.PINK_DYE, 4), false);
register(getStack(Blocks.DANDELION), getStack(Items.DANDELION_YELLOW, 2), false);
register(getStack(Blocks.SUNFLOWER), getStack(Items.DANDELION_YELLOW, 2), false);
register(getStack(Blocks.TALL_GRASS), getStack(Items.WHEAT_SEEDS), false);
register(getStack(Blocks.LARGE_FERN), getStack(Items.WHEAT_SEEDS), false);
register(getStack(Blocks.DEAD_BUSH), getStack(Items.STICK));
for (int i = 1; i < 15; i++)
register(getStack(Blocks.WOOL, 1, i), getStack(Blocks.WOOL, 1, 0), false);
for (Fluid fluid : FluidRegistry.getRegisteredFluids().values()) {
register(DynamicCell.getCellWithFluid(fluid), DynamicCell.getEmptyCell(1), false);
}
}
static void register(ItemStack input, ItemStack output) {
register(input, output, true);
}
static void register(ItemStack input, ItemStack output, boolean oreDict) {
RecipeHandler.addRecipe(Reference.EXTRACTOR_RECIPE, new ExtractorRecipe(input, output, 400, 2, oreDict));
}
*/
}

View file

@ -24,20 +24,23 @@
package techreborn.init.recipes;
import net.minecraft.item.ItemStack;
import techreborn.api.reactor.FusionReactorRecipe;
import techreborn.api.reactor.FusionReactorRecipeHelper;
import techreborn.init.ModFluids;
import techreborn.init.TRContent;
import techreborn.items.ItemDynamicCell;
/**
* @author drcrazy
*
*/
public class FusionReactorRecipes extends RecipeMethods {
public static void init() {
// FusionReactorRecipeHelper.registerRecipe(new FusionReactorRecipe(ItemCells.getCellByName("helium3"),
// ItemCells.getCellByName("deuterium"), ItemCells.getCellByName("heliumplasma"), 40000000, 32768, 1024));
// FusionReactorRecipeHelper.registerRecipe(new FusionReactorRecipe(ItemCells.getCellByName("tritium"),
// ItemCells.getCellByName("deuterium"), ItemCells.getCellByName("helium3"), 60000000, 16384, 2048));
// FusionReactorRecipeHelper.registerRecipe(new FusionReactorRecipe(ItemCells.getCellByName("wolframium"),
// ItemCells.getCellByName("Berylium"), TRContent.Dusts.PLATINUM.getStack(), 80000000, -2048, 1024));
// TODO: Fix recipe
// FusionReactorRecipeHelper.registerRecipe(new FusionReactorRecipe(ItemCells.getCellByName("wolframium"),
// ItemCells.getCellByName("lithium"), BlockOre.getOreByName("iridium"), 90000000, -2048, 1024));
FusionReactorRecipeHelper.registerRecipe(new FusionReactorRecipe(ItemDynamicCell.getCellWithFluid(ModFluids.HELIUM_3.getFluid()), ItemDynamicCell.getCellWithFluid(ModFluids.DEUTERIUM.getFluid()), ItemDynamicCell.getCellWithFluid(ModFluids.HELIUMPLASMA.getFluid()), 40000000, 32768, 1024));
FusionReactorRecipeHelper.registerRecipe(new FusionReactorRecipe(ItemDynamicCell.getCellWithFluid(ModFluids.TRITIUM.getFluid()), ItemDynamicCell.getCellWithFluid(ModFluids.DEUTERIUM.getFluid()), ItemDynamicCell.getCellWithFluid(ModFluids.HELIUM_3.getFluid()), 60000000, 16384, 2048));
FusionReactorRecipeHelper.registerRecipe(new FusionReactorRecipe(ItemDynamicCell.getCellWithFluid(ModFluids.WOLFRAMIUM.getFluid()), ItemDynamicCell.getCellWithFluid(ModFluids.BERYLIUM.getFluid()), TRContent.Dusts.PLATINUM.getStack(), 80000000, -2048, 1024));
FusionReactorRecipeHelper.registerRecipe(new FusionReactorRecipe(ItemDynamicCell.getCellWithFluid(ModFluids.WOLFRAMIUM.getFluid()), ItemDynamicCell.getCellWithFluid(ModFluids.LITHIUM.getFluid()), new ItemStack(TRContent.Ores.IRIDIUM.asItem()), 90000000, -2048, 1024));
}
}

View file

@ -1,180 +0,0 @@
/*
* This file is part of TechReborn, licensed under the MIT License (MIT).
*
* Copyright (c) 2018 TechReborn
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package techreborn.init.recipes;
import net.minecraft.block.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import techreborn.items.ItemDynamicCell;
import java.security.InvalidParameterException;
/**
* Created by Prospector
*/
public class IndustrialCentrifugeRecipes extends RecipeMethods {
public static void init() {
register(getStack(Blocks.DIRT, 16), 2500, getStack(Blocks.SAND, 8), getStack(Items.CLAY_BALL), getStack(Blocks.GRAVEL, 2));
register(getStack(Blocks.GRASS, 16), 2500, getStack(Blocks.SAND, 8), getStack(Items.CLAY_BALL), getStack(Blocks.GRAVEL, 2), getStack(Items.WHEAT_SEEDS, 4));
register(getStack(Blocks.MYCELIUM, 8), 1640, getStack(Blocks.SAND, 4), getStack(Items.CLAY_BALL), getStack(Blocks.BROWN_MUSHROOM, 2), getStack(Blocks.RED_MUSHROOM, 2));
register(getStack(Items.GOLDEN_APPLE), 5000, getStack(Items.GOLD_INGOT, 6), getMaterial("methane", Type.CELL));
register(getStack(Items.ENCHANTED_GOLDEN_APPLE), 5000, getStack(Items.GOLD_INGOT, 64), getMaterial("methane", Type.CELL));
register(getStack(Items.GOLDEN_CARROT), 5000, getStack(Items.GOLD_NUGGET, 6), getMaterial("methane", Type.CELL));
register(getStack(Items.GLISTERING_MELON_SLICE, 8), 5000, getStack(Items.GOLD_NUGGET, 6), getMaterial("methane", Type.CELL));
register(getStack(Items.APPLE, 32), 5000, getMaterial("methane", Type.CELL));
register(getStack(Items.MUSHROOM_STEW, 16), 5000, getMaterial("methane", Type.CELL));
register(getStack(Items.BREAD, 64), 5000, getMaterial("methane", Type.CELL));
register(getStack(Items.PORKCHOP, 12), 5000, getMaterial("methane", Type.CELL));
register(getStack(Items.COOKED_PORKCHOP, 16), 5000, getMaterial("methane", Type.CELL));
register(getStack(Items.BEEF, 12), 5000, getMaterial("methane", Type.CELL));
register(getStack(Items.COOKED_BEEF, 16), 5000, getMaterial("methane", Type.CELL));
register(getStack(Items.CHICKEN, 12), 5000, getMaterial("methane", Type.CELL));
register(getStack(Items.COOKED_CHICKEN, 16), 5000, getMaterial("methane", Type.CELL));
register(getStack(Items.MUTTON, 12), 5000, getMaterial("methane", Type.CELL));
register(getStack(Items.COOKED_MUTTON, 16), 5000, getMaterial("methane", Type.CELL));
register(getStack(Items.RABBIT, 12), 5000, getMaterial("methane", Type.CELL));
register(getStack(Items.COOKED_RABBIT, 16), 5000, getMaterial("methane", Type.CELL));
register(getStack(Items.COD, 12), 5000, getMaterial("methane", Type.CELL));
register(getStack(Items.COOKED_COD, 16), 5000, getMaterial("methane", Type.CELL));
register(getStack(Items.SALMON, 12), 5000, getMaterial("methane", Type.CELL));
register(getStack(Items.COOKED_SALMON, 16), 5000, getMaterial("methane", Type.CELL));
register(getStack(Items.MELON_SLICE, 64), 5000, getMaterial("methane", Type.CELL));
register(getStack(Blocks.PUMPKIN, 16), 5000, getMaterial("methane", Type.CELL));
register(getStack(Items.ROTTEN_FLESH, 16), 5000, getMaterial("methane", Type.CELL));
register(getStack(Items.SPIDER_EYE, 32), 5000, getMaterial("methane", Type.CELL));
register(getStack(Items.CARROT, 16), 5000, getMaterial("methane", Type.CELL));
register(getStack(Items.POTATO, 16), 5000, getMaterial("methane", Type.CELL));
register(getStack(Items.POISONOUS_POTATO, 12), 5000, getMaterial("methane", Type.CELL));
register(getStack(Items.BAKED_POTATO, 24), 5000, getMaterial("methane", Type.CELL));
register(getStack(Items.BEETROOT, 12), 5000, getMaterial("methane", Type.CELL));
register(getStack(Items.COOKIE, 64), 5000, getMaterial("methane", Type.CELL));
register(getStack(Blocks.BROWN_MUSHROOM_BLOCK, 12), 5000, getMaterial("methane", Type.CELL));
register(getStack(Blocks.RED_MUSHROOM_BLOCK, 12), 5000, getMaterial("methane", Type.CELL));
register(getStack(Blocks.BROWN_MUSHROOM, 32), 5000, getMaterial("methane", Type.CELL));
register(getStack(Blocks.RED_MUSHROOM, 32), 5000, getMaterial("methane", Type.CELL));
register(getStack(Items.NETHER_WART, 32), 5000, getMaterial("methane", Type.CELL));
//TODO: Fixme
// register(getMaterial("sap", 4, Type.PART), 1300, getMaterial("rubber", 14, Type.PART));
// register(getStack(ModBlocks.RUBBER_LOG, 16), 5000, false, getMaterial("sap", 8, Type.PART), getMaterial("methane", Type.CELL), getMaterial("carbon", 4, Type.CELL));
// register(getStack(Blocks.SOUL_SAND, 16), 2500, getStack(Blocks.SAND, 10), getMaterial("saltpeter", 4, Type.DUST), getMaterial("coal", Type.DUST), getMaterial("oil", Type.CELL));
// register(getOre("dustBronze"), 1500, getMaterial("copper", 6, Type.SMALL_DUST), getMaterial("tin", 2, Type.SMALL_DUST));
// register(getOre("dustIron", 2), 1500, getMaterial("tin", Type.SMALL_DUST), getMaterial("nickel", Type.SMALL_DUST));
// register(getOre("dustSilver", 2), 2400, getMaterial("lead", Type.SMALL_DUST));
// register(getOre("dustLead", 2), 2400, getMaterial("silver", Type.SMALL_DUST));
// register(getOre("dustTin", 2), 210, getMaterial("zinc", Type.SMALL_DUST), getMaterial("iron", Type.SMALL_DUST));
// register(getOre("dustElectrum"), 960, getMaterial("gold", 2, Type.SMALL_DUST), getMaterial("silver", 2, Type.SMALL_DUST));
// register(getOre("dustZinc"), 1040, getMaterial("tin", Type.SMALL_DUST));
// register(getOre("dustBrass"), 1500, getMaterial("copper", 3, Type.SMALL_DUST), getMaterial("zinc", Type.SMALL_DUST));
// register(getOre("dustPlatinum", 2), 3000, getMaterial("iridium", 2, Type.NUGGET), getMaterial("nickel", Type.SMALL_DUST));
// register(getOre("dustNickel", 3), 3440, getMaterial("iron", Type.SMALL_DUST), getMaterial("gold", Type.SMALL_DUST), getMaterial("copper", Type.SMALL_DUST));
// register(getOre("dustGold", 3), 2400, getMaterial("copper", Type.SMALL_DUST), getMaterial("nickel", Type.SMALL_DUST));
// register(getOre("dustCopper", 3), 2400, getMaterial("gold", Type.SMALL_DUST), getMaterial("nickel", Type.SMALL_DUST));
// register(getOre("dustRedstone", 32), 2200, getMaterial("silicon", 3, Type.CELL), getMaterial("pyrite", 16, Type.DUST), getMaterial("ruby", 3, Type.DUST), getMaterial("mercury", 10, Type.CELL));
// register(getOre("dustGlowstone", 16), 2500, getStack(Items.REDSTONE, 8), getMaterial("sulfur", Type.CELL), getMaterial("helium", Type.CELL));
// register(getStack(Items.DYE, 4, 4), 1500, false, getMaterial("lazurite", 3, Type.DUST), getMaterial("pyrite", Type.SMALL_DUST), getMaterial("calcite", Type.SMALL_DUST), getMaterial("sodalite", 2, Type.SMALL_DUST));
// register(getOre("dustEnderEye", 2), 1840, getMaterial("ender_pearl", 2, Type.DUST), getStack(Items.BLAZE_POWDER));
// register(getOre("dustNetherrack", 16), 2400, getStack(Items.REDSTONE), getMaterial("sulfur", Type.CELL), getMaterial("coal", Type.DUST), getStack(Items.GOLD_NUGGET));
// register(getOre("dustEndstone", 16), 4800, getMaterial("helium3", Type.CELL), getMaterial("helium", Type.CELL), getMaterial("tungsten", Type.SMALL_DUST), getStack(Blocks.SAND, 12));
// register(getOre("dustRedGarnet", 16), 3000, getMaterial("pyrope", 3, Type.DUST), getMaterial("almandine", 5, Type.DUST), getMaterial("spessartine", 8, Type.DUST));
// register(getOre("dustYellowGarnet", 16), 3500, getMaterial("andradite", 5, Type.DUST), getMaterial("grossular", 8, Type.DUST), getMaterial("uvarovite", 3, Type.DUST));
// register(getOre("dustDarkAshes", 2), 240, getMaterial("ashes", 1, Type.DUST));
// register(getOre("dustAshes", 2), 240, getMaterial("carbon", Type.CELL));
// register(getOre("dustMarble"), 1040, getMaterial("magnesium", Type.DUST), getMaterial("calcite", 7, Type.DUST));
// register(getOre("dustBasalt", 16), 2040, getMaterial("peridot", Type.DUST), getMaterial("calcite", 3, Type.DUST), getMaterial("flint", 8, Type.DUST), getMaterial("dark_ashes", 4, Type.DUST));
// register(getMaterial("lava", 16, Type.CELL), 1500, getMaterial("tin", 6, Type.INGOT), getMaterial("copper", 4, Type.INGOT), getMaterial("electrum", Type.INGOT), getMaterial("tungsten", Type.SMALL_DUST));
register(getMaterial("hydrogen", 4, Type.CELL), 3000, getMaterial("deuterium", Type.CELL));
register(getMaterial("deuterium", 4, Type.CELL), 3000, getMaterial("tritium", Type.CELL));
register(getMaterial("helium", 16, Type.CELL), 5000, getMaterial("helium3", Type.CELL));
// register(getMaterial("calciumcarbonate", Type.CELL), 40, getMaterial("calcite", Type.DUST));
// register(getMaterial("sulfur", Type.CELL), 40, getMaterial("sulfur", Type.DUST));
}
static void register(Object input, int ticks, boolean oreDict, ItemStack... outputs) {
ItemStack output1;
ItemStack output2 = null;
ItemStack output3 = null;
ItemStack output4 = null;
if (outputs.length == 3) {
output1 = outputs[0];
output2 = outputs[1];
output3 = outputs[2];
} else if (outputs.length == 2) {
output1 = outputs[0];
output2 = outputs[1];
} else if (outputs.length == 1) {
output1 = outputs[0];
} else if (outputs.length == 4) {
output1 = outputs[0];
output2 = outputs[1];
output3 = outputs[2];
output4 = outputs[3];
} else {
throw new InvalidParameterException("Invalid industrial centrifuge outputs: " + outputs);
}
int cellCount = 0;
for (ItemStack stack : outputs) {
if (stack.getItem() instanceof ItemDynamicCell) {
cellCount += stack.getCount();
}
}
if (input instanceof ItemStack) {
if (((ItemStack) input).getItem() instanceof ItemDynamicCell) {
int inputCount = ((ItemStack) input).getCount();
if (cellCount < inputCount) {
if (output2 == null) {
output2 = ItemDynamicCell.getEmptyCell(inputCount - cellCount);
} else if (output3 == null) {
output3 = ItemDynamicCell.getEmptyCell(inputCount - cellCount);
} else if (output4 == null) {
output4 = ItemDynamicCell.getEmptyCell(inputCount - cellCount);
}
}
cellCount -= inputCount;
}
}
if (cellCount < 0) {
cellCount = 0;
}
ItemStack cells = null;
if (cellCount > 0) {
if (cellCount > 64) {
throw new InvalidParameterException("Invalid industrial centrifuge outputs: " + outputs + "(Recipe requires > 64 cells)");
}
cells = ItemDynamicCell.getEmptyCell(cellCount);
}
//RecipeHandler.addRecipe(Reference.CENTRIFUGE_RECIPE, new CentrifugeRecipe(input, cells, output1, output2, output3, output4, ticks, 5, oreDict));
}
static void register(Object input, int ticks, ItemStack... outputs) {
register(input, ticks, true, outputs);
}
}

View file

@ -25,46 +25,84 @@
package techreborn.init.recipes;
import net.minecraft.block.Block;
import net.minecraft.fluid.Fluid;
import net.minecraft.fluid.Fluids;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.recipe.Ingredient;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
import reborncore.common.util.StringUtils;
import techreborn.items.ItemDynamicCell;
/**
* Created by Prospector
*/
public abstract class RecipeMethods {
public static ItemStack getMaterial(String name, int count, Type type) {
// if (type == Type.DUST) {
// return ItemDusts.getDustByName(name, count);
// } else if (type == Type.SMALL_DUST) {
// return ItemDustsSmall.getSmallDustByName(name, count);
// } else if (type == Type.INGOT) {
// return ItemIngots.getIngotByName(name, count);
// } else if (type == Type.GEM) {
// return ItemGems.getGemByName(name, count);
// TODO: fix recipe
// } else if (type == Type.PLATE) {
// return ItemPlates.getPlateByName(name, count);
// } else if (type == Type.NUGGET) {
// return ItemNuggets.getNuggetByName(name, count);
// } else
// if (type == Type.CELL) {
// return ItemCells.getCellByName(name, count);
// } else if (type == Type.PART) {
// return ItemParts.getPartByName(name, count);
// } else if (type == Type.CABLE) {
// return BlockCable.getCableByName(name, count);
// } else if (type == Type.MACHINE_FRAME) {
// return BlockMachineFrames.getFrameByName(name, count);
// } else if (type == Type.MACHINE_CASING) {
// return BlockMachineCasing.getStackByName(name, count);
// } else if (type == Type.UPGRADE) {
// return ItemUpgrades.getUpgradeByName(name, count);
// } else if (type == Type.ORE) {
// return BlockOre.getOreByName(name, count);
// }
return ItemStack.EMPTY;
name = name.toLowerCase();
if(type == Type.CELL){
Fluid fluid = Registry.FLUID.get(new Identifier("techreborn", name.toLowerCase()));
if(name.equals("water")){
fluid = Fluids.WATER;
}
if(name.equals("lava")){
fluid = Fluids.LAVA;
}
if(fluid == Fluids.EMPTY){
throw new RuntimeException("could not find fluid " + name);
}
return ItemDynamicCell.getCellWithFluid(fluid, count);
}
if(type == Type.INGOT){
return find(name + "_ingot", count);
}
if(type == Type.DUST){
return find(name + "_dust", count);
}
if(type == Type.PLATE){
return find(name + "_plate", count);
}
if(type == Type.NUGGET){
return find(name + "_nugget", count);
}
if(type == Type.SMALL_DUST){
return find(name + "_small_dust", count);
}
if(type == Type.ORE){
return find(name + "_ore", count);
}
if(type == Type.PART){
return find(name, count);
}
throw new UnsupportedOperationException(type.name());
}
private static ItemStack find(String path, int count){
Identifier identifier = new Identifier(path);
Item item = Registry.ITEM.get(identifier);
if(item != Items.AIR){
return new ItemStack(item, count);
}
identifier = new Identifier("techreborn", path);
item = Registry.ITEM.get(identifier);
if(item != Items.AIR){
return new ItemStack(item, count);
}
throw new UnsupportedOperationException("Could not find" + path);
}
static Object getMaterialObjectFromType(String name, Type type) {
@ -98,23 +136,25 @@ public abstract class RecipeMethods {
return getMaterial(name, 1, type);
}
public static Object getMaterialObject(String name, Type type) {
return getMaterialObjectFromType(name, type);
}
@Deprecated
public static ItemStack getOre(String name, int count) {
throw new UnsupportedOperationException("Use tags");
if(name.equals("dustRedstone")){
return new ItemStack(Items.REDSTONE, count);
}
if(name.startsWith("dust")){
return getMaterial(name.replace("dust", ""), count, Type.DUST);
}
return getMaterial(name, count, Type.ORE);
}
@Deprecated
public static ItemStack getOre(String name) {
throw new UnsupportedOperationException("Use tags");
return getOre(name, 1);
}
@Deprecated
public static boolean oresExist(String... names) {
throw new UnsupportedOperationException("Use tags");
return false;
}
public static ItemStack getStack(Item item) {
@ -132,7 +172,7 @@ public abstract class RecipeMethods {
@Deprecated
public static ItemStack getStack(Item item, int count, boolean wildcard) {
throw new UnsupportedOperationException("Use tags");
return new ItemStack(item, count);
}
public static ItemStack getStack(Block block) {
@ -140,7 +180,7 @@ public abstract class RecipeMethods {
}
public static ItemStack getStack(Block block, int count) {
return getStack(block, count);
return new ItemStack(block, count);
}
public static ItemStack getStack(Block block, boolean wildcard) {