arc furnace recipe autogen

This commit is contained in:
Boblet 2024-05-22 16:46:20 +02:00
parent 40cc6e009e
commit 6da3baf1fa
5 changed files with 176 additions and 20 deletions

View File

@ -1,11 +1,12 @@
## Changed
* Updated russian localization
* Updated russian and italian localization
* Nerfed conventional explosives (dynamite, TNT, semtex, C4) in order to not outclass small nukes
* Plastic explosive blocks no longer drop and blocks
* Sellafite diamond ore now shreds into diamond gravel
* ICF vessel blocks now use half as much fullerite as before
* ICF capacitor and turbocharger blocks are now quite a bit cheaper
* MEP is no longer self-igniting
* The foundry storage basin now holds 4 blocks worth of material instea of 1
## Fixed
* Fixed missing localization for meteorite ores and the new crucible materials

View File

@ -19,6 +19,7 @@ import com.hbm.hazard.HazardData;
import com.hbm.hazard.HazardEntry;
import com.hbm.hazard.HazardRegistry;
import com.hbm.hazard.HazardSystem;
import com.hbm.inventory.RecipesCommon.ComparableStack;
import com.hbm.inventory.material.MaterialShapes;
import com.hbm.inventory.material.Mats;
import com.hbm.inventory.material.NTMMaterial;
@ -665,13 +666,12 @@ public class OreDictManager {
recursionBrake = false;
if(event.Name.startsWith("ingot")) { ingots.add(event.Name); names.add(event.Name.substring(5)); }
if(event.Name.startsWith("ore")) { ores.add(event.Name); names.add(event.Name.substring(3)); }
if(event.Name.startsWith("ingot") || event.Name.startsWith("ore") || event.Name.startsWith("plate")) {
arcSmeltable.add(new ComparableStack(event.Ore));
}
}
public static final HashSet<String> ores = new HashSet();
public static final HashSet<String> ingots = new HashSet();
public static final HashSet<String> names = new HashSet();
public static final HashSet<ComparableStack> arcSmeltable = new HashSet();
public static class DictFrame {
public String[] mats;

View File

@ -1,22 +1,29 @@
package com.hbm.inventory.recipes;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;
import static com.hbm.inventory.OreDictManager.*;
import com.google.gson.JsonElement;
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.MaterialShapes;
import com.hbm.inventory.material.Mats;
import com.hbm.inventory.material.NTMMaterial;
import com.hbm.inventory.material.NTMMaterial.SmeltingBehavior;
import com.hbm.inventory.material.Mats.MaterialStack;
import com.hbm.inventory.recipes.loader.SerializableRecipe;
import com.hbm.items.ModItems;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraftforge.oredict.OreDictionary;
public class ArcFurnaceRecipes extends SerializableRecipe {
@ -31,6 +38,68 @@ public class ArcFurnaceRecipes extends SerializableRecipe {
recipes.put(new OreDictStack(QUARTZ.block()), new ArcFurnaceRecipe().solid(new ItemStack(ModItems.nugget_silicon, 12)) .fluid(new MaterialStack(Mats.MAT_SILICON, MaterialShapes.NUGGET.q(12))));
recipes.put(new OreDictStack(FIBER.ingot()), new ArcFurnaceRecipe().solid(new ItemStack(ModItems.nugget_silicon, 4)) .fluid(new MaterialStack(Mats.MAT_SILICON, MaterialShapes.INGOT.q(1, 2))));
recipes.put(new OreDictStack(FIBER.block()), new ArcFurnaceRecipe().solid(new ItemStack(ModItems.nugget_silicon, 40)) .fluid(new MaterialStack(Mats.MAT_SILICON, MaterialShapes.INGOT.q(9, 2))));
// Autogen for simple single type items
for(NTMMaterial material : Mats.orderedList) {
int in = material.convIn;
int out = material.convOut;
NTMMaterial convert = material.smeltsInto;
if(convert.smeltable == SmeltingBehavior.SMELTABLE) {
for(MaterialShapes shape : MaterialShapes.allShapes) {
String name = shape.name() + material.names[0];
if(!OreDictionary.getOres(name).isEmpty()) {
OreDictStack dict = new OreDictStack(name);
ArcFurnaceRecipe recipe = recipes.get(dict);
if(recipe == null) recipe = new ArcFurnaceRecipe();
if(recipe.fluidOutput == null) {
recipe.fluid(new MaterialStack(convert, (int) (shape.q(1) * out / in)));
recipes.put(dict, recipe);
}
}
}
}
}
// Autogen for custom smeltables
for(Entry<String, List<MaterialStack>> entry : Mats.materialOreEntries.entrySet()) {
OreDictStack dict = new OreDictStack(entry.getKey());
addCustomSmeltable(dict, entry.getValue());
}
for(Entry<ComparableStack, List<MaterialStack>> entry : Mats.materialEntries.entrySet()) {
addCustomSmeltable(entry.getKey(), entry.getValue());
}
// Autogen for furnace recipes
for(Object o : FurnaceRecipes.smelting().getSmeltingList().entrySet()) {
Entry entry = (Entry) o;
ItemStack input = (ItemStack) entry.getKey();
ItemStack output = (ItemStack) entry.getValue();
ComparableStack comp = new ComparableStack(input);
if(OreDictManager.arcSmeltable.contains(comp) || OreDictManager.arcSmeltable.contains(new ComparableStack(output))) {
ArcFurnaceRecipe recipe = recipes.get(comp);
if(recipe == null) recipe = new ArcFurnaceRecipe();
if(recipe.solidOutput == null) {
recipe.solid(output.copy());
recipes.put(comp, recipe);
}
}
}
}
private static void addCustomSmeltable(AStack astack, List<MaterialStack> mats) {
List<MaterialStack> smeltables = new ArrayList();
for(MaterialStack mat : mats) {
if(mat.material.smeltable == SmeltingBehavior.SMELTABLE) {
smeltables.add(mat);
}
}
ArcFurnaceRecipe recipe = recipes.get(astack);
if(recipe == null) recipe = new ArcFurnaceRecipe();
if(recipe.fluidOutput == null) {
recipe.fluid(smeltables.toArray(new MaterialStack[0]));
recipes.put(astack, recipe);
}
}
public static ArcFurnaceRecipe getOutput(ItemStack stack) {
@ -38,9 +107,10 @@ public class ArcFurnaceRecipes extends SerializableRecipe {
if(stack == null || stack.getItem() == null) return null;
ComparableStack comp = new ComparableStack(stack).makeSingular();
if(recipes.containsKey(comp))
return recipes.get(comp);
if(recipes.containsKey(comp)) return recipes.get(comp);
comp.meta = OreDictionary.WILDCARD_VALUE;
if(recipes.containsKey(comp)) return recipes.get(comp);
for(Entry<AStack, ArcFurnaceRecipe> entry : recipes.entrySet()) {
if(entry.getKey().matchesRecipe(stack, true)) return entry.getValue();
@ -66,12 +136,32 @@ public class ArcFurnaceRecipes extends SerializableRecipe {
@Override
public void readRecipe(JsonElement recipe) {
// TBI
}
@Override
public void writeRecipe(Object recipe, JsonWriter writer) throws IOException {
Entry<AStack, ArcFurnaceRecipe> rec = (Entry<AStack, ArcFurnaceRecipe>) recipe;
writer.name("input");
this.writeAStack(rec.getKey(), writer);
if(rec.getValue().solidOutput != null) {
writer.name("solid");
this.writeItemStack(rec.getValue().solidOutput, writer);
}
if(rec.getValue().fluidOutput != null) {
writer.name("fluid").beginArray();
writer.setIndent("");
for(MaterialStack stack : rec.getValue().fluidOutput) {
writer.beginArray();
writer.value(stack.material.names[0]).value(stack.amount);
writer.endArray();
}
writer.endArray();
writer.setIndent(" ");
}
}
public static class ArcFurnaceRecipe {

View File

@ -112,6 +112,6 @@ public class TileEntityFoundryTank extends TileEntityFoundryBase {
@Override
public int getCapacity() {
return MaterialShapes.BLOCK.q(1);
return MaterialShapes.BLOCK.q(4);
}
}

View File

@ -3,6 +3,7 @@ package com.hbm.tileentity.machine;
import java.util.ArrayList;
import java.util.List;
import com.hbm.blocks.ModBlocks;
import com.hbm.interfaces.IControlReceiver;
import com.hbm.inventory.UpgradeManager;
import com.hbm.inventory.container.ContainerMachineArcFurnaceLarge;
@ -19,8 +20,10 @@ import com.hbm.lib.Library;
import com.hbm.packet.AuxParticlePacketNT;
import com.hbm.packet.PacketDispatcher;
import com.hbm.tileentity.IGUIProvider;
import com.hbm.tileentity.IUpgradeInfoProvider;
import com.hbm.tileentity.TileEntityMachineBase;
import com.hbm.util.CrucibleUtil;
import com.hbm.util.I18nUtil;
import com.hbm.util.fauxpointtwelve.DirPos;
import api.hbm.energymk2.IEnergyReceiverMK2;
@ -34,11 +37,12 @@ import net.minecraft.inventory.Container;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityMachineArcFurnaceLarge extends TileEntityMachineBase implements IEnergyReceiverMK2, IControlReceiver, IGUIProvider {
public class TileEntityMachineArcFurnaceLarge extends TileEntityMachineBase implements IEnergyReceiverMK2, IControlReceiver, IGUIProvider, IUpgradeInfoProvider {
public long power;
public static final long maxPower = 10_000_000;
@ -87,7 +91,8 @@ public class TileEntityMachineArcFurnaceLarge extends TileEntityMachineBase impl
boolean electrodes = this.hasElectrodes();
UpgradeManager.eval(slots, 4, 4);
int upgrade = UpgradeManager.getLevel(UpgradeType.SPEED);
int upgrade = Math.min(UpgradeManager.getLevel(UpgradeType.SPEED), 3);
int consumption = (int) (1_000 * Math.pow(5, upgrade));
if(ingredients && electrodes && delay <= 0 && this.liquids.isEmpty()) {
if(lid > 0) {
@ -95,13 +100,17 @@ public class TileEntityMachineArcFurnaceLarge extends TileEntityMachineBase impl
if(lid < 0) lid = 0;
this.progress = 0;
} else {
int duration = 400 / (upgrade * 2 + 1);
this.progress += 1F / duration;
this.isProgressing = true;
if(this.progress >= 1F) {
this.process();
this.progress = 0;
this.delay = 120;
if(power >= consumption) {
int duration = 400 / (upgrade * 2 + 1);
this.progress += 1F / duration;
this.isProgressing = true;
this.power -= consumption;
if(this.progress >= 1F) {
this.process();
this.progress = 0;
this.delay = 120;
}
}
}
} else {
@ -330,6 +339,42 @@ public class TileEntityMachineArcFurnaceLarge extends TileEntityMachineBase impl
this.approachNum = 2;
}
@Override
public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt);
this.power = nbt.getLong("power");
this.liquidMode = nbt.getBoolean("liquidMode");
this.progress = nbt.getFloat("progress");
this.lid = nbt.getFloat("lid");
this.delay = nbt.getInteger("delay");
int count = nbt.getShort("count");
liquids.clear();
for(int i = 0; i < count; i++) {
liquids.add(new MaterialStack(Mats.matById.get(nbt.getInteger("m" + i)), nbt.getInteger("a" + i)));
}
}
@Override
public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt);
nbt.setLong("power", power);
nbt.setBoolean("liquidMode", liquidMode);
nbt.setFloat("progress", progress);
nbt.setFloat("lid", lid);
nbt.setInteger("delay", delay);
int count = liquids.size();
nbt.setShort("count", (short) count);
for(int i = 0; i < count; i++) {
MaterialStack mat = liquids.get(i);
nbt.setInteger("m" + i, mat.material.id);
nbt.setInteger("a" + i, mat.amount);
}
}
@Override
public long getPower() {
return power;
@ -393,4 +438,24 @@ public class TileEntityMachineArcFurnaceLarge extends TileEntityMachineBase impl
this.markDirty();
}
}
@Override
public boolean canProvideInfo(UpgradeType type, int level, boolean extendedInfo) {
return type == UpgradeType.SPEED;
}
@Override
public void provideInfo(UpgradeType type, int level, List<String> info, boolean extendedInfo) {
info.add(IUpgradeInfoProvider.getStandardLabel(ModBlocks.machine_arc_furnace));
if(type == UpgradeType.SPEED) {
info.add(EnumChatFormatting.GREEN + I18nUtil.resolveKey(this.KEY_DELAY, "-" + (100 - 100 / (level * 2 + 1)) + "%"));
info.add(EnumChatFormatting.RED + I18nUtil.resolveKey(this.KEY_CONSUMPTION, "+" + ((int) Math.pow(5, level) * 100 - 100) + "%"));
}
}
@Override
public int getMaxLevel(UpgradeType type) {
if(type == UpgradeType.SPEED) return 3;
return 0;
}
}