This commit is contained in:
Boblet 2025-11-13 16:43:41 +01:00
parent 0c0a3c952b
commit c6a7d2aba4
9 changed files with 227 additions and 99 deletions

View File

@ -9,7 +9,7 @@ import java.util.Map;
import com.hbm.blocks.ModBlocks;
import com.hbm.handler.imc.ICompatNHNEI;
import com.hbm.inventory.gui.GUIITER;
import com.hbm.inventory.recipes.FusionRecipes;
import com.hbm.inventory.recipes.FusionRecipesLegacy;
import com.hbm.lib.RefStrings;
import codechicken.nei.NEIServerUtils;
@ -67,7 +67,7 @@ public class FusionRecipeHandler extends TemplateRecipeHandler implements ICompa
if(outputId.equals("fusion") && getClass() == FusionRecipeHandler.class) {
Map<ItemStack, ItemStack> recipes = FusionRecipes.getRecipes();
Map<ItemStack, ItemStack> recipes = FusionRecipesLegacy.getRecipes();
for(Map.Entry<ItemStack, ItemStack> recipe : recipes.entrySet()) {
this.arecipes.add(new SmeltingSet(recipe.getKey(), recipe.getValue()));
@ -81,7 +81,7 @@ public class FusionRecipeHandler extends TemplateRecipeHandler implements ICompa
@Override
public void loadCraftingRecipes(ItemStack result) {
Map<ItemStack, ItemStack> recipes = FusionRecipes.getRecipes();
Map<ItemStack, ItemStack> recipes = FusionRecipesLegacy.getRecipes();
for(Map.Entry<ItemStack, ItemStack> recipe : recipes.entrySet()) {
@ -104,7 +104,7 @@ public class FusionRecipeHandler extends TemplateRecipeHandler implements ICompa
@Override
public void loadUsageRecipes(ItemStack ingredient) {
Map<ItemStack, ItemStack> recipes = FusionRecipes.getRecipes();
Map<ItemStack, ItemStack> recipes = FusionRecipesLegacy.getRecipes();
for(Map.Entry<ItemStack, ItemStack> recipe : recipes.entrySet()) {

View File

@ -0,0 +1,37 @@
package com.hbm.inventory.recipes;
import java.util.ArrayList;
import java.util.List;
import com.hbm.inventory.recipes.loader.GenericRecipe;
import com.hbm.util.BobMathUtil;
import com.hbm.util.i18n.I18nUtil;
import net.minecraft.util.EnumChatFormatting;
public class FusionRecipe extends GenericRecipe {
// minimum klystron energy to ignite the plasma
public long ignitionTemp;
// plasma output energy at full blast
public long outputTemp;
public FusionRecipe(String name) { super(name); }
public FusionRecipe setInputEnergy(long ignitionTemp) { this.ignitionTemp = ignitionTemp; return this; }
public FusionRecipe setOutputEnergy(long outputTemp) { this.outputTemp = outputTemp; return this; }
public List<String> print() {
List<String> list = new ArrayList();
list.add(EnumChatFormatting.YELLOW + this.getLocalizedName());
duration(list);
power(list);
list.add(EnumChatFormatting.RED + I18nUtil.resolveKey("gui.recipe.fusionIn") + ": " + BobMathUtil.getShortNumber(ignitionTemp) + "KyU/t");
list.add(EnumChatFormatting.RED + I18nUtil.resolveKey("gui.recipe.fusionOut") + ": " + BobMathUtil.getShortNumber(outputTemp) + "TU/t");
input(list);
output(list);
return list;
}
}

View File

@ -1,83 +1,29 @@
package com.hbm.inventory.recipes;
import java.util.HashMap;
import java.util.Map.Entry;
import com.hbm.inventory.fluid.FluidType;
import com.hbm.inventory.FluidStack;
import com.hbm.inventory.fluid.Fluids;
import com.hbm.items.ModItems;
import com.hbm.inventory.recipes.loader.GenericRecipes;
import net.minecraft.item.ItemStack;
public class FusionRecipes extends GenericRecipes<FusionRecipe> {
public class FusionRecipes {
public static HashMap<FluidType, Integer> delays = new HashMap();
static {
delays.put(Fluids.PLASMA_DT, 900);
delays.put(Fluids.PLASMA_DH3, 600);
delays.put(Fluids.PLASMA_HD, 1200);
delays.put(Fluids.PLASMA_HT, 900);
delays.put(Fluids.PLASMA_XM, 1200);
delays.put(Fluids.PLASMA_BF, 150);
}
public static int getByproductDelay(FluidType plasma) {
Integer delay = delays.get(plasma);
return delay != null ? delay : 0;
}
public static HashMap<FluidType, Integer> levels = new HashMap();
static {
levels.put(Fluids.PLASMA_DT, 1000);
levels.put(Fluids.PLASMA_DH3, 2000);
levels.put(Fluids.PLASMA_HD, 1000);
levels.put(Fluids.PLASMA_HT, 1000);
levels.put(Fluids.PLASMA_XM, 3000);
levels.put(Fluids.PLASMA_BF, 4000);
}
public static int getBreedingLevel(FluidType plasma) {
Integer level = levels.get(plasma);
return level != null ? level : 0;
}
public static HashMap<FluidType, ItemStack> byproducts = new HashMap();
static {
byproducts.put(Fluids.PLASMA_DT, new ItemStack(ModItems.pellet_charged));
byproducts.put(Fluids.PLASMA_DH3, new ItemStack(ModItems.pellet_charged));
byproducts.put(Fluids.PLASMA_HD, new ItemStack(ModItems.pellet_charged));
byproducts.put(Fluids.PLASMA_HT, new ItemStack(ModItems.pellet_charged));
byproducts.put(Fluids.PLASMA_XM, new ItemStack(ModItems.powder_chlorophyte));
byproducts.put(Fluids.PLASMA_BF, new ItemStack(ModItems.powder_balefire));
}
public static ItemStack getByproduct(FluidType plasma) {
ItemStack byproduct = byproducts.get(plasma);
return byproduct != null ? byproduct.copy() : null;
}
public static HashMap<FluidType, Integer> steamprod = new HashMap();
static {
steamprod.put(Fluids.PLASMA_DT, 30);
steamprod.put(Fluids.PLASMA_DH3, 50);
steamprod.put(Fluids.PLASMA_HD, 20);
steamprod.put(Fluids.PLASMA_HT, 25);
steamprod.put(Fluids.PLASMA_XM, 60);
steamprod.put(Fluids.PLASMA_BF, 160);
}
public static int getSteamProduction(FluidType plasma) {
Integer steam = steamprod.get(plasma);
return steam != null ? steam : 0;
}
public static HashMap<ItemStack, ItemStack> getRecipes() {
public static final FusionRecipes INSTANCE = new FusionRecipes();
@Override public int inputItemLimit() { return 0; }
@Override public int inputFluidLimit() { return 3; }
@Override public int outputItemLimit() { return 1; }
@Override public int outputFluidLimit() { return 11; }
@Override public String getFileName() { return "hbmFusion.json"; }
@Override public FusionRecipe instantiateRecipe(String name) { return new FusionRecipe(name); }
@Override
public void registerDefaults() {
HashMap<ItemStack, ItemStack> map = new HashMap();
for(Entry<FluidType, ItemStack> entry : byproducts.entrySet()) {
map.put(new ItemStack(ModItems.fluid_icon, 1, entry.getKey().getID()), entry.getValue().copy());
}
return map;
long solenoid = 100_000;
this.register((FusionRecipe) new FusionRecipe("fus.d-t").setInputEnergy(1_000_000).setOutputEnergy(20_000_000)
.setPower(solenoid).setDuration(100)
.inputFluids(new FluidStack(Fluids.DEUTERIUM, 10), new FluidStack(Fluids.TRITIUM, 10))
.outputFluids(new FluidStack(Fluids.HELIUM4, 1_000)));
}
}

View File

@ -0,0 +1,83 @@
package com.hbm.inventory.recipes;
import java.util.HashMap;
import java.util.Map.Entry;
import com.hbm.inventory.fluid.FluidType;
import com.hbm.inventory.fluid.Fluids;
import com.hbm.items.ModItems;
import net.minecraft.item.ItemStack;
public class FusionRecipesLegacy {
public static HashMap<FluidType, Integer> delays = new HashMap();
static {
delays.put(Fluids.PLASMA_DT, 900);
delays.put(Fluids.PLASMA_DH3, 600);
delays.put(Fluids.PLASMA_HD, 1200);
delays.put(Fluids.PLASMA_HT, 900);
delays.put(Fluids.PLASMA_XM, 1200);
delays.put(Fluids.PLASMA_BF, 150);
}
public static int getByproductDelay(FluidType plasma) {
Integer delay = delays.get(plasma);
return delay != null ? delay : 0;
}
public static HashMap<FluidType, Integer> levels = new HashMap();
static {
levels.put(Fluids.PLASMA_DT, 1000);
levels.put(Fluids.PLASMA_DH3, 2000);
levels.put(Fluids.PLASMA_HD, 1000);
levels.put(Fluids.PLASMA_HT, 1000);
levels.put(Fluids.PLASMA_XM, 3000);
levels.put(Fluids.PLASMA_BF, 4000);
}
public static int getBreedingLevel(FluidType plasma) {
Integer level = levels.get(plasma);
return level != null ? level : 0;
}
public static HashMap<FluidType, ItemStack> byproducts = new HashMap();
static {
byproducts.put(Fluids.PLASMA_DT, new ItemStack(ModItems.pellet_charged));
byproducts.put(Fluids.PLASMA_DH3, new ItemStack(ModItems.pellet_charged));
byproducts.put(Fluids.PLASMA_HD, new ItemStack(ModItems.pellet_charged));
byproducts.put(Fluids.PLASMA_HT, new ItemStack(ModItems.pellet_charged));
byproducts.put(Fluids.PLASMA_XM, new ItemStack(ModItems.powder_chlorophyte));
byproducts.put(Fluids.PLASMA_BF, new ItemStack(ModItems.powder_balefire));
}
public static ItemStack getByproduct(FluidType plasma) {
ItemStack byproduct = byproducts.get(plasma);
return byproduct != null ? byproduct.copy() : null;
}
public static HashMap<FluidType, Integer> steamprod = new HashMap();
static {
steamprod.put(Fluids.PLASMA_DT, 30);
steamprod.put(Fluids.PLASMA_DH3, 50);
steamprod.put(Fluids.PLASMA_HD, 20);
steamprod.put(Fluids.PLASMA_HT, 25);
steamprod.put(Fluids.PLASMA_XM, 60);
steamprod.put(Fluids.PLASMA_BF, 160);
}
public static int getSteamProduction(FluidType plasma) {
Integer steam = steamprod.get(plasma);
return steam != null ? steam : 0;
}
public static HashMap<ItemStack, ItemStack> getRecipes() {
HashMap<ItemStack, ItemStack> map = new HashMap();
for(Entry<FluidType, ItemStack> entry : byproducts.entrySet()) {
map.put(new ItemStack(ModItems.fluid_icon, 1, entry.getKey().getID()), entry.getValue().copy());
}
return map;
}
}

View File

@ -116,32 +116,45 @@ public class GenericRecipe {
List<String> list = new ArrayList();
list.add(EnumChatFormatting.YELLOW + this.getLocalizedName());
// autoswitch group
autoSwitch(list);
duration(list);
power(list);
input(list);
output(list);
return list;
}
protected void autoSwitch(List<String> list) {
if(this.autoSwitchGroup != null) {
String[] lines = I18nUtil.resolveKeyArray("autoswitch", I18nUtil.resolveKey(this.autoSwitchGroup));
for(String line : lines) list.add(EnumChatFormatting.GOLD + line);
}
// duration (seconds)
}
protected void duration(List<String> list) {
if(duration > 0) {
double seconds = this.duration / 20D;
list.add(EnumChatFormatting.RED + I18nUtil.resolveKey("gui.recipe.duration") + ": " + seconds + "s");
}
// power / consumption
}
protected void power(List<String> list) {
if(power > 0) {
list.add(EnumChatFormatting.RED + I18nUtil.resolveKey("gui.recipe.consumption") + ": " + BobMathUtil.getShortNumber(power) + "HE/t");
}
}
// input label + items
protected void input(List<String> list) {
list.add(EnumChatFormatting.BOLD + I18nUtil.resolveKey("gui.recipe.input") + ":");
if(inputItem != null) for(AStack stack : inputItem) {
ItemStack display = stack.extractForCyclingDisplay(20);
list.add(" " + EnumChatFormatting.GRAY + display.stackSize + "x " + display.getDisplayName());
}
if (inputFluid != null) for (FluidStack fluid : inputFluid) list.add(" " + EnumChatFormatting.BLUE + fluid.fill + "mB " + fluid.type.getLocalizedName() + (fluid.pressure == 0 ? "" : " " + I18nUtil.resolveKey("gui.recipe.atPressure") + " " + EnumChatFormatting.RED + fluid.pressure + " PU"));
}
// output label + items
protected void output(List<String> list) {
list.add(EnumChatFormatting.BOLD + I18nUtil.resolveKey("gui.recipe.output") + ":");
if(outputItem != null) for(IOutput output : outputItem)
for(String line : output.getLabel()) list.add(" " + line);
@ -150,8 +163,6 @@ public class GenericRecipe {
" " + I18nUtil.resolveKey("gui.recipe.atPressure") + " " + EnumChatFormatting.RED + fluid.pressure + " PU";
list.add(" " + EnumChatFormatting.BLUE + fluid.fill + "mB " + fluid.type.getLocalizedName() + pressurePart);
}
return list;
}

View File

@ -49,7 +49,7 @@ public abstract class ModuleMachineBase {
if(recipe == null) return false;
// auto switch functionality
if(recipe.autoSwitchGroup != null && slots[inputSlots[0]] != null) {
if(recipe.autoSwitchGroup != null && inputSlots.length > 0 && slots[inputSlots[0]] != null) {
ItemStack itemToSwitchBy = slots[inputSlots[0]];
List<GenericRecipe> recipes = (List<GenericRecipe>) this.getRecipeSet().autoSwitchGroups.get(recipe.autoSwitchGroup);
if(recipes != null) for(GenericRecipe nextRec : recipes) {
@ -190,7 +190,7 @@ public abstract class ModuleMachineBase {
List<GenericRecipe> recipes = (List<GenericRecipe>) this.getRecipeSet().autoSwitchGroups.get(recipe.autoSwitchGroup); // why the FUCK does this need a cast
if(recipes != null) for(GenericRecipe newRec : recipes) {
if(newRec.inputItem == null) continue;
if(inputSlots[0] == slot && newRec.inputItem[0].matchesRecipe(stack, true)) {
if(inputSlots.length > 0 && inputSlots[0] == slot && newRec.inputItem[0].matchesRecipe(stack, true)) {
return true;
}
}

View File

@ -0,0 +1,28 @@
package com.hbm.module.machine;
import com.hbm.inventory.fluid.tank.FluidTank;
import com.hbm.inventory.recipes.FusionRecipes;
import com.hbm.inventory.recipes.loader.GenericRecipes;
import api.hbm.energymk2.IEnergyHandlerMK2;
import net.minecraft.item.ItemStack;
public class ModuleMachineFusion extends ModuleMachineBase {
public ModuleMachineFusion(int index, IEnergyHandlerMK2 battery, ItemStack[] slots) {
super(index, battery, slots);
this.inputSlots = new int[0];
this.outputSlots = new int[1];
this.inputTanks = new FluidTank[3];
this.outputTanks = new FluidTank[1];
}
@Override
public GenericRecipes getRecipeSet() {
return FusionRecipes.INSTANCE;
}
public ModuleMachineFusion itemOutput(int slot) { outputSlots[0] = slot; return this; }
public ModuleMachineFusion fluidInput(FluidTank a, FluidTank b, FluidTank c) { inputTanks[0] = a; inputTanks[1] = b; inputTanks[2] = c; return this; }
public ModuleMachineFusion fluidOutput(FluidTank a) { outputTanks[0] = a; return this; }
}

View File

@ -17,7 +17,7 @@ import com.hbm.inventory.fluid.tank.FluidTank;
import com.hbm.inventory.gui.GUIITER;
import com.hbm.inventory.recipes.BreederRecipes;
import com.hbm.inventory.recipes.BreederRecipes.BreederRecipe;
import com.hbm.inventory.recipes.FusionRecipes;
import com.hbm.inventory.recipes.FusionRecipesLegacy;
import com.hbm.items.ModItems;
import com.hbm.items.special.ItemFusionShield;
import com.hbm.lib.Library;
@ -114,7 +114,7 @@ public class TileEntityITER extends TileEntityMachineBase implements IEnergyRece
if(plasma.getFill() > 0) {
this.totalRuntime++;
int delay = FusionRecipes.getByproductDelay(plasma.getTankType());
int delay = FusionRecipesLegacy.getByproductDelay(plasma.getTankType());
if(delay > 0 && totalRuntime % delay == 0) produceByproduct();
}
@ -130,7 +130,7 @@ public class TileEntityITER extends TileEntityMachineBase implements IEnergyRece
}
}
int prod = FusionRecipes.getSteamProduction(plasma.getTankType());
int prod = FusionRecipesLegacy.getSteamProduction(plasma.getTankType());
for(int i = 0; i < 20; i++) {
@ -288,7 +288,7 @@ public class TileEntityITER extends TileEntityMachineBase implements IEnergyRece
return;
}
int level = FusionRecipes.getBreedingLevel(plasma.getTankType());
int level = FusionRecipesLegacy.getBreedingLevel(plasma.getTankType());
if(out.flux > level) {
this.progress = 0;
@ -337,7 +337,7 @@ public class TileEntityITER extends TileEntityMachineBase implements IEnergyRece
private void produceByproduct() {
ItemStack by = FusionRecipes.getByproduct(plasma.getTankType());
ItemStack by = FusionRecipesLegacy.getByproduct(plasma.getTankType());
if(by == null)
return;
@ -556,7 +556,7 @@ public class TileEntityITER extends TileEntityMachineBase implements IEnergyRece
@Override
public void provideExtraInfo(NBTTagCompound data) {
data.setBoolean(CompatEnergyControl.B_ACTIVE, this.isOn && plasma.getFill() > 0);
int output = FusionRecipes.getSteamProduction(plasma.getTankType());
int output = FusionRecipesLegacy.getSteamProduction(plasma.getTankType());
data.setDouble("consumption", output * 10);
data.setDouble("outputmb", output);
}

View File

@ -2,12 +2,14 @@ package com.hbm.tileentity.machine.fusion;
import com.hbm.inventory.container.ContainerFusionTorus;
import com.hbm.inventory.gui.GUIFusionTorus;
import com.hbm.module.machine.ModuleMachineFusion;
import com.hbm.tileentity.IGUIProvider;
import com.hbm.tileentity.machine.albion.TileEntityCooledBase;
import com.hbm.util.fauxpointtwelve.DirPos;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import io.netty.buffer.ByteBuf;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.util.AxisAlignedBB;
@ -15,6 +17,9 @@ import net.minecraft.world.World;
public class TileEntityFusionTorus extends TileEntityCooledBase implements IGUIProvider {
public ModuleMachineFusion fusionModule;
public TileEntityFusionTorus() {
super(3);
}
@ -26,17 +31,35 @@ public class TileEntityFusionTorus extends TileEntityCooledBase implements IGUIP
@Override
public void updateEntity() {
super.updateEntity();
}
@Override
public void serialize(ByteBuf buf) {
super.serialize(buf);
this.fusionModule.serialize(buf);
}
@Override
public void deserialize(ByteBuf buf) {
super.deserialize(buf);
this.fusionModule.deserialize(buf);
}
@Override
public long getMaxPower() {
return 0;
return 10_000_000;
}
/** Linearly scales up from 0% to 100% from 0 to 0.5, then stays at 100% */
public static double getSpeedScaled(double max, double level) {
if(level >= max * 0.5) return 1D;
return level / max * 2D;
}
@Override
public DirPos[] getConPos() {
return null;
return new DirPos[0]; // TBI
}
AxisAlignedBB bb = null;