Merge pull request #2021 from MellowArpeggiation/rbmk-crafting

Full RBMK crafting chains
This commit is contained in:
HbmMods 2025-03-28 09:44:54 +01:00 committed by GitHub
commit b1f4dfd984
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 212 additions and 30 deletions

View File

@ -2,6 +2,9 @@ package com.hbm.handler.nei;
import com.hbm.blocks.ModBlocks; import com.hbm.blocks.ModBlocks;
import com.hbm.inventory.recipes.FuelPoolRecipes; import com.hbm.inventory.recipes.FuelPoolRecipes;
import com.hbm.items.machine.ItemRBMKRod;
import net.minecraft.item.ItemStack;
public class FuelPoolHandler extends NEIUniversalHandler { public class FuelPoolHandler extends NEIUniversalHandler {
@ -13,4 +16,22 @@ public class FuelPoolHandler extends NEIUniversalHandler {
public String getKey() { public String getKey() {
return "ntmSpentDrum"; return "ntmSpentDrum";
} }
@Override
public void loadUsageRecipes(ItemStack ingredient) {
if(ingredient != null && ingredient.getItem() != null && ingredient.getItem() instanceof ItemRBMKRod) {
if(ItemRBMKRod.getCoreHeat(ingredient) < 50 && ItemRBMKRod.getHullHeat(ingredient) < 50) return;
}
super.loadUsageRecipes(ingredient);
}
@Override
public void loadCraftingRecipes(ItemStack ingredient) {
if(ingredient != null && ingredient.getItem() != null && ingredient.getItem() instanceof ItemRBMKRod) {
if(ItemRBMKRod.getCoreHeat(ingredient) >= 50 || ItemRBMKRod.getHullHeat(ingredient) >= 50) return;
}
super.loadCraftingRecipes(ingredient);
}
} }

View File

@ -0,0 +1,94 @@
package com.hbm.handler.nei;
import java.util.HashMap;
import com.hbm.inventory.RecipesCommon.ComparableStack;
import com.hbm.items.machine.ItemRBMKRod;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
public class RBMKRodDisassemblyHandler extends NEIUniversalHandler {
public RBMKRodDisassemblyHandler() {
super("RBMK Rod Disassembly", Blocks.crafting_table, getRecipes());
}
@Override
public String getKey() {
return "ntmRBMKDisassembly";
}
public static HashMap<ComparableStack, ItemStack> getRecipes() {
HashMap<ComparableStack, ItemStack> map = new HashMap<>();
for(ItemRBMKRod rod : ItemRBMKRod.craftableRods) {
for(int enrichment = 0; enrichment <= 4; enrichment++) {
ItemStack result = new ItemStack(rod.pellet, 8, enrichment);
map.put(new ComparableStackHeat(rod, false, enrichment, false), result);
if(rod.pellet.isXenonEnabled()) {
ItemStack resultPoison = new ItemStack(rod.pellet, 8, enrichment + 5);
map.put(new ComparableStackHeat(rod, false, enrichment, true), resultPoison);
}
}
}
return map;
}
// Don't show recipes for hot rods (which will cause it to only show cooling recipes)
@Override
public void loadUsageRecipes(ItemStack ingredient) {
if(ingredient != null && ingredient.getItem() != null && ingredient.getItem() instanceof ItemRBMKRod) {
if(ItemRBMKRod.getCoreHeat(ingredient) > 50 || ItemRBMKRod.getHullHeat(ingredient) > 50) return;
}
super.loadUsageRecipes(ingredient);
}
public static class ComparableStackHeat extends ComparableStack {
// I was going to filter by all of these, but found it is just best to show all possible recipes for everything but heat
private final boolean isHot;
private final int enrichment;
private final boolean hasPoison;
public ComparableStackHeat(Item item, boolean isHot) {
this(item, isHot, -1, false);
}
public ComparableStackHeat(Item item, boolean isHot, int enrichment, boolean hasPoison) {
super(item);
this.isHot = isHot;
this.enrichment = enrichment;
this.hasPoison = hasPoison;
}
public ItemStack toStack() {
ItemStack stack = super.toStack();
ItemRBMKRod rod = (ItemRBMKRod) stack.getItem();
if(enrichment >= 0) {
ItemRBMKRod.setYield(stack, Math.min(1 - ((double) enrichment) / 5, 0.99) * rod.yield);
} else {
ItemRBMKRod.setYield(stack, 0.2 * rod.yield);
}
if(hasPoison) ItemRBMKRod.setPoison(stack, 50);
if(!isHot) return stack;
ItemRBMKRod.setCoreHeat(stack, 100);
ItemRBMKRod.setHullHeat(stack, 50);
return stack;
}
@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result + enrichment;
result = prime * result + (hasPoison ? 1 : 0);
return result;
}
}
}

View File

@ -0,0 +1,40 @@
package com.hbm.handler.nei;
import java.util.HashMap;
import com.hbm.blocks.ModBlocks;
import com.hbm.inventory.RecipesCommon.ComparableStack;
import com.hbm.items.ModItems;
import com.hbm.items.special.ItemWasteLong;
import com.hbm.items.special.ItemWasteShort;
import net.minecraft.item.ItemStack;
public class RBMKWasteDecayHandler extends NEIUniversalHandler {
public RBMKWasteDecayHandler() {
super("Nuclear Waste Decay", ModBlocks.machine_storage_drum, getRecipes());
}
@Override
public String getKey() {
return "ntmRBMKWaste";
}
public static HashMap<ComparableStack, ItemStack> getRecipes() {
HashMap<ComparableStack, ItemStack> map = new HashMap<>();
for(ItemWasteShort.WasteClass waste : ItemWasteShort.WasteClass.values()) {
map.put(new ComparableStack(ModItems.nuclear_waste_short, 1, waste), new ItemStack(ModItems.nuclear_waste_short_depleted, 1, waste.ordinal()));
map.put(new ComparableStack(ModItems.nuclear_waste_short_tiny, 1, waste), new ItemStack(ModItems.nuclear_waste_short_depleted_tiny, 1, waste.ordinal()));
}
for(ItemWasteLong.WasteClass waste : ItemWasteLong.WasteClass.values()) {
map.put(new ComparableStack(ModItems.nuclear_waste_long, 1, waste), new ItemStack(ModItems.nuclear_waste_long_depleted, 1, waste.ordinal()));
map.put(new ComparableStack(ModItems.nuclear_waste_long_tiny, 1, waste), new ItemStack(ModItems.nuclear_waste_long_depleted_tiny, 1, waste.ordinal()));
}
return map;
}
}

View File

@ -8,10 +8,12 @@ import com.google.gson.JsonArray;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.stream.JsonWriter; import com.google.gson.stream.JsonWriter;
import com.hbm.handler.nei.RBMKRodDisassemblyHandler;
import com.hbm.inventory.RecipesCommon.ComparableStack; import com.hbm.inventory.RecipesCommon.ComparableStack;
import com.hbm.inventory.recipes.loader.SerializableRecipe; import com.hbm.inventory.recipes.loader.SerializableRecipe;
import com.hbm.items.ModItems; import com.hbm.items.ModItems;
import com.hbm.items.machine.ItemPWRFuel.EnumPWRFuel; import com.hbm.items.machine.ItemPWRFuel.EnumPWRFuel;
import com.hbm.items.machine.ItemRBMKRod;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -40,6 +42,12 @@ public class FuelPoolRecipes extends SerializableRecipe {
recipes.put(new ComparableStack(ModItems.waste_plate_pu238be, 1, 1), new ItemStack(ModItems.waste_plate_pu238be)); recipes.put(new ComparableStack(ModItems.waste_plate_pu238be, 1, 1), new ItemStack(ModItems.waste_plate_pu238be));
for(EnumPWRFuel pwr : EnumPWRFuel.values()) recipes.put(new ComparableStack(ModItems.pwr_fuel_hot, 1, pwr.ordinal()), new ItemStack(ModItems.pwr_fuel_depleted, 1, pwr.ordinal())); for(EnumPWRFuel pwr : EnumPWRFuel.values()) recipes.put(new ComparableStack(ModItems.pwr_fuel_hot, 1, pwr.ordinal()), new ItemStack(ModItems.pwr_fuel_depleted, 1, pwr.ordinal()));
for(ItemRBMKRod rod : ItemRBMKRod.craftableRods) {
ItemStack result = new ItemStack(rod);
ItemRBMKRod.setYield(result, 0.2 * rod.yield);
recipes.put(new RBMKRodDisassemblyHandler.ComparableStackHeat(rod, true), result);
}
} }
@Override @Override

View File

@ -32,6 +32,10 @@ public class ItemRBMKPellet extends ItemNuclearWaste {
return this; return this;
} }
public boolean isXenonEnabled() {
return hasXenon;
}
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs tabs, List list) { public void getSubItems(Item item, CreativeTabs tabs, List list) {

View File

@ -1,5 +1,6 @@
package com.hbm.items.machine; package com.hbm.items.machine;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.function.BiFunction; import java.util.function.BiFunction;
@ -56,9 +57,13 @@ public class ItemRBMKRod extends Item {
* i drew a fuel rod yay * i drew a fuel rod yay
*/ */
public static List<ItemRBMKRod> craftableRods = new ArrayList<>();
public ItemRBMKRod(ItemRBMKPellet pellet) { public ItemRBMKRod(ItemRBMKPellet pellet) {
this(pellet.fullName); this(pellet.fullName);
this.pellet = pellet; this.pellet = pellet;
craftableRods.add(this);
} }
public ItemRBMKRod(String fullName) { public ItemRBMKRod(String fullName) {
@ -420,6 +425,10 @@ public class ItemRBMKRod extends Item {
if(this == ModItems.rbmk_fuel_drx) { if(this == ModItems.rbmk_fuel_drx) {
if(ItemRBMKRod.getHullHeat(stack) >= 50 || ItemRBMKRod.getCoreHeat(stack) >= 50) {
list.add(EnumChatFormatting.GOLD + I18nUtil.resolveKey("desc.item.wasteCooling"));
}
if(selfRate > 0 || this.function == EnumBurnFunc.SIGMOID) { if(selfRate > 0 || this.function == EnumBurnFunc.SIGMOID) {
list.add(EnumChatFormatting.RED + I18nUtil.resolveKey("trait.rbmx.source")); list.add(EnumChatFormatting.RED + I18nUtil.resolveKey("trait.rbmx.source"));
} }
@ -440,6 +449,10 @@ public class ItemRBMKRod extends Item {
} else { } else {
if(ItemRBMKRod.getHullHeat(stack) >= 50 || ItemRBMKRod.getCoreHeat(stack) >= 50) {
list.add(EnumChatFormatting.GOLD + I18nUtil.resolveKey("desc.item.wasteCooling"));
}
if(selfRate > 0 || this.function == EnumBurnFunc.SIGMOID) { if(selfRate > 0 || this.function == EnumBurnFunc.SIGMOID) {
list.add(EnumChatFormatting.RED + I18nUtil.resolveKey("trait.rbmk.source")); list.add(EnumChatFormatting.RED + I18nUtil.resolveKey("trait.rbmk.source"));
} }

View File

@ -38,6 +38,8 @@ public class NEIRegistry {
handlers.add(new FusionRecipeHandler()); handlers.add(new FusionRecipeHandler());
handlers.add(new SILEXRecipeHandler()); handlers.add(new SILEXRecipeHandler());
handlers.add(new FuelPoolHandler()); handlers.add(new FuelPoolHandler());
handlers.add(new RBMKRodDisassemblyHandler());
handlers.add(new RBMKWasteDecayHandler());
handlers.add(new CrucibleSmeltingHandler()); handlers.add(new CrucibleSmeltingHandler());
handlers.add(new CrucibleAlloyingHandler()); handlers.add(new CrucibleAlloyingHandler());
handlers.add(new CrucibleCastingHandler()); handlers.add(new CrucibleCastingHandler());

View File

@ -14,19 +14,19 @@ public class DepthDeposit {
public static void generateConditionOverworld(World world, int x, int yMin, int yDev, int z, int size, double fill, Block block, Random rand, int chance) { public static void generateConditionOverworld(World world, int x, int yMin, int yDev, int z, int size, double fill, Block block, Random rand, int chance) {
if(rand.nextInt(chance) == 0) if(rand.nextInt(chance) == 0)
generate(world, x + rand.nextInt(16), yMin + rand.nextInt(yDev), z + rand.nextInt(16), size, fill, block, rand, Blocks.stone, ModBlocks.stone_depth); generate(world, x + rand.nextInt(16) + 8, yMin + rand.nextInt(yDev), z + rand.nextInt(16) + 8, size, fill, block, rand, Blocks.stone, ModBlocks.stone_depth);
} }
public static void generateConditionNether(World world, int x, int yMin, int yDev, int z, int size, double fill, Block block, Random rand, int chance) { public static void generateConditionNether(World world, int x, int yMin, int yDev, int z, int size, double fill, Block block, Random rand, int chance) {
if(rand.nextInt(chance) == 0) if(rand.nextInt(chance) == 0)
generate(world, x + rand.nextInt(16), yMin + rand.nextInt(yDev), z + rand.nextInt(16), size, fill, block, rand, Blocks.netherrack, ModBlocks.stone_depth_nether); generate(world, x + rand.nextInt(16) + 8, yMin + rand.nextInt(yDev), z + rand.nextInt(16) + 8, size, fill, block, rand, Blocks.netherrack, ModBlocks.stone_depth_nether);
} }
public static void generateCondition(World world, int x, int yMin, int yDev, int z, int size, double fill, Block block, Random rand, int chance, Block genTarget, Block filler) { public static void generateCondition(World world, int x, int yMin, int yDev, int z, int size, double fill, Block block, Random rand, int chance, Block genTarget, Block filler) {
if(rand.nextInt(chance) == 0) if(rand.nextInt(chance) == 0)
generate(world, x + rand.nextInt(16), yMin + rand.nextInt(yDev), z + rand.nextInt(16), size, fill, block, rand, genTarget, filler); generate(world, x + rand.nextInt(16) + 8, yMin + rand.nextInt(yDev), z + rand.nextInt(16) + 8, size, fill, block, rand, genTarget, filler);
} }
public static void generate(World world, int x, int y, int z, int size, double fill, Block block, Random rand, Block genTarget, Block filler) { public static void generate(World world, int x, int y, int z, int size, double fill, Block block, Random rand, Block genTarget, Block filler) {