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 new file mode 100644 index 000000000..1e7decef2 --- /dev/null +++ b/src/main/java/com/hbm/handler/nei/RBMKRodDisassemblyHandler.java @@ -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 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; + } + + // 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; + } + + } +} \ 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 c1e39e213..59635dcdd 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; @@ -56,9 +57,13 @@ public class ItemRBMKRod extends Item { * 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) { @@ -420,6 +425,10 @@ public class ItemRBMKRod extends Item { 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")); } @@ -440,6 +449,10 @@ public class ItemRBMKRod extends Item { } 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")); } 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()); 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); }