Re-did DuplicateItems, into Ore Camo Feature, better logic, and better config.
This commit is contained in:
parent
7ccb850037
commit
476d9a478a
15 changed files with 226 additions and 72 deletions
|
@ -16,6 +16,7 @@ import appeng.api.util.IConfigManager;
|
||||||
import appeng.api.util.IConfigureableObject;
|
import appeng.api.util.IConfigureableObject;
|
||||||
import appeng.core.features.AEFeature;
|
import appeng.core.features.AEFeature;
|
||||||
import appeng.core.settings.TickRates;
|
import appeng.core.settings.TickRates;
|
||||||
|
import appeng.items.materials.MaterialType;
|
||||||
import appeng.util.ConfigManager;
|
import appeng.util.ConfigManager;
|
||||||
import appeng.util.IConfigManagerHost;
|
import appeng.util.IConfigManagerHost;
|
||||||
import appeng.util.Platform;
|
import appeng.util.Platform;
|
||||||
|
@ -94,7 +95,7 @@ public class AEConfig extends Configuration implements IConfigureableObject, ICo
|
||||||
|
|
||||||
public String grinderOres[] = {
|
public String grinderOres[] = {
|
||||||
// Vanilla Items
|
// Vanilla Items
|
||||||
"Obsidian", "Ender", "Coal", "Iron", "Gold", "Charcoal", "NetherQuartz",
|
"Obsidian", "Ender", "EnderPearl", "Coal", "Iron", "Gold", "Charcoal", "NetherQuartz",
|
||||||
// Common Mod Ores
|
// Common Mod Ores
|
||||||
"Copper", "Tin", "Silver", "Lead", "Bronze",
|
"Copper", "Tin", "Silver", "Lead", "Bronze",
|
||||||
// AE
|
// AE
|
||||||
|
@ -260,9 +261,6 @@ public class AEConfig extends Configuration implements IConfigureableObject, ICo
|
||||||
featureFlags.add( feature );
|
featureFlags.add( feature );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( featureFlags.contains( AEFeature.WebsiteRecipes ) )
|
|
||||||
featureFlags.add( AEFeature.DuplicateItems );
|
|
||||||
|
|
||||||
if ( cpw.mods.fml.common.Loader.isModLoaded( "ImmibisMicroblocks" ) )
|
if ( cpw.mods.fml.common.Loader.isModLoaded( "ImmibisMicroblocks" ) )
|
||||||
featureFlags.remove( AEFeature.AlphaPass );
|
featureFlags.remove( AEFeature.AlphaPass );
|
||||||
|
|
||||||
|
@ -302,6 +300,20 @@ public class AEConfig extends Configuration implements IConfigureableObject, ICo
|
||||||
updateable = true;
|
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)
|
private String getListComment(Enum value)
|
||||||
{
|
{
|
||||||
String comment = null;
|
String comment = null;
|
||||||
|
|
|
@ -80,6 +80,7 @@ import appeng.core.features.AEFeatureHandler;
|
||||||
import appeng.core.features.ColoredItemDefinition;
|
import appeng.core.features.ColoredItemDefinition;
|
||||||
import appeng.core.features.DamagedItemDefinition;
|
import appeng.core.features.DamagedItemDefinition;
|
||||||
import appeng.core.features.IAEFeature;
|
import appeng.core.features.IAEFeature;
|
||||||
|
import appeng.core.features.IStackSrc;
|
||||||
import appeng.core.features.ItemStackSrc;
|
import appeng.core.features.ItemStackSrc;
|
||||||
import appeng.core.features.NullItemDefinition;
|
import appeng.core.features.NullItemDefinition;
|
||||||
import appeng.core.features.WrappedDamageItemDefinition;
|
import appeng.core.features.WrappedDamageItemDefinition;
|
||||||
|
@ -234,7 +235,7 @@ public class Registration
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Field f = materialClass.getField( "material" + mat.name() );
|
Field f = materialClass.getField( "material" + mat.name() );
|
||||||
ItemStackSrc is = ((ItemMultiMaterial) materialItem.item()).createMaterial( mat );
|
IStackSrc is = ((ItemMultiMaterial) materialItem.item()).createMaterial( mat );
|
||||||
if ( is != null )
|
if ( is != null )
|
||||||
f.set( materials, new DamagedItemDefinition( is ) );
|
f.set( materials, new DamagedItemDefinition( is ) );
|
||||||
else
|
else
|
||||||
|
@ -509,6 +510,9 @@ public class Registration
|
||||||
|
|
||||||
public void Init(FMLInitializationEvent event)
|
public void Init(FMLInitializationEvent event)
|
||||||
{
|
{
|
||||||
|
// Perform ore camouflage!
|
||||||
|
ItemMultiMaterial.instance.unduplicate();
|
||||||
|
|
||||||
if ( AEConfig.instance.isFeatureEnabled( AEFeature.CustomRecipes ) )
|
if ( AEConfig.instance.isFeatureEnabled( AEFeature.CustomRecipes ) )
|
||||||
recipeHandler.parseRecipes( new ConfigLoader( AppEng.instance.getConfigPath() ), "index.recipe" );
|
recipeHandler.parseRecipes( new ConfigLoader( AppEng.instance.getConfigPath() ), "index.recipe" );
|
||||||
else
|
else
|
||||||
|
|
|
@ -46,7 +46,7 @@ public enum AEFeature
|
||||||
|
|
||||||
MassCannonBlockDamage("BlockFeatures"), TinyTNTBlockDamage("BlockFeatures"), Facades("Facades"),
|
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),
|
GrinderLogging("Misc", false), Logging("Misc"), IntegrationLogging("Misc", false), CustomRecipes("Crafting", false), WebsiteRecipes("Misc", false),
|
||||||
|
|
||||||
|
|
|
@ -10,20 +10,10 @@ import appeng.api.util.AEItemDefinition;
|
||||||
public class DamagedItemDefinition implements AEItemDefinition
|
public class DamagedItemDefinition implements AEItemDefinition
|
||||||
{
|
{
|
||||||
|
|
||||||
final Item baseItem;
|
final IStackSrc src;
|
||||||
final int damage;
|
|
||||||
|
|
||||||
public DamagedItemDefinition(ItemStackSrc is) {
|
public DamagedItemDefinition(IStackSrc is) {
|
||||||
if ( is == null )
|
src = is;
|
||||||
{
|
|
||||||
baseItem = null;
|
|
||||||
damage = -1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
baseItem = is.item;
|
|
||||||
damage = is.damage;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -35,7 +25,7 @@ public class DamagedItemDefinition implements AEItemDefinition
|
||||||
@Override
|
@Override
|
||||||
public Item item()
|
public Item item()
|
||||||
{
|
{
|
||||||
return baseItem;
|
return src.getItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -47,10 +37,7 @@ public class DamagedItemDefinition implements AEItemDefinition
|
||||||
@Override
|
@Override
|
||||||
public ItemStack stack(int stackSize)
|
public ItemStack stack(int stackSize)
|
||||||
{
|
{
|
||||||
if ( baseItem == null )
|
return src.stack( stackSize );
|
||||||
return null;
|
|
||||||
|
|
||||||
return new ItemStack( baseItem, stackSize, damage );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -59,7 +46,7 @@ public class DamagedItemDefinition implements AEItemDefinition
|
||||||
if ( comparableItem == null )
|
if ( comparableItem == null )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return comparableItem.getItem() == baseItem && comparableItem.getItemDamage() == damage;
|
return comparableItem.getItem() == src.getItem() && comparableItem.getItemDamage() == src.getDamage();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
15
core/features/IStackSrc.java
Normal file
15
core/features/IStackSrc.java
Normal file
|
@ -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();
|
||||||
|
|
||||||
|
}
|
|
@ -4,7 +4,7 @@ import net.minecraft.block.Block;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
public class ItemStackSrc
|
public class ItemStackSrc implements IStackSrc
|
||||||
{
|
{
|
||||||
|
|
||||||
public final Item item;
|
public final Item item;
|
||||||
|
@ -23,11 +23,27 @@ public class ItemStackSrc
|
||||||
damage = dmg;
|
damage = dmg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ItemStack stack(int i)
|
public ItemStack stack(int i)
|
||||||
{
|
{
|
||||||
if ( block != null )
|
if ( block != null )
|
||||||
return new ItemStack( block, i, damage );
|
return new ItemStack( block, i, damage );
|
||||||
|
|
||||||
|
if ( item != null )
|
||||||
return new ItemStack( item, i, damage );
|
return new ItemStack( item, i, damage );
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Item getItem()
|
||||||
|
{
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getDamage()
|
||||||
|
{
|
||||||
|
return damage;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
36
core/features/MaterialStackSrc.java
Normal file
36
core/features/MaterialStackSrc.java
Normal file
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -46,7 +46,9 @@ public class GrinderRecipeManager implements IGrinderRegistry, IOreListener
|
||||||
addIngot( "Iron", new ItemStack( Items.iron_ingot ) );
|
addIngot( "Iron", new ItemStack( Items.iron_ingot ) );
|
||||||
|
|
||||||
addOre( "Obsidian", new ItemStack( Blocks.obsidian ) );
|
addOre( "Obsidian", new ItemStack( Blocks.obsidian ) );
|
||||||
|
|
||||||
addIngot( "Ender", new ItemStack( Items.ender_pearl ) );
|
addIngot( "Ender", new ItemStack( Items.ender_pearl ) );
|
||||||
|
addIngot( "EnderPearl", new ItemStack( Items.ender_pearl ) );
|
||||||
|
|
||||||
addIngot( "Wheat", new ItemStack( Items.wheat ) );
|
addIngot( "Wheat", new ItemStack( Items.wheat ) );
|
||||||
|
|
||||||
|
@ -226,7 +228,7 @@ public class GrinderRecipeManager implements IGrinderRegistry, IOreListener
|
||||||
@Override
|
@Override
|
||||||
public void oreRegistered(String Name, ItemStack item)
|
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)
|
for (String ore : AEConfig.instance.grinderOres)
|
||||||
{
|
{
|
||||||
|
@ -234,11 +236,7 @@ public class GrinderRecipeManager implements IGrinderRegistry, IOreListener
|
||||||
{
|
{
|
||||||
addOre( ore, item );
|
addOre( ore, item );
|
||||||
}
|
}
|
||||||
else if ( Name.equals( "crystal" + ore ) )
|
else if ( Name.equals( "crystal" + ore ) || Name.equals( "ingot" + ore ) || Name.equals( "gem" + ore ) )
|
||||||
{
|
|
||||||
addIngot( ore, item );
|
|
||||||
}
|
|
||||||
else if ( Name.equals( "ingot" + ore ) )
|
|
||||||
{
|
{
|
||||||
addIngot( ore, item );
|
addIngot( ore, item );
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,6 +54,8 @@ public class NEIAEShapedRecipeHandler extends TemplateRecipeHandler
|
||||||
for (IRecipe irecipe : allrecipes)
|
for (IRecipe irecipe : allrecipes)
|
||||||
{
|
{
|
||||||
if ( (irecipe instanceof ShapedRecipe) )
|
if ( (irecipe instanceof ShapedRecipe) )
|
||||||
|
{
|
||||||
|
if ( ((ShapedRecipe) irecipe).isEnabled() )
|
||||||
{
|
{
|
||||||
CachedShapedRecipe recipe = new CachedShapedRecipe( (ShapedRecipe) irecipe );
|
CachedShapedRecipe recipe = new CachedShapedRecipe( (ShapedRecipe) irecipe );
|
||||||
recipe.computeVisuals();
|
recipe.computeVisuals();
|
||||||
|
@ -61,6 +63,7 @@ public class NEIAEShapedRecipeHandler extends TemplateRecipeHandler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
super.loadCraftingRecipes( outputId, results );
|
super.loadCraftingRecipes( outputId, results );
|
||||||
|
@ -74,7 +77,7 @@ public class NEIAEShapedRecipeHandler extends TemplateRecipeHandler
|
||||||
{
|
{
|
||||||
if ( (irecipe instanceof ShapedRecipe) )
|
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 );
|
CachedShapedRecipe recipe = new CachedShapedRecipe( (ShapedRecipe) irecipe );
|
||||||
recipe.computeVisuals();
|
recipe.computeVisuals();
|
||||||
|
@ -93,7 +96,7 @@ public class NEIAEShapedRecipeHandler extends TemplateRecipeHandler
|
||||||
{
|
{
|
||||||
CachedShapedRecipe recipe = new CachedShapedRecipe( (ShapedRecipe) irecipe );
|
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();
|
recipe.computeVisuals();
|
||||||
if ( recipe.contains( recipe.ingredients, ingredient ) )
|
if ( recipe.contains( recipe.ingredients, ingredient ) )
|
||||||
|
|
|
@ -54,6 +54,8 @@ public class NEIAEShapelessRecipeHandler extends TemplateRecipeHandler
|
||||||
for (IRecipe irecipe : allrecipes)
|
for (IRecipe irecipe : allrecipes)
|
||||||
{
|
{
|
||||||
if ( (irecipe instanceof ShapelessRecipe) )
|
if ( (irecipe instanceof ShapelessRecipe) )
|
||||||
|
{
|
||||||
|
if ( ((ShapelessRecipe) irecipe).isEnabled() )
|
||||||
{
|
{
|
||||||
CachedShapelessRecipe recipe = new CachedShapelessRecipe( (ShapelessRecipe) irecipe );
|
CachedShapelessRecipe recipe = new CachedShapelessRecipe( (ShapelessRecipe) irecipe );
|
||||||
recipe.computeVisuals();
|
recipe.computeVisuals();
|
||||||
|
@ -61,6 +63,7 @@ public class NEIAEShapelessRecipeHandler extends TemplateRecipeHandler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
super.loadCraftingRecipes( outputId, results );
|
super.loadCraftingRecipes( outputId, results );
|
||||||
|
@ -74,7 +77,7 @@ public class NEIAEShapelessRecipeHandler extends TemplateRecipeHandler
|
||||||
{
|
{
|
||||||
if ( (irecipe instanceof ShapelessRecipe) )
|
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 );
|
CachedShapelessRecipe recipe = new CachedShapelessRecipe( (ShapelessRecipe) irecipe );
|
||||||
recipe.computeVisuals();
|
recipe.computeVisuals();
|
||||||
|
@ -93,7 +96,7 @@ public class NEIAEShapelessRecipeHandler extends TemplateRecipeHandler
|
||||||
{
|
{
|
||||||
CachedShapelessRecipe recipe = new CachedShapelessRecipe( (ShapelessRecipe) irecipe );
|
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();
|
recipe.computeVisuals();
|
||||||
if ( recipe.contains( recipe.ingredients, ingredient ) )
|
if ( recipe.contains( recipe.ingredients, ingredient ) )
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package appeng.items.materials;
|
package appeng.items.materials;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
@ -37,7 +38,8 @@ import appeng.client.texture.MissingIcon;
|
||||||
import appeng.core.AEConfig;
|
import appeng.core.AEConfig;
|
||||||
import appeng.core.features.AEFeature;
|
import appeng.core.features.AEFeature;
|
||||||
import appeng.core.features.AEFeatureHandler;
|
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.items.AEBaseItem;
|
||||||
import appeng.util.InventoryAdaptor;
|
import appeng.util.InventoryAdaptor;
|
||||||
import appeng.util.Platform;
|
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() )
|
if ( !mat.isRegistered() )
|
||||||
{
|
{
|
||||||
|
@ -144,19 +146,17 @@ public class ItemMultiMaterial extends AEBaseItem implements IStorageComponent,
|
||||||
|
|
||||||
if ( enabled )
|
if ( enabled )
|
||||||
{
|
{
|
||||||
|
mat.itemInstance = this;
|
||||||
int newMaterialNum = mat.damageValue;
|
int newMaterialNum = mat.damageValue;
|
||||||
mat.markReady();
|
mat.markReady();
|
||||||
|
|
||||||
ItemStackSrc output = new ItemStackSrc( this, newMaterialNum );
|
IStackSrc output = mat.stackSrc = new MaterialStackSrc( mat );
|
||||||
|
|
||||||
if ( dmgToMaterial.get( newMaterialNum ) == null )
|
if ( dmgToMaterial.get( newMaterialNum ) == null )
|
||||||
dmgToMaterial.put( newMaterialNum, mat );
|
dmgToMaterial.put( newMaterialNum, mat );
|
||||||
else
|
else
|
||||||
throw new RuntimeException( "Meta Overlap detected." );
|
throw new RuntimeException( "Meta Overlap detected." );
|
||||||
|
|
||||||
if ( mat.getOreName() != null )
|
|
||||||
OreDictionary.registerOre( mat.getOreName(), output.stack( 1 ) );
|
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,9 +166,49 @@ public class ItemMultiMaterial extends AEBaseItem implements IStorageComponent,
|
||||||
throw new RuntimeException( "Cannot create the same material twice..." );
|
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<ItemStack> 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)
|
public MaterialType getTypeByStack(ItemStack is)
|
||||||
|
@ -364,7 +404,7 @@ public class ItemMultiMaterial extends AEBaseItem implements IStorageComponent,
|
||||||
|
|
||||||
for (MaterialType mat : types)
|
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 ) );
|
cList.add( new ItemStack( this, 1, mat.damageValue ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,11 +3,12 @@ package appeng.items.materials;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
|
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.IIcon;
|
import net.minecraft.util.IIcon;
|
||||||
import net.minecraftforge.oredict.OreDictionary;
|
|
||||||
import appeng.core.AppEng;
|
import appeng.core.AppEng;
|
||||||
import appeng.core.features.AEFeature;
|
import appeng.core.features.AEFeature;
|
||||||
|
import appeng.core.features.MaterialStackSrc;
|
||||||
import appeng.entity.EntityChargedQuartz;
|
import appeng.entity.EntityChargedQuartz;
|
||||||
import appeng.entity.EntityIds;
|
import appeng.entity.EntityIds;
|
||||||
import appeng.entity.EntitySingularity;
|
import appeng.entity.EntitySingularity;
|
||||||
|
@ -59,7 +60,7 @@ public enum MaterialType
|
||||||
|
|
||||||
SkyDust(45, AEFeature.Core),
|
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),
|
EntitySingularity.class), QESingularity(48, AEFeature.QuantumNetworkBridge, EntitySingularity.class),
|
||||||
|
|
||||||
BlankPattern(52), CardCrafting(53);
|
BlankPattern(52), CardCrafting(53);
|
||||||
|
@ -71,9 +72,15 @@ public enum MaterialType
|
||||||
// IIcon for the material.
|
// IIcon for the material.
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public IIcon IIcon;
|
public IIcon IIcon;
|
||||||
final public int damageValue;
|
|
||||||
|
public Item itemInstance;
|
||||||
|
public int damageValue;
|
||||||
|
|
||||||
private boolean isRegistered = false;
|
private boolean isRegistered = false;
|
||||||
|
|
||||||
|
// stack!
|
||||||
|
public MaterialStackSrc stackSrc;
|
||||||
|
|
||||||
MaterialType(int metaValue) {
|
MaterialType(int metaValue) {
|
||||||
damageValue = metaValue;
|
damageValue = metaValue;
|
||||||
features = EnumSet.of( AEFeature.Core );
|
features = EnumSet.of( AEFeature.Core );
|
||||||
|
@ -96,9 +103,6 @@ public enum MaterialType
|
||||||
features = EnumSet.of( part );
|
features = EnumSet.of( part );
|
||||||
damageValue = metaValue;
|
damageValue = metaValue;
|
||||||
oreName = oreDictionary;
|
oreName = oreDictionary;
|
||||||
if ( OreDictionary.getOres( oreDictionary ).size() > 0 )
|
|
||||||
features.add( AEFeature.DuplicateItems );
|
|
||||||
|
|
||||||
droppedEntity = c;
|
droppedEntity = c;
|
||||||
EntityRegistry.registerModEntity( droppedEntity, droppedEntity.getSimpleName(), EntityIds.get( droppedEntity ), AppEng.instance, 16, 4, true );
|
EntityRegistry.registerModEntity( droppedEntity, droppedEntity.getSimpleName(), EntityIds.get( droppedEntity ), AppEng.instance, 16, 4, true );
|
||||||
}
|
}
|
||||||
|
@ -107,13 +111,11 @@ public enum MaterialType
|
||||||
features = EnumSet.of( part );
|
features = EnumSet.of( part );
|
||||||
damageValue = metaValue;
|
damageValue = metaValue;
|
||||||
oreName = oreDictionary;
|
oreName = oreDictionary;
|
||||||
if ( OreDictionary.getOres( oreDictionary ).size() > 0 )
|
|
||||||
features.add( AEFeature.DuplicateItems );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack stack(int size)
|
public ItemStack stack(int size)
|
||||||
{
|
{
|
||||||
return new ItemStack( ItemMultiMaterial.instance, size, damageValue );
|
return new ItemStack( itemInstance, size, damageValue );
|
||||||
}
|
}
|
||||||
|
|
||||||
public EnumSet<AEFeature> getFeature()
|
public EnumSet<AEFeature> getFeature()
|
||||||
|
|
|
@ -8,6 +8,7 @@ import appeng.api.recipes.ResolverResultSet;
|
||||||
import appeng.api.util.AEColor;
|
import appeng.api.util.AEColor;
|
||||||
import appeng.api.util.AEColoredItemDefinition;
|
import appeng.api.util.AEColoredItemDefinition;
|
||||||
import appeng.core.AppEng;
|
import appeng.core.AppEng;
|
||||||
|
import appeng.items.materials.ItemMultiMaterial;
|
||||||
import appeng.items.materials.MaterialType;
|
import appeng.items.materials.MaterialType;
|
||||||
import appeng.items.misc.ItemCrystalSeed;
|
import appeng.items.misc.ItemCrystalSeed;
|
||||||
import appeng.items.parts.ItemMultiPart;
|
import appeng.items.parts.ItemMultiPart;
|
||||||
|
@ -89,7 +90,7 @@ public class AEItemResolver implements ISubItemResolver
|
||||||
String materialName = itemName.substring( itemName.indexOf( "." ) + 1 );
|
String materialName = itemName.substring( itemName.indexOf( "." ) + 1 );
|
||||||
MaterialType mt = MaterialType.valueOf( materialName );
|
MaterialType mt = MaterialType.valueOf( materialName );
|
||||||
// itemName = itemName.substring( 0, itemName.indexOf( "." ) );
|
// 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 );
|
return new ResolverResult( "ItemMultiMaterial", mt.damageValue );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,12 @@ public class ShapedRecipe implements IRecipe, IRecipeBakeable
|
||||||
private int width = 0;
|
private int width = 0;
|
||||||
private int height = 0;
|
private int height = 0;
|
||||||
private boolean mirrored = true;
|
private boolean mirrored = true;
|
||||||
|
private boolean disable = false;
|
||||||
|
|
||||||
|
public boolean isEnabled()
|
||||||
|
{
|
||||||
|
return !disable;
|
||||||
|
}
|
||||||
|
|
||||||
public ShapedRecipe(ItemStack result, Object... recipe) {
|
public ShapedRecipe(ItemStack result, Object... recipe) {
|
||||||
output = result.copy();
|
output = result.copy();
|
||||||
|
@ -130,6 +136,9 @@ public class ShapedRecipe implements IRecipe, IRecipeBakeable
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(InventoryCrafting inv, World world)
|
public boolean matches(InventoryCrafting inv, World world)
|
||||||
{
|
{
|
||||||
|
if ( disable )
|
||||||
|
return false;
|
||||||
|
|
||||||
for (int x = 0; x <= MAX_CRAFT_GRID_WIDTH - width; x++)
|
for (int x = 0; x <= MAX_CRAFT_GRID_WIDTH - width; x++)
|
||||||
{
|
{
|
||||||
for (int y = 0; y <= MAX_CRAFT_GRID_HEIGHT - height; ++y)
|
for (int y = 0; y <= MAX_CRAFT_GRID_HEIGHT - height; ++y)
|
||||||
|
@ -152,6 +161,9 @@ public class ShapedRecipe implements IRecipe, IRecipeBakeable
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private boolean checkMatch(InventoryCrafting inv, int startX, int startY, boolean mirror)
|
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 x = 0; x < MAX_CRAFT_GRID_WIDTH; x++)
|
||||||
{
|
{
|
||||||
for (int y = 0; y < MAX_CRAFT_GRID_HEIGHT; y++)
|
for (int y = 0; y < MAX_CRAFT_GRID_HEIGHT; y++)
|
||||||
|
@ -266,13 +278,21 @@ public class ShapedRecipe implements IRecipe, IRecipeBakeable
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void bake() throws RegistrationError, MissingIngredientError
|
public void bake() throws RegistrationError
|
||||||
{
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
disable = false;
|
||||||
for (Object o : getInput())
|
for (Object o : getInput())
|
||||||
{
|
{
|
||||||
if ( o instanceof IIngredient )
|
if ( o instanceof IIngredient )
|
||||||
((IIngredient) o).bake();
|
((IIngredient) o).bake();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (MissingIngredientError err)
|
||||||
|
{
|
||||||
|
disable = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -17,6 +17,12 @@ public class ShapelessRecipe implements IRecipe, IRecipeBakeable
|
||||||
|
|
||||||
private ItemStack output = null;
|
private ItemStack output = null;
|
||||||
private ArrayList<Object> input = new ArrayList<Object>();
|
private ArrayList<Object> input = new ArrayList<Object>();
|
||||||
|
private boolean disable = false;
|
||||||
|
|
||||||
|
public boolean isEnabled()
|
||||||
|
{
|
||||||
|
return !disable;
|
||||||
|
}
|
||||||
|
|
||||||
public ShapelessRecipe(ItemStack result, Object... recipe) {
|
public ShapelessRecipe(ItemStack result, Object... recipe) {
|
||||||
output = result.copy();
|
output = result.copy();
|
||||||
|
@ -61,6 +67,9 @@ public class ShapelessRecipe implements IRecipe, IRecipeBakeable
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(InventoryCrafting var1, World world)
|
public boolean matches(InventoryCrafting var1, World world)
|
||||||
{
|
{
|
||||||
|
if ( disable )
|
||||||
|
return false;
|
||||||
|
|
||||||
ArrayList<Object> required = new ArrayList<Object>( input );
|
ArrayList<Object> required = new ArrayList<Object>( input );
|
||||||
|
|
||||||
for (int x = 0; x < var1.getSizeInventory(); x++)
|
for (int x = 0; x < var1.getSizeInventory(); x++)
|
||||||
|
@ -135,10 +144,18 @@ public class ShapelessRecipe implements IRecipe, IRecipeBakeable
|
||||||
@Override
|
@Override
|
||||||
public void bake() throws RegistrationError, MissingIngredientError
|
public void bake() throws RegistrationError, MissingIngredientError
|
||||||
{
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
disable = false;
|
||||||
for (Object o : getInput())
|
for (Object o : getInput())
|
||||||
{
|
{
|
||||||
if ( o instanceof IIngredient )
|
if ( o instanceof IIngredient )
|
||||||
((IIngredient) o).bake();
|
((IIngredient) o).bake();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (MissingIngredientError e)
|
||||||
|
{
|
||||||
|
disable = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue