Skip to content

Commit

Permalink
Add ore dictionary support for altar recipes
Browse files Browse the repository at this point in the history
  • Loading branch information
ACGaming committed Jun 13, 2024
1 parent d1d851f commit aecd043
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
15 changes: 15 additions & 0 deletions src/main/java/mod/emt/harkenscythe/init/HSAltarRecipes.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package mod.emt.harkenscythe.init;

import java.util.List;
import java.util.Map;
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;

public class HSAltarRecipes
{
Expand All @@ -18,6 +21,12 @@ public static void addBloodRecipe(Item input, Item output, int requiredBlood)
BLOOD_INPUT_BLOODCOUNT_MAP.put(input, Math.max(requiredBlood, 10));
}

public static void addBloodRecipe(String oreDictName, Item output, int requiredBlood)
{
List<ItemStack> ores = OreDictionary.getOres(oreDictName);
for (ItemStack ore : ores) addBloodRecipe(ore.getItem(), output, requiredBlood);
}

public static boolean isValidInputBlood(Item input)
{
return BLOOD_INPUT_OUTPUT_MAP.containsKey(input) && BLOOD_INPUT_BLOODCOUNT_MAP.containsKey(input);
Expand All @@ -39,6 +48,12 @@ public static void addSoulRecipe(Item input, Item output, int requiredSouls)
SOUL_INPUT_SOULCOUNT_MAP.put(input, Math.max(requiredSouls, 10));
}

public static void addSoulRecipe(String oreDictName, Item output, int requiredSouls)
{
List<ItemStack> ores = OreDictionary.getOres(oreDictName);
for (ItemStack ore : ores) addSoulRecipe(ore.getItem(), output, requiredSouls);
}

public static boolean isValidInputSoul(Item input)
{
return SOUL_INPUT_OUTPUT_MAP.containsKey(input) && SOUL_INPUT_SOULCOUNT_MAP.containsKey(input);
Expand Down
9 changes: 4 additions & 5 deletions src/main/java/mod/emt/harkenscythe/init/HSRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.event.RegistryEvent;
Expand Down Expand Up @@ -71,14 +70,14 @@ public static void registerRecipes()
{
HSAltarRecipes.addBloodRecipe(HSItems.biomass_seed, HSItems.germinated_biomass_seed, 20);
HSAltarRecipes.addBloodRecipe(Items.GLASS_BOTTLE, Items.DRAGON_BREATH, 40);
HSAltarRecipes.addBloodRecipe(new ItemStack(Blocks.WOOL).getItem(), new ItemStack(HSBlocks.bloodweave_cloth).getItem(), 10); // TODO: OreDictionary
HSAltarRecipes.addBloodRecipe("wool", Item.getItemFromBlock(HSBlocks.soulweave_cloth), 10);

HSAltarRecipes.addSoulRecipe(Items.CAKE, HSItems.soul_cake, 10);
HSAltarRecipes.addSoulRecipe(Items.COOKIE, HSItems.soul_cookie, 10);
//HSAltarRecipes.addSoulRecipe(PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM), PotionTypes.AWKWARD).getItem(), Items.EXPERIENCE_BOTTLE, 40); // TODO: Something better for this?
HSAltarRecipes.addSoulRecipe(Items.IRON_INGOT, HSItems.livingmetal_ingot, 10);
HSAltarRecipes.addSoulRecipe(new ItemStack(Blocks.SAND).getItem(), new ItemStack(Blocks.SOUL_SAND).getItem(), 10); // TODO: OreDictionary
HSAltarRecipes.addSoulRecipe(new ItemStack(Blocks.WOOL).getItem(), new ItemStack(HSBlocks.soulweave_cloth).getItem(), 10); // TODO: OreDictionary
HSAltarRecipes.addSoulRecipe("ingotIron", HSItems.livingmetal_ingot, 10);
HSAltarRecipes.addSoulRecipe("sand", Item.getItemFromBlock(Blocks.SOUL_SAND), 10);
HSAltarRecipes.addSoulRecipe("wool", Item.getItemFromBlock(HSBlocks.soulweave_cloth), 10);
}

@SideOnly(Side.CLIENT)
Expand Down

0 comments on commit aecd043

Please sign in to comment.