From 476d9a478a583890a97361ceffc58d67cb3a61ef Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Sat, 2 Aug 2014 18:09:41 -0500 Subject: [PATCH] Re-did DuplicateItems, into Ore Camo Feature, better logic, and better config. --- core/AEConfig.java | 20 +++++-- core/Registration.java | 6 +- core/features/AEFeature.java | 2 +- core/features/DamagedItemDefinition.java | 25 ++------ core/features/IStackSrc.java | 15 +++++ core/features/ItemStackSrc.java | 20 ++++++- core/features/MaterialStackSrc.java | 36 ++++++++++++ .../registries/GrinderRecipeManager.java | 10 ++-- .../NEIHelpers/NEIAEShapedRecipeHandler.java | 13 +++-- .../NEIAEShapelessRecipeHandler.java | 13 +++-- items/materials/ItemMultiMaterial.java | 58 ++++++++++++++++--- items/materials/MaterialType.java | 20 ++++--- recipes/AEItemResolver.java | 3 +- recipes/game/ShapedRecipe.java | 32 ++++++++-- recipes/game/ShapelessRecipe.java | 25 ++++++-- 15 files changed, 226 insertions(+), 72 deletions(-) create mode 100644 core/features/IStackSrc.java create mode 100644 core/features/MaterialStackSrc.java diff --git a/core/AEConfig.java b/core/AEConfig.java index 8ee1b2bb..8184d1d3 100644 --- a/core/AEConfig.java +++ b/core/AEConfig.java @@ -16,6 +16,7 @@ import appeng.api.util.IConfigManager; import appeng.api.util.IConfigureableObject; import appeng.core.features.AEFeature; import appeng.core.settings.TickRates; +import appeng.items.materials.MaterialType; import appeng.util.ConfigManager; import appeng.util.IConfigManagerHost; import appeng.util.Platform; @@ -94,7 +95,7 @@ public class AEConfig extends Configuration implements IConfigureableObject, ICo public String grinderOres[] = { // Vanilla Items - "Obsidian", "Ender", "Coal", "Iron", "Gold", "Charcoal", "NetherQuartz", + "Obsidian", "Ender", "EnderPearl", "Coal", "Iron", "Gold", "Charcoal", "NetherQuartz", // Common Mod Ores "Copper", "Tin", "Silver", "Lead", "Bronze", // AE @@ -260,9 +261,6 @@ public class AEConfig extends Configuration implements IConfigureableObject, ICo featureFlags.add( feature ); } - if ( featureFlags.contains( AEFeature.WebsiteRecipes ) ) - featureFlags.add( AEFeature.DuplicateItems ); - if ( cpw.mods.fml.common.Loader.isModLoaded( "ImmibisMicroblocks" ) ) featureFlags.remove( AEFeature.AlphaPass ); @@ -302,6 +300,20 @@ public class AEConfig extends Configuration implements IConfigureableObject, ICo updateable = true; } + public boolean useAEVersion(MaterialType mt) + { + if ( isFeatureEnabled( AEFeature.WebsiteRecipes ) ) + return true; + + setCategoryComment( + "OreCamouflage", + "AE2 Automatically uses alternative ores present in your instance of MC to blend better with its surroundings, if you prefer you can disable this selectively using these flags; Its important to note, that some if these items even if enabled may not be craftable in game because other items are overriding their recipes." ); + Property p = get( "OreCamouflage", mt.name(), true ); + p.comment = "OreDictionary Names: " + mt.getOreName(); + + return !p.getBoolean( true ); + } + private String getListComment(Enum value) { String comment = null; diff --git a/core/Registration.java b/core/Registration.java index e8d31762..677c3296 100644 --- a/core/Registration.java +++ b/core/Registration.java @@ -80,6 +80,7 @@ import appeng.core.features.AEFeatureHandler; import appeng.core.features.ColoredItemDefinition; import appeng.core.features.DamagedItemDefinition; import appeng.core.features.IAEFeature; +import appeng.core.features.IStackSrc; import appeng.core.features.ItemStackSrc; import appeng.core.features.NullItemDefinition; import appeng.core.features.WrappedDamageItemDefinition; @@ -234,7 +235,7 @@ public class Registration else { Field f = materialClass.getField( "material" + mat.name() ); - ItemStackSrc is = ((ItemMultiMaterial) materialItem.item()).createMaterial( mat ); + IStackSrc is = ((ItemMultiMaterial) materialItem.item()).createMaterial( mat ); if ( is != null ) f.set( materials, new DamagedItemDefinition( is ) ); else @@ -509,6 +510,9 @@ public class Registration public void Init(FMLInitializationEvent event) { + // Perform ore camouflage! + ItemMultiMaterial.instance.unduplicate(); + if ( AEConfig.instance.isFeatureEnabled( AEFeature.CustomRecipes ) ) recipeHandler.parseRecipes( new ConfigLoader( AppEng.instance.getConfigPath() ), "index.recipe" ); else diff --git a/core/features/AEFeature.java b/core/features/AEFeature.java index 3ec29d16..8fb05e83 100644 --- a/core/features/AEFeature.java +++ b/core/features/AEFeature.java @@ -46,7 +46,7 @@ public enum AEFeature MassCannonBlockDamage("BlockFeatures"), TinyTNTBlockDamage("BlockFeatures"), Facades("Facades"), - DuplicateItems("Misc", false), Profiler("Services", false), VersionChecker("Services"), UnsupportedDeveloperTools("Misc", false), Creative("Misc"), + Profiler("Services", false), VersionChecker("Services"), UnsupportedDeveloperTools("Misc", false), Creative("Misc"), GrinderLogging("Misc", false), Logging("Misc"), IntegrationLogging("Misc", false), CustomRecipes("Crafting", false), WebsiteRecipes("Misc", false), diff --git a/core/features/DamagedItemDefinition.java b/core/features/DamagedItemDefinition.java index 40423350..60730878 100644 --- a/core/features/DamagedItemDefinition.java +++ b/core/features/DamagedItemDefinition.java @@ -10,20 +10,10 @@ import appeng.api.util.AEItemDefinition; public class DamagedItemDefinition implements AEItemDefinition { - final Item baseItem; - final int damage; + final IStackSrc src; - public DamagedItemDefinition(ItemStackSrc is) { - if ( is == null ) - { - baseItem = null; - damage = -1; - } - else - { - baseItem = is.item; - damage = is.damage; - } + public DamagedItemDefinition(IStackSrc is) { + src = is; } @Override @@ -35,7 +25,7 @@ public class DamagedItemDefinition implements AEItemDefinition @Override public Item item() { - return baseItem; + return src.getItem(); } @Override @@ -47,10 +37,7 @@ public class DamagedItemDefinition implements AEItemDefinition @Override public ItemStack stack(int stackSize) { - if ( baseItem == null ) - return null; - - return new ItemStack( baseItem, stackSize, damage ); + return src.stack( stackSize ); } @Override @@ -59,7 +46,7 @@ public class DamagedItemDefinition implements AEItemDefinition if ( comparableItem == null ) return false; - return comparableItem.getItem() == baseItem && comparableItem.getItemDamage() == damage; + return comparableItem.getItem() == src.getItem() && comparableItem.getItemDamage() == src.getDamage(); } @Override diff --git a/core/features/IStackSrc.java b/core/features/IStackSrc.java new file mode 100644 index 00000000..8c564c2d --- /dev/null +++ b/core/features/IStackSrc.java @@ -0,0 +1,15 @@ +package appeng.core.features; + +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +public interface IStackSrc +{ + + ItemStack stack(int i); + + Item getItem(); + + int getDamage(); + +} diff --git a/core/features/ItemStackSrc.java b/core/features/ItemStackSrc.java index 75a40daa..d91fee48 100644 --- a/core/features/ItemStackSrc.java +++ b/core/features/ItemStackSrc.java @@ -4,7 +4,7 @@ import net.minecraft.block.Block; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -public class ItemStackSrc +public class ItemStackSrc implements IStackSrc { public final Item item; @@ -23,11 +23,27 @@ public class ItemStackSrc damage = dmg; } + @Override public ItemStack stack(int i) { if ( block != null ) return new ItemStack( block, i, damage ); - return new ItemStack( item, i, damage ); + + if ( item != null ) + return new ItemStack( item, i, damage ); + + return null; } + @Override + public Item getItem() + { + return item; + } + + @Override + public int getDamage() + { + return damage; + } } diff --git a/core/features/MaterialStackSrc.java b/core/features/MaterialStackSrc.java new file mode 100644 index 00000000..4150b878 --- /dev/null +++ b/core/features/MaterialStackSrc.java @@ -0,0 +1,36 @@ +package appeng.core.features; + +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import appeng.items.materials.MaterialType; + +public class MaterialStackSrc implements IStackSrc +{ + + MaterialType src; + + public MaterialStackSrc(MaterialType src) { + this.src = src; + if ( src == null ) + throw new RuntimeException( "Invalid Item Stack" ); + } + + @Override + public ItemStack stack(int stackSize) + { + return src.stack( stackSize ); + } + + @Override + public Item getItem() + { + return src.itemInstance; + } + + @Override + public int getDamage() + { + return src.damageValue; + } + +} diff --git a/core/features/registries/GrinderRecipeManager.java b/core/features/registries/GrinderRecipeManager.java index 4d0bd216..8145029f 100644 --- a/core/features/registries/GrinderRecipeManager.java +++ b/core/features/registries/GrinderRecipeManager.java @@ -46,7 +46,9 @@ public class GrinderRecipeManager implements IGrinderRegistry, IOreListener addIngot( "Iron", new ItemStack( Items.iron_ingot ) ); addOre( "Obsidian", new ItemStack( Blocks.obsidian ) ); + addIngot( "Ender", new ItemStack( Items.ender_pearl ) ); + addIngot( "EnderPearl", new ItemStack( Items.ender_pearl ) ); addIngot( "Wheat", new ItemStack( Items.wheat ) ); @@ -226,7 +228,7 @@ public class GrinderRecipeManager implements IGrinderRegistry, IOreListener @Override public void oreRegistered(String Name, ItemStack item) { - if ( Name.startsWith( "ore" ) || Name.startsWith( "crystal" ) || Name.startsWith( "ingot" ) || Name.startsWith( "dust" ) ) + if ( Name.startsWith( "ore" ) || Name.startsWith( "crystal" ) || Name.startsWith( "gem" ) || Name.startsWith( "ingot" ) || Name.startsWith( "dust" ) ) { for (String ore : AEConfig.instance.grinderOres) { @@ -234,11 +236,7 @@ public class GrinderRecipeManager implements IGrinderRegistry, IOreListener { addOre( ore, item ); } - else if ( Name.equals( "crystal" + ore ) ) - { - addIngot( ore, item ); - } - else if ( Name.equals( "ingot" + ore ) ) + else if ( Name.equals( "crystal" + ore ) || Name.equals( "ingot" + ore ) || Name.equals( "gem" + ore ) ) { addIngot( ore, item ); } diff --git a/integration/modules/NEIHelpers/NEIAEShapedRecipeHandler.java b/integration/modules/NEIHelpers/NEIAEShapedRecipeHandler.java index cac38129..02b1d138 100644 --- a/integration/modules/NEIHelpers/NEIAEShapedRecipeHandler.java +++ b/integration/modules/NEIHelpers/NEIAEShapedRecipeHandler.java @@ -55,9 +55,12 @@ public class NEIAEShapedRecipeHandler extends TemplateRecipeHandler { if ( (irecipe instanceof ShapedRecipe) ) { - CachedShapedRecipe recipe = new CachedShapedRecipe( (ShapedRecipe) irecipe ); - recipe.computeVisuals(); - arecipes.add( recipe ); + if ( ((ShapedRecipe) irecipe).isEnabled() ) + { + CachedShapedRecipe recipe = new CachedShapedRecipe( (ShapedRecipe) irecipe ); + recipe.computeVisuals(); + arecipes.add( recipe ); + } } } } @@ -74,7 +77,7 @@ public class NEIAEShapedRecipeHandler extends TemplateRecipeHandler { if ( (irecipe instanceof ShapedRecipe) ) { - if ( NEIServerUtils.areStacksSameTypeCrafting( irecipe.getRecipeOutput(), result ) ) + if ( ((ShapedRecipe) irecipe).isEnabled() && NEIServerUtils.areStacksSameTypeCrafting( irecipe.getRecipeOutput(), result ) ) { CachedShapedRecipe recipe = new CachedShapedRecipe( (ShapedRecipe) irecipe ); recipe.computeVisuals(); @@ -93,7 +96,7 @@ public class NEIAEShapedRecipeHandler extends TemplateRecipeHandler { CachedShapedRecipe recipe = new CachedShapedRecipe( (ShapedRecipe) irecipe ); - if ( recipe.contains( recipe.ingredients, ingredient.getItem() ) ) + if ( ((ShapedRecipe) irecipe).isEnabled() && recipe.contains( recipe.ingredients, ingredient.getItem() ) ) { recipe.computeVisuals(); if ( recipe.contains( recipe.ingredients, ingredient ) ) diff --git a/integration/modules/NEIHelpers/NEIAEShapelessRecipeHandler.java b/integration/modules/NEIHelpers/NEIAEShapelessRecipeHandler.java index 1352c0f5..ff9468fc 100644 --- a/integration/modules/NEIHelpers/NEIAEShapelessRecipeHandler.java +++ b/integration/modules/NEIHelpers/NEIAEShapelessRecipeHandler.java @@ -55,9 +55,12 @@ public class NEIAEShapelessRecipeHandler extends TemplateRecipeHandler { if ( (irecipe instanceof ShapelessRecipe) ) { - CachedShapelessRecipe recipe = new CachedShapelessRecipe( (ShapelessRecipe) irecipe ); - recipe.computeVisuals(); - this.arecipes.add( recipe ); + if ( ((ShapelessRecipe) irecipe).isEnabled() ) + { + CachedShapelessRecipe recipe = new CachedShapelessRecipe( (ShapelessRecipe) irecipe ); + recipe.computeVisuals(); + this.arecipes.add( recipe ); + } } } } @@ -74,7 +77,7 @@ public class NEIAEShapelessRecipeHandler extends TemplateRecipeHandler { if ( (irecipe instanceof ShapelessRecipe) ) { - if ( NEIServerUtils.areStacksSameTypeCrafting( irecipe.getRecipeOutput(), result ) ) + if ( ((ShapelessRecipe) irecipe).isEnabled() && NEIServerUtils.areStacksSameTypeCrafting( irecipe.getRecipeOutput(), result ) ) { CachedShapelessRecipe recipe = new CachedShapelessRecipe( (ShapelessRecipe) irecipe ); recipe.computeVisuals(); @@ -93,7 +96,7 @@ public class NEIAEShapelessRecipeHandler extends TemplateRecipeHandler { CachedShapelessRecipe recipe = new CachedShapelessRecipe( (ShapelessRecipe) irecipe ); - if ( recipe.contains( recipe.ingredients, ingredient.getItem() ) ) + if ( ((ShapelessRecipe) irecipe).isEnabled() && recipe.contains( recipe.ingredients, ingredient.getItem() ) ) { recipe.computeVisuals(); if ( recipe.contains( recipe.ingredients, ingredient ) ) diff --git a/items/materials/ItemMultiMaterial.java b/items/materials/ItemMultiMaterial.java index 7a78bd8b..af809576 100644 --- a/items/materials/ItemMultiMaterial.java +++ b/items/materials/ItemMultiMaterial.java @@ -1,5 +1,6 @@ package appeng.items.materials; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; @@ -37,7 +38,8 @@ import appeng.client.texture.MissingIcon; import appeng.core.AEConfig; import appeng.core.features.AEFeature; import appeng.core.features.AEFeatureHandler; -import appeng.core.features.ItemStackSrc; +import appeng.core.features.IStackSrc; +import appeng.core.features.MaterialStackSrc; import appeng.items.AEBaseItem; import appeng.util.InventoryAdaptor; import appeng.util.Platform; @@ -134,7 +136,7 @@ public class ItemMultiMaterial extends AEBaseItem implements IStorageComponent, } } - public ItemStackSrc createMaterial(MaterialType mat) + public IStackSrc createMaterial(MaterialType mat) { if ( !mat.isRegistered() ) { @@ -144,19 +146,17 @@ public class ItemMultiMaterial extends AEBaseItem implements IStorageComponent, if ( enabled ) { + mat.itemInstance = this; int newMaterialNum = mat.damageValue; mat.markReady(); - ItemStackSrc output = new ItemStackSrc( this, newMaterialNum ); + IStackSrc output = mat.stackSrc = new MaterialStackSrc( mat ); if ( dmgToMaterial.get( newMaterialNum ) == null ) dmgToMaterial.put( newMaterialNum, mat ); else throw new RuntimeException( "Meta Overlap detected." ); - if ( mat.getOreName() != null ) - OreDictionary.registerOre( mat.getOreName(), output.stack( 1 ) ); - return output; } @@ -166,9 +166,49 @@ public class ItemMultiMaterial extends AEBaseItem implements IStorageComponent, throw new RuntimeException( "Cannot create the same material twice..." ); } - public ItemStack getStackByType(MaterialType mt) + public void unduplicate() { - return new ItemStack( this, 1, mt.damageValue ); + for (MaterialType mt : dmgToMaterial.values()) + { + if ( mt.getOreName() != null ) + { + ItemStack replacement = null; + + String names[] = mt.getOreName().split( "," ); + + for (String name : names) + { + if ( replacement != null ) + break; + + ArrayList options = OreDictionary.getOres( name ); + if ( options != null && options.size() > 0 ) + { + for (ItemStack is : options) + { + if ( is != null && is.getItem() != null ) + { + replacement = is.copy(); + break; + } + } + } + } + + if ( replacement == null || AEConfig.instance.useAEVersion( mt ) ) + { + // continue using the AE2 item. + for (String name : names) + OreDictionary.registerOre( name, mt.stack( 1 ) ); + } + else + { + mt.itemInstance = replacement.getItem(); + mt.damageValue = replacement.getItemDamage(); + } + + } + } } public MaterialType getTypeByStack(ItemStack is) @@ -364,7 +404,7 @@ public class ItemMultiMaterial extends AEBaseItem implements IStorageComponent, for (MaterialType mat : types) { - if ( mat.damageValue >= 0 && mat.isRegistered() ) + if ( mat.damageValue >= 0 && mat.isRegistered() && mat.itemInstance == this ) cList.add( new ItemStack( this, 1, mat.damageValue ) ); } } diff --git a/items/materials/MaterialType.java b/items/materials/MaterialType.java index c346cb2f..4dd65a19 100644 --- a/items/materials/MaterialType.java +++ b/items/materials/MaterialType.java @@ -3,11 +3,12 @@ package appeng.items.materials; import java.util.EnumSet; import net.minecraft.entity.Entity; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; -import net.minecraftforge.oredict.OreDictionary; import appeng.core.AppEng; import appeng.core.features.AEFeature; +import appeng.core.features.MaterialStackSrc; import appeng.entity.EntityChargedQuartz; import appeng.entity.EntityIds; import appeng.entity.EntitySingularity; @@ -59,7 +60,7 @@ public enum MaterialType SkyDust(45, AEFeature.Core), - EnderDust(46, AEFeature.QuantumNetworkBridge, "dustEnder", EntitySingularity.class), Singularity(47, AEFeature.QuantumNetworkBridge, + EnderDust(46, AEFeature.QuantumNetworkBridge, "dustEnder,dustEnderPearl", EntitySingularity.class), Singularity(47, AEFeature.QuantumNetworkBridge, EntitySingularity.class), QESingularity(48, AEFeature.QuantumNetworkBridge, EntitySingularity.class), BlankPattern(52), CardCrafting(53); @@ -71,9 +72,15 @@ public enum MaterialType // IIcon for the material. @SideOnly(Side.CLIENT) public IIcon IIcon; - final public int damageValue; + + public Item itemInstance; + public int damageValue; + private boolean isRegistered = false; + // stack! + public MaterialStackSrc stackSrc; + MaterialType(int metaValue) { damageValue = metaValue; features = EnumSet.of( AEFeature.Core ); @@ -96,9 +103,6 @@ public enum MaterialType features = EnumSet.of( part ); damageValue = metaValue; oreName = oreDictionary; - if ( OreDictionary.getOres( oreDictionary ).size() > 0 ) - features.add( AEFeature.DuplicateItems ); - droppedEntity = c; EntityRegistry.registerModEntity( droppedEntity, droppedEntity.getSimpleName(), EntityIds.get( droppedEntity ), AppEng.instance, 16, 4, true ); } @@ -107,13 +111,11 @@ public enum MaterialType features = EnumSet.of( part ); damageValue = metaValue; oreName = oreDictionary; - if ( OreDictionary.getOres( oreDictionary ).size() > 0 ) - features.add( AEFeature.DuplicateItems ); } public ItemStack stack(int size) { - return new ItemStack( ItemMultiMaterial.instance, size, damageValue ); + return new ItemStack( itemInstance, size, damageValue ); } public EnumSet getFeature() diff --git a/recipes/AEItemResolver.java b/recipes/AEItemResolver.java index 4034bb7c..95b52e36 100644 --- a/recipes/AEItemResolver.java +++ b/recipes/AEItemResolver.java @@ -8,6 +8,7 @@ import appeng.api.recipes.ResolverResultSet; import appeng.api.util.AEColor; import appeng.api.util.AEColoredItemDefinition; import appeng.core.AppEng; +import appeng.items.materials.ItemMultiMaterial; import appeng.items.materials.MaterialType; import appeng.items.misc.ItemCrystalSeed; import appeng.items.parts.ItemMultiPart; @@ -89,7 +90,7 @@ public class AEItemResolver implements ISubItemResolver String materialName = itemName.substring( itemName.indexOf( "." ) + 1 ); MaterialType mt = MaterialType.valueOf( materialName ); // itemName = itemName.substring( 0, itemName.indexOf( "." ) ); - if ( mt.damageValue >= 0 && mt.isRegistered() ) + if ( mt.itemInstance == ItemMultiMaterial.instance && mt.damageValue >= 0 && mt.isRegistered() ) return new ResolverResult( "ItemMultiMaterial", mt.damageValue ); } diff --git a/recipes/game/ShapedRecipe.java b/recipes/game/ShapedRecipe.java index 4e34d508..ed2c1631 100644 --- a/recipes/game/ShapedRecipe.java +++ b/recipes/game/ShapedRecipe.java @@ -24,6 +24,12 @@ public class ShapedRecipe implements IRecipe, IRecipeBakeable private int width = 0; private int height = 0; private boolean mirrored = true; + private boolean disable = false; + + public boolean isEnabled() + { + return !disable; + } public ShapedRecipe(ItemStack result, Object... recipe) { output = result.copy(); @@ -130,6 +136,9 @@ public class ShapedRecipe implements IRecipe, IRecipeBakeable @Override public boolean matches(InventoryCrafting inv, World world) { + if ( disable ) + return false; + for (int x = 0; x <= MAX_CRAFT_GRID_WIDTH - width; x++) { for (int y = 0; y <= MAX_CRAFT_GRID_HEIGHT - height; ++y) @@ -152,6 +161,9 @@ public class ShapedRecipe implements IRecipe, IRecipeBakeable @SuppressWarnings("unchecked") private boolean checkMatch(InventoryCrafting inv, int startX, int startY, boolean mirror) { + if ( disable ) + return false; + for (int x = 0; x < MAX_CRAFT_GRID_WIDTH; x++) { for (int y = 0; y < MAX_CRAFT_GRID_HEIGHT; y++) @@ -180,14 +192,14 @@ public class ShapedRecipe implements IRecipe, IRecipeBakeable try { - for (ItemStack item : ((IIngredient) target).getItemStackSet() ) + for (ItemStack item : ((IIngredient) target).getItemStackSet()) { matched = matched || checkItemEquals( item, slot ); } } catch (RegistrationError e) { - // :P + // :P } catch (MissingIngredientError e) { @@ -266,12 +278,20 @@ public class ShapedRecipe implements IRecipe, IRecipeBakeable } @Override - public void bake() throws RegistrationError, MissingIngredientError + public void bake() throws RegistrationError { - for ( Object o : getInput() ) + try { - if ( o instanceof IIngredient ) - ((IIngredient)o).bake(); + disable = false; + for (Object o : getInput()) + { + if ( o instanceof IIngredient ) + ((IIngredient) o).bake(); + } + } + catch (MissingIngredientError err) + { + disable = true; } } diff --git a/recipes/game/ShapelessRecipe.java b/recipes/game/ShapelessRecipe.java index 1a5a0774..a1c46f2d 100644 --- a/recipes/game/ShapelessRecipe.java +++ b/recipes/game/ShapelessRecipe.java @@ -17,6 +17,12 @@ public class ShapelessRecipe implements IRecipe, IRecipeBakeable private ItemStack output = null; private ArrayList input = new ArrayList(); + private boolean disable = false; + + public boolean isEnabled() + { + return !disable; + } public ShapelessRecipe(ItemStack result, Object... recipe) { output = result.copy(); @@ -61,6 +67,9 @@ public class ShapelessRecipe implements IRecipe, IRecipeBakeable @Override public boolean matches(InventoryCrafting var1, World world) { + if ( disable ) + return false; + ArrayList required = new ArrayList( input ); for (int x = 0; x < var1.getSizeInventory(); x++) @@ -82,7 +91,7 @@ public class ShapelessRecipe implements IRecipe, IRecipeBakeable { try { - for (ItemStack item : ((IIngredient) next).getItemStackSet() ) + for (ItemStack item : ((IIngredient) next).getItemStackSet()) { match = match || checkItemEquals( item, slot ); } @@ -135,10 +144,18 @@ public class ShapelessRecipe implements IRecipe, IRecipeBakeable @Override public void bake() throws RegistrationError, MissingIngredientError { - for ( Object o : getInput() ) + try { - if ( o instanceof IIngredient ) - ((IIngredient)o).bake(); + disable = false; + for (Object o : getInput()) + { + if ( o instanceof IIngredient ) + ((IIngredient) o).bake(); + } + } + catch (MissingIngredientError e) + { + disable = true; } } } \ No newline at end of file