Some more recipes

This commit is contained in:
modmuss50 2019-07-30 01:58:41 +01:00
parent 6c0f8afa68
commit b5d5ef2ca0
28 changed files with 523 additions and 115 deletions

View file

@ -26,16 +26,18 @@ package techreborn;
import net.fabricmc.api.ModInitializer; import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder; import net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder;
import net.fabricmc.fabric.api.registry.CommandRegistry;
import net.minecraft.block.DispenserBlock; import net.minecraft.block.DispenserBlock;
import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.server.command.CommandManager;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import reborncore.common.recipes.RecipeCrafter; import reborncore.common.recipes.RecipeCrafter;
import reborncore.common.registration.RegistrationManager; import reborncore.common.registration.RegistrationManager;
import reborncore.common.util.Torus; import reborncore.common.util.Torus;
import techreborn.blockentity.fusionReactor.FusionControlComputerBlockEntity;
import techreborn.client.GuiHandler; import techreborn.client.GuiHandler;
import techreborn.events.ModRegistry; import techreborn.events.ModRegistry;
import techreborn.events.StackToolTipHandler; import techreborn.events.StackToolTipHandler;
@ -43,7 +45,6 @@ import techreborn.init.*;
import techreborn.packets.ClientboundPackets; import techreborn.packets.ClientboundPackets;
import techreborn.packets.ServerboundPackets; import techreborn.packets.ServerboundPackets;
import techreborn.proxies.CommonProxy; import techreborn.proxies.CommonProxy;
import techreborn.blockentity.fusionReactor.FusionControlComputerBlockEntity;
import techreborn.utils.BehaviorDispenseScrapbox; import techreborn.utils.BehaviorDispenseScrapbox;
import techreborn.utils.StackWIPHandler; import techreborn.utils.StackWIPHandler;
import techreborn.world.WorldGenerator; import techreborn.world.WorldGenerator;
@ -118,6 +119,15 @@ public class TechReborn implements ModInitializer {
ModRecipes.postInit(); ModRecipes.postInit();
CommandRegistry.INSTANCE.register(false, dispatcher -> dispatcher.register(CommandManager.literal("recipe").executes(context -> {
try {
RecipeTemplate.generate(context.getSource().getPlayer());
} catch (Exception e){
e.printStackTrace();
}
return 0;
})));
LOGGER.info("TechReborn setup done!"); LOGGER.info("TechReborn setup done!");
} }

View file

@ -94,29 +94,7 @@ public class ModRecipes {
} }
private static void addCompressorRecipes() { private static void addCompressorRecipes() {
// RecipeHandler.addRecipe(Reference.COMPRESSOR_RECIPE, new CompressorRecipe(ItemIngots.getIngotByName("advanced_alloy"),
// ItemPlates.getPlateByName("advanced_alloy"), 400, 20));
// RecipeHandler.addRecipe(Reference.COMPRESSOR_RECIPE, new CompressorRecipe(ItemParts.getPartByName("carbon_mesh"),
// ItemPlates.getPlateByName("carbon"), 400, 2));
// RecipeHandler.addRecipe(Reference.COMPRESSOR_RECIPE, new CompressorRecipe(OreUtil.getStackFromName("plankWood", 1),
// OreUtil.getStackFromName("plateWood", 1), 300, 4));
// RecipeHandler.addRecipe(Reference.COMPRESSOR_RECIPE, new CompressorRecipe(OreUtil.getStackFromName("dustLazurite", 1),
// ItemPlates.getPlateByName("lazurite", 1), 300, 4));
// RecipeHandler.addRecipe(Reference.COMPRESSOR_RECIPE, new CompressorRecipe(OreUtil.getStackFromName("obsidian", 1),
// ItemPlates.getPlateByName("obsidian", 9), 300, 4));
// RecipeHandler.addRecipe(Reference.COMPRESSOR_RECIPE, new CompressorRecipe(OreUtil.getStackFromName("dustObsidian", 1),
// ItemPlates.getPlateByName("obsidian", 1), 300, 4));
// RecipeHandler.addRecipe(Reference.COMPRESSOR_RECIPE, new CompressorRecipe(OreUtil.getStackFromName("dustYellowGarnet", 1),
// ItemPlates.getPlateByName("YellowGarnet"), 300, 4));
// RecipeHandler.addRecipe(Reference.COMPRESSOR_RECIPE, new CompressorRecipe(OreUtil.getStackFromName("blockYellowGarnet", 1),
// ItemPlates.getPlateByName("YellowGarnet", 9), 300, 4));
// RecipeHandler.addRecipe(Reference.COMPRESSOR_RECIPE, new CompressorRecipe(OreUtil.getStackFromName("dustRedGarnet", 1),
// ItemPlates.getPlateByName("RedGarnet"), 300, 4));
// RecipeHandler.addRecipe(Reference.COMPRESSOR_RECIPE, new CompressorRecipe(OreUtil.getStackFromName("blockRedGarnet", 1),
// ItemPlates.getPlateByName("RedGarnet", 9), 300, 4));
// RecipeHandler.addRecipe(Reference.COMPRESSOR_RECIPE, new CompressorRecipe(OreUtil.getStackFromName("ingotRefinedIron", 1),
// ItemPlates.getPlateByName("RefinedIron"), 300, 4));
//
// ItemStack plate; // ItemStack plate;
// for (String ore : OreUtil.oreNames) { // for (String ore : OreUtil.oreNames) {
// if (ore.equals("iridium")) { // if (ore.equals("iridium")) {
@ -151,82 +129,7 @@ public class ModRecipes {
static void addGrinderRecipes() { static void addGrinderRecipes() {
// Vanilla
// int eutick = 2;
// int ticktime = 300;
// RecipeHandler.addRecipe(Reference.GRINDER_RECIPE, new GrinderRecipe(
// new ItemStack(Blocks.NETHERRACK),
// ItemDusts.getDustByName("netherrack"),
// 300, 27));
//
// RecipeHandler.addRecipe(Reference.GRINDER_RECIPE, new GrinderRecipe(
// new ItemStack(Blocks.END_STONE),
// ItemDusts.getDustByName("endstone"),
// 300, 16));
// RecipeHandler.addRecipe(Reference.GRINDER_RECIPE, new GrinderRecipe(
// new ItemStack(Items.ENDER_EYE),
// ItemDusts.getDustByName("ender_eye", 2),
// 200, 22));
// RecipeHandler.addRecipe(Reference.GRINDER_RECIPE, new GrinderRecipe(
// new ItemStack(Items.ENDER_PEARL),
// ItemDusts.getDustByName("ender_pearl", 2),
// 200, 22));
// RecipeHandler.addRecipe(Reference.GRINDER_RECIPE, new GrinderRecipe(
// new ItemStack(Blocks.LAPIS_ORE),
// new ItemStack(Items.DYE, 10, 4),
// 170, 19));
// RecipeHandler.addRecipe(Reference.GRINDER_RECIPE, new GrinderRecipe(
// new ItemStack(Blocks.OBSIDIAN),
// ItemDusts.getDustByName("obsidian", 4),
// 170, 19));
//
// RecipeHandler.addRecipe(Reference.GRINDER_RECIPE, new GrinderRecipe(
// new ItemStack(Items.BLAZE_ROD),
// new ItemStack(Items.BLAZE_POWDER, 4),
// 170, 19));
// if (OreUtil.doesOreExistAndValid("stoneMarble")) {
// ItemStack marbleStack = getOre("stoneMarble");
// marbleStack.setCount(1);
// RecipeHandler.addRecipe(Reference.GRINDER_RECIPE, new GrinderRecipe(
// marbleStack, ItemDusts.getDustByName("marble"),
// 120, 10));
// }
// if (OreUtil.doesOreExistAndValid("stoneBasalt")) {
// ItemStack marbleStack = getOre("stoneBasalt");
// marbleStack.setCount(1);
// RecipeHandler.addRecipe(Reference.GRINDER_RECIPE, new GrinderRecipe(
// marbleStack, ItemDusts.getDustByName("basalt"),
// 120, 10));
// }
//See comments bellow, this allows the ore to go to the product when it sometimes goes straight to dust. //See comments bellow, this allows the ore to go to the product when it sometimes goes straight to dust.
// RecipeHandler.addRecipe(Reference.GRINDER_RECIPE, new GrinderRecipe(
// "oreCoal", new ItemStack(Items.COAL, 2),
// 270, 31));
//
// RecipeHandler.addRecipe(Reference.GRINDER_RECIPE, new GrinderRecipe(
// "oreDiamond", new ItemStack(Items.DIAMOND, 1),
// 270, 31));
//
// RecipeHandler.addRecipe(Reference.GRINDER_RECIPE, new GrinderRecipe(
// "oreEmerald", new ItemStack(Items.EMERALD, 1),
// 270, 31));
//
// RecipeHandler.addRecipe(Reference.GRINDER_RECIPE, new GrinderRecipe(
// "oreRedstone", new ItemStack(Items.REDSTONE, 8),
// 270, 31));
//
// RecipeHandler.addRecipe(Reference.GRINDER_RECIPE, new GrinderRecipe(
// "oreQuartz", new ItemStack(Items.QUARTZ, 2),
// 270, 31));
// for (String oreDictionaryName : OreDictionary.getOreNames()) { // for (String oreDictionaryName : OreDictionary.getOreNames()) {
// if (isDictPrefixed(oreDictionaryName, "ore", "gem", "ingot")) { // if (isDictPrefixed(oreDictionaryName, "ore", "gem", "ingot")) {
@ -269,21 +172,6 @@ public class ModRecipes {
// } // }
} }
static void addVacuumFreezerRecipes() {
// RecipeHandler.addRecipe(Reference.VACUUM_FREEZER_RECIPE,
// new VacuumFreezerRecipe(new ItemStack(Blocks.ICE, 2), new ItemStack(Blocks.PACKED_ICE), 60, 64));
// TODO: Fix recipe
// RecipeHandler.addRecipe(Reference.VACUUM_FREEZER_RECIPE, new VacuumFreezerRecipe(
// ItemIngots.getIngotByName("hot_tungstensteel"), ItemIngots.getIngotByName("tungstensteel"), 440, 64));
// RecipeHandler.addRecipe(Reference.VACUUM_FREEZER_RECIPE, new VacuumFreezerRecipe(
// ItemCells.getCellByName("heliumplasma"), ItemCells.getCellByName("helium"), 440, 64));
//
// RecipeHandler.addRecipe(Reference.VACUUM_FREEZER_RECIPE,
// new VacuumFreezerRecipe(ItemCells.getCellByName("water"), ItemCells.getCellByName("cell"), 60, 64));
}
public static ItemStack getBucketWithFluid(Fluid fluid) { public static ItemStack getBucketWithFluid(Fluid fluid) {
return FluidUtil.getFilledBucket(new FluidInstance(fluid, 1000)); return FluidUtil.getFilledBucket(new FluidInstance(fluid, 1000));
} }

View file

@ -0,0 +1,120 @@
package techreborn.init;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.mojang.datafixers.Dynamic;
import com.mojang.datafixers.types.JsonOps;
import net.minecraft.client.MinecraftClient;
import net.minecraft.datafixers.NbtOps;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.text.LiteralText;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
import org.apache.commons.io.FileUtils;
import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Function;
public class RecipeTemplate {
public static void generate(PlayerEntity playerEntity) throws IOException {
if(playerEntity.inventory.getInvStack(0).isEmpty()){
playerEntity.sendMessage(new LiteralText("no machine in first slot"));
return;
}
List<ItemStack> inputs = new ArrayList<>();
List<ItemStack> outputs = new ArrayList<>();
Identifier type = Registry.ITEM.getId(playerEntity.inventory.getInvStack(0).getItem());
for (int i = 1; i < playerEntity.inventory.getInvSize(); i++) {
ItemStack stack = playerEntity.inventory.getInvStack(i);
if(!stack.isEmpty()){
if(i < 9){
outputs.add(stack);
} else {
inputs.add(stack);
}
}
}
JsonObject object = new JsonObject();
object.addProperty("type", type.toString());
object.addProperty("power", 20);
object.addProperty("time", 400);
{
JsonArray ingredients = new JsonArray();
Function<ItemStack, JsonObject> toIngredient = stack -> {
JsonObject jsonObject = new JsonObject();
if(stack.getItem() == TRContent.CELL){
jsonObject.addProperty("fluid", Registry.FLUID.getId(TRContent.CELL.getFluid(stack)).toString());
jsonObject.addProperty("holder", "techreborn:cell");
} else {
jsonObject.addProperty("item", Registry.ITEM.getId(stack.getItem()).toString());
if(stack.getCount() > 1){
jsonObject.addProperty("count", stack.getCount());
}
}
return jsonObject;
};
inputs.forEach(stack -> ingredients.add(toIngredient.apply(stack)));
object.add("ingredients", ingredients);
}
{
JsonArray results = new JsonArray();
Function<ItemStack, JsonObject> toResult = stack -> {
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("item", Registry.ITEM.getId(stack.getItem()).toString());
if(stack.getCount() > 1){
jsonObject.addProperty("count", stack.getCount());
}
if(stack.hasTag()){
jsonObject.add("tag", Dynamic.convert(NbtOps.INSTANCE, JsonOps.INSTANCE, stack.getTag()));
}
return jsonObject;
};
outputs.forEach(stack -> results.add(toResult.apply(stack)));
object.add("results", results);
}
String json = new GsonBuilder().setPrettyPrinting().create().toJson(object);
File dir = new File("C:\\Users\\mark\\Documents\\Modding\\1.14\\TechReborn\\");
System.out.println(dir.getAbsolutePath());
File file = null;
int i = 0;
while (file == null || file.exists()){
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();
}
file = new File(dir, "src/main/resources/data/techreborn/recipes/" + type.getPath() + "/" + name + (i == 0 ? "" : "_" + i) + ".json");
i ++;
}
FileUtils.writeStringToFile(file, json, StandardCharsets.UTF_8);
MinecraftClient.getInstance().keyboard.setClipboard(file.getAbsolutePath());
System.out.println(MinecraftClient.getInstance().keyboard.getClipboard());
playerEntity.sendMessage(new LiteralText("done: " + file.getAbsolutePath()));
}
}

View file

@ -0,0 +1,15 @@
{
"type": "techreborn:compressor",
"power": 20,
"time": 400,
"ingredients": [
{
"item": "techreborn:advanced_alloy_ingot"
}
],
"results": [
{
"item": "techreborn:advanced_alloy_plate"
}
]
}

View file

@ -0,0 +1,15 @@
{
"type": "techreborn:compressor",
"power": 20,
"time": 400,
"ingredients": [
{
"item": "techreborn:carbon_mesh"
}
],
"results": [
{
"item": "techreborn:carbon_plate"
}
]
}

View file

@ -0,0 +1,15 @@
{
"type": "techreborn:compressor",
"power": 20,
"time": 300,
"ingredients": [
{
"item": "techreborn:lazurite_dust"
}
],
"results": [
{
"item": "techreborn:lazurite_plate"
}
]
}

View file

@ -0,0 +1,15 @@
{
"type": "techreborn:compressor",
"power": 20,
"time": 450,
"ingredients": [
{
"item": "minecraft:obsidian"
}
],
"results": [
{
"item": "techreborn:obsidian_plate"
}
]
}

View file

@ -0,0 +1,15 @@
{
"type": "techreborn:compressor",
"power": 20,
"time": 300,
"ingredients": [
{
"item": "techreborn:obsidian_dust"
}
],
"results": [
{
"item": "techreborn:obsidian_plate"
}
]
}

View file

@ -0,0 +1,15 @@
{
"type": "techreborn:compressor",
"power": 20,
"time": 300,
"ingredients": [
{
"item": "techreborn:red_garnet_dust"
}
],
"results": [
{
"item": "techreborn:red_garnet_plate"
}
]
}

View file

@ -0,0 +1,16 @@
{
"type": "techreborn:compressor",
"power": 20,
"time": 400,
"ingredients": [
{
"item": "techreborn:red_garnet_storage_block"
}
],
"results": [
{
"item": "techreborn:red_garnet_plate",
"count": 9
}
]
}

View file

@ -0,0 +1,15 @@
{
"type": "techreborn:compressor",
"power": 20,
"time": 400,
"ingredients": [
{
"item": "techreborn:refined_iron_ingot"
}
],
"results": [
{
"item": "techreborn:refined_iron_plate"
}
]
}

View file

@ -0,0 +1,15 @@
{
"type": "techreborn:compressor",
"power": 10,
"time": 300,
"ingredients": [
{
"item": "minecraft:oak_planks"
}
],
"results": [
{
"item": "techreborn:wood_plate"
}
]
}

View file

@ -0,0 +1,15 @@
{
"type": "techreborn:compressor",
"power": 20,
"time": 300,
"ingredients": [
{
"item": "techreborn:yellow_garnet_dust"
}
],
"results": [
{
"item": "techreborn:yellow_garnet_plate"
}
]
}

View file

@ -0,0 +1,16 @@
{
"type": "techreborn:compressor",
"power": 20,
"time": 400,
"ingredients": [
{
"item": "techreborn:yellow_garnet_storage_block"
}
],
"results": [
{
"item": "techreborn:yellow_garnet_plate",
"count": 9
}
]
}

View file

@ -0,0 +1,16 @@
{
"type": "techreborn:grinder",
"power": 20,
"time": 200,
"ingredients": [
{
"item": "minecraft:blaze_rod"
}
],
"results": [
{
"item": "minecraft:blaze_powder",
"count": 4
}
]
}

View file

@ -0,0 +1,16 @@
{
"type": "techreborn:grinder",
"power": 20,
"time": 200,
"ingredients": [
{
"item": "minecraft:coal_ore"
}
],
"results": [
{
"item": "minecraft:coal",
"count": 2
}
]
}

View file

@ -0,0 +1,15 @@
{
"type": "techreborn:grinder",
"power": 30,
"time": 270,
"ingredients": [
{
"item": "minecraft:diamond_ore"
}
],
"results": [
{
"item": "minecraft:diamond"
}
]
}

View file

@ -0,0 +1,15 @@
{
"type": "techreborn:grinder",
"power": 30,
"time": 270,
"ingredients": [
{
"item": "minecraft:emerald_ore"
}
],
"results": [
{
"item": "minecraft:emerald"
}
]
}

View file

@ -0,0 +1,16 @@
{
"type": "techreborn:grinder",
"power": 20,
"time": 200,
"ingredients": [
{
"item": "minecraft:ender_eye"
}
],
"results": [
{
"item": "techreborn:ender_eye_dust",
"count": 2
}
]
}

View file

@ -0,0 +1,16 @@
{
"type": "techreborn:grinder",
"power": 20,
"time": 200,
"ingredients": [
{
"item": "minecraft:ender_pearl"
}
],
"results": [
{
"item": "techreborn:ender_pearl_dust",
"count": 2
}
]
}

View file

@ -0,0 +1,15 @@
{
"type": "techreborn:grinder",
"power": 20,
"time": 200,
"ingredients": [
{
"item": "minecraft:end_stone"
}
],
"results": [
{
"item": "techreborn:endstone_dust"
}
]
}

View file

@ -0,0 +1,16 @@
{
"type": "techreborn:grinder",
"power": 20,
"time": 200,
"ingredients": [
{
"item": "minecraft:lapis_ore"
}
],
"results": [
{
"item": "minecraft:lapis_lazuli",
"count": 10
}
]
}

View file

@ -0,0 +1,16 @@
{
"type": "techreborn:grinder",
"power": 20,
"time": 300,
"ingredients": [
{
"item": "minecraft:obsidian"
}
],
"results": [
{
"item": "techreborn:obsidian_dust",
"count": 4
}
]
}

View file

@ -0,0 +1,16 @@
{
"type": "techreborn:grinder",
"power": 30,
"time": 270,
"ingredients": [
{
"item": "minecraft:nether_quartz_ore"
}
],
"results": [
{
"item": "minecraft:quartz",
"count": 2
}
]
}

View file

@ -0,0 +1,16 @@
{
"type": "techreborn:grinder",
"power": 30,
"time": 270,
"ingredients": [
{
"item": "minecraft:redstone_ore"
}
],
"results": [
{
"item": "minecraft:redstone",
"count": 8
}
]
}

View file

@ -0,0 +1,19 @@
{
"type": "techreborn:vacuum_freezer",
"power": 60,
"time": 440,
"ingredients": [
{
"fluid": "techreborn:heliumplasma",
"holder": "techreborn:cell"
}
],
"results": [
{
"item": "techreborn:cell",
"tag": {
"fluid": "techreborn:helium"
}
}
]
}

View file

@ -0,0 +1,16 @@
{
"type": "techreborn:vacuum_freezer",
"power": 60,
"time": 64,
"ingredients": [
{
"item": "minecraft:ice",
"count": 2
}
],
"results": [
{
"item": "minecraft:packed_ice"
}
]
}

View file

@ -0,0 +1,15 @@
{
"type": "techreborn:vacuum_freezer",
"power": 64,
"time": 440,
"ingredients": [
{
"item": "techreborn:hot_tungstensteel_ingot"
}
],
"results": [
{
"item": "techreborn:tungstensteel_ingot"
}
]
}