Crate GregTech's MaterialLib parts instead of IndustrialCraft 2 copies

This commit is contained in:
Ruling-0 committed 2026-10-12 15:23:57 -05:00
1 parent e78b80e21d
commit f5e8fcd0a3
2 files changed
+19 -3

No files matched your search

@@ -34,4 +34,9 @@ public abstract class MaterialLibStacks {
return new Stack(id.toString(), stack.getItemDamage());
}
/// The named material's item in the named shape, or null when MaterialLib serves no such pair.
public static ItemStack getStack(String material, String shape) {
return StackResolver.getStack(material, shape, 1);
}
}
@@ -48,6 +48,7 @@ import forestry.core.items.EnumElectronTube;
import forestry.core.recipes.RecipeUtil;
import forestry.core.utils.ItemStackUtil;
import forestry.core.utils.Log;
import forestry.core.utils.MaterialLibStacks;
import forestry.core.utils.ModUtil;
import forestry.energy.blocks.BlockEngineType;
import forestry.energy.blocks.BlockRegistryEnergy;
@@ -227,7 +228,7 @@ public class PluginIC2 extends ForestryPlugin {
}
if (rubber != null) {
crateRegistry.registerCrate(rubber, "cratedRubber");
crateRegistry.registerCrate(cratedPart(rubber, "Rubber", "ingot"), "cratedRubber");
}
if (scrap != null) {
@@ -239,14 +240,24 @@ public class PluginIC2 extends ForestryPlugin {
}
if (silver != null) {
crateRegistry.registerCrateUsingOreDict(silver, "cratedSilver");
crateRegistry.registerCrateUsingOreDict(cratedPart(silver, "Silver", "ingot"), "cratedSilver");
}
if (brass != null) {
crateRegistry.registerCrateUsingOreDict(brass, "cratedBrass");
crateRegistry.registerCrateUsingOreDict(cratedPart(brass, "Bronze", "ingot"), "cratedBrass");
}
}
/// GregTech's MaterialLib part in place of IndustrialCraft 2's copy of it, so uncrating hands out the part that
/// GregTech's recipes produce.
private static ItemStack cratedPart(ItemStack ic2Part, String material, String shape) {
if (!ModUtil.isModLoaded("gregtech")) {
return ic2Part;
}
ItemStack part = MaterialLibStacks.getStack(material, shape);
return part != null ? part : ic2Part;
}
@Optional.Method(modid = "IC2")
protected void registerRecipes() {