From 86ce0f650993952a3a3b437f16e69d8a14c5b782 Mon Sep 17 00:00:00 2001 From: George Paton Date: Wed, 26 Mar 2025 11:50:35 +1100 Subject: [PATCH] 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")); }