From 2dca3e503464aa16c817ce4620aa2f5c19bad071 Mon Sep 17 00:00:00 2001 From: DarkGuardsman Date: Sun, 27 Oct 2013 04:13:17 -0400 Subject: [PATCH] Made ruble to dust output random --- src/dark/api/ProcessorRecipes.java | 27 +++++++++++++++++++--- src/dark/core/common/CoreRecipeLoader.java | 2 +- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/dark/api/ProcessorRecipes.java b/src/dark/api/ProcessorRecipes.java index 3fba2bd10..eac1886c4 100644 --- a/src/dark/api/ProcessorRecipes.java +++ b/src/dark/api/ProcessorRecipes.java @@ -35,6 +35,7 @@ public class ProcessorRecipes GRINDER(), PRESS(); public HashMap, ItemStack> recipes = new HashMap(); + public HashMap, Pair> output = new HashMap(); public HashMap, Pair> recipesChance = new HashMap(); public HashMap, Float> recipesChanceSalvage = new HashMap(); public HashMap, ItemStack> damagedOutput = new HashMap(); @@ -76,6 +77,11 @@ public class ProcessorRecipes * @param in - input item, stacksize is ignored * @param out - ouput item */ public static void createRecipe(ProcessorType type, Object in, Object out) + { + createRecipe(type, in, out, 1, 1); + } + + public static void createRecipe(ProcessorType type, Object in, Object out, int min, int max) { if (in != null && out != null && type != null) { @@ -84,9 +90,11 @@ public class ProcessorRecipes if (input != null && output != null) { HashMap, ItemStack> map = type.recipes; - if (map != null && !map.containsKey(new Pair(input.itemID, input.getItemDamage()))) + HashMap, Pair> map2 = type.output; + if (map != null && output != null) { map.put(new Pair(input.itemID, input.getItemDamage()), output); + map2.put(new Pair(input.itemID, input.getItemDamage()), new Pair(min, max)); } } } @@ -210,6 +218,7 @@ public class ProcessorRecipes return null; } HashMap, ItemStack> map = type.recipes; + HashMap, Pair> map2 = type.output; HashMap, Pair> mapChance = type.recipesChance; HashMap, Float> mapSalvage = type.recipesChanceSalvage; HashMap, ItemStack> altSalvageMap = type.damagedOutput; @@ -219,14 +228,26 @@ public class ProcessorRecipes if (map != null) { ItemStack re = map.get(new Pair(stack.itemID, -1)); + Pair range = map2.get(new Pair(stack.itemID, -1)); if (re != null) { - return new ItemStack[] { convert(re) }; + ItemStack retm = convert(re); + if (!(range.left() == 1 && range.right() == 1)) + { + retm.stackSize = range.left() + random.nextInt(range.right()); + } + return new ItemStack[] { retm }; } re = map.get(blockSet); + range = map2.get(blockSet); if (re != null) { - return new ItemStack[] { convert(re) }; + ItemStack retm = convert(re); + if (!(range.left() == 1 && range.right() == 1)) + { + retm.stackSize = range.left() + random.nextInt(range.right()); + } + return new ItemStack[] { retm }; } } diff --git a/src/dark/core/common/CoreRecipeLoader.java b/src/dark/core/common/CoreRecipeLoader.java index 8dc9b9443..3027f88b0 100644 --- a/src/dark/core/common/CoreRecipeLoader.java +++ b/src/dark/core/common/CoreRecipeLoader.java @@ -140,7 +140,7 @@ public class CoreRecipeLoader extends RecipeLoader { dust.stackSize = 2; FurnaceRecipes.smelting().addSmelting(dust.itemID, dust.getItemDamage(), ingot, 0.6f); - ProcessorRecipes.createRecipe(ProcessorType.GRINDER, rubble, dust); + ProcessorRecipes.createRecipe(ProcessorType.GRINDER, rubble, dust, 1, 4); dust.stackSize = 1; ProcessorRecipes.createRecipe(ProcessorType.GRINDER, scraps, dust); ProcessorRecipes.createRecipe(ProcessorType.GRINDER, ingot, dust);