mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
crucible smelting and alloying JSON configs
This commit is contained in:
parent
8134907dd9
commit
67ee28ddbe
@ -482,7 +482,6 @@ public class OreDictManager {
|
||||
OreDictionary.registerOre("blockGlassBlack", glass_ash);
|
||||
|
||||
MaterialShapes.registerCompatShapes();
|
||||
MatDistribution.register(); //TEMP
|
||||
}
|
||||
|
||||
public static String getReflector() {
|
||||
|
||||
@ -3,11 +3,21 @@ package com.hbm.inventory.material;
|
||||
import static com.hbm.inventory.material.Mats.*;
|
||||
import static com.hbm.inventory.material.MaterialShapes.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import com.hbm.inventory.OreDictManager;
|
||||
import com.hbm.inventory.RecipesCommon.AStack;
|
||||
import com.hbm.inventory.RecipesCommon.ComparableStack;
|
||||
import com.hbm.inventory.RecipesCommon.OreDictStack;
|
||||
import com.hbm.inventory.material.Mats.MaterialStack;
|
||||
import com.hbm.inventory.recipes.loader.SerializableRecipe;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.util.Compat;
|
||||
|
||||
@ -17,9 +27,10 @@ import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class MatDistribution {
|
||||
public class MatDistribution extends SerializableRecipe {
|
||||
|
||||
public static void register() {
|
||||
@Override
|
||||
public void registerDefaults() {
|
||||
//vanilla crap
|
||||
registerOre("stone", MAT_STONE, BLOCK.q(1));
|
||||
registerOre("cobblestone", MAT_STONE, BLOCK.q(1));
|
||||
@ -106,4 +117,73 @@ public class MatDistribution {
|
||||
|
||||
materialOreEntries.put(key, stacks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFileName() {
|
||||
return "hbmCrucibleSmelting.json";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getRecipeObject() {
|
||||
List entries = new ArrayList();
|
||||
entries.addAll(Mats.materialEntries.entrySet());
|
||||
entries.addAll(Mats.materialOreEntries.entrySet());
|
||||
return entries;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readRecipe(JsonElement recipe) {
|
||||
JsonObject obj = (JsonObject) recipe;
|
||||
AStack input = this.readAStack(obj.get("input").getAsJsonArray());
|
||||
List<MaterialStack> materials = new ArrayList();
|
||||
JsonArray output = obj.get("output").getAsJsonArray();
|
||||
for(int i = 0; i < output.size(); i++) {
|
||||
JsonArray entry = output.get(i).getAsJsonArray();
|
||||
String mat = entry.get(0).getAsString();
|
||||
int amount = entry.get(1).getAsInt();
|
||||
materials.add(new MaterialStack(Mats.matByName.get(mat), amount));
|
||||
}
|
||||
if(input instanceof ComparableStack) {
|
||||
Mats.materialEntries.put((ComparableStack) input, materials);
|
||||
} else if(input instanceof OreDictStack) {
|
||||
Mats.materialOreEntries.put(((OreDictStack) input).name, materials);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeRecipe(Object recipe, JsonWriter writer) throws IOException {
|
||||
AStack toSmelt = null;
|
||||
Entry entry = (Entry) recipe;
|
||||
List<MaterialStack> materials = (List<MaterialStack>) entry.getValue();
|
||||
if(entry.getKey() instanceof String) {
|
||||
toSmelt = new OreDictStack((String) entry.getKey());
|
||||
} else if(entry.getKey() instanceof ComparableStack) {
|
||||
toSmelt = (ComparableStack) entry.getKey();
|
||||
}
|
||||
if(toSmelt == null) return;
|
||||
writer.name("input");
|
||||
this.writeAStack(toSmelt, writer);
|
||||
writer.name("output").beginArray();
|
||||
writer.setIndent("");
|
||||
for(MaterialStack stack : materials) {
|
||||
writer.beginArray();
|
||||
writer.value(stack.material.names[0]).value(stack.amount);
|
||||
writer.endArray();
|
||||
}
|
||||
writer.endArray();
|
||||
writer.setIndent(" ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteRecipes() {
|
||||
Mats.materialEntries.clear();
|
||||
Mats.materialOreEntries.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getComment() {
|
||||
return "Defines a set of items that can be smelted. Smelting generated from the ore dictionary (prefix + material) is auto-generated and cannot be "
|
||||
+ "changed. This config only changes fixed items (like recycling for certain metallic objects) and ores (with variable byproducts). "
|
||||
+ "Amounts used are in quanta (1 quantum is 1/72 of an ingot or 1/8 of a nugget). Material names are the ore dict suffixes, case-sensitive.";
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,7 +6,9 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.inventory.RecipesCommon.AStack;
|
||||
@ -133,17 +135,63 @@ public class CrucibleRecipes extends SerializableRecipe {
|
||||
|
||||
@Override
|
||||
public String getComment() {
|
||||
return "/// under construction ///";
|
||||
return "ID must be unique, but not sequential. Order in which the recipes are defined determines the order in which they are displayed in-game. "
|
||||
+ "Frequency is the amount of ticks between operations, must be at least 1. The names are unlocalized by default, but if they can't be found in "
|
||||
+ "the lang files the names will be displayed as-is. The icon is what's being displayed when holding shift on the template.";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readRecipe(JsonElement recipe) {
|
||||
|
||||
JsonObject obj = (JsonObject) recipe;
|
||||
int id = obj.get("id").getAsInt();
|
||||
String name = obj.get("name").getAsString();
|
||||
int freq = obj.get("frequency").getAsInt();
|
||||
ItemStack icon = this.readItemStack(obj.get("icon").getAsJsonArray());
|
||||
MaterialStack[] input = new MaterialStack[obj.get("input").getAsJsonArray().size()];
|
||||
for(int i = 0; i < input.length; i++) {
|
||||
JsonArray entry = obj.get("input").getAsJsonArray().get(i).getAsJsonArray();
|
||||
String matname = entry.get(0).getAsString();
|
||||
int amount = entry.get(1).getAsInt();
|
||||
input[i] = new MaterialStack(Mats.matByName.get(matname), amount);
|
||||
}
|
||||
MaterialStack[] output = new MaterialStack[obj.get("output").getAsJsonArray().size()];
|
||||
for(int i = 0; i < input.length; i++) {
|
||||
JsonArray entry = obj.get("output").getAsJsonArray().get(i).getAsJsonArray();
|
||||
String matname = entry.get(0).getAsString();
|
||||
int amount = entry.get(1).getAsInt();
|
||||
input[i] = new MaterialStack(Mats.matByName.get(matname), amount);
|
||||
}
|
||||
recipes.add(new CrucibleRecipe(id, name, freq, icon).inputs(input).outputs(output));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeRecipe(Object recipe, JsonWriter writer) throws IOException {
|
||||
|
||||
CrucibleRecipe rec = (CrucibleRecipe) recipe;
|
||||
writer.name("id").value(rec.id);
|
||||
writer.name("name").value(rec.name);
|
||||
writer.name("frequency").value(rec.frequency);
|
||||
writer.name("icon");
|
||||
this.writeItemStack(rec.icon, writer);
|
||||
writer.name("input");
|
||||
writer.beginArray();
|
||||
for(MaterialStack mat : rec.input) {
|
||||
writer.beginArray();
|
||||
writer.setIndent("");
|
||||
writer.value(mat.material.names[0]).value(mat.amount);
|
||||
writer.endArray();
|
||||
writer.setIndent(" ");
|
||||
}
|
||||
writer.endArray();
|
||||
writer.name("output");
|
||||
writer.beginArray();
|
||||
for(MaterialStack mat : rec.output) {
|
||||
writer.beginArray();
|
||||
writer.setIndent("");
|
||||
writer.value(mat.material.names[0]).value(mat.amount);
|
||||
writer.endArray();
|
||||
writer.setIndent(" ");
|
||||
}
|
||||
writer.endArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -20,6 +20,7 @@ import com.hbm.inventory.RecipesCommon.ComparableStack;
|
||||
import com.hbm.inventory.RecipesCommon.OreDictStack;
|
||||
import com.hbm.inventory.fluid.FluidType;
|
||||
import com.hbm.inventory.fluid.Fluids;
|
||||
import com.hbm.inventory.material.MatDistribution;
|
||||
import com.hbm.inventory.recipes.*;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.main.MainRegistry;
|
||||
@ -45,6 +46,7 @@ public abstract class SerializableRecipe {
|
||||
recipeHandlers.add(new CyclotronRecipes());
|
||||
recipeHandlers.add(new HadronRecipes());
|
||||
recipeHandlers.add(new FuelPoolRecipes());
|
||||
recipeHandlers.add(new MatDistribution());
|
||||
}
|
||||
|
||||
public static void initialize() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user