use of buildcraft.api.recipes.AssemblyRecipeBasic in project BuildCraft by BuildCraft.
the class BCTransportRecipes method makeGateModifierAssembly.
private static void makeGateModifierAssembly(int multiplier, EnumGateMaterial material, EnumGateModifier modifier, IngredientStack... mods) {
for (EnumGateLogic logic : EnumGateLogic.VALUES) {
String name = String.format("gate-modifier-%s-%s-%s", logic, material, modifier);
ItemStack toUpgrade = BCTransportItems.plugGate.getStack(new GateVariant(logic, material, EnumGateModifier.NO_MODIFIER));
ItemStack output = BCTransportItems.plugGate.getStack(new GateVariant(logic, material, modifier));
ImmutableSet<IngredientStack> input = new ImmutableSet.Builder<IngredientStack>().add(IngredientStack.of(toUpgrade)).add(mods).build();
AssemblyRecipeRegistry.register((new AssemblyRecipeBasic(name, MjAPI.MJ * multiplier, input, output)));
}
}
use of buildcraft.api.recipes.AssemblyRecipeBasic in project BuildCraft by BuildCraft.
the class BCSiliconRecipes method registerRecipes.
@SubscribeEvent
public static void registerRecipes(RegistryEvent.Register<IRecipe> event) {
Loader.instance().getActiveModList().forEach((mod) -> {
JsonContext ctx = new JsonContext(mod.getModId());
CraftingHelper.findFiles(mod, "assets/" + mod.getModId() + "/assembly_recipes", null, (root, file) -> {
String path = root.relativize(file).toString();
if (!FilenameUtils.getExtension(file.toString()).equals("json"))
return true;
String name = FilenameUtils.removeExtension(path).replaceAll("\\\\", "/");
ResourceLocation key = new ResourceLocation(mod.getModId(), name);
BufferedReader reader = null;
try {
reader = Files.newBufferedReader(file);
JsonObject json = JsonUtils.fromJson(GSON, reader, JsonObject.class);
if (json == null || json.isJsonNull())
throw new JsonSyntaxException("Json is null (empty file?)");
ItemStack output = CraftingHelper.getItemStack(json.getAsJsonObject("result"), ctx);
long powercost = json.get("MJ").getAsLong() * MjAPI.MJ;
ArrayList<IngredientStack> ingredients = new ArrayList<>();
json.getAsJsonArray("components").forEach(element -> {
JsonObject object = element.getAsJsonObject();
ingredients.add(new IngredientStack(CraftingHelper.getIngredient(object.get("ingredient"), ctx), JsonUtils.getInt(object, "amount", 1)));
});
AssemblyRecipeRegistry.REGISTRY.put(key, new AssemblyRecipeBasic(key, powercost, ImmutableSet.copyOf(ingredients), output));
} catch (IOException e) {
BCLog.logger.error("Couldn't read recipe {} from {}", key, file, e);
return false;
} finally {
IOUtils.closeQuietly(reader);
}
return true;
});
CraftingHelper.findFiles(mod, "assets/" + mod.getModId() + "/integration_recipes", null, (root, file) -> {
String path = root.relativize(file).toString();
if (!FilenameUtils.getExtension(file.toString()).equals("json"))
return true;
String name = FilenameUtils.removeExtension(path).replaceAll("\\\\", "/");
ResourceLocation key = new ResourceLocation(mod.getModId(), name);
BufferedReader reader = null;
try {
reader = Files.newBufferedReader(file);
JsonObject json = JsonUtils.fromJson(GSON, reader, JsonObject.class);
if (json == null || json.isJsonNull())
throw new JsonSyntaxException("Json is null (empty file?)");
ItemStack output = CraftingHelper.getItemStack(json.getAsJsonObject("result"), ctx);
IngredientStack centerStack = IngredientStack.of(CraftingHelper.getIngredient(json.getAsJsonObject("centerStack"), ctx));
long powercost = json.get("MJ").getAsLong() * MjAPI.MJ;
ArrayList<IngredientStack> ingredients = new ArrayList<>();
json.getAsJsonArray("components").forEach(element -> {
JsonObject object = element.getAsJsonObject();
ingredients.add(new IngredientStack(CraftingHelper.getIngredient(object.get("ingredient"), ctx), JsonUtils.getInt(object, "amount", 1)));
});
IntegrationRecipeRegistry.INSTANCE.addRecipe(new IntegrationRecipeBasic(key, powercost, centerStack, ingredients, output));
} catch (IOException e) {
BCLog.logger.error("Couldn't read recipe {} from {}", key, file, e);
return false;
} finally {
IOUtils.closeQuietly(reader);
}
return true;
});
});
}
use of buildcraft.api.recipes.AssemblyRecipeBasic in project BuildCraft by BuildCraft.
the class BCTransportRecipes method makeGateAssembly.
private static void makeGateAssembly(int multiplier, EnumGateMaterial material, EnumGateModifier modifier, EnumRedstoneChipset chipset, IngredientStack... additional) {
ImmutableSet.Builder<IngredientStack> temp = ImmutableSet.builder();
temp.add(IngredientStack.of(chipset.getStack()));
temp.add(additional);
ImmutableSet<IngredientStack> input = temp.build();
String name = String.format("gate-and-%s-%s", material, modifier);
ItemStack output = BCTransportItems.plugGate.getStack(new GateVariant(EnumGateLogic.AND, material, modifier));
AssemblyRecipeRegistry.register((new AssemblyRecipeBasic(name, MjAPI.MJ * multiplier, input, output)));
name = String.format("gate-or-%s-%s", material, modifier);
output = BCTransportItems.plugGate.getStack(new GateVariant(EnumGateLogic.OR, material, modifier));
AssemblyRecipeRegistry.register((new AssemblyRecipeBasic(name, MjAPI.MJ * multiplier, input, output)));
}
use of buildcraft.api.recipes.AssemblyRecipeBasic in project BuildCraft by BuildCraft.
the class BCTransportRecipes method registerRecipes.
@SubscribeEvent
public static void registerRecipes(RegistryEvent.Register<IRecipe> event) {
addPipeRecipe(BCTransportItems.pipeItemWood, "plankWood");
addPipeRecipe(BCTransportItems.pipeItemCobble, "cobblestone");
addPipeRecipe(BCTransportItems.pipeItemStone, "stone");
addPipeRecipe(BCTransportItems.pipeItemQuartz, "blockQuartz");
addPipeRecipe(BCTransportItems.pipeItemIron, "ingotIron");
addPipeRecipe(BCTransportItems.pipeItemGold, "ingotGold");
addPipeRecipe(BCTransportItems.pipeItemClay, Blocks.CLAY);
addPipeRecipe(BCTransportItems.pipeItemSandstone, new ItemStack(Blocks.SANDSTONE, 1, OreDictionary.WILDCARD_VALUE));
addPipeRecipe(BCTransportItems.pipeItemVoid, new ItemStack(Items.DYE, 1, EnumDyeColor.BLACK.getDyeDamage()), "dustRedstone");
addPipeRecipe(BCTransportItems.pipeItemObsidian, Blocks.OBSIDIAN);
addPipeRecipe(BCTransportItems.pipeItemDiamond, Items.DIAMOND);
addPipeRecipe(BCTransportItems.pipeItemLapis, Blocks.LAPIS_BLOCK);
addPipeRecipe(BCTransportItems.pipeItemDaizuli, Blocks.LAPIS_BLOCK, Items.DIAMOND);
addPipeRecipe(BCTransportItems.pipeItemDiaWood, "plankWood", Items.DIAMOND);
addPipeRecipe(BCTransportItems.pipeItemStripes, "gearGold");
addPipeUpgradeRecipe(BCTransportItems.pipeItemDiaWood, BCTransportItems.pipeItemEmzuli, Blocks.LAPIS_BLOCK);
Item waterproof = BCTransportItems.waterproof;
if (waterproof == null) {
waterproof = Items.SLIME_BALL;
}
addPipeUpgradeRecipe(BCTransportItems.pipeItemWood, BCTransportItems.pipeFluidWood, waterproof);
addPipeUpgradeRecipe(BCTransportItems.pipeItemCobble, BCTransportItems.pipeFluidCobble, waterproof);
addPipeUpgradeRecipe(BCTransportItems.pipeItemStone, BCTransportItems.pipeFluidStone, waterproof);
addPipeUpgradeRecipe(BCTransportItems.pipeItemQuartz, BCTransportItems.pipeFluidQuartz, waterproof);
addPipeUpgradeRecipe(BCTransportItems.pipeItemIron, BCTransportItems.pipeFluidIron, waterproof);
addPipeUpgradeRecipe(BCTransportItems.pipeItemGold, BCTransportItems.pipeFluidGold, waterproof);
addPipeUpgradeRecipe(BCTransportItems.pipeItemClay, BCTransportItems.pipeFluidClay, waterproof);
addPipeUpgradeRecipe(BCTransportItems.pipeItemSandstone, BCTransportItems.pipeFluidSandstone, waterproof);
addPipeUpgradeRecipe(BCTransportItems.pipeItemVoid, BCTransportItems.pipeFluidVoid, waterproof);
addPipeUpgradeRecipe(BCTransportItems.pipeItemObsidian, BCTransportItems.pipeFluidObsidian, waterproof);
addPipeUpgradeRecipe(BCTransportItems.pipeItemDiamond, BCTransportItems.pipeFluidDiamond, waterproof);
addPipeUpgradeRecipe(BCTransportItems.pipeItemDiaWood, BCTransportItems.pipeFluidDiaWood, waterproof);
String upgrade = "dustRedstone";
addPipeUpgradeRecipe(BCTransportItems.pipeItemWood, BCTransportItems.pipePowerWood, upgrade);
addPipeUpgradeRecipe(BCTransportItems.pipeItemCobble, BCTransportItems.pipePowerCobble, upgrade);
addPipeUpgradeRecipe(BCTransportItems.pipeItemStone, BCTransportItems.pipePowerStone, upgrade);
addPipeUpgradeRecipe(BCTransportItems.pipeItemQuartz, BCTransportItems.pipePowerQuartz, upgrade);
// addPipeUpgradeRecipe(BCTransportItems.pipeItemIron, BCTransportItems.pipePowerIron, upgrade);
addPipeUpgradeRecipe(BCTransportItems.pipeItemGold, BCTransportItems.pipePowerGold, upgrade);
addPipeUpgradeRecipe(BCTransportItems.pipeItemSandstone, BCTransportItems.pipePowerSandstone, upgrade);
// addPipeUpgradeRecipe(BCTransportItems.pipeItemDiamond, BCTransportItems.pipePowerDiamond, upgrade);
if (BCTransportItems.plugGate != null) {
// You can craft some of the basic gate types in a normal crafting table
RecipeBuilderShaped builder = new RecipeBuilderShaped();
builder.add(" m ");
builder.add("mrm");
builder.add(" b ");
builder.map('r', "dustRedstone");
builder.map('b', BCTransportItems.plugBlocker, Blocks.COBBLESTONE);
// Base craftable types
builder.map('m', Items.BRICK);
makeGateRecipe(builder, EnumGateMaterial.CLAY_BRICK, EnumGateModifier.NO_MODIFIER);
builder.map('m', "ingotIron");
makeGateRecipe(builder, EnumGateMaterial.IRON, EnumGateModifier.NO_MODIFIER);
builder.map('m', Items.NETHERBRICK);
makeGateRecipe(builder, EnumGateMaterial.NETHER_BRICK, EnumGateModifier.NO_MODIFIER);
// Iron modifier addition
GateVariant variant = new GateVariant(EnumGateLogic.AND, EnumGateMaterial.IRON, EnumGateModifier.NO_MODIFIER);
ItemStack ironGateBase = BCTransportItems.plugGate.getStack(variant);
builder = new RecipeBuilderShaped();
builder.add(" m ");
builder.add("mgm");
builder.add(" m ");
builder.map('g', ironGateBase);
builder.map('m', new ItemStack(Items.DYE, 1, EnumDyeColor.BLUE.getDyeDamage()));
makeGateRecipe(builder, EnumGateMaterial.IRON, EnumGateModifier.LAPIS);
builder.map('m', Items.QUARTZ);
makeGateRecipe(builder, EnumGateMaterial.IRON, EnumGateModifier.QUARTZ);
// TODO: Create a recipe class for this instead!
for (EnumGateMaterial material : EnumGateMaterial.VALUES) {
if (material == EnumGateMaterial.CLAY_BRICK) {
continue;
}
for (EnumGateModifier modifier : EnumGateModifier.VALUES) {
GateVariant varAnd = new GateVariant(EnumGateLogic.AND, material, modifier);
ItemStack resultAnd = BCTransportItems.plugGate.getStack(varAnd);
GateVariant varOr = new GateVariant(EnumGateLogic.OR, material, modifier);
ItemStack resultOr = BCTransportItems.plugGate.getStack(varOr);
String regNamePrefix = resultOr.getItem().getRegistryName() + "_" + modifier + "_" + material;
ForgeRegistries.RECIPES.register(new ShapedOreRecipe(resultOr.getItem().getRegistryName(), resultAnd, "i", 'i', new IngredientNBTBC(resultOr)).setRegistryName(regNamePrefix + "_or"));
ForgeRegistries.RECIPES.register(new ShapedOreRecipe(resultAnd.getItem().getRegistryName(), resultOr, "i", 'i', new IngredientNBTBC(resultAnd)).setRegistryName(regNamePrefix + "_and"));
}
}
}
if (BCTransportItems.plugPulsar != null) {
ItemStack output = new ItemStack(BCTransportItems.plugPulsar);
ItemStack redstoneEngine;
if (BCCoreBlocks.engine != null) {
redstoneEngine = BCCoreBlocks.engine.getStack(EnumEngineType.WOOD);
} else {
redstoneEngine = new ItemStack(Blocks.REDSTONE_BLOCK);
}
if (SILICON_TABLE_ASSEMBLY != null) {
Set<IngredientStack> input = new HashSet<>();
input.add(new IngredientStack(Ingredient.fromStacks(redstoneEngine)));
input.add(new IngredientStack(CraftingHelper.getIngredient("ingotIron"), 2));
AssemblyRecipe recipe = new AssemblyRecipeBasic("plug_pulsar", 1000 * MjAPI.MJ, input, output);
AssemblyRecipeRegistry.register(recipe);
}
}
if (BCTransportItems.plugGate != null) {
IngredientStack lapis = IngredientStack.of("gemLapis");
makeGateAssembly(20_000, EnumGateMaterial.IRON, EnumGateModifier.NO_MODIFIER, EnumRedstoneChipset.IRON);
makeGateAssembly(40_000, EnumGateMaterial.NETHER_BRICK, EnumGateModifier.NO_MODIFIER, EnumRedstoneChipset.IRON, IngredientStack.of(new ItemStack(Blocks.NETHER_BRICK)));
makeGateAssembly(80_000, EnumGateMaterial.GOLD, EnumGateModifier.NO_MODIFIER, EnumRedstoneChipset.GOLD);
makeGateModifierAssembly(40_000, EnumGateMaterial.IRON, EnumGateModifier.LAPIS, lapis);
makeGateModifierAssembly(60_000, EnumGateMaterial.IRON, EnumGateModifier.QUARTZ, IngredientStack.of(EnumRedstoneChipset.QUARTZ.getStack()));
makeGateModifierAssembly(80_000, EnumGateMaterial.IRON, EnumGateModifier.DIAMOND, IngredientStack.of(EnumRedstoneChipset.DIAMOND.getStack()));
makeGateModifierAssembly(80_000, EnumGateMaterial.NETHER_BRICK, EnumGateModifier.LAPIS, lapis);
makeGateModifierAssembly(100_000, EnumGateMaterial.NETHER_BRICK, EnumGateModifier.QUARTZ, IngredientStack.of(EnumRedstoneChipset.QUARTZ.getStack()));
makeGateModifierAssembly(120_000, EnumGateMaterial.NETHER_BRICK, EnumGateModifier.DIAMOND, IngredientStack.of(EnumRedstoneChipset.DIAMOND.getStack()));
makeGateModifierAssembly(100_000, EnumGateMaterial.GOLD, EnumGateModifier.LAPIS, lapis);
makeGateModifierAssembly(140_000, EnumGateMaterial.GOLD, EnumGateModifier.QUARTZ, IngredientStack.of(EnumRedstoneChipset.QUARTZ.getStack()));
makeGateModifierAssembly(180_000, EnumGateMaterial.GOLD, EnumGateModifier.DIAMOND, IngredientStack.of(EnumRedstoneChipset.DIAMOND.getStack()));
}
if (BCTransportItems.plugLightSensor != null) {
AssemblyRecipeRegistry.register(new AssemblyRecipeBasic("light-sensor", 500 * MjAPI.MJ, ImmutableSet.of(IngredientStack.of(Blocks.DAYLIGHT_DETECTOR)), new ItemStack(BCTransportItems.plugLightSensor)));
}
if (BCTransportItems.plugFacade != null) {
AssemblyRecipeRegistry.register(FacadeAssemblyRecipes.INSTANCE);
ForgeRegistries.RECIPES.register(FacadeSwapRecipe.INSTANCE);
}
if (BCTransportItems.wire != null) {
for (EnumDyeColor color : ColourUtil.COLOURS) {
String name = String.format("wire-%s", color.getUnlocalizedName());
ImmutableSet<IngredientStack> input = ImmutableSet.of(IngredientStack.of("dustRedstone"), IngredientStack.of(ColourUtil.getDyeName(color)));
AssemblyRecipeRegistry.register(new AssemblyRecipeBasic(name, 10_000 * MjAPI.MJ, input, new ItemStack(BCTransportItems.wire, 8, color.getMetadata())));
}
}
if (BCTransportItems.plugLens != null) {
for (EnumDyeColor colour : ColourUtil.COLOURS) {
String name = String.format("lens-regular-%s", colour.getUnlocalizedName());
IngredientStack stainedGlass = IngredientStack.of("blockGlass" + ColourUtil.getName(colour));
ImmutableSet<IngredientStack> input = ImmutableSet.of(stainedGlass);
ItemStack output = BCTransportItems.plugLens.getStack(colour, false);
AssemblyRecipeRegistry.register(new AssemblyRecipeBasic(name, 500 * MjAPI.MJ, input, output));
name = String.format("lens-filter-%s", colour.getUnlocalizedName());
output = BCTransportItems.plugLens.getStack(colour, true);
input = ImmutableSet.of(stainedGlass, IngredientStack.of(new ItemStack(Blocks.IRON_BARS)));
AssemblyRecipeRegistry.register(new AssemblyRecipeBasic(name, 500 * MjAPI.MJ, input, output));
}
IngredientStack glass = IngredientStack.of("blockGlass");
ImmutableSet<IngredientStack> input = ImmutableSet.of(glass);
ItemStack output = BCTransportItems.plugLens.getStack(null, false);
AssemblyRecipeRegistry.register(new AssemblyRecipeBasic("lens-regular", 500 * MjAPI.MJ, input, output));
output = BCTransportItems.plugLens.getStack(null, true);
input = ImmutableSet.of(glass, IngredientStack.of(new ItemStack(Blocks.IRON_BARS)));
AssemblyRecipeRegistry.register(new AssemblyRecipeBasic("lens-filter", 500 * MjAPI.MJ, input, output));
}
}
use of buildcraft.api.recipes.AssemblyRecipeBasic in project BuildCraft by BuildCraft.
the class BCSiliconRecipes method addChipsetAssembly.
private static void addChipsetAssembly(int multiplier, String additional, EnumRedstoneChipset type) {
ItemStack output = type.getStack();
ImmutableSet.Builder<IngredientStack> inputs = ImmutableSet.builder();
inputs.add(new IngredientStack(CraftingHelper.getIngredient("dustRedstone")));
if (additional != null) {
inputs.add(new IngredientStack(CraftingHelper.getIngredient(additional)));
}
String name = String.format("chipset-%s", type);
AssemblyRecipe recp = new AssemblyRecipeBasic(name, multiplier * 10_000L * MjAPI.MJ, inputs.build(), output);
AssemblyRecipeRegistry.REGISTRY.put(recp.getRegistryName(), recp);
}
Aggregations