From a2f5eeada77d1b0f0af84f5ba27add3644ede365 Mon Sep 17 00:00:00 2001 From: George Paton Date: Tue, 25 Mar 2025 16:42:00 +1100 Subject: [PATCH 1/3] Add crafting recipes for RBMK fuel cooling, rod disassembly, and waste decaying --- .../nei/RBMKRodDisassemblyHandler.java | 85 +++++++++ .../handler/nei/RBMKWasteDecayHandler.java | 40 ++++ .../inventory/recipes/FuelPoolRecipes.java | 12 +- .../com/hbm/items/machine/ItemRBMKPellet.java | 36 ++-- .../com/hbm/items/machine/ItemRBMKRod.java | 175 ++++++++++-------- src/main/java/com/hbm/main/NEIRegistry.java | 2 + 6 files changed, 251 insertions(+), 99 deletions(-) create mode 100644 src/main/java/com/hbm/handler/nei/RBMKRodDisassemblyHandler.java create mode 100644 src/main/java/com/hbm/handler/nei/RBMKWasteDecayHandler.java diff --git a/src/main/java/com/hbm/handler/nei/RBMKRodDisassemblyHandler.java b/src/main/java/com/hbm/handler/nei/RBMKRodDisassemblyHandler.java new file mode 100644 index 000000000..fe92ebec5 --- /dev/null +++ b/src/main/java/com/hbm/handler/nei/RBMKRodDisassemblyHandler.java @@ -0,0 +1,85 @@ +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 getRecipes() { + HashMap 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; + } + + public static class ComparableStackHeat extends ComparableStack { + + // I was going to filter by these, but found it is just best to show all possible recipes for everything but heat + // that and... I'm actually stumped on how to filter by NBT, seeing as both `isApplicable` and `matchesRecipe` don't seem to work + private final boolean matchHot; + private final int matchEnrichment; + private final boolean matchPoison; + + public ComparableStackHeat(Item item, boolean matchHot) { + this(item, matchHot, -1, false); + } + + public ComparableStackHeat(Item item, boolean matchHot, int matchEnrichment, boolean matchPoison) { + super(item); + this.matchHot = matchHot; + this.matchEnrichment = matchEnrichment; + this.matchPoison = matchPoison; + } + + public ItemStack toStack() { + ItemStack stack = super.toStack(); + ItemRBMKRod rod = (ItemRBMKRod) stack.getItem(); + if(matchEnrichment >= 0) { + ItemRBMKRod.setYield(stack, Math.max(1 - ((double) matchEnrichment) / 5, 0.05) * rod.yield); + } else { + ItemRBMKRod.setYield(stack, 0.2 * rod.yield); + } + if(matchPoison) ItemRBMKRod.setPoison(stack, 50); + if(!matchHot) 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 + matchEnrichment; + result = prime * result + (matchPoison ? 1 : 0); + return result; + } + + } +} \ No newline at end of file diff --git a/src/main/java/com/hbm/handler/nei/RBMKWasteDecayHandler.java b/src/main/java/com/hbm/handler/nei/RBMKWasteDecayHandler.java new file mode 100644 index 000000000..9be5a6ae2 --- /dev/null +++ b/src/main/java/com/hbm/handler/nei/RBMKWasteDecayHandler.java @@ -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 getRecipes() { + HashMap 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; + } + +} diff --git a/src/main/java/com/hbm/inventory/recipes/FuelPoolRecipes.java b/src/main/java/com/hbm/inventory/recipes/FuelPoolRecipes.java index 9f01c9d80..12bf21f4e 100644 --- a/src/main/java/com/hbm/inventory/recipes/FuelPoolRecipes.java +++ b/src/main/java/com/hbm/inventory/recipes/FuelPoolRecipes.java @@ -8,15 +8,17 @@ import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.stream.JsonWriter; +import com.hbm.handler.nei.RBMKRodDisassemblyHandler; import com.hbm.inventory.RecipesCommon.ComparableStack; import com.hbm.inventory.recipes.loader.SerializableRecipe; import com.hbm.items.ModItems; import com.hbm.items.machine.ItemPWRFuel.EnumPWRFuel; +import com.hbm.items.machine.ItemRBMKRod; import net.minecraft.item.ItemStack; public class FuelPoolRecipes extends SerializableRecipe { - + public static final HashMap recipes = new HashMap(); public static final FuelPoolRecipes instance = new FuelPoolRecipes(); @@ -38,8 +40,14 @@ public class FuelPoolRecipes extends SerializableRecipe { recipes.put(new ComparableStack(ModItems.waste_plate_sa326, 1, 1), new ItemStack(ModItems.waste_plate_sa326)); recipes.put(new ComparableStack(ModItems.waste_plate_ra226be, 1, 1), new ItemStack(ModItems.waste_plate_ra226be)); 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(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 diff --git a/src/main/java/com/hbm/items/machine/ItemRBMKPellet.java b/src/main/java/com/hbm/items/machine/ItemRBMKPellet.java index e50dbcd66..2b252f2ff 100644 --- a/src/main/java/com/hbm/items/machine/ItemRBMKPellet.java +++ b/src/main/java/com/hbm/items/machine/ItemRBMKPellet.java @@ -16,7 +16,7 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.IIcon; public class ItemRBMKPellet extends ItemNuclearWaste { - + public String fullName = ""; protected boolean hasXenon = true; @@ -26,12 +26,16 @@ public class ItemRBMKPellet extends ItemNuclearWaste { this.setMaxDamage(0); this.setCreativeTab(MainRegistry.controlTab); } - + public ItemRBMKPellet disableXenon() { this.hasXenon = false; return this; } + public boolean isXenonEnabled() { + return hasXenon; + } + @Override @SideOnly(Side.CLIENT) public void getSubItems(Item item, CreativeTabs tabs, List list) { @@ -39,10 +43,10 @@ public class ItemRBMKPellet extends ItemNuclearWaste { list.add(new ItemStack(item, 1, i)); } } - + @SideOnly(Side.CLIENT) private IIcon[] enrichmentOverlays; - + @SideOnly(Side.CLIENT) private IIcon xenonOverlay; @@ -50,13 +54,13 @@ public class ItemRBMKPellet extends ItemNuclearWaste { @SideOnly(Side.CLIENT) public void registerIcons(IIconRegister iconRegister) { super.registerIcons(iconRegister); - + this.enrichmentOverlays = new IIcon[5]; - + for(int i = 0; i < enrichmentOverlays.length; i++) { enrichmentOverlays[i] = iconRegister.registerIcon("hbm:rbmk_pellet_overlay_e" + i); } - + if(this.hasXenon) xenonOverlay = iconRegister.registerIcon("hbm:rbmk_pellet_overlay_xenon"); } @@ -71,16 +75,16 @@ public class ItemRBMKPellet extends ItemNuclearWaste { public int getRenderPasses(int meta) { return hasXenon(meta) ? 3 : 2; } - + @Override public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool) { super.addInformation(stack, player, list, bool); list.add(EnumChatFormatting.ITALIC + this.fullName); list.add(EnumChatFormatting.DARK_GRAY + "" + EnumChatFormatting.ITALIC + "Pellet for recycling"); - + int meta = rectify(stack.getItemDamage()); - + switch(meta % 5) { case 0: list.add(EnumChatFormatting.GOLD + "Brand New"); break; case 1: list.add(EnumChatFormatting.YELLOW + "Barely Depleted"); break; @@ -88,7 +92,7 @@ public class ItemRBMKPellet extends ItemNuclearWaste { case 3: list.add(EnumChatFormatting.DARK_GREEN + "Highly Depleted"); break; case 4: list.add(EnumChatFormatting.DARK_GRAY + "Fully Depleted"); break; } - + if(hasXenon(meta)) list.add(EnumChatFormatting.DARK_PURPLE + "High Xenon Poison"); } @@ -96,20 +100,20 @@ public class ItemRBMKPellet extends ItemNuclearWaste { @Override @SideOnly(Side.CLIENT) public IIcon getIconFromDamageForRenderPass(int meta, int pass) { - + if(pass == 0) return this.itemIcon; - + if(pass == 2) return this.xenonOverlay; - + return this.enrichmentOverlays[rectify(meta) % 5]; } - + public static boolean hasXenon(int meta) { return rectify(meta) >= 5; } - + public static int rectify(int meta) { return Math.abs(meta) % 10; } diff --git a/src/main/java/com/hbm/items/machine/ItemRBMKRod.java b/src/main/java/com/hbm/items/machine/ItemRBMKRod.java index 895c788c6..2b0fd0e98 100644 --- a/src/main/java/com/hbm/items/machine/ItemRBMKRod.java +++ b/src/main/java/com/hbm/items/machine/ItemRBMKRod.java @@ -1,5 +1,6 @@ package com.hbm.items.machine; +import java.util.ArrayList; import java.util.List; import java.util.Locale; import java.util.function.BiFunction; @@ -20,7 +21,7 @@ import net.minecraft.util.MathHelper; import net.minecraft.world.World; public class ItemRBMKRod extends Item { - + public ItemRBMKPellet pellet; public String fullName = ""; //full name of the fuel rod public double reactivity; //endpoint of the function @@ -35,7 +36,7 @@ public class ItemRBMKRod extends Item { public double diffusion = 0.02D; //the speed at which the core heats the hull public NType nType = NType.SLOW; //neutronType, the most efficient neutron type for fission public NType rType = NType.FAST; //releaseType, the type of neutrons released by this fuel - + /* _____ * ,I I I I, * |'-----'| @@ -52,18 +53,22 @@ public class ItemRBMKRod extends Item { * | | * '-----' * I I I I - * + * * i drew a fuel rod yay */ + public static List craftableRods = new ArrayList<>(); + public ItemRBMKRod(ItemRBMKPellet pellet) { this(pellet.fullName); this.pellet = pellet; + + craftableRods.add(this); } public ItemRBMKRod(String fullName) { this.fullName = fullName; - + this.setContainerItem(ModItems.rbmk_fuel_empty); this.setMaxStackSize(1); this.setCreativeTab(MainRegistry.controlTab); @@ -93,7 +98,7 @@ public class ItemRBMKRod extends Item { this.depFunc = func; return this; } - + public ItemRBMKRod setXenon(double gen, double burn) { this.xGen = gen; this.xBurn = burn; @@ -120,7 +125,7 @@ public class ItemRBMKRod extends Item { this.rType = rType; return this; } - + /** * Adjusts the input flux using the poison level * Generates, then burns poison @@ -131,82 +136,82 @@ public class ItemRBMKRod extends Item { * @return outFlux */ public double burn(World world, ItemStack stack, double inFlux) { - + inFlux += selfRate; - + //if xenon poison is enabled if(RBMKDials.getXenon(world)) { double xenon = getPoison(stack); xenon -= xenonBurnFunc(inFlux); - + inFlux *= (1D - getPoisonLevel(stack)); - + xenon += xenonGenFunc(inFlux); - + if(xenon < 0D) xenon = 0D; if(xenon > 100D) xenon = 100D; - + setPoison(stack, xenon); } - + double outFlux = reactivityFunc(inFlux, getEnrichment(stack)) * RBMKDials.getReactivityMod(world); //if depletion is enabled if(RBMKDials.getDepletion(world)) { double y = getYield(stack); y -= inFlux; - + if(y < 0D) y = 0D; - + setYield(stack, y); } - + double coreHeat = this.getCoreHeat(stack); coreHeat += outFlux * heat; - + this.setCoreHeat(stack, rectify(coreHeat)); - + return outFlux; } - + private double rectify(double num) { - + if(num > 1_000_000D) num = 1_000_000D; if(num < 20D || Double.isNaN(num)) num = 20D; - + return num; } - + /** * Heat up the core based on the outFlux, then move some heat to the hull * @param stack */ public void updateHeat(World world, ItemStack stack, double mod) { - + double coreHeat = this.getCoreHeat(stack); double hullHeat = this.getHullHeat(stack); - + if(coreHeat > hullHeat) { - + double mid = (coreHeat - hullHeat) / 2D; - + coreHeat -= mid * this.diffusion * RBMKDials.getFuelDiffusionMod(world) * mod; hullHeat += mid * this.diffusion * RBMKDials.getFuelDiffusionMod(world) * mod; - + this.setCoreHeat(stack, rectify(coreHeat)); this.setHullHeat(stack, rectify(hullHeat)); } } - + /** * return one tick's worth of heat and cool the hull of the fuel rod, this heat goes into the fuel rod assembly block * @param stack * @return */ public double provideHeat(World world, ItemStack stack, double heat, double mod) { - + double hullHeat = this.getHullHeat(stack); - + //metldown! the hull melts so the entire structure stops making sense //hull and core heats are instantly equalized into 33% of their sum each, //the rest is sent to the component which is always fatal @@ -217,20 +222,20 @@ public class ItemRBMKRod extends Item { this.setHullHeat(stack, avg); return avg - heat; } - + if(hullHeat <= heat) return 0; - + double ret = (hullHeat - heat) / 2; - + ret *= RBMKDials.getFuelHeatProvision(world) * mod; - + hullHeat -= ret; this.setHullHeat(stack, hullHeat); - + return ret; } - + public static enum EnumBurnFunc { PASSIVE(EnumChatFormatting.DARK_GREEN + "SAFE / PASSIVE"), //const, no reactivity LOG_TEN(EnumChatFormatting.YELLOW + "MEDIUM / LOGARITHMIC"), //log10(x + 1) * reactivity * 50 @@ -241,22 +246,22 @@ public class ItemRBMKRod extends Item { LINEAR(EnumChatFormatting.RED + "DANGEROUS / LINEAR"), //x * reactivity QUADRATIC(EnumChatFormatting.RED + "DANGEROUS / QUADRATIC"), //x^2 / 100 * reactivity EXPERIMENTAL(EnumChatFormatting.RED + "EXPERIMENTAL / SINE SLOPE"); //x * (sin(x) + 1) - + public String title = ""; - + private EnumBurnFunc(String title) { this.title = title; } } - + /** * @param enrichment [0;100] ...or at least those are sane levels * @return the amount of reactivity yielded, unmodified by xenon */ public double reactivityFunc(double in, double enrichment) { - + double flux = in * reactivityModByEnrichment(enrichment); - + switch(this.function) { case PASSIVE: return selfRate * enrichment; case LOG_TEN: return Math.log10(flux + 1) * 0.5D * reactivity; @@ -268,14 +273,14 @@ public class ItemRBMKRod extends Item { case QUADRATIC: return flux * flux / 10000D * reactivity; case EXPERIMENTAL: return flux * (Math.sin(flux) + 1) * reactivity; } - + return 0; } - + public String getFuncDescription(ItemStack stack) { - + String function; - + switch(this.function) { case PASSIVE: function = EnumChatFormatting.RED + "" + selfRate; break; @@ -297,20 +302,20 @@ public class ItemRBMKRod extends Item { break; default: function = "ERROR"; } - + double enrichment = getEnrichment(stack); - + if(enrichment < 1) { enrichment = reactivityModByEnrichment(enrichment); String reactivity = EnumChatFormatting.YELLOW + "" + ((int)(this.reactivity * enrichment * 1000D) / 1000D) + EnumChatFormatting.WHITE; String enrichmentPer = EnumChatFormatting.GOLD + " (" + ((int)(enrichment * 1000D) / 10D) + "%)"; - + return String.format(Locale.US, function, selfRate > 0 ? "(x" + EnumChatFormatting.RED + " + " + selfRate + "" + EnumChatFormatting.WHITE + ")" : "x", reactivity).concat(enrichmentPer); } - + return String.format(Locale.US, function, selfRate > 0 ? "(x" + EnumChatFormatting.RED + " + " + selfRate + "" + EnumChatFormatting.WHITE + ")" : "x", reactivity); } - + public static enum EnumDepleteFunc { LINEAR, //old function RAISING_SLOPE, //for breeding fuels such as MEU, maximum of 110% at 28% depletion @@ -318,9 +323,9 @@ public class ItemRBMKRod extends Item { GENTLE_SLOPE, //recommended for most fuels, maximum barely over the start, near the beginning STATIC; //for arcade-style neutron sources } - + public double reactivityModByEnrichment(double enrichment) { - + switch(this.depFunc) { default: case LINEAR: return enrichment; @@ -330,7 +335,7 @@ public class ItemRBMKRod extends Item { case GENTLE_SLOPE: return enrichment + (Math.sin(enrichment * Math.PI) / 3D); //x + (sin(x * pi) / 3) also works } } - + /** * Xenon generated per tick, linear function * @param flux @@ -339,7 +344,7 @@ public class ItemRBMKRod extends Item { public double xenonGenFunc(double flux) { return flux * xGen; } - + /** * Xenon burned away per tick, quadratic function * @param flux @@ -348,7 +353,7 @@ public class ItemRBMKRod extends Item { public double xenonBurnFunc(double flux) { return (flux * flux) / xBurn; } - + /** * @param stack * @return enrichment [0;1] @@ -356,7 +361,7 @@ public class ItemRBMKRod extends Item { public static double getEnrichment(ItemStack stack) { return getYield(stack) / ((ItemRBMKRod) stack.getItem()).yield; } - + /** * @param stack * @return poison [0;1] @@ -415,15 +420,19 @@ public class ItemRBMKRod extends Item { @Override public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool) { - + list.add(EnumChatFormatting.ITALIC + this.fullName); - + 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) { list.add(EnumChatFormatting.RED + I18nUtil.resolveKey("trait.rbmx.source")); } - + list.add(EnumChatFormatting.GREEN + I18nUtil.resolveKey("trait.rbmx.depletion", ((int)(((yield - getYield(stack)) / yield) * 100000)) / 1000D + "%")); list.add(EnumChatFormatting.DARK_PURPLE + I18nUtil.resolveKey("trait.rbmx.xenon", ((int)(getPoison(stack) * 1000D) / 1000D) + "%")); list.add(EnumChatFormatting.BLUE + I18nUtil.resolveKey("trait.rbmx.splitsWith", I18nUtil.resolveKey(nType.unlocalized + ".x"))); @@ -437,13 +446,17 @@ public class ItemRBMKRod extends Item { list.add(EnumChatFormatting.RED + I18nUtil.resolveKey("trait.rbmx.skinTemp", ((int)(getHullHeat(stack) * 10D) / 10D) + "m")); list.add(EnumChatFormatting.RED + I18nUtil.resolveKey("trait.rbmx.coreTemp", ((int)(getCoreHeat(stack) * 10D) / 10D) + "m")); list.add(EnumChatFormatting.DARK_RED + I18nUtil.resolveKey("trait.rbmx.melt", meltingPoint + "m")); - + } 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) { list.add(EnumChatFormatting.RED + I18nUtil.resolveKey("trait.rbmk.source")); } - + list.add(EnumChatFormatting.GREEN + I18nUtil.resolveKey("trait.rbmk.depletion", ((int)(((yield - getYield(stack)) / yield) * 100000D)) / 1000D + "%")); list.add(EnumChatFormatting.DARK_PURPLE + I18nUtil.resolveKey("trait.rbmk.xenon", ((int)(getPoison(stack) * 1000D) / 1000D) + "%")); list.add(EnumChatFormatting.BLUE + I18nUtil.resolveKey("trait.rbmk.splitsWith", I18nUtil.resolveKey(nType.unlocalized))); @@ -471,10 +484,10 @@ public class ItemRBMKRod extends Item { list.add(EnumChatFormatting.RED + "Skin temp: " + ((int)(getHullHeat(stack) * 10D) / 10D) + "°C"); list.add(EnumChatFormatting.RED + "Core temp: " + ((int)(getCoreHeat(stack) * 10D) / 10D) + "°C"); list.add(EnumChatFormatting.DARK_RED + "Melting point: " + meltingPoint + "°C");*/ - + super.addInformation(stack, player, list, bool); } - + /* __ __ ____ ________ * | \ | | | __ \ |__ __| * | \ | | | |__| | | | @@ -482,40 +495,40 @@ public class ItemRBMKRod extends Item { * | | \ | | |__| | | | * |__| \__| |_____/ |__| */ - + public static void setYield(ItemStack stack, double yield) { setDouble(stack, "yield", yield); } - + public static double getYield(ItemStack stack) { - + if(stack.getItem() instanceof ItemRBMKRod) { return getDouble(stack, "yield"); } - + return 0; } - + public static void setPoison(ItemStack stack, double xenon) { setDouble(stack, "xenon", xenon); } - + public static double getPoison(ItemStack stack) { return getDouble(stack, "xenon"); } - + public static void setCoreHeat(ItemStack stack, double heat) { setDouble(stack, "core", heat); } - + public static double getCoreHeat(ItemStack stack) { return getDouble(stack, "core"); } - + public static void setHullHeat(ItemStack stack, double heat) { setDouble(stack, "hull", heat); } - + public static double getHullHeat(ItemStack stack) { return getDouble(stack, "hull"); } @@ -529,23 +542,23 @@ public class ItemRBMKRod extends Item { public double getDurabilityForDisplay(ItemStack stack) { return 1D - getEnrichment(stack); } - + public static void setDouble(ItemStack stack, String key, double yield) { - + if(!stack.hasTagCompound()) setNBTDefaults(stack); - + stack.stackTagCompound.setDouble(key, yield); } - + public static double getDouble(ItemStack stack, String key) { - + if(!stack.hasTagCompound()) setNBTDefaults(stack); return stack.stackTagCompound.getDouble(key); } - + /** * Sets up the default values for all NBT data because doing it one-by-one will only correctly set the first called value and the rest stays 0 which is very not good * @param stack @@ -557,7 +570,7 @@ public class ItemRBMKRod extends Item { setCoreHeat(stack, 20.0D); setHullHeat(stack, 20.0D); } - + @Override public void onCreated(ItemStack stack, World world, EntityPlayer player) { setNBTDefaults(stack); //minimize the window where NBT screwups can happen diff --git a/src/main/java/com/hbm/main/NEIRegistry.java b/src/main/java/com/hbm/main/NEIRegistry.java index 12d7101c7..a7f6b916b 100644 --- a/src/main/java/com/hbm/main/NEIRegistry.java +++ b/src/main/java/com/hbm/main/NEIRegistry.java @@ -38,6 +38,8 @@ public class NEIRegistry { handlers.add(new FusionRecipeHandler()); handlers.add(new SILEXRecipeHandler()); handlers.add(new FuelPoolHandler()); + handlers.add(new RBMKRodDisassemblyHandler()); + handlers.add(new RBMKWasteDecayHandler()); handlers.add(new CrucibleSmeltingHandler()); handlers.add(new CrucibleAlloyingHandler()); handlers.add(new CrucibleCastingHandler()); From 86ce0f650993952a3a3b437f16e69d8a14c5b782 Mon Sep 17 00:00:00 2001 From: George Paton Date: Wed, 26 Mar 2025 11:50:35 +1100 Subject: [PATCH 2/3] if rod is hot, only show cooling recipe, if rod is cold, show only disassembly recipe --- .../com/hbm/handler/nei/FuelPoolHandler.java | 21 ++++++++ .../nei/RBMKRodDisassemblyHandler.java | 49 +++++++++++-------- .../com/hbm/items/machine/ItemRBMKRod.java | 4 +- 3 files changed, 52 insertions(+), 22 deletions(-) diff --git a/src/main/java/com/hbm/handler/nei/FuelPoolHandler.java b/src/main/java/com/hbm/handler/nei/FuelPoolHandler.java index cdbce5b5c..92b08e2c7 100644 --- a/src/main/java/com/hbm/handler/nei/FuelPoolHandler.java +++ b/src/main/java/com/hbm/handler/nei/FuelPoolHandler.java @@ -2,6 +2,9 @@ package com.hbm.handler.nei; import com.hbm.blocks.ModBlocks; import com.hbm.inventory.recipes.FuelPoolRecipes; +import com.hbm.items.machine.ItemRBMKRod; + +import net.minecraft.item.ItemStack; public class FuelPoolHandler extends NEIUniversalHandler { @@ -13,4 +16,22 @@ public class FuelPoolHandler extends NEIUniversalHandler { public String getKey() { 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); + } } diff --git a/src/main/java/com/hbm/handler/nei/RBMKRodDisassemblyHandler.java b/src/main/java/com/hbm/handler/nei/RBMKRodDisassemblyHandler.java index fe92ebec5..1e7decef2 100644 --- a/src/main/java/com/hbm/handler/nei/RBMKRodDisassemblyHandler.java +++ b/src/main/java/com/hbm/handler/nei/RBMKRodDisassemblyHandler.java @@ -38,35 +38,44 @@ public class RBMKRodDisassemblyHandler extends NEIUniversalHandler { return map; } - public static class ComparableStackHeat extends ComparableStack { - - // I was going to filter by these, but found it is just best to show all possible recipes for everything but heat - // that and... I'm actually stumped on how to filter by NBT, seeing as both `isApplicable` and `matchesRecipe` don't seem to work - private final boolean matchHot; - private final int matchEnrichment; - private final boolean matchPoison; - - public ComparableStackHeat(Item item, boolean matchHot) { - this(item, matchHot, -1, false); + // 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; } - public ComparableStackHeat(Item item, boolean matchHot, int matchEnrichment, boolean matchPoison) { + 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.matchHot = matchHot; - this.matchEnrichment = matchEnrichment; - this.matchPoison = matchPoison; + this.isHot = isHot; + this.enrichment = enrichment; + this.hasPoison = hasPoison; } public ItemStack toStack() { ItemStack stack = super.toStack(); ItemRBMKRod rod = (ItemRBMKRod) stack.getItem(); - if(matchEnrichment >= 0) { - ItemRBMKRod.setYield(stack, Math.max(1 - ((double) matchEnrichment) / 5, 0.05) * rod.yield); + 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(matchPoison) ItemRBMKRod.setPoison(stack, 50); - if(!matchHot) return stack; + if(hasPoison) ItemRBMKRod.setPoison(stack, 50); + if(!isHot) return stack; ItemRBMKRod.setCoreHeat(stack, 100); ItemRBMKRod.setHullHeat(stack, 50); return stack; @@ -76,8 +85,8 @@ public class RBMKRodDisassemblyHandler extends NEIUniversalHandler { public int hashCode() { final int prime = 31; int result = super.hashCode(); - result = prime * result + matchEnrichment; - result = prime * result + (matchPoison ? 1 : 0); + result = prime * result + enrichment; + result = prime * result + (hasPoison ? 1 : 0); return result; } diff --git a/src/main/java/com/hbm/items/machine/ItemRBMKRod.java b/src/main/java/com/hbm/items/machine/ItemRBMKRod.java index 2b0fd0e98..e9c502348 100644 --- a/src/main/java/com/hbm/items/machine/ItemRBMKRod.java +++ b/src/main/java/com/hbm/items/machine/ItemRBMKRod.java @@ -425,7 +425,7 @@ public class ItemRBMKRod extends Item { if(this == ModItems.rbmk_fuel_drx) { - if(ItemRBMKRod.getHullHeat(stack) >= 50 && ItemRBMKRod.getCoreHeat(stack) >= 50) { + if(ItemRBMKRod.getHullHeat(stack) >= 50 || ItemRBMKRod.getCoreHeat(stack) >= 50) { list.add(EnumChatFormatting.GOLD + I18nUtil.resolveKey("desc.item.wasteCooling")); } @@ -449,7 +449,7 @@ public class ItemRBMKRod extends Item { } else { - if(ItemRBMKRod.getHullHeat(stack) >= 50 && ItemRBMKRod.getCoreHeat(stack) >= 50) { + if(ItemRBMKRod.getHullHeat(stack) >= 50 || ItemRBMKRod.getCoreHeat(stack) >= 50) { list.add(EnumChatFormatting.GOLD + I18nUtil.resolveKey("desc.item.wasteCooling")); } From fe2dddec3b6aaf38ca599883af5a11916be59920 Mon Sep 17 00:00:00 2001 From: George Paton Date: Fri, 28 Mar 2025 19:10:12 +1100 Subject: [PATCH 3/3] bonus: fix cascading worldgen lag on depth deposits --- .../com/hbm/world/feature/DepthDeposit.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/hbm/world/feature/DepthDeposit.java b/src/main/java/com/hbm/world/feature/DepthDeposit.java index f3ac76f35..3a99b6198 100644 --- a/src/main/java/com/hbm/world/feature/DepthDeposit.java +++ b/src/main/java/com/hbm/world/feature/DepthDeposit.java @@ -12,40 +12,40 @@ import net.minecraft.world.World; 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) { - + 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) { - + 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) { - + 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) { - + for(int i = x - size; i <= x + size; i++) { for(int j = y - size; j <= y + size; j++) { for(int k = z - size; k <= z + size; k++) { - + if(j < 1 || j > 126) continue; - + double len = Vec3.createVectorHelper(x - i, y - j, z - k).lengthVector(); Block target = world.getBlock(i, j, k); - + if(target.isReplaceableOreGen(world, i, j, k, genTarget) || target.isReplaceableOreGen(world, i, j, k, Blocks.bedrock)) { //yes you've heard right, bedrock - + if(len + rand.nextInt(2) < size * fill) { world.setBlock(i, j, k, block); - + } else if(len + rand.nextInt(2) <= size) { world.setBlock(i, j, k, filler); }