Fixes #675 No disabled feature should log spam or crash anymore.

Deprecates the old usage of the AEItemDefinitions via the direct method access of

* blocks()
* parts()
* items()
* materials()

and thus use the new re-direct via definitions().

All definitions are now initialized, no matter what. But SubItems, Items and Blocks are not registered, if by chance are disabled.
This commit is contained in:
thatsIch
2015-01-03 02:53:14 +01:00
parent 3dd81433ac
commit 9986ffc458
385 changed files with 12477 additions and 8292 deletions
+138 -121
View File
@@ -19,7 +19,7 @@
package appeng.integration.modules;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
@@ -44,8 +44,10 @@ import buildcraft.transport.ItemFacade;
import buildcraft.transport.PipeIconProvider;
import appeng.api.AEApi;
import appeng.api.IAppEngApi;
import appeng.api.config.TunnelType;
import appeng.api.definitions.Blocks;
import appeng.api.definitions.IBlockDefinition;
import appeng.api.definitions.IBlocks;
import appeng.api.features.IP2PTunnelRegistry;
import appeng.api.parts.IFacadePart;
import appeng.api.util.AEItemDefinition;
@@ -58,56 +60,58 @@ import appeng.integration.modules.BCHelpers.AEGenericSchematicTile;
import appeng.integration.modules.BCHelpers.AERotatableBlockSchematic;
import appeng.integration.modules.BCHelpers.BCPipeHandler;
public final class BC extends BaseModule implements IBC
{
public static BC instance;
public BC() {
public BC()
{
this.testClassExistence( IPipeConnection.class );
this.testClassExistence( ItemFacade.class );
this.testClassExistence( IToolWrench.class );
}
@Override
public void addFacade(ItemStack item)
{
if ( item != null )
FMLInterModComms.sendMessage( "BuildCraft|Transport", "add-facade", item );
}
@Override
public boolean isWrench(Item eq)
public boolean isWrench( Item eq )
{
return eq instanceof IToolWrench;
}
@Override
public boolean isPipe(TileEntity te, ForgeDirection dir)
public boolean canWrench( Item i, EntityPlayer p, int x, int y, int z )
{
if ( te instanceof IPipeTile )
return ( (IToolWrench) i ).canWrench( p, x, y, z );
}
@Override
public void wrenchUsed( Item i, EntityPlayer p, int x, int y, int z )
{
( (IToolWrench) i ).wrenchUsed( p, x, y, z );
}
@Override
public boolean canAddItemsToPipe( TileEntity te, ItemStack is, ForgeDirection dir )
{
if ( is != null && te != null && te instanceof IInjectable )
{
final IPipeTile pipeTile = (IPipeTile) te;
return !pipeTile.hasPipePluggable( dir.getOpposite() );
IInjectable pt = (IInjectable) te;
if ( pt.canInjectItems( dir ) )
{
int amt = pt.injectItem( is, false, dir, null );
if ( amt == is.stackSize )
{
return true;
}
}
}
return false;
}
@Override
public boolean canWrench(Item i, EntityPlayer p, int x, int y, int z)
{
return ((IToolWrench) i).canWrench( p, x, y, z );
}
@Override
public void wrenchUsed(Item i, EntityPlayer p, int x, int y, int z)
{
((IToolWrench) i).wrenchUsed( p, x, y, z );
}
@Override
public boolean addItemsToPipe(TileEntity te, ItemStack is, ForgeDirection dir)
public boolean addItemsToPipe( TileEntity te, ItemStack is, ForgeDirection dir )
{
if ( is != null && te != null && te instanceof IInjectable )
{
@@ -127,7 +131,7 @@ public final class BC extends BaseModule implements IBC
}
@Override
public boolean isFacade(ItemStack is)
public boolean isFacade( ItemStack is )
{
if ( is == null )
return false;
@@ -136,24 +140,24 @@ public final class BC extends BaseModule implements IBC
}
@Override
public boolean canAddItemsToPipe(TileEntity te, ItemStack is, ForgeDirection dir)
public boolean isPipe( TileEntity te, ForgeDirection dir )
{
if ( is != null && te != null && te instanceof IInjectable )
if ( te instanceof IPipeTile )
{
IInjectable pt = (IInjectable) te;
if ( pt.canInjectItems( dir ) )
{
int amt = pt.injectItem( is, false, dir, null );
if ( amt == is.stackSize )
{
return true;
}
}
final IPipeTile pipeTile = (IPipeTile) te;
return !pipeTile.hasPipePluggable( dir.getOpposite() );
}
return false;
}
@Override
public void addFacade( ItemStack item )
{
if ( item != null )
FMLInterModComms.sendMessage( "BuildCraft|Transport", "add-facade", item );
}
@Override
public void registerPowerP2P()
{
@@ -201,82 +205,7 @@ public final class BC extends BaseModule implements IBC
}
@Override
public void init()
{
AEApi.instance().partHelper().registerNewLayer( "appeng.parts.layers.LayerIPipeConnection", "buildcraft.api.transport.IPipeConnection" );
AEApi.instance().registries().externalStorage().addExternalStorageInterface( new BCPipeHandler() );
Blocks b = AEApi.instance().blocks();
this.addFacade( b.blockFluix.stack( 1 ) );
this.addFacade( b.blockQuartz.stack( 1 ) );
this.addFacade( b.blockQuartzChiseled.stack( 1 ) );
this.addFacade( b.blockQuartzPillar.stack( 1 ) );
try
{
this.initBuilderSupport();
}
catch (Throwable builderSupport)
{
// not supported?
}
Block skyStone = b.blockSkyStone.block();
if ( skyStone != null )
{
this.addFacade( new ItemStack( skyStone, 1, 0 ) );
this.addFacade( new ItemStack( skyStone, 1, 1 ) );
this.addFacade( new ItemStack( skyStone, 1, 2 ) );
this.addFacade( new ItemStack( skyStone, 1, 3 ) );
}
}
private void initBuilderSupport()
{
final ISchematicRegistry schematicRegistry = BuilderAPI.schematicRegistry;
Blocks blocks = AEApi.instance().blocks();
Block cable = blocks.blockMultiPart.block();
for (Field f : blocks.getClass().getFields())
{
AEItemDefinition def;
try
{
def = (AEItemDefinition) f.get( blocks );
if ( def != null )
{
Block myBlock = def.block();
if ( myBlock instanceof IOrientableBlock && ((IOrientableBlock) myBlock).usesMetadata() && def.entity() == null )
{
schematicRegistry.registerSchematicBlock( myBlock, AERotatableBlockSchematic.class );
}
else if ( myBlock == cable )
{
schematicRegistry.registerSchematicBlock( myBlock, AECableSchematicTile.class );
}
else if ( def.entity() != null )
{
schematicRegistry.registerSchematicBlock( myBlock, AEGenericSchematicTile.class );
}
}
}
catch (Throwable t)
{
// :P
}
}
}
@Override
public void postInit()
{
this.registerPowerP2P();
this.registerItemP2P();
this.registerLiquidsP2P();
}
@Override
public IFacadePart createFacadePart(Block blk, int meta, ForgeDirection side)
public IFacadePart createFacadePart( Block blk, int meta, ForgeDirection side )
{
try
{
@@ -285,7 +214,7 @@ public final class BC extends BaseModule implements IBC
return new FacadePart( facade, side );
}
catch (Throwable ignored)
catch ( Throwable ignored )
{
}
@@ -294,17 +223,17 @@ public final class BC extends BaseModule implements IBC
}
@Override
public IFacadePart createFacadePart(ItemStack fs, ForgeDirection side)
public IFacadePart createFacadePart( ItemStack fs, ForgeDirection side )
{
return new FacadePart( fs, side );
}
@Override
public ItemStack getTextureForFacade(ItemStack facade)
public ItemStack getTextureForFacade( ItemStack facade )
{
final Item maybeFacadeItem = facade.getItem();
if ( maybeFacadeItem instanceof buildcraft.api.facades.IFacadeItem)
if ( maybeFacadeItem instanceof buildcraft.api.facades.IFacadeItem )
{
final buildcraft.api.facades.IFacadeItem facadeItem = (buildcraft.api.facades.IFacadeItem) maybeFacadeItem;
@@ -327,11 +256,99 @@ public final class BC extends BaseModule implements IBC
{
return BuildCraftTransport.instance.pipeIconProvider.getIcon( PipeIconProvider.TYPE.PipeStructureCobblestone.ordinal() ); // Structure
}
catch (Throwable ignored)
catch ( Throwable ignored )
{
}
return null;
// Pipe
}
private void addFacadeStack( IBlockDefinition definition )
{
for ( ItemStack facadeStack : definition.maybeStack( 1 ).asSet() )
{
this.addFacade( facadeStack );
}
}
@Override
public void init()
{
final IAppEngApi api = AEApi.instance();
api.partHelper().registerNewLayer( "appeng.parts.layers.LayerIPipeConnection", "buildcraft.api.transport.IPipeConnection" );
api.registries().externalStorage().addExternalStorageInterface( new BCPipeHandler() );
final IBlocks blocks = api.definitions().blocks();
this.addFacadeStack( blocks.fluix() );
this.addFacadeStack( blocks.quartz() );
this.addFacadeStack( blocks.quartzChiseled() );
this.addFacadeStack( blocks.quartzPillar() );
try
{
this.initBuilderSupport();
}
catch ( Throwable builderSupport )
{
// not supported?
}
for ( Block skyStoneBlock : blocks.skyStone().maybeBlock().asSet() )
{
this.addFacade( new ItemStack( skyStoneBlock, 1, 0 ) );
this.addFacade( new ItemStack( skyStoneBlock, 1, 1 ) );
this.addFacade( new ItemStack( skyStoneBlock, 1, 2 ) );
this.addFacade( new ItemStack( skyStoneBlock, 1, 3 ) );
}
}
private void initBuilderSupport()
{
final ISchematicRegistry schematicRegistry = BuilderAPI.schematicRegistry;
final IBlocks blocks = AEApi.instance().definitions().blocks();
final IBlockDefinition maybeMultiPart = blocks.multiPart();
for ( Method blockDefinition : blocks.getClass().getMethods() )
{
AEItemDefinition def;
try
{
def = (AEItemDefinition) blockDefinition.invoke( blocks );
Block myBlock = def.block();
if ( myBlock instanceof IOrientableBlock && ( (IOrientableBlock) myBlock ).usesMetadata() && def.entity() == null )
{
schematicRegistry.registerSchematicBlock( myBlock, AERotatableBlockSchematic.class );
}
else if ( maybeMultiPart.isSameAs( new ItemStack( myBlock ) ) )
{
schematicRegistry.registerSchematicBlock( myBlock, AECableSchematicTile.class );
}
else if ( def.entity() != null )
{
schematicRegistry.registerSchematicBlock( myBlock, AEGenericSchematicTile.class );
}
}
catch ( Throwable t )
{
// :P
}
}
}
@Override
public void postInit()
{
this.registerPowerP2P();
this.registerItemP2P();
this.registerLiquidsP2P();
}
private void registerOrientableBlocks()
{
}
}
@@ -18,7 +18,8 @@
package appeng.integration.modules;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayerMP;
@@ -36,9 +37,11 @@ import codechicken.multipart.MultiPartRegistry.IPartFactory;
import codechicken.multipart.MultipartGenerator;
import codechicken.multipart.TMultiPart;
import codechicken.multipart.TileMultipart;
import com.google.common.collect.Lists;
import appeng.api.AEApi;
import appeng.api.definitions.Blocks;
import appeng.api.definitions.IBlockDefinition;
import appeng.api.definitions.IBlocks;
import appeng.api.parts.IPartHost;
import appeng.core.AELog;
import appeng.fmp.CableBusPart;
@@ -86,13 +89,15 @@ public class FMP implements IIntegrationModule, IPartFactory, IPartConverter, IF
@Override
public void init() throws Throwable
{
this.createAndRegister( AEApi.instance().blocks().blockQuartz.block(), 0 );
this.createAndRegister( AEApi.instance().blocks().blockQuartzPillar.block(), 0 );
this.createAndRegister( AEApi.instance().blocks().blockQuartzChiseled.block(), 0 );
this.createAndRegister( AEApi.instance().blocks().blockSkyStone.block(), 0 );
this.createAndRegister( AEApi.instance().blocks().blockSkyStone.block(), 1 );
this.createAndRegister( AEApi.instance().blocks().blockSkyStone.block(), 2 );
this.createAndRegister( AEApi.instance().blocks().blockSkyStone.block(), 3 );
final IBlocks blocks = AEApi.instance().definitions().blocks();
this.createAndRegister( blocks.quartz(), 0 );
this.createAndRegister( blocks.quartzPillar(), 0 );
this.createAndRegister( blocks.quartzChiseled(), 0 );
this.createAndRegister( blocks.skyStone(), 0 );
this.createAndRegister( blocks.skyStone(), 1 );
this.createAndRegister( blocks.skyStone(), 2 );
this.createAndRegister( blocks.skyStone(), 3 );
PartRegistry[] reg = PartRegistry.values();
@@ -106,10 +111,12 @@ public class FMP implements IIntegrationModule, IPartFactory, IPartConverter, IF
MultipartGenerator.registerPassThroughInterface( "appeng.helpers.AEMultiTile" );
}
private void createAndRegister(Block block, int i)
private void createAndRegister(IBlockDefinition definition, int i)
{
if ( block != null )
for ( Block block : definition.maybeBlock().asSet() )
{
BlockMicroMaterial.createAndRegister( block, i );
}
}
@Override
@@ -186,8 +193,20 @@ public class FMP implements IIntegrationModule, IPartFactory, IPartConverter, IF
@Override
public Iterable<Block> blockTypes()
{
Blocks def = AEApi.instance().blocks();
return Arrays.asList( def.blockMultiPart.block(), def.blockQuartzTorch.block() );
final IBlocks blocks = AEApi.instance().definitions().blocks();
final List<Block> blockTypes = Lists.newArrayListWithCapacity( 2 );
this.addBlockTypes( blockTypes, blocks.multiPart() );
this.addBlockTypes( blockTypes, blocks.quartzTorch() );
return blockTypes;
}
private void addBlockTypes( Collection<Block> blockTypes, IBlockDefinition definition )
{
for ( Block block : definition.maybeBlock().asSet() )
{
blockTypes.add( block );
}
}
}
@@ -27,21 +27,24 @@ import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import com.google.common.base.Optional;
import mods.immibis.core.api.multipart.ICoverSystem;
import mods.immibis.core.api.multipart.IMultipartTile;
import mods.immibis.core.api.multipart.IPartContainer;
import appeng.api.AEApi;
import appeng.api.definitions.IBlockDefinition;
import appeng.api.parts.IPartHost;
import appeng.api.parts.IPartItem;
import appeng.core.AELog;
import appeng.helpers.Reflected;
import appeng.integration.BaseModule;
import appeng.integration.abstraction.IImmibisMicroblocks;
public class ImmibisMicroblocks extends BaseModule implements IImmibisMicroblocks
{
@Reflected
public static ImmibisMicroblocks INSTANCE;
private boolean canConvertTiles = false;
@@ -102,19 +105,28 @@ public class ImmibisMicroblocks extends BaseModule implements IImmibisMicroblock
if ( te instanceof IMultipartTile && this.canConvertTiles && isPartItem )
{
final Block blk = AEApi.instance().blocks().blockMultiPart.block();
final ItemStack what = AEApi.instance().blocks().blockMultiPart.stack( 1 );
final IBlockDefinition multiPart = AEApi.instance().definitions().blocks().multiPart();
final Optional<Block> maybeMultiPartBlock = multiPart.maybeBlock();
final Optional<ItemStack> maybeMultiPartStack = multiPart.maybeStack( 1 );
try
final boolean multiPartPresent = maybeMultiPartBlock.isPresent() && maybeMultiPartStack.isPresent();
if ( multiPartPresent )
{
// ItemStack.class, EntityPlayer.class, World.class,
// int.class, int.class, int.class, int.class, Block.class, int.class );
this.mergeIntoMicroblockContainer.invoke( null, what, player, w, x, y, z, side, blk, 0 );
}
catch ( Throwable e )
{
this.canConvertTiles = false;
return null;
final Block multiPartBlock = maybeMultiPartBlock.get();
final ItemStack multiPartStack = maybeMultiPartStack.get();
try
{
// ItemStack.class, EntityPlayer.class, World.class,
// int.class, int.class, int.class, int.class, Block.class, int.class );
this.mergeIntoMicroblockContainer.invoke( null, multiPartStack, player, w, x, y, z, side, multiPartBlock, 0 );
}
catch ( Throwable e )
{
this.canConvertTiles = false;
return null;
}
}
}
@@ -18,7 +18,8 @@
package appeng.integration.modules.NEIHelpers;
import java.awt.Rectangle;
import java.awt.*;
import java.util.ArrayList;
import java.util.List;
@@ -36,14 +37,25 @@ import codechicken.nei.recipe.RecipeInfo;
import codechicken.nei.recipe.TemplateRecipeHandler;
import appeng.api.AEApi;
import appeng.api.definitions.IDefinitions;
import appeng.api.definitions.IItemDefinition;
import appeng.core.localization.GuiText;
import appeng.facade.IFacadeItem;
import appeng.items.parts.ItemFacade;
public class NEIFacadeRecipeHandler extends TemplateRecipeHandler
{
final ItemFacade facade;
final IItemDefinition anchorDefinition;
final ItemFacade ifa = (ItemFacade) AEApi.instance().items().itemFacade.item();
final ItemStack cable_anchor = AEApi.instance().parts().partCableAnchor.stack( 1 );
public NEIFacadeRecipeHandler()
{
final IDefinitions definitions = AEApi.instance().definitions();
this.facade = (ItemFacade) definitions.items().facade();
this.anchorDefinition = definitions.parts().cableAnchor();
}
@Override
public void loadTransferRects()
@@ -52,29 +64,19 @@ public class NEIFacadeRecipeHandler extends TemplateRecipeHandler
}
@Override
public Class<? extends GuiContainer> getGuiClass()
public void loadCraftingRecipes( String outputId, Object... results )
{
return GuiCrafting.class;
}
@Override
public String getRecipeName()
{
return GuiText.FacadeCrafting.getLocal();
}
@Override
public void loadCraftingRecipes(String outputId, Object... results)
{
if ( (outputId.equals( "crafting" )) && (this.getClass() == NEIFacadeRecipeHandler.class) )
if ( ( outputId.equals( "crafting" ) ) && ( this.getClass() == NEIFacadeRecipeHandler.class ) )
{
ItemFacade ifa = (ItemFacade) AEApi.instance().items().itemFacade.item();
List<ItemStack> facades = ifa.getFacades();
for (ItemStack is : facades)
final List<ItemStack> facades = this.facade.getFacades();
for ( ItemStack anchorStack : this.anchorDefinition.maybeStack( 1 ).asSet() )
{
CachedShapedRecipe recipe = new CachedShapedRecipe( is );
recipe.computeVisuals();
this.arecipes.add( recipe );
for ( ItemStack is : facades )
{
CachedShapedRecipe recipe = new CachedShapedRecipe( this.facade, anchorStack, is );
recipe.computeVisuals();
this.arecipes.add( recipe );
}
}
}
else
@@ -84,31 +86,37 @@ public class NEIFacadeRecipeHandler extends TemplateRecipeHandler
}
@Override
public void loadCraftingRecipes(ItemStack result)
public void loadCraftingRecipes( ItemStack result )
{
if ( result.getItem() == this.ifa )
if ( result.getItem() == this.facade )
{
CachedShapedRecipe recipe = new CachedShapedRecipe( result );
recipe.computeVisuals();
this.arecipes.add( recipe );
for ( ItemStack anchorStack : this.anchorDefinition.maybeStack( 1 ).asSet() )
{
CachedShapedRecipe recipe = new CachedShapedRecipe( this.facade, anchorStack, result );
recipe.computeVisuals();
this.arecipes.add( recipe );
}
}
}
@Override
public void loadUsageRecipes(ItemStack ingredient)
public void loadUsageRecipes( ItemStack ingredient )
{
List<ItemStack> facades = this.ifa.getFacades();
for (ItemStack is : facades)
List<ItemStack> facades = this.facade.getFacades();
for ( ItemStack anchorStack : this.anchorDefinition.maybeStack( 1 ).asSet() )
{
CachedShapedRecipe recipe = new CachedShapedRecipe( is );
if ( recipe.contains( recipe.ingredients, ingredient.getItem() ) )
for ( ItemStack is : facades )
{
recipe.computeVisuals();
if ( recipe.contains( recipe.ingredients, ingredient ) )
CachedShapedRecipe recipe = new CachedShapedRecipe( this.facade, anchorStack, is );
if ( recipe.contains( recipe.ingredients, ingredient.getItem() ) )
{
recipe.setIngredientPermutation( recipe.ingredients, ingredient );
this.arecipes.add( recipe );
recipe.computeVisuals();
if ( recipe.contains( recipe.ingredients, ingredient ) )
{
recipe.setIngredientPermutation( recipe.ingredients, ingredient );
this.arecipes.add( recipe );
}
}
}
}
@@ -127,13 +135,19 @@ public class NEIFacadeRecipeHandler extends TemplateRecipeHandler
}
@Override
public boolean hasOverlay(GuiContainer gui, Container container, int recipe)
public Class<? extends GuiContainer> getGuiClass()
{
return (super.hasOverlay( gui, container, recipe )) || ((this.isRecipe2x2( recipe )) && (RecipeInfo.hasDefaultOverlay( gui, "crafting2x2" )));
return GuiCrafting.class;
}
@Override
public IRecipeOverlayRenderer getOverlayRenderer(GuiContainer gui, int recipe)
public boolean hasOverlay( GuiContainer gui, Container container, int recipe )
{
return ( super.hasOverlay( gui, container, recipe ) ) || ( ( this.isRecipe2x2( recipe ) ) && ( RecipeInfo.hasDefaultOverlay( gui, "crafting2x2" ) ) );
}
@Override
public IRecipeOverlayRenderer getOverlayRenderer( GuiContainer gui, int recipe )
{
IRecipeOverlayRenderer renderer = super.getOverlayRenderer( gui, recipe );
if ( renderer != null )
@@ -147,7 +161,7 @@ public class NEIFacadeRecipeHandler extends TemplateRecipeHandler
}
@Override
public IOverlayHandler getOverlayHandler(GuiContainer gui, int recipe)
public IOverlayHandler getOverlayHandler( GuiContainer gui, int recipe )
{
IOverlayHandler handler = super.getOverlayHandler( gui, recipe );
if ( handler != null )
@@ -156,39 +170,45 @@ public class NEIFacadeRecipeHandler extends TemplateRecipeHandler
return RecipeInfo.getOverlayHandler( gui, "crafting2x2" );
}
public boolean isRecipe2x2(int recipe)
public boolean isRecipe2x2( int recipe )
{
for (PositionedStack stack : this.getIngredientStacks( recipe ))
for ( PositionedStack stack : this.getIngredientStacks( recipe ) )
{
if ( (stack.relx > 43) || (stack.rely > 24) )
if ( ( stack.relx > 43 ) || ( stack.rely > 24 ) )
return false;
}
return true;
}
public class CachedShapedRecipe extends TemplateRecipeHandler.CachedRecipe
@Override
public String getRecipeName()
{
return GuiText.FacadeCrafting.getLocal();
}
private final class CachedShapedRecipe extends TemplateRecipeHandler.CachedRecipe
{
public final ArrayList<PositionedStack> ingredients;
public final PositionedStack result;
public CachedShapedRecipe(ItemStack output) {
public CachedShapedRecipe( IFacadeItem facade, ItemStack anchor, ItemStack output )
{
output.stackSize = 4;
this.result = new PositionedStack( output, 119, 24 );
this.ingredients = new ArrayList<PositionedStack>();
ItemStack in = NEIFacadeRecipeHandler.this.ifa.getTextureItem( output );
this.setIngredients( 3, 3, new Object[] { null, NEIFacadeRecipeHandler.this.cable_anchor, null, NEIFacadeRecipeHandler.this.cable_anchor, in, NEIFacadeRecipeHandler.this.cable_anchor, null, NEIFacadeRecipeHandler.this.cable_anchor, null } );
ItemStack in = facade.getTextureItem( output );
this.setIngredients( 3, 3, new Object[] { null, anchor, null, anchor, in, anchor, null, anchor, null } );
}
public void setIngredients(int width, int height, Object[] items)
public void setIngredients( int width, int height, Object[] items )
{
for (int x = 0; x < width; x++)
for ( int x = 0; x < width; x++ )
{
for (int y = 0; y < height; y++)
for ( int y = 0; y < height; y++ )
{
if ( items[(y * width + x)] != null )
if ( items[( y * width + x )] != null )
{
ItemStack is = (ItemStack) items[(y * width + x)];
ItemStack is = (ItemStack) items[( y * width + x )];
PositionedStack stack = new PositionedStack( is, 25 + x * 18, 6 + y * 18, false );
stack.setMaxSize( 1 );
this.ingredients.add( stack );
@@ -197,21 +217,21 @@ public class NEIFacadeRecipeHandler extends TemplateRecipeHandler
}
}
@Override
public List<PositionedStack> getIngredients()
{
return this.getCycledIngredients( NEIFacadeRecipeHandler.this.cycleticks / 20, this.ingredients );
}
@Override
public PositionedStack getResult()
{
return this.result;
}
@Override
public List<PositionedStack> getIngredients()
{
return this.getCycledIngredients( NEIFacadeRecipeHandler.this.cycleticks / 20, this.ingredients );
}
public void computeVisuals()
{
for (PositionedStack p : this.ingredients)
for ( PositionedStack p : this.ingredients )
{
p.generatePermutations();
}
@@ -22,6 +22,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import org.lwjgl.opengl.GL11;
@@ -40,7 +41,9 @@ import codechicken.nei.recipe.ICraftingHandler;
import codechicken.nei.recipe.IUsageHandler;
import appeng.api.AEApi;
import appeng.api.util.AEItemDefinition;
import appeng.api.definitions.IDefinitions;
import appeng.api.definitions.IItemDefinition;
import appeng.api.definitions.IMaterials;
import appeng.core.AEConfig;
import appeng.core.features.AEFeature;
import appeng.core.localization.GuiText;
@@ -48,49 +51,64 @@ import appeng.core.localization.GuiText;
public class NEIWorldCraftingHandler implements ICraftingHandler, IUsageHandler
{
final HashMap<AEItemDefinition, String> details = new HashMap<AEItemDefinition, String>();
final List<AEItemDefinition> offsets = new LinkedList<AEItemDefinition>();
final List<PositionedStack> outputs = new LinkedList<PositionedStack>();
private final Map<IItemDefinition, String> details = new HashMap<IItemDefinition, String>();
private final List<IItemDefinition> offsets = new LinkedList<IItemDefinition>();
private final List<PositionedStack> outputs = new LinkedList<PositionedStack>();
ItemStack target;
private ItemStack target;
private void addRecipe(AEItemDefinition def, String msg)
private void addRecipe(IItemDefinition def, String msg)
{
if ( NEIServerUtils.areStacksSameTypeCrafting( def.stack( 1 ), this.target ) )
for ( ItemStack definitionStack : def.maybeStack( 1 ).asSet() )
{
this.offsets.add( def );
this.outputs.add( new PositionedStack( def.stack( 1 ), 75, 4 ) );
this.details.put( def, msg );
if ( NEIServerUtils.areStacksSameTypeCrafting( definitionStack, this.target ) )
{
this.offsets.add( def );
this.outputs.add( new PositionedStack( definitionStack, 75, 4 ) );
this.details.put( def, msg );
}
}
}
private void addRecipes()
{
final IDefinitions definitions = AEApi.instance().definitions();
final IMaterials materials = definitions.materials();
final String message;
if ( AEConfig.instance.isFeatureEnabled( AEFeature.CertusQuartzWorldGen ) )
this.addRecipe( AEApi.instance().materials().materialCertusQuartzCrystalCharged,
GuiText.ChargedQuartz.getLocal() + "\n\n" + GuiText.ChargedQuartzFind.getLocal() );
{
message = GuiText.ChargedQuartz.getLocal() + "\n\n" + GuiText.ChargedQuartzFind.getLocal();
}
else
this.addRecipe( AEApi.instance().materials().materialCertusQuartzCrystalCharged, GuiText.ChargedQuartzFind.getLocal() );
{
message = GuiText.ChargedQuartzFind.getLocal();
}
this.addRecipe( materials.certusQuartzCrystalCharged(), message );
if ( AEConfig.instance.isFeatureEnabled( AEFeature.MeteoriteWorldGen ) )
{
this.addRecipe( AEApi.instance().materials().materialLogicProcessorPress, GuiText.inWorldCraftingPresses.getLocal() );
this.addRecipe( AEApi.instance().materials().materialCalcProcessorPress, GuiText.inWorldCraftingPresses.getLocal() );
this.addRecipe( AEApi.instance().materials().materialEngProcessorPress, GuiText.inWorldCraftingPresses.getLocal() );
this.addRecipe( materials.logicProcessorPress(), GuiText.inWorldCraftingPresses.getLocal() );
this.addRecipe( materials.calcProcessorPress(), GuiText.inWorldCraftingPresses.getLocal() );
this.addRecipe( materials.engProcessorPress(), GuiText.inWorldCraftingPresses.getLocal() );
}
if ( AEConfig.instance.isFeatureEnabled( AEFeature.inWorldFluix ) )
this.addRecipe( AEApi.instance().materials().materialFluixCrystal, GuiText.inWorldFluix.getLocal() );
{
this.addRecipe( materials.fluixCrystal(), GuiText.inWorldFluix.getLocal() );
}
if ( AEConfig.instance.isFeatureEnabled( AEFeature.inWorldSingularity ) )
this.addRecipe( AEApi.instance().materials().materialQESingularity, GuiText.inWorldSingularity.getLocal() );
{
this.addRecipe( materials.qESingularity(), GuiText.inWorldSingularity.getLocal() );
}
if ( AEConfig.instance.isFeatureEnabled( AEFeature.inWorldPurification ) )
{
this.addRecipe( AEApi.instance().materials().materialPurifiedCertusQuartzCrystal, GuiText.inWorldPurificationCertus.getLocal() );
this.addRecipe( AEApi.instance().materials().materialPurifiedNetherQuartzCrystal, GuiText.inWorldPurificationNether.getLocal() );
this.addRecipe( AEApi.instance().materials().materialPurifiedFluixCrystal, GuiText.inWorldPurificationFluix.getLocal() );
this.addRecipe( materials.purifiedCertusQuartzCrystal(), GuiText.inWorldPurificationCertus.getLocal() );
this.addRecipe( materials.purifiedNetherQuartzCrystal(), GuiText.inWorldPurificationNether.getLocal() );
this.addRecipe( materials.purifiedFluixCrystal(), GuiText.inWorldPurificationFluix.getLocal() );
}
}
@@ -18,6 +18,7 @@
package appeng.integration.modules.helpers;
import net.mcft.copy.betterstorage.api.crate.ICrateStorage;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.util.ForgeDirection;
@@ -30,30 +31,25 @@ import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
import appeng.util.item.AEItemStack;
public class BSCrate implements IMEInventory<IAEItemStack>
{
private final ICrateStorage crateStorage;
private final ForgeDirection side;
final ICrateStorage cs;
final ForgeDirection side;
public BSCrate(Object object, ForgeDirection d) {
this.cs = (ICrateStorage) object;
public BSCrate( Object object, ForgeDirection d )
{
this.crateStorage = (ICrateStorage) object;
this.side = d;
}
@Override
public StorageChannel getChannel()
{
return StorageChannel.ITEMS;
}
@Override
public IAEItemStack injectItems(IAEItemStack input, Actionable mode, BaseActionSource src)
public IAEItemStack injectItems( IAEItemStack input, Actionable mode, BaseActionSource src )
{
if ( mode == Actionable.SIMULATE )
return null;
ItemStack failed = this.cs.insertItems( input.getItemStack() );
ItemStack failed = this.crateStorage.insertItems( input.getItemStack() );
if ( failed == null )
return null;
input.setStackSize( failed.stackSize );
@@ -61,26 +57,31 @@ public class BSCrate implements IMEInventory<IAEItemStack>
}
@Override
public IAEItemStack extractItems(IAEItemStack request, Actionable mode, BaseActionSource src)
public IAEItemStack extractItems( IAEItemStack request, Actionable mode, BaseActionSource src )
{
if ( mode == Actionable.SIMULATE )
{
int howMany = this.cs.getItemCount( request.getItemStack() );
int howMany = this.crateStorage.getItemCount( request.getItemStack() );
return howMany > request.getStackSize() ? request : request.copy().setStackSize( howMany );
}
ItemStack Obtained = this.cs.extractItems( request.getItemStack(), (int) request.getStackSize() );
return AEItemStack.create( Obtained );
ItemStack obtained = this.crateStorage.extractItems( request.getItemStack(), (int) request.getStackSize() );
return AEItemStack.create( obtained );
}
@Override
public IItemList getAvailableItems(IItemList out)
public IItemList getAvailableItems( IItemList out )
{
for (ItemStack is : this.cs.getContents())
for ( ItemStack is : this.crateStorage.getContents() )
{
out.add( AEItemStack.create( is ) );
}
return out;
}
@Override
public StorageChannel getChannel()
{
return StorageChannel.ITEMS;
}
}