From fdc263702ef22de74dd596c47afed1d140416f4a Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Sun, 20 Jul 2014 01:50:50 -0500 Subject: [PATCH] API Synced with Grinder canges. --- .../registries/GrinderRecipeManager.java | 14 +++++++ .../entries/AppEngGrinderRecipe.java | 37 ++++++++++++++++++- tile/grindstone/TileGrinder.java | 4 ++ 3 files changed, 54 insertions(+), 1 deletion(-) diff --git a/core/features/registries/GrinderRecipeManager.java b/core/features/registries/GrinderRecipeManager.java index 96b25173..4d0bd216 100644 --- a/core/features/registries/GrinderRecipeManager.java +++ b/core/features/registries/GrinderRecipeManager.java @@ -96,6 +96,20 @@ public class GrinderRecipeManager implements IGrinderRegistry, IOreListener injectRecipe( new AppEngGrinderRecipe( copy( in ), copy( out ), copy( optional ), chance, cost ) ); } + @Override + public void addRecipe(ItemStack in, ItemStack out, ItemStack optional, float chance, ItemStack optional2, float chance2, int cost) + { + if ( in == null || (optional == null && out == null && optional2 == null) ) + { + log( "Invalid Grinder Recipe Specified." ); + return; + } + + log( "Allow Grinding of " + Platform.getItemDisplayName( in ) + " to " + Platform.getItemDisplayName( out ) + " with optional " + + Platform.getItemDisplayName( optional ) + " for " + cost ); + injectRecipe( new AppEngGrinderRecipe( copy( in ), copy( out ), copy( optional ), chance, cost ) ); + } + @Override public IGrinderEntry getRecipeForInput(ItemStack input) { diff --git a/core/features/registries/entries/AppEngGrinderRecipe.java b/core/features/registries/entries/AppEngGrinderRecipe.java index f8bab220..ea8832a3 100644 --- a/core/features/registries/entries/AppEngGrinderRecipe.java +++ b/core/features/registries/entries/AppEngGrinderRecipe.java @@ -12,6 +12,9 @@ public class AppEngGrinderRecipe implements IGrinderEntry private float optionalChance; private ItemStack optionalOutput; + private float optionalChance2; + private ItemStack optionalOutput2; + private int energy; public AppEngGrinderRecipe(ItemStack a, ItemStack b, int cost) { @@ -30,6 +33,19 @@ public class AppEngGrinderRecipe implements IGrinderEntry energy = cost; } + public AppEngGrinderRecipe(ItemStack a, ItemStack b, ItemStack c, ItemStack d, float chance, float chance2, int cost) { + in = a; + out = b; + + optionalOutput = c; + optionalChance = chance; + + optionalOutput2 = d; + optionalChance2 = chance2; + + energy = cost; + } + @Override public ItemStack getInput() { @@ -75,7 +91,7 @@ public class AppEngGrinderRecipe implements IGrinderEntry @Override public void setOptionalOutput(ItemStack output, float chance) { - optionalOutput = output; + optionalOutput = output.copy(); optionalChance = chance; } @@ -85,4 +101,23 @@ public class AppEngGrinderRecipe implements IGrinderEntry return optionalChance; } + @Override + public ItemStack getSecondOptionalOutput() + { + return optionalOutput2; + } + + @Override + public void setSecondOptionalOutput(ItemStack output, float chance) + { + optionalChance2 = chance; + optionalOutput2 = output.copy(); + } + + @Override + public float getSecondOptionalChance() + { + return optionalChance2; + } + } diff --git a/tile/grindstone/TileGrinder.java b/tile/grindstone/TileGrinder.java index 1b66eaed..ea7fc93d 100644 --- a/tile/grindstone/TileGrinder.java +++ b/tile/grindstone/TileGrinder.java @@ -144,6 +144,10 @@ public class TileGrinder extends AEBaseInvTile implements ICrankable if ( chance <= r.getOptionalChance() ) addItem( sia, r.getOptionalOutput() ); + chance = (Platform.getRandomInt() % 2000) / 2000.0f; + if ( chance <= r.getSecondOptionalChance() ) + addItem( sia, r.getSecondOptionalOutput() ); + this.setInventorySlotContents( 6, null ); } }