AE2 First Commit, the dawn of 1.7 hast arrived.
This commit is contained in:
@@ -0,0 +1,221 @@
|
||||
package appeng.integration.modules;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.TunnelType;
|
||||
import appeng.api.features.IP2PTunnelRegistry;
|
||||
import appeng.api.parts.IFacadePart;
|
||||
import appeng.facade.FacadePart;
|
||||
import appeng.integration.IIntegrationModule;
|
||||
import appeng.integration.abstraction.IBC;
|
||||
import buildcraft.BuildCraftEnergy;
|
||||
import buildcraft.BuildCraftTransport;
|
||||
import buildcraft.api.tools.IToolWrench;
|
||||
import buildcraft.api.transport.FacadeManager;
|
||||
import buildcraft.api.transport.IPipeTile;
|
||||
import buildcraft.api.transport.IPipeTile.PipeType;
|
||||
import buildcraft.transport.ItemFacade;
|
||||
import buildcraft.transport.PipeIconProvider;
|
||||
import buildcraft.transport.TileGenericPipe;
|
||||
|
||||
public class BC implements IIntegrationModule, IBC
|
||||
{
|
||||
|
||||
public static BC instance;
|
||||
|
||||
@Override
|
||||
public void addFacade(ItemStack item)
|
||||
{
|
||||
// Myrathi :
|
||||
// FMLInterModComms.sendMessage("BuildCraft|Transport", "add-facade",
|
||||
// <your block ID> + "@" + <your block meta>);
|
||||
FacadeManager.addFacade( item );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWrench(Item eq)
|
||||
{
|
||||
return eq instanceof IToolWrench;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPipe(TileEntity te, ForgeDirection dir)
|
||||
{
|
||||
if ( te instanceof IPipeTile )
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( te instanceof TileGenericPipe )
|
||||
if ( ((TileGenericPipe) te).hasPlug( dir.getOpposite() ) )
|
||||
return false;
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
if ( is != null && te != null && te instanceof IPipeTile )
|
||||
{
|
||||
IPipeTile pt = (IPipeTile) te;
|
||||
if ( pt.getPipeType() == PipeType.ITEM )
|
||||
{
|
||||
int amt = pt.injectItem( is, false, dir );
|
||||
if ( amt == is.stackSize )
|
||||
{
|
||||
pt.injectItem( is, true, dir );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFacade(ItemStack is)
|
||||
{
|
||||
if ( is == null )
|
||||
return false;
|
||||
return is.getItem() instanceof ItemFacade;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAddItemsToPipe(TileEntity te, ItemStack is, ForgeDirection dir)
|
||||
{
|
||||
|
||||
if ( is != null && te != null && te instanceof IPipeTile )
|
||||
{
|
||||
IPipeTile pt = (IPipeTile) te;
|
||||
if ( pt.getPipeType() == PipeType.ITEM )
|
||||
{
|
||||
int amt = pt.injectItem( is, false, dir );
|
||||
if ( amt == is.stackSize )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerPowerP2P()
|
||||
{
|
||||
IP2PTunnelRegistry reg = AEApi.instance().registries().p2pTunnel();
|
||||
reg.addNewAttunement( new ItemStack( BuildCraftEnergy.engineBlock, 1, 0 ), TunnelType.BC_POWER );
|
||||
reg.addNewAttunement( new ItemStack( BuildCraftEnergy.engineBlock, 1, 1 ), TunnelType.BC_POWER );
|
||||
reg.addNewAttunement( new ItemStack( BuildCraftEnergy.engineBlock, 1, 2 ), TunnelType.BC_POWER );
|
||||
reg.addNewAttunement( new ItemStack( BuildCraftTransport.pipePowerCobblestone ), TunnelType.BC_POWER );
|
||||
reg.addNewAttunement( new ItemStack( BuildCraftTransport.pipePowerDiamond ), TunnelType.BC_POWER );
|
||||
reg.addNewAttunement( new ItemStack( BuildCraftTransport.pipePowerGold ), TunnelType.BC_POWER );
|
||||
reg.addNewAttunement( new ItemStack( BuildCraftTransport.pipePowerQuartz ), TunnelType.BC_POWER );
|
||||
reg.addNewAttunement( new ItemStack( BuildCraftTransport.pipePowerStone ), TunnelType.BC_POWER );
|
||||
reg.addNewAttunement( new ItemStack( BuildCraftTransport.pipePowerWood ), TunnelType.BC_POWER );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerItemP2P()
|
||||
{
|
||||
IP2PTunnelRegistry reg = AEApi.instance().registries().p2pTunnel();
|
||||
reg.addNewAttunement( new ItemStack( BuildCraftTransport.pipeItemsWood ), TunnelType.ITEM );
|
||||
reg.addNewAttunement( new ItemStack( BuildCraftTransport.pipeItemsVoid ), TunnelType.ITEM );
|
||||
reg.addNewAttunement( new ItemStack( BuildCraftTransport.pipeItemsSandstone ), TunnelType.ITEM );
|
||||
reg.addNewAttunement( new ItemStack( BuildCraftTransport.pipeItemsQuartz ), TunnelType.ITEM );
|
||||
reg.addNewAttunement( new ItemStack( BuildCraftTransport.pipeItemsObsidian ), TunnelType.ITEM );
|
||||
reg.addNewAttunement( new ItemStack( BuildCraftTransport.pipeItemsIron ), TunnelType.ITEM );
|
||||
reg.addNewAttunement( new ItemStack( BuildCraftTransport.pipeItemsGold ), TunnelType.ITEM );
|
||||
reg.addNewAttunement( new ItemStack( BuildCraftTransport.pipeItemsEmerald ), TunnelType.ITEM );
|
||||
reg.addNewAttunement( new ItemStack( BuildCraftTransport.pipeItemsDiamond ), TunnelType.ITEM );
|
||||
reg.addNewAttunement( new ItemStack( BuildCraftTransport.pipeItemsStone ), TunnelType.ITEM );
|
||||
reg.addNewAttunement( new ItemStack( BuildCraftTransport.pipeItemsCobblestone ), TunnelType.ITEM );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerLiquidsP2P()
|
||||
{
|
||||
IP2PTunnelRegistry reg = AEApi.instance().registries().p2pTunnel();
|
||||
reg.addNewAttunement( new ItemStack( BuildCraftTransport.pipeFluidsCobblestone ), TunnelType.FLUID );
|
||||
reg.addNewAttunement( new ItemStack( BuildCraftTransport.pipeFluidsEmerald ), TunnelType.FLUID );
|
||||
reg.addNewAttunement( new ItemStack( BuildCraftTransport.pipeFluidsGold ), TunnelType.FLUID );
|
||||
reg.addNewAttunement( new ItemStack( BuildCraftTransport.pipeFluidsIron ), TunnelType.FLUID );
|
||||
reg.addNewAttunement( new ItemStack( BuildCraftTransport.pipeFluidsSandstone ), TunnelType.FLUID );
|
||||
reg.addNewAttunement( new ItemStack( BuildCraftTransport.pipeFluidsStone ), TunnelType.FLUID );
|
||||
reg.addNewAttunement( new ItemStack( BuildCraftTransport.pipeFluidsVoid ), TunnelType.FLUID );
|
||||
reg.addNewAttunement( new ItemStack( BuildCraftTransport.pipeFluidsWood ), TunnelType.FLUID );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Init()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PostInit()
|
||||
{
|
||||
registerPowerP2P();
|
||||
registerItemP2P();
|
||||
registerLiquidsP2P();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFacadePart createFacadePart(int[] ids, ForgeDirection side)
|
||||
{
|
||||
ItemStack fs = ItemFacade.getStack( ids[0], ids[1] );
|
||||
return new FacadePart( fs, side );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFacadePart createFacadePart(ItemStack fs, ForgeDirection side)
|
||||
{
|
||||
return new FacadePart( fs, side );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getTextureForFacade(ItemStack facade)
|
||||
{
|
||||
return new ItemStack( Block.blocksList[ItemFacade.getBlockId( facade )], 1, ItemFacade.getMetaData( facade ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getFacadeTexture()
|
||||
{
|
||||
try
|
||||
{
|
||||
return BuildCraftTransport.instance.pipeIconProvider.getIcon( PipeIconProvider.TYPE.PipeStructureCobblestone.ordinal() ); // Structure
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
}
|
||||
return null;
|
||||
// Pipe
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package appeng.integration.modules;
|
||||
|
||||
import net.mcft.copy.betterstorage.api.ICrateStorage;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import appeng.integration.IIntegrationModule;
|
||||
import appeng.integration.abstraction.IBS;
|
||||
import appeng.integration.modules.helpers.BSCrateStorageAdaptor;
|
||||
import appeng.util.InventoryAdaptor;
|
||||
|
||||
public class BS implements IIntegrationModule, IBS
|
||||
{
|
||||
|
||||
public static BS instance;
|
||||
|
||||
@Override
|
||||
public boolean isStorageCrate(Object te)
|
||||
{
|
||||
return te instanceof ICrateStorage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InventoryAdaptor getAdaptor(Object te, ForgeDirection d)
|
||||
{
|
||||
if ( te instanceof ICrateStorage )
|
||||
{
|
||||
return new BSCrateStorageAdaptor( te, d );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Init()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PostInit()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
package appeng.integration.modules;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.parts.IPartHost;
|
||||
import appeng.core.AELog;
|
||||
import appeng.fmp.CableBusPart;
|
||||
import appeng.fmp.FMPEvent;
|
||||
import appeng.fmp.PartRegistry;
|
||||
import appeng.integration.IIntegrationModule;
|
||||
import appeng.integration.abstraction.IFMP;
|
||||
import appeng.parts.CableBusContainer;
|
||||
import appeng.util.Platform;
|
||||
import codechicken.lib.vec.BlockCoord;
|
||||
import codechicken.microblock.BlockMicroMaterial;
|
||||
import codechicken.multipart.MultiPartRegistry;
|
||||
import codechicken.multipart.MultiPartRegistry.IPartConverter;
|
||||
import codechicken.multipart.MultiPartRegistry.IPartFactory;
|
||||
import codechicken.multipart.MultipartGenerator;
|
||||
import codechicken.multipart.TMultiPart;
|
||||
import codechicken.multipart.TileMultipart;
|
||||
|
||||
public class FMP implements IIntegrationModule, IPartFactory, IPartConverter, IFMP
|
||||
{
|
||||
|
||||
public static FMP instance;
|
||||
|
||||
@Override
|
||||
public TMultiPart createPart(String name, boolean client)
|
||||
{
|
||||
for (PartRegistry pr : PartRegistry.values())
|
||||
{
|
||||
if ( pr.getName() == name )
|
||||
return pr.construct( 0 );
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConvert(int blockID)
|
||||
{
|
||||
return PartRegistry.isPart( Block.blocksList[blockID] );
|
||||
}
|
||||
|
||||
@Override
|
||||
public TMultiPart convert(World world, BlockCoord pos)
|
||||
{
|
||||
int blockID = world.getBlockId( pos.x, pos.y, pos.z );
|
||||
int meta = world.getBlockMetadata( pos.x, pos.y, pos.z );
|
||||
|
||||
TMultiPart part = PartRegistry.getPartByBlock( Block.blocksList[blockID], meta );
|
||||
if ( part instanceof CableBusPart )
|
||||
{
|
||||
CableBusPart cbp = (CableBusPart) part;
|
||||
cbp.convertFromTile( world.getBlockTileEntity( pos.x, pos.y, pos.z ) );
|
||||
}
|
||||
|
||||
return part;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Init() throws Throwable
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PostInit() throws Throwable
|
||||
{
|
||||
BlockMicroMaterial.createAndRegister( AEApi.instance().blocks().blockQuartz.block() );
|
||||
BlockMicroMaterial.createAndRegister( AEApi.instance().blocks().blockQuartzPiller.block() );
|
||||
BlockMicroMaterial.createAndRegister( AEApi.instance().blocks().blockQuartzChiseled.block() );
|
||||
|
||||
PartRegistry reg[] = PartRegistry.values();
|
||||
|
||||
String data[] = new String[reg.length];
|
||||
for (int x = 0; x < data.length; x++)
|
||||
data[x] = reg[x].getName();
|
||||
|
||||
MultiPartRegistry.registerConverter( this );
|
||||
MultiPartRegistry.registerParts( this, data );
|
||||
MinecraftForge.EVENT_BUS.register( new FMPEvent() );
|
||||
// MultipartGenerator.registerPassThroughInterface( "appeng.helpers.AEMultiTile" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPartHost getOrCreateHost(TileEntity tile)
|
||||
{
|
||||
try
|
||||
{
|
||||
BlockCoord loc = new BlockCoord( tile.xCoord, tile.yCoord, tile.zCoord );
|
||||
|
||||
TileMultipart mp = TileMultipart.getOrConvertTile( tile.worldObj, loc );
|
||||
if ( mp != null )
|
||||
{
|
||||
scala.collection.Iterator<TMultiPart> i = mp.partList().iterator();
|
||||
while (i.hasNext())
|
||||
{
|
||||
TMultiPart p = i.next();
|
||||
if ( p instanceof CableBusPart )
|
||||
return (IPartHost) p;
|
||||
}
|
||||
|
||||
TMultiPart part = PartRegistry.CableBusPart.construct( 0 );
|
||||
if ( mp.canAddPart( part ) && Platform.isServer() )
|
||||
TileMultipart.addPart( tile.worldObj, loc, part );
|
||||
return (CableBusPart) part;
|
||||
}
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
t.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CableBusContainer getCableContainer(TileEntity te)
|
||||
{
|
||||
if ( te instanceof TileMultipart )
|
||||
{
|
||||
TileMultipart mp = (TileMultipart) te;
|
||||
scala.collection.Iterator<TMultiPart> i = mp.partList().iterator();
|
||||
while (i.hasNext())
|
||||
{
|
||||
TMultiPart p = i.next();
|
||||
if ( p instanceof CableBusPart )
|
||||
return ((CableBusPart) p).cb;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerPassThru(Class<?> layerInterface)
|
||||
{
|
||||
try
|
||||
{
|
||||
MultipartGenerator.registerPassThroughInterface( layerInterface.getName() );
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
AELog.severe( "Failed to register " + layerInterface.getName() + " with FMP, some features may not work with MultiParts." );
|
||||
t.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,207 @@
|
||||
package appeng.integration.modules;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.integration.IIntegrationModule;
|
||||
import appeng.integration.abstraction.IFZ;
|
||||
import appeng.integration.modules.helpers.FactorizationBarrel;
|
||||
import appeng.util.Platform;
|
||||
|
||||
/**
|
||||
* 100% Hacks.
|
||||
*/
|
||||
public class FZ implements IFZ, IIntegrationModule
|
||||
{
|
||||
|
||||
public static FZ instance;
|
||||
|
||||
private static Class day_BarrelClass;
|
||||
private static Method day_getItemCount;
|
||||
private static Method day_setItemCount;
|
||||
private static Method day_getMaxSize;
|
||||
private static Field day_item;
|
||||
|
||||
private static Class barrelClass;
|
||||
private static Method getItemCount;
|
||||
private static Method setItemCount;
|
||||
private static Method getMaxSize;
|
||||
private static Field item;
|
||||
|
||||
@Override
|
||||
public ItemStack barrelGetItem(TileEntity te)
|
||||
{
|
||||
try
|
||||
{
|
||||
ItemStack i;
|
||||
|
||||
if ( day_BarrelClass.isInstance( te ) ) i = (ItemStack) day_item.get( te );
|
||||
else
|
||||
i = (ItemStack) item.get( te );
|
||||
|
||||
if ( i != null ) i = Platform.cloneItemStack( i );
|
||||
return i;
|
||||
}
|
||||
catch (IllegalArgumentException e)
|
||||
{
|
||||
}
|
||||
catch (IllegalAccessException e)
|
||||
{
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int barrelGetMaxItemCount(TileEntity te)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
if ( day_BarrelClass.isInstance( te ) ) return (Integer) day_getMaxSize.invoke( te );
|
||||
else
|
||||
return (Integer) getMaxSize.invoke( te );
|
||||
}
|
||||
catch (IllegalAccessException e)
|
||||
{
|
||||
}
|
||||
catch (IllegalArgumentException e)
|
||||
{
|
||||
}
|
||||
catch (InvocationTargetException e)
|
||||
{
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int barrelGetItemCount(TileEntity te)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
if ( day_BarrelClass.isInstance( te ) ) return (Integer) day_getItemCount.invoke( te );
|
||||
else
|
||||
return (Integer) getItemCount.invoke( te );
|
||||
}
|
||||
catch (IllegalAccessException e)
|
||||
{
|
||||
}
|
||||
catch (IllegalArgumentException e)
|
||||
{
|
||||
}
|
||||
catch (InvocationTargetException e)
|
||||
{
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItemType(TileEntity te, ItemStack input)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
if ( day_BarrelClass.isInstance( te ) ) day_item.set( te, input == null ? null : input.copy() );
|
||||
else
|
||||
item.set( te, input == null ? null : input.copy() );
|
||||
}
|
||||
catch (IllegalArgumentException e)
|
||||
{
|
||||
}
|
||||
catch (IllegalAccessException e)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void barrelSetCount(TileEntity te, int max)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
if ( day_BarrelClass.isInstance( te ) ) day_setItemCount.invoke( te, max );
|
||||
else
|
||||
setItemCount.invoke( te, max );
|
||||
|
||||
te.worldObj.markBlockForUpdate( te.xCoord, te.yCoord, te.zCoord );
|
||||
}
|
||||
catch (IllegalAccessException e)
|
||||
{
|
||||
}
|
||||
catch (IllegalArgumentException e)
|
||||
{
|
||||
}
|
||||
catch (InvocationTargetException e)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMEInventory getFactorizationBarrel(TileEntity te)
|
||||
{
|
||||
return new FactorizationBarrel( this, te );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBarrel(TileEntity te)
|
||||
{
|
||||
if ( day_BarrelClass.isAssignableFrom( te.getClass() ) ) return true;
|
||||
if ( barrelClass.isAssignableFrom( te.getClass() ) ) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Init() throws Throwable
|
||||
{
|
||||
barrelClass = Class.forName( "factorization.common.TileEntityBarrel" );
|
||||
day_BarrelClass = Class.forName( "factorization.common.TileEntityDayBarrel" );
|
||||
|
||||
getItemCount = barrelClass.getDeclaredMethod( "getItemCount", new Class[] {} );
|
||||
setItemCount = barrelClass.getDeclaredMethod( "setItemCount", new Class[] { int.class } );
|
||||
getMaxSize = barrelClass.getDeclaredMethod( "getMaxSize", new Class[] {} );
|
||||
item = barrelClass.getDeclaredField( "item" );
|
||||
|
||||
day_getItemCount = day_BarrelClass.getDeclaredMethod( "getItemCount", new Class[] {} );
|
||||
day_setItemCount = day_BarrelClass.getDeclaredMethod( "setItemCount", new Class[] { int.class } );
|
||||
day_getMaxSize = day_BarrelClass.getDeclaredMethod( "getMaxSize", new Class[] {} );
|
||||
day_item = day_BarrelClass.getDeclaredField( "item" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PostInit()
|
||||
{
|
||||
// certus quartz
|
||||
grinderRecipe( AEApi.instance().materials().materialCertusQuartzCrystal.stack( 1 ),
|
||||
AEApi.instance().materials().materialCertusQuartzDust.stack( 1 ) );
|
||||
|
||||
grinderRecipe( AEApi.instance().materials().materialCertusQuartzCrystalCharged.stack( 1 ),
|
||||
AEApi.instance().materials().materialCertusQuartzDust.stack( 1 ) );
|
||||
|
||||
// fluix
|
||||
grinderRecipe( AEApi.instance().materials().materialFluixCrystal.stack( 1 ),
|
||||
AEApi.instance().materials().materialFluixDust.stack( 1 ) );
|
||||
|
||||
// nether quartz
|
||||
grinderRecipe( new ItemStack( Item.netherQuartz ), AEApi.instance().materials().materialNetherQuartzDust.stack( 1 ) );
|
||||
}
|
||||
|
||||
private void grinderRecipe(ItemStack in, ItemStack out)
|
||||
{
|
||||
try
|
||||
{
|
||||
Class c = Class.forName( "factorization.common.TileEntityGrinder" );
|
||||
Method m = c.getMethod( "addRecipe", Object.class, ItemStack.class, float.class );
|
||||
m.invoke( c, in, out, 1.0 );
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
throw new RuntimeException( t );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package appeng.integration.modules;
|
||||
|
||||
import appeng.integration.IIntegrationModule;
|
||||
|
||||
public class Forestry implements IIntegrationModule
|
||||
{
|
||||
|
||||
public static Forestry instance;
|
||||
|
||||
@Override
|
||||
public void Init()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PostInit()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package appeng.integration.modules;
|
||||
|
||||
import gregtechmod.api.interfaces.IDigitalChest;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.integration.IIntegrationModule;
|
||||
import appeng.integration.abstraction.IGT;
|
||||
import appeng.integration.modules.helpers.GregTechQuantumChest;
|
||||
import appeng.util.InventoryAdaptor;
|
||||
|
||||
public class GT implements IGT, IIntegrationModule
|
||||
{
|
||||
|
||||
public static GT instance;
|
||||
|
||||
@Override
|
||||
public IMEInventory getQuantumChest(TileEntity te)
|
||||
{
|
||||
return new GregTechQuantumChest( (IInventory) te, InventoryAdaptor.getAdaptor( te, ForgeDirection.NORTH ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isQuantumChest(TileEntity te)
|
||||
{
|
||||
if ( te instanceof IDigitalChest )
|
||||
return ((IDigitalChest) te).isDigitalChest();
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Init()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PostInit()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package appeng.integration.modules;
|
||||
|
||||
import ic2.api.recipe.RecipeInputItemStack;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.integration.IIntegrationModule;
|
||||
|
||||
public class IC2 implements IIntegrationModule
|
||||
{
|
||||
|
||||
public static IC2 instance;
|
||||
|
||||
@Override
|
||||
public void Init()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PostInit()
|
||||
{
|
||||
// certus quartz
|
||||
maceratorRecipe( AEApi.instance().materials().materialCertusQuartzCrystal.stack( 1 ),
|
||||
AEApi.instance().materials().materialCertusQuartzDust.stack( 1 ) );
|
||||
|
||||
maceratorRecipe( AEApi.instance().materials().materialCertusQuartzCrystalCharged.stack( 1 ),
|
||||
AEApi.instance().materials().materialCertusQuartzDust.stack( 1 ) );
|
||||
|
||||
// fluix
|
||||
maceratorRecipe( AEApi.instance().materials().materialFluixCrystal.stack( 1 ),
|
||||
AEApi.instance().materials().materialFluixDust.stack( 1 ) );
|
||||
|
||||
// nether quartz
|
||||
maceratorRecipe( new ItemStack( Item.netherQuartz ), AEApi.instance().materials().materialNetherQuartzDust.stack( 1 ) );
|
||||
}
|
||||
|
||||
private void maceratorRecipe(ItemStack in, ItemStack out)
|
||||
{
|
||||
ic2.api.recipe.Recipes.macerator.addRecipe( new RecipeInputItemStack( in, in.stackSize ), null, out );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package appeng.integration.modules;
|
||||
|
||||
import appeng.integration.IIntegrationModule;
|
||||
|
||||
public class InvTweaks implements IIntegrationModule
|
||||
{
|
||||
|
||||
public static InvTweaks instance;
|
||||
|
||||
@Override
|
||||
public void Init()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PostInit()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package appeng.integration.modules;
|
||||
|
||||
import appeng.integration.IIntegrationModule;
|
||||
|
||||
public class LP implements IIntegrationModule
|
||||
{
|
||||
|
||||
public static LP instance;
|
||||
|
||||
@Override
|
||||
public void Init()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PostInit()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package appeng.integration.modules;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import powercrystals.minefactoryreloaded.api.IDeepStorageUnit;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.integration.IIntegrationModule;
|
||||
import appeng.integration.abstraction.IMFR;
|
||||
import appeng.integration.modules.helpers.MFRDSU;
|
||||
|
||||
public class MFR implements IIntegrationModule, IMFR
|
||||
{
|
||||
|
||||
public static MFR instance;
|
||||
|
||||
@Override
|
||||
public IMEInventory getDSU(TileEntity te)
|
||||
{
|
||||
return new MFRDSU( te );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDSU(TileEntity te)
|
||||
{
|
||||
if ( te instanceof IDeepStorageUnit ) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Init()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PostInit()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package appeng.integration.modules;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.integration.IIntegrationModule;
|
||||
|
||||
public class Mekanism implements IIntegrationModule
|
||||
{
|
||||
|
||||
public static Mekanism instance;
|
||||
|
||||
@Override
|
||||
public void Init()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PostInit()
|
||||
{
|
||||
// certus quartz
|
||||
crusher( AEApi.instance().materials().materialCertusQuartzCrystal.stack( 1 ),
|
||||
AEApi.instance().materials().materialCertusQuartzDust.stack( 1 ) );
|
||||
|
||||
crusher( AEApi.instance().materials().materialCertusQuartzCrystalCharged.stack( 1 ),
|
||||
AEApi.instance().materials().materialCertusQuartzDust.stack( 1 ) );
|
||||
|
||||
// fluix
|
||||
crusher( AEApi.instance().materials().materialFluixCrystal.stack( 1 ), AEApi.instance().materials().materialFluixDust.stack( 1 ) );
|
||||
|
||||
// nether quartz
|
||||
crusher( new ItemStack( Item.netherQuartz ), AEApi.instance().materials().materialNetherQuartzDust.stack( 1 ) );
|
||||
}
|
||||
|
||||
private void crusher(ItemStack input, ItemStack output)
|
||||
{
|
||||
mekanism.api.RecipeHelper.addCrusherRecipe( input, output );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package appeng.integration.modules;
|
||||
|
||||
import appeng.integration.IIntegrationModule;
|
||||
|
||||
public class Mystcraft implements IIntegrationModule
|
||||
{
|
||||
|
||||
public static Mystcraft instance;
|
||||
|
||||
@Override
|
||||
public void Init()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PostInit()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package appeng.integration.modules;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import appeng.integration.IIntegrationModule;
|
||||
import appeng.integration.modules.helpers.NEIQuartzShapedRecipeHandler;
|
||||
|
||||
public class NEI implements IIntegrationModule
|
||||
{
|
||||
|
||||
public static NEI instance;
|
||||
|
||||
@Override
|
||||
public void Init() throws Throwable
|
||||
{
|
||||
Class API = Class.forName( "codechicken.nei.api.API" );
|
||||
Method registerRecipeHandler = API.getDeclaredMethod( "registerRecipeHandler", new Class[] { codechicken.nei.recipe.ICraftingHandler.class } );
|
||||
Method registerUsageHandler = API.getDeclaredMethod( "registerUsageHandler", new Class[] { codechicken.nei.recipe.IUsageHandler.class } );
|
||||
|
||||
registerRecipeHandler.invoke( API, new NEIQuartzShapedRecipeHandler() );
|
||||
registerUsageHandler.invoke( API, new NEIQuartzShapedRecipeHandler() );
|
||||
|
||||
/*
|
||||
* Method registerGuiOverlay = API.getDeclaredMethod( "registerGuiOverlay", new Class[] { Class.class,
|
||||
* String.class, int.class, int.class } ); Class IOverlayHandler = Class.forName(
|
||||
* "codechicken.nei.api.IOverlayHandler" ); Class DefaultOverlayHandler =
|
||||
* NEICraftingTerminalOverlayHandler.class; Method registerGuiOverlayHandler = API.getDeclaredMethod(
|
||||
* "registerGuiOverlayHandler", new Class[] { Class.class, IOverlayHandler, String.class } );
|
||||
* registerGuiOverlay.invoke( API, GuiCraftingTerminal.class, "crafting", 6, 75 ); Constructor
|
||||
* DefaultOverlayHandlerConstructor = DefaultOverlayHandler .getConstructor( new Class[] { int.class, int.class
|
||||
* } ); registerGuiOverlayHandler.invoke( API, GuiCraftingTerminal.class,
|
||||
* DefaultOverlayHandlerConstructor.newInstance( 6, 75 ), "crafting" );
|
||||
*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PostInit() throws Throwable
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package appeng.integration.modules;
|
||||
|
||||
import mods.railcraft.api.crafting.IRockCrusherRecipe;
|
||||
import mods.railcraft.api.crafting.RailcraftCraftingManager;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.integration.IIntegrationModule;
|
||||
|
||||
public class RC implements IIntegrationModule
|
||||
{
|
||||
|
||||
public static RC instance;
|
||||
|
||||
public void rockCrusher(ItemStack input, ItemStack output)
|
||||
{
|
||||
IRockCrusherRecipe re = RailcraftCraftingManager.rockCrusher.createNewRecipe( input, true, true );
|
||||
re.addOutput( output, 1.0f );
|
||||
}
|
||||
|
||||
public void rockCrusher(ItemStack input, ItemStack output, ItemStack secondary, float chance)
|
||||
{
|
||||
IRockCrusherRecipe re = RailcraftCraftingManager.rockCrusher.createNewRecipe( input, true, true );
|
||||
re.addOutput( output, 1.0f );
|
||||
if ( secondary != null ) re.addOutput( secondary, chance );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Init()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PostInit()
|
||||
{
|
||||
// certus quartz
|
||||
rockCrusher( AEApi.instance().materials().materialCertusQuartzCrystal.stack( 1 ),
|
||||
AEApi.instance().materials().materialCertusQuartzDust.stack( 1 ) );
|
||||
|
||||
rockCrusher( AEApi.instance().materials().materialCertusQuartzCrystalCharged.stack( 1 ),
|
||||
AEApi.instance().materials().materialCertusQuartzDust.stack( 1 ) );
|
||||
|
||||
// fluix
|
||||
rockCrusher( AEApi.instance().materials().materialFluixCrystal.stack( 1 ), AEApi.instance().materials().materialFluixDust.stack( 1 ) );
|
||||
|
||||
// nether quartz
|
||||
rockCrusher( new ItemStack( Item.netherQuartz ), AEApi.instance().materials().materialNetherQuartzDust.stack( 1 ) );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package appeng.integration.modules;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.integration.IIntegrationModule;
|
||||
|
||||
public class TE implements IIntegrationModule
|
||||
{
|
||||
|
||||
public static TE instance;
|
||||
|
||||
@Override
|
||||
public void Init()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PostInit()
|
||||
{
|
||||
// certus quartz
|
||||
pulverizer( AEApi.instance().materials().materialCertusQuartzCrystal.stack( 1 ),
|
||||
AEApi.instance().materials().materialCertusQuartzDust.stack( 1 ) );
|
||||
|
||||
pulverizer( AEApi.instance().materials().materialCertusQuartzCrystalCharged.stack( 1 ),
|
||||
AEApi.instance().materials().materialCertusQuartzDust.stack( 1 ) );
|
||||
|
||||
// fluix
|
||||
pulverizer( AEApi.instance().materials().materialFluixCrystal.stack( 1 ), AEApi.instance().materials().materialFluixDust.stack( 1 ) );
|
||||
|
||||
// nether quartz
|
||||
pulverizer( new ItemStack( Item.netherQuartz ), AEApi.instance().materials().materialNetherQuartzDust.stack( 1 ) );
|
||||
}
|
||||
|
||||
private void pulverizer(ItemStack in, ItemStack out)
|
||||
{
|
||||
thermalexpansion.api.crafting.CraftingManagers.pulverizerManager.addRecipe( 320, in, out );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package appeng.integration.modules;
|
||||
|
||||
import appeng.integration.IIntegrationModule;
|
||||
|
||||
public class UE implements IIntegrationModule
|
||||
{
|
||||
|
||||
public static UE instance;
|
||||
|
||||
@Override
|
||||
public void Init()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PostInit()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package appeng.integration.modules.helpers;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import appeng.api.storage.IExternalStorageHandler;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.integration.modules.BC;
|
||||
|
||||
public class BCPipeHandler implements IExternalStorageHandler
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean canHandle(TileEntity te, ForgeDirection d, StorageChannel chan)
|
||||
{
|
||||
return chan == StorageChannel.ITEMS && BC.instance.isPipe( te, d );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMEInventory getInventory(TileEntity te, ForgeDirection d, StorageChannel chan)
|
||||
{
|
||||
if ( chan == StorageChannel.ITEMS )
|
||||
return new BCPipeInventory( te, d );
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package appeng.integration.modules.helpers;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.integration.modules.BC;
|
||||
|
||||
public class BCPipeInventory implements IMEInventory<IAEItemStack>
|
||||
{
|
||||
|
||||
TileEntity te;
|
||||
ForgeDirection dir;
|
||||
|
||||
public BCPipeInventory(TileEntity _te, ForgeDirection _dir) {
|
||||
te = _te;
|
||||
dir = _dir;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StorageChannel getChannel()
|
||||
{
|
||||
return StorageChannel.ITEMS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack injectItems(IAEItemStack input, Actionable mode)
|
||||
{
|
||||
if ( mode == Actionable.SIMULATE )
|
||||
{
|
||||
if ( BC.instance.canAddItemsToPipe( te, input.getItemStack(), dir ) )
|
||||
return null;
|
||||
return input;
|
||||
}
|
||||
|
||||
if ( BC.instance.addItemsToPipe( te, input.getItemStack(), dir ) )
|
||||
return null;
|
||||
return input;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack extractItems(IAEItemStack request, Actionable mode)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemList<IAEItemStack> getAvailableItems(IItemList out)
|
||||
{
|
||||
return out;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package appeng.integration.modules.helpers;
|
||||
|
||||
import net.mcft.copy.betterstorage.api.ICrateStorage;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.util.item.AEItemStack;
|
||||
|
||||
public class BSCrate implements IMEInventory<IAEItemStack>
|
||||
{
|
||||
|
||||
ICrateStorage cs;
|
||||
ForgeDirection side;
|
||||
|
||||
public BSCrate(Object object, ForgeDirection d) {
|
||||
cs = (ICrateStorage) object;
|
||||
side = d;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StorageChannel getChannel()
|
||||
{
|
||||
return StorageChannel.ITEMS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack injectItems(IAEItemStack input, Actionable mode)
|
||||
{
|
||||
if ( mode == Actionable.SIMULATE )
|
||||
return null;
|
||||
|
||||
ItemStack failed = cs.insertItems( side, input.getItemStack() );
|
||||
if ( failed == null )
|
||||
return null;
|
||||
input.setStackSize( failed.stackSize );
|
||||
return input;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack extractItems(IAEItemStack request, Actionable mode)
|
||||
{
|
||||
if ( mode == Actionable.SIMULATE )
|
||||
{
|
||||
int howMany = cs.getItemCount( side, request.getItemStack() );
|
||||
return howMany > request.getStackSize() ? request : request.copy().setStackSize( howMany );
|
||||
}
|
||||
|
||||
ItemStack Obtained = cs.extractItems( side, request.getItemStack() );
|
||||
return AEItemStack.create( Obtained );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemList getAvailableItems(IItemList out)
|
||||
{
|
||||
for (ItemStack is : cs.getContents( side ))
|
||||
{
|
||||
out.add( AEItemStack.create( is ) );
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package appeng.integration.modules.helpers;
|
||||
|
||||
import net.mcft.copy.betterstorage.api.ICrateStorage;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import appeng.api.storage.IExternalStorageHandler;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
|
||||
public class BSCrateHandler implements IExternalStorageHandler
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean canHandle(TileEntity te, ForgeDirection d, StorageChannel chan)
|
||||
{
|
||||
return chan == StorageChannel.ITEMS && te instanceof ICrateStorage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMEInventory getInventory(TileEntity te, ForgeDirection d, StorageChannel chan)
|
||||
{
|
||||
if ( chan == StorageChannel.ITEMS )
|
||||
return new BSCrate( te, ForgeDirection.UNKNOWN );
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,185 @@
|
||||
package appeng.integration.modules.helpers;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import net.mcft.copy.betterstorage.api.ICrateStorage;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.util.InventoryAdaptor;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.inv.IInventoryDestination;
|
||||
import appeng.util.inv.ItemSlot;
|
||||
import appeng.util.iterators.StackToSlotIterator;
|
||||
|
||||
public class BSCrateStorageAdaptor extends InventoryAdaptor
|
||||
{
|
||||
|
||||
ICrateStorage cs;
|
||||
ForgeDirection side;
|
||||
|
||||
public BSCrateStorageAdaptor(Object te, ForgeDirection d) {
|
||||
cs = (ICrateStorage) te;
|
||||
side = d;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack removeItems(int how_many, ItemStack Filter, IInventoryDestination dest)
|
||||
{
|
||||
ItemStack target = null;
|
||||
|
||||
for (ItemStack is : cs.getContents( side ))
|
||||
{
|
||||
if ( is != null )
|
||||
{
|
||||
if ( is.stackSize > 0 && (Filter == null || Platform.isSameItem( Filter, is )) )
|
||||
{
|
||||
if ( dest == null || dest.canInsert( is ) )
|
||||
{
|
||||
target = is;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( target != null )
|
||||
{
|
||||
ItemStack f = Platform.cloneItemStack( target );
|
||||
f.stackSize = how_many;
|
||||
return cs.extractItems( side, f );
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack simulateRemove(int how_many, ItemStack Filter, IInventoryDestination dest)
|
||||
{
|
||||
ItemStack target = null;
|
||||
|
||||
for (ItemStack is : cs.getContents( side ))
|
||||
{
|
||||
if ( is != null )
|
||||
{
|
||||
if ( is.stackSize > 0 && (Filter == null || Platform.isSameItem( Filter, is )) )
|
||||
{
|
||||
if ( dest == null || dest.canInsert( is ) )
|
||||
{
|
||||
target = is;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( target != null )
|
||||
{
|
||||
int cnt = cs.getItemCount( side, target );
|
||||
if ( cnt == 0 )
|
||||
return null;
|
||||
if ( cnt > how_many )
|
||||
cnt = how_many;
|
||||
ItemStack c = target.copy();
|
||||
c.stackSize = cnt;
|
||||
return c;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack removeSimilarItems(int amount, ItemStack filter, FuzzyMode fuzzyMode, IInventoryDestination dest)
|
||||
{
|
||||
ItemStack target = null;
|
||||
|
||||
for (ItemStack is : cs.getContents( side ))
|
||||
{
|
||||
if ( is != null )
|
||||
{
|
||||
if ( is.stackSize > 0 && (filter == null || Platform.isSameItemFuzzy( filter, is, fuzzyMode )) )
|
||||
{
|
||||
if ( dest == null || dest.canInsert( is ) )
|
||||
{
|
||||
target = is;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( target != null )
|
||||
{
|
||||
ItemStack f = Platform.cloneItemStack( target );
|
||||
f.stackSize = amount;
|
||||
return cs.extractItems( side, f );
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack simulateSimilarRemove(int how_many, ItemStack filter, FuzzyMode fuzzyMode, IInventoryDestination dest)
|
||||
{
|
||||
ItemStack target = null;
|
||||
|
||||
for (ItemStack is : cs.getContents( side ))
|
||||
{
|
||||
if ( is != null )
|
||||
{
|
||||
if ( is.stackSize > 0 && (filter == null || Platform.isSameItemFuzzy( filter, is, fuzzyMode )) )
|
||||
{
|
||||
if ( dest == null || dest.canInsert( is ) )
|
||||
{
|
||||
target = is;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( target != null )
|
||||
{
|
||||
int cnt = cs.getItemCount( side, target );
|
||||
if ( cnt == 0 )
|
||||
return null;
|
||||
if ( cnt > how_many )
|
||||
cnt = how_many;
|
||||
ItemStack c = target.copy();
|
||||
c.stackSize = cnt;
|
||||
return c;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack addItems(ItemStack A)
|
||||
{
|
||||
return cs.insertItems( side, A );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack simulateAdd(ItemStack A)
|
||||
{
|
||||
int items = cs.spaceForItem( side, A );
|
||||
ItemStack B = Platform.cloneItemStack( A );
|
||||
if ( A.stackSize <= items )
|
||||
return null;
|
||||
B.stackSize -= items;
|
||||
return B;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsItems()
|
||||
{
|
||||
return cs.getContents( side ).size() > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<ItemSlot> iterator()
|
||||
{
|
||||
return new StackToSlotIterator( cs.getContents( side ).iterator() );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package appeng.integration.modules.helpers;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraftforge.event.Event;
|
||||
|
||||
public class FMPPacketEvent extends Event
|
||||
{
|
||||
|
||||
public final EntityPlayerMP sender;
|
||||
|
||||
public FMPPacketEvent(EntityPlayerMP sender) {
|
||||
this.sender = sender;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,400 @@
|
||||
package appeng.integration.modules.helpers;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import buildcraft.transport.ItemFacade;
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class FacadeProxyBC implements IFacadeProxy
|
||||
{
|
||||
|
||||
float facadeThickness = 1F / 16F;
|
||||
|
||||
int facadeBlocks[];
|
||||
int facadeMeta[];
|
||||
|
||||
public FacadeProxyBC() {
|
||||
facadeBlocks = new int[6];
|
||||
facadeMeta = new int[6];
|
||||
}
|
||||
|
||||
/**
|
||||
* Mirrors the array on the Y axis by calculating offsets from 0.5F
|
||||
*
|
||||
* @param targetArray
|
||||
*/
|
||||
private void mirrorY(float[][] targetArray)
|
||||
{
|
||||
float temp = targetArray[1][0];
|
||||
targetArray[1][0] = (targetArray[1][1] - 0.5F) * -1F + 0.5F; // 1 ->
|
||||
// 0.5F
|
||||
// ->
|
||||
// -0.5F
|
||||
// -> 0F
|
||||
targetArray[1][1] = (temp - 0.5F) * -1F + 0.5F; // 0 -> -0.5F -> 0.5F ->
|
||||
// 1F
|
||||
}
|
||||
|
||||
/**
|
||||
* Shifts the coordinates around effectivly rotating something. Zero state
|
||||
* is DOWN then -> NORTH -> WEST Note - To obtain Pos, do a mirrorY() before
|
||||
* rotating
|
||||
*
|
||||
* @param targetArray
|
||||
* the array that should be rotated
|
||||
*/
|
||||
private void rotate(float[][] targetArray)
|
||||
{
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
float temp = targetArray[2][i];
|
||||
targetArray[2][i] = targetArray[1][i];
|
||||
targetArray[1][i] = targetArray[0][i];
|
||||
targetArray[0][i] = temp;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param targetArray
|
||||
* the array that should be transformed
|
||||
* @param direction
|
||||
*/
|
||||
private void transform(float[][] targetArray, ForgeDirection direction)
|
||||
{
|
||||
if ( (direction.ordinal() & 0x1) == 1 )
|
||||
{
|
||||
mirrorY( targetArray );
|
||||
}
|
||||
|
||||
for (int i = 0; i < (direction.ordinal() >> 1); i++)
|
||||
{
|
||||
rotate( targetArray );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clones both dimensions of a float[][]
|
||||
*
|
||||
* @param source
|
||||
* the float[][] to deepClone
|
||||
* @return
|
||||
*/
|
||||
private float[][] deepClone(float[][] source)
|
||||
{
|
||||
float[][] target = source.clone();
|
||||
for (int i = 0; i < target.length; i++)
|
||||
{
|
||||
target[i] = source[i].clone();
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void facadeRender(RenderBlocks renderblocks, Block block, IFacadeTile ft, int x, int y, int z, float tubeThickness)
|
||||
{
|
||||
float zFightOffset = 1F / 4096F;
|
||||
|
||||
float[][] zeroState = new float[3][2];
|
||||
// X START - END
|
||||
zeroState[0][0] = 0.0F - zFightOffset / 2;
|
||||
zeroState[0][1] = 1.0F + zFightOffset / 2;
|
||||
// Y START - END
|
||||
zeroState[1][0] = 0.0F - zFightOffset;
|
||||
zeroState[1][1] = facadeThickness;
|
||||
// Z START - END
|
||||
zeroState[2][0] = 0.0F;
|
||||
zeroState[2][1] = 1.0F;
|
||||
|
||||
renderblocks.renderAllFaces = true;
|
||||
|
||||
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
if ( hasFacade( ft, direction ) )
|
||||
{
|
||||
Block blk = Block.blocksList[facadeBlocks[direction.ordinal()]];
|
||||
renderblocks.overrideBlockTexture = blk.getIcon( direction.ordinal(), facadeMeta[direction.ordinal()] );
|
||||
|
||||
try
|
||||
{
|
||||
// AppEngBlockRenderer.instance.overrideRenderColor =
|
||||
// Item.itemsList[ facadeBlocks[ direction.ordinal() ]
|
||||
// ].getColorFromItemStack(new ItemStack( facadeBlocks[
|
||||
// direction.ordinal() ], 1, facadeMeta[ direction.ordinal()
|
||||
// ] ), 0);
|
||||
} catch (Throwable error)
|
||||
{
|
||||
// explosion!
|
||||
}
|
||||
|
||||
if ( blk.getRenderType() == 31 )
|
||||
{
|
||||
if ( (facadeMeta[direction.ordinal()] & 12) == 4 )
|
||||
{
|
||||
renderblocks.uvRotateEast = 1;
|
||||
renderblocks.uvRotateWest = 1;
|
||||
renderblocks.uvRotateTop = 1;
|
||||
renderblocks.uvRotateBottom = 1;
|
||||
} else if ( (facadeMeta[direction.ordinal()] & 12) == 8 )
|
||||
{
|
||||
renderblocks.uvRotateSouth = 1;
|
||||
renderblocks.uvRotateNorth = 1;
|
||||
}
|
||||
}
|
||||
|
||||
float holeThickness = ft.getHoleThickness( direction );
|
||||
|
||||
// Hollow facade
|
||||
if ( ft.isConnected( direction ) )
|
||||
{
|
||||
float[][] rotated = deepClone( zeroState );
|
||||
rotated[2][0] = 0.0F;
|
||||
rotated[2][1] = 0.0f + holeThickness;
|
||||
rotated[1][0] -= zFightOffset / 2;
|
||||
transform( rotated, direction );
|
||||
block.setBlockBounds( rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1],
|
||||
rotated[2][1] );
|
||||
renderblocks.setRenderBoundsFromBlock( block );
|
||||
renderblocks.renderStandardBlock( block, x, y, z );
|
||||
|
||||
rotated = deepClone( zeroState );
|
||||
rotated[2][0] = 1.0f - holeThickness;
|
||||
rotated[1][0] -= zFightOffset / 2;
|
||||
transform( rotated, direction );
|
||||
block.setBlockBounds( rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1],
|
||||
rotated[2][1] );
|
||||
renderblocks.setRenderBoundsFromBlock( block );
|
||||
renderblocks.renderStandardBlock( block, x, y, z );
|
||||
|
||||
rotated = deepClone( zeroState );
|
||||
rotated[0][0] = 0.0F;
|
||||
rotated[0][1] = 0.0f + holeThickness;
|
||||
rotated[1][1] -= zFightOffset;
|
||||
transform( rotated, direction );
|
||||
block.setBlockBounds( rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1],
|
||||
rotated[2][1] );
|
||||
renderblocks.setRenderBoundsFromBlock( block );
|
||||
renderblocks.renderStandardBlock( block, x, y, z );
|
||||
|
||||
rotated = deepClone( zeroState );
|
||||
rotated[0][0] = 1.0f - holeThickness;
|
||||
rotated[0][1] = 1F;
|
||||
rotated[1][1] -= zFightOffset;
|
||||
transform( rotated, direction );
|
||||
block.setBlockBounds( rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1],
|
||||
rotated[2][1] );
|
||||
renderblocks.setRenderBoundsFromBlock( block );
|
||||
renderblocks.renderStandardBlock( block, x, y, z );
|
||||
} else
|
||||
{ // Solid facade
|
||||
float[][] rotated = deepClone( zeroState );
|
||||
transform( rotated, direction );
|
||||
block.setBlockBounds( rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1],
|
||||
rotated[2][1] );
|
||||
renderblocks.setRenderBoundsFromBlock( block );
|
||||
renderblocks.renderStandardBlock( block, x, y, z );
|
||||
}
|
||||
|
||||
// AppEngBlockRenderer.instance.overrideRenderColor = -1;
|
||||
}
|
||||
|
||||
renderblocks.uvRotateEast = 0;
|
||||
renderblocks.uvRotateWest = 0;
|
||||
renderblocks.uvRotateTop = 0;
|
||||
renderblocks.uvRotateBottom = 0;
|
||||
renderblocks.uvRotateSouth = 0;
|
||||
renderblocks.uvRotateNorth = 0;
|
||||
}
|
||||
|
||||
// X START - END
|
||||
zeroState[0][0] = 0.0f + tubeThickness; // Utils.pipeMinPos;
|
||||
zeroState[0][1] = 1.0f - tubeThickness; // Utils.pipeMaxPos;
|
||||
// Y START - END
|
||||
zeroState[1][0] = facadeThickness;
|
||||
zeroState[1][1] = 0.0f + tubeThickness; // Utils.pipeMinPos;
|
||||
// Z START - END
|
||||
zeroState[2][0] = 0.0f + tubeThickness; // Utils.pipeMinPos;
|
||||
zeroState[2][1] = 1.0f - tubeThickness; // Utils.pipeMaxPos;
|
||||
|
||||
if ( tubeThickness > 0.001 )
|
||||
{
|
||||
// renderblocks.overrideBlockTexture =
|
||||
// BuildCraftTransport.instance.pipeIconProvider.getIcon(PipeIconProvider.PipeStructureCobblestone);
|
||||
// // Structure Pipe
|
||||
|
||||
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
if ( hasFacade( ft, direction ) && !ft.isConnected( direction ) )
|
||||
{
|
||||
float[][] rotated = deepClone( zeroState );
|
||||
transform( rotated, direction );
|
||||
|
||||
block.setBlockBounds( rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1],
|
||||
rotated[2][1] );
|
||||
renderblocks.setRenderBoundsFromBlock( block );
|
||||
renderblocks.renderStandardBlock( block, x, y, z );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
renderblocks.renderAllFaces = false;
|
||||
renderblocks.overrideBlockTexture = null;
|
||||
}
|
||||
|
||||
ItemStack createFacade(int itemid, int meta)
|
||||
{
|
||||
try
|
||||
{
|
||||
return ItemFacade.getStack( itemid, meta );
|
||||
} catch (Throwable e)
|
||||
{
|
||||
try
|
||||
{
|
||||
// return new ItemStack( BuildCraftTransport.facadeItem, 1,
|
||||
// ItemFacade.encode( itemid, meta ) );
|
||||
} catch (Throwable e2)
|
||||
{
|
||||
FMLLog.severe( "Unable to create facade item, please make sure your using the newest Version of BC and AE, and if you are inform AlgorithmX2 of this message." );
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(IFacadeTile ft)
|
||||
{
|
||||
List<ItemStack> out = new ArrayList();
|
||||
|
||||
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
if ( this.facadeBlocks[direction.ordinal()] != 0 )
|
||||
{
|
||||
ItemStack facade = createFacade( this.facadeBlocks[direction.ordinal()], this.facadeMeta[direction.ordinal()] );
|
||||
|
||||
this.facadeMeta[direction.ordinal()] = 0;
|
||||
|
||||
out.add( facade );
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addFacade(IFacadeTile ft, ForgeDirection direction, int blockid, int meta)
|
||||
{
|
||||
if ( hasFacade( ft, direction ) )
|
||||
dropFacade( ft, direction );
|
||||
|
||||
// if ( ft.isConnected( direction ) )
|
||||
// return false;
|
||||
|
||||
this.facadeBlocks[direction.ordinal()] = blockid;
|
||||
this.facadeMeta[direction.ordinal()] = meta;
|
||||
|
||||
ft.markForUpdate();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasFacade(IFacadeTile ft, ForgeDirection direction)
|
||||
{
|
||||
return this.facadeBlocks[direction.ordinal()] != 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dropFacade(IFacadeTile ft, ForgeDirection direction)
|
||||
{
|
||||
if ( this.facadeBlocks[direction.ordinal()] != 0 )
|
||||
{
|
||||
ItemStack facade = createFacade( this.facadeBlocks[direction.ordinal()], this.facadeMeta[direction.ordinal()] );
|
||||
|
||||
this.facadeBlocks[direction.ordinal()] = 0;
|
||||
this.facadeMeta[direction.ordinal()] = 0;
|
||||
|
||||
ft.dropFacadeItem( facade );
|
||||
|
||||
ft.markForUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean readFromStream(DataInputStream out) throws IOException
|
||||
{
|
||||
boolean diffrent = false;
|
||||
for (int x = 0; x < 6; x++)
|
||||
{
|
||||
int fb = facadeBlocks[x];
|
||||
int fm = facadeMeta[x];
|
||||
facadeBlocks[x] = out.readInt();
|
||||
facadeMeta[x] = out.readInt();
|
||||
diffrent = diffrent || fb != facadeBlocks[x] || fm != facadeMeta[x];
|
||||
}
|
||||
return diffrent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToStream(DataOutputStream out) throws IOException
|
||||
{
|
||||
for (int x = 0; x < 6; x++)
|
||||
{
|
||||
out.writeInt( facadeBlocks[x] );
|
||||
out.writeInt( facadeMeta[x] );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound tc)
|
||||
{
|
||||
tc.setIntArray( "facadeBlocks", facadeBlocks );
|
||||
tc.setIntArray( "facadeMeta", facadeMeta );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tc)
|
||||
{
|
||||
facadeBlocks = tc.getIntArray( "facadeBlocks" );
|
||||
facadeMeta = tc.getIntArray( "facadeMeta" );
|
||||
|
||||
if ( facadeBlocks == null )
|
||||
facadeBlocks = new int[6];
|
||||
if ( facadeMeta == null )
|
||||
facadeMeta = new int[6];
|
||||
if ( facadeBlocks.length != 6 )
|
||||
facadeBlocks = new int[6];
|
||||
if ( facadeMeta.length != 6 )
|
||||
facadeMeta = new int[6];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addFacade(TileEntity tileEntity, int side, ItemStack hand)
|
||||
{
|
||||
if ( tileEntity instanceof IFacadeTile )
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
return addFacade( (IFacadeTile) tileEntity, ForgeDirection.getOrientation( side ), ItemFacade.getBlockId( hand ),
|
||||
ItemFacade.getMetaData( hand ) );
|
||||
} catch (Throwable e)
|
||||
{
|
||||
FMLLog.severe( "Unable to place facade item, please make sure your using the newest Version of BC and AE, and if you are inform AlgorithmX2 of this message." );
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package appeng.integration.modules.helpers;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class FacadeProxyNull implements IFacadeProxy
|
||||
{
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void facadeRender(RenderBlocks renderblocks, Block block, IFacadeTile ft, int x, int y, int z, float th)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(IFacadeTile ft)
|
||||
{
|
||||
return new ArrayList<ItemStack>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addFacade(IFacadeTile ft, ForgeDirection direction, int blockid, int meta)
|
||||
{
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasFacade(IFacadeTile ft, ForgeDirection direction)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dropFacade(IFacadeTile ft, ForgeDirection direction)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound tc)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToStream(DataOutputStream out) throws IOException
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean readFromStream(DataInputStream out) throws IOException
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tc)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addFacade(TileEntity tileEntity, int side, ItemStack hand)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
package appeng.integration.modules.helpers;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.integration.abstraction.IFZ;
|
||||
import appeng.util.item.AEItemStack;
|
||||
|
||||
public class FactorizationBarrel implements IMEInventory<IAEItemStack>
|
||||
{
|
||||
|
||||
private final TileEntity te;
|
||||
IFZ fProxy;
|
||||
|
||||
public FactorizationBarrel(IFZ proxy, TileEntity tile) {
|
||||
te = tile;
|
||||
fProxy = proxy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StorageChannel getChannel()
|
||||
{
|
||||
return StorageChannel.ITEMS;
|
||||
}
|
||||
|
||||
public long remainingItemTypes()
|
||||
{
|
||||
return fProxy.barrelGetItem( te ) == null ? 1 : 0;
|
||||
}
|
||||
|
||||
public long remainingItemCount()
|
||||
{
|
||||
return fProxy.barrelGetMaxItemCount( te ) - fProxy.barrelGetItemCount( te );
|
||||
}
|
||||
|
||||
public boolean containsItemType(IAEItemStack i)
|
||||
{
|
||||
return i.equals( fProxy.barrelGetItem( te ) );
|
||||
}
|
||||
|
||||
public long storedItemCount()
|
||||
{
|
||||
return fProxy.barrelGetItemCount( te );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack injectItems(IAEItemStack input, Actionable mode)
|
||||
{
|
||||
if ( input == null )
|
||||
return null;
|
||||
if ( input.getStackSize() == 0 )
|
||||
return null;
|
||||
|
||||
ItemStack shared = input.getItemStack();
|
||||
if ( shared.isItemDamaged() )
|
||||
return input;
|
||||
|
||||
if ( remainingItemTypes() > 0 )
|
||||
{
|
||||
if ( mode == Actionable.MODULATE )
|
||||
fProxy.setItemType( te, input.getItemStack() );
|
||||
}
|
||||
|
||||
if ( containsItemType( input ) )
|
||||
{
|
||||
int max = fProxy.barrelGetMaxItemCount( te );
|
||||
int newTotal = (int) storedItemCount() + (int) input.getStackSize();
|
||||
if ( newTotal > max )
|
||||
{
|
||||
if ( mode == Actionable.MODULATE )
|
||||
fProxy.barrelSetCount( te, max );
|
||||
IAEItemStack result = input.copy();
|
||||
result.setStackSize( newTotal - max );
|
||||
return result;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( mode == Actionable.MODULATE )
|
||||
fProxy.barrelSetCount( te, newTotal );
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return input;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack extractItems(IAEItemStack request, Actionable mode)
|
||||
{
|
||||
if ( containsItemType( request ) )
|
||||
{
|
||||
int howMany = (int) storedItemCount();
|
||||
if ( request.getStackSize() >= howMany )
|
||||
{
|
||||
if ( mode == Actionable.MODULATE )
|
||||
{
|
||||
fProxy.setItemType( te, null );
|
||||
fProxy.barrelSetCount( te, 0 );
|
||||
}
|
||||
|
||||
IAEItemStack r = request.copy();
|
||||
r.setStackSize( howMany );
|
||||
return r;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( mode == Actionable.MODULATE )
|
||||
fProxy.barrelSetCount( te, (int) (howMany - request.getStackSize()) );
|
||||
return request.copy();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemList<IAEItemStack> getAvailableItems(IItemList out)
|
||||
{
|
||||
ItemStack i = fProxy.barrelGetItem( te );
|
||||
if ( i != null )
|
||||
{
|
||||
i.stackSize = fProxy.barrelGetItemCount( te );
|
||||
out.addStorage( AEItemStack.create( i ) );
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package appeng.integration.modules.helpers;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import appeng.api.storage.IExternalStorageHandler;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.integration.modules.FZ;
|
||||
|
||||
public class FactorizationHandler implements IExternalStorageHandler
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean canHandle(TileEntity te, ForgeDirection d, StorageChannel chan)
|
||||
{
|
||||
return chan == StorageChannel.ITEMS && FZ.instance.isBarrel( te );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMEInventory getInventory(TileEntity te, ForgeDirection d, StorageChannel chan)
|
||||
{
|
||||
if ( chan == StorageChannel.ITEMS )
|
||||
return FZ.instance.getFactorizationBarrel( te );
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package appeng.integration.modules.helpers;
|
||||
|
||||
import appeng.api.features.IItemComparison;
|
||||
import appeng.api.integration.IBeeComparison;
|
||||
import forestry.api.arboriculture.EnumTreeChromosome;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
|
||||
public class ForestryGeneticsComparison implements IItemComparison, IBeeComparison
|
||||
{
|
||||
|
||||
IIndividual idiv;
|
||||
String Species;
|
||||
|
||||
@Override
|
||||
public IIndividual getIndividual()
|
||||
{
|
||||
return idiv;
|
||||
}
|
||||
|
||||
public ForestryGeneticsComparison(IIndividual _idiv) {
|
||||
idiv = _idiv;
|
||||
Species = _idiv.getGenome().getActiveAllele( EnumTreeChromosome.SPECIES.ordinal() ).getUID();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sameAsPrecise(IItemComparison comp)
|
||||
{
|
||||
if ( comp instanceof ForestryGeneticsComparison )
|
||||
{
|
||||
IIndividual op = ((ForestryGeneticsComparison) comp).idiv;
|
||||
if ( idiv.isAnalyzed() == op.isAnalyzed() )
|
||||
return idiv.isGeneticEqual( op );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sameAsFuzzy(IItemComparison comp)
|
||||
{
|
||||
if ( comp instanceof ForestryGeneticsComparison )
|
||||
return Species.equals( ((ForestryGeneticsComparison) comp).Species );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package appeng.integration.modules.helpers;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import appeng.api.features.IItemComparisionProvider;
|
||||
import appeng.api.features.IItemComparison;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
|
||||
public class ForestryGeneticsProvider implements IItemComparisionProvider
|
||||
{
|
||||
|
||||
@Override
|
||||
public IItemComparison getComparison(ItemStack is)
|
||||
{
|
||||
if ( forestry.api.genetics.AlleleManager.alleleRegistry != null )
|
||||
{
|
||||
IIndividual idiv = forestry.api.genetics.AlleleManager.alleleRegistry.getIndividual( is );
|
||||
if ( idiv == null )
|
||||
return null;
|
||||
return new ForestryGeneticsComparison( idiv );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canHandle(ItemStack stack)
|
||||
{
|
||||
if ( forestry.api.genetics.AlleleManager.alleleRegistry != null )
|
||||
return forestry.api.genetics.AlleleManager.alleleRegistry.isIndividual( stack );
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package appeng.integration.modules.helpers;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import appeng.api.storage.IExternalStorageHandler;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.integration.modules.GT;
|
||||
|
||||
public class GregTechHandler implements IExternalStorageHandler
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean canHandle(TileEntity te, ForgeDirection d, StorageChannel chan)
|
||||
{
|
||||
return chan == StorageChannel.ITEMS && GT.instance.isQuantumChest( te );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMEInventory getInventory(TileEntity te, ForgeDirection d, StorageChannel chan)
|
||||
{
|
||||
if ( chan == StorageChannel.ITEMS )
|
||||
return GT.instance.getQuantumChest( te );
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
package appeng.integration.modules.helpers;
|
||||
|
||||
import gregtechmod.api.interfaces.IDigitalChest;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.me.storage.MEIInventoryWrapper;
|
||||
import appeng.util.InventoryAdaptor;
|
||||
import appeng.util.item.AEItemStack;
|
||||
|
||||
public class GregTechQuantumChest extends MEIInventoryWrapper
|
||||
{
|
||||
|
||||
IDigitalChest qc;
|
||||
|
||||
public GregTechQuantumChest(IInventory m, InventoryAdaptor ia) {
|
||||
super( m, ia );
|
||||
qc = (IDigitalChest) m;
|
||||
}
|
||||
|
||||
private ItemStack getType()
|
||||
{
|
||||
ItemStack[] array = qc.getStoredItemData();
|
||||
if ( array.length > 0 && array[0].itemID > 0 )
|
||||
return array[0];
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack injectItems(IAEItemStack input, Actionable mode)
|
||||
{
|
||||
ItemStack type = getType();
|
||||
if ( input.hasTagCompound() )
|
||||
return input;
|
||||
|
||||
if ( type == null )
|
||||
{
|
||||
return input;
|
||||
}
|
||||
|
||||
if ( (type.getItem() == input.getItem() && type.getItemDamage() == input.getItemDamage()) )
|
||||
{
|
||||
if ( type.stackSize < qc.getMaxItemCount() )
|
||||
{
|
||||
int room = (int) ((long) qc.getMaxItemCount() - (long) type.stackSize);
|
||||
if ( input.getStackSize() > room )
|
||||
{
|
||||
IAEItemStack is = input.copy();
|
||||
is.setStackSize( is.getStackSize() - room );
|
||||
if ( mode == Actionable.MODULATE )
|
||||
qc.setItemCount( type.stackSize + room );
|
||||
|
||||
return super.injectItems( is, mode );
|
||||
}
|
||||
|
||||
if ( mode == Actionable.MODULATE )
|
||||
qc.setItemCount( type.stackSize + (int) input.getStackSize() );
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
return super.injectItems( input, mode );
|
||||
}
|
||||
|
||||
return input;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack extractItems(IAEItemStack i, Actionable mode)
|
||||
{
|
||||
ItemStack type = getType();
|
||||
if ( type != null )
|
||||
{
|
||||
if ( type.getItem() == i.getItem() && type.getItemDamage() == i.getItemDamage() )
|
||||
{
|
||||
if ( type.stackSize > i.getStackSize() )
|
||||
{
|
||||
IAEItemStack output = AEItemStack.create( type );
|
||||
output.setStackSize( (int) i.getStackSize() );
|
||||
if ( mode == Actionable.MODULATE )
|
||||
qc.setItemCount( type.stackSize - (int) output.getStackSize() );
|
||||
return output;
|
||||
}
|
||||
}
|
||||
}
|
||||
return super.extractItems( i, mode );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemList getAvailableItems(IItemList out)
|
||||
{
|
||||
ItemStack type = getType();
|
||||
if ( type != null )
|
||||
{
|
||||
super.getAvailableItems( out );
|
||||
if ( type != null && type.stackSize > 0 )
|
||||
out.addStorage( AEItemStack.create( type ) );
|
||||
}
|
||||
return out;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package appeng.integration.modules.helpers;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public interface IFacadeProxy
|
||||
{
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
void facadeRender(RenderBlocks renderblocks, Block block, IFacadeTile ft, int x, int y, int z, float tubeThickness);
|
||||
|
||||
List<ItemStack> getDrops(IFacadeTile ft);
|
||||
|
||||
boolean addFacade(IFacadeTile ft, ForgeDirection direction, int blockid, int meta);
|
||||
|
||||
boolean hasFacade(IFacadeTile ft, ForgeDirection direction);
|
||||
|
||||
void dropFacade(IFacadeTile ft, ForgeDirection direction);
|
||||
|
||||
void writeToNBT(NBTTagCompound tc);
|
||||
|
||||
void writeToStream(DataOutputStream out) throws IOException;
|
||||
|
||||
boolean readFromStream(DataInputStream out) throws IOException;
|
||||
|
||||
void readFromNBT(NBTTagCompound tc);
|
||||
|
||||
boolean addFacade(TileEntity tileEntity, int side, ItemStack hand);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package appeng.integration.modules.helpers;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
public interface IFacadeTile
|
||||
{
|
||||
|
||||
boolean isConnected(ForgeDirection direction);
|
||||
|
||||
void dropFacadeItem(ItemStack facade);
|
||||
|
||||
IFacadeProxy getFacadeProxy();
|
||||
|
||||
void markForUpdate();
|
||||
|
||||
float getHoleThickness(ForgeDirection direction);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
package appeng.integration.modules.helpers;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import powercrystals.minefactoryreloaded.api.IDeepStorageUnit;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.util.item.AEItemStack;
|
||||
|
||||
public class MFRDSU implements IMEInventory<IAEItemStack>
|
||||
{
|
||||
|
||||
IDeepStorageUnit dsu;
|
||||
TileEntity te;
|
||||
|
||||
public MFRDSU(TileEntity ta) {
|
||||
te = ta;
|
||||
dsu = (IDeepStorageUnit) ta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StorageChannel getChannel()
|
||||
{
|
||||
return StorageChannel.ITEMS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack injectItems(IAEItemStack input, Actionable mode)
|
||||
{
|
||||
ItemStack is = dsu.getStoredItemType();
|
||||
if ( is != null )
|
||||
{
|
||||
if ( input.equals( is ) )
|
||||
{
|
||||
long max = dsu.getMaxStoredCount();
|
||||
long additiona = is.stackSize;
|
||||
additiona += input.getStackSize();
|
||||
if ( additiona > max )
|
||||
{
|
||||
IAEItemStack overflow = AEItemStack.create( is );
|
||||
overflow.setStackSize( (int) (additiona - max) );
|
||||
if ( mode == Actionable.MODULATE )
|
||||
dsu.setStoredItemCount( (int) max );
|
||||
return overflow;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( mode == Actionable.MODULATE )
|
||||
dsu.setStoredItemCount( is.stackSize + (int) input.getStackSize() );
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( input.getTagCompound() != null )
|
||||
return input;
|
||||
if ( mode == Actionable.MODULATE )
|
||||
dsu.setStoredItemType( input.getItemStack(), (int) input.getStackSize() );
|
||||
return null;
|
||||
}
|
||||
return input;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack extractItems(IAEItemStack request, Actionable mode)
|
||||
{
|
||||
ItemStack is = dsu.getStoredItemType();
|
||||
if ( request.equals( is ) )
|
||||
{
|
||||
if ( request.getStackSize() >= is.stackSize )
|
||||
{
|
||||
if ( mode == Actionable.MODULATE )
|
||||
dsu.setStoredItemCount( 0 );
|
||||
return AEItemStack.create( is );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( mode == Actionable.MODULATE )
|
||||
dsu.setStoredItemCount( is.stackSize - (int) request.getStackSize() );
|
||||
return request.copy();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemList<IAEItemStack> getAvailableItems(IItemList out)
|
||||
{
|
||||
ItemStack is = dsu.getStoredItemType();
|
||||
if ( is != null )
|
||||
{
|
||||
out.add( AEItemStack.create( is ) );
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package appeng.integration.modules.helpers;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import appeng.api.storage.IExternalStorageHandler;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.integration.modules.MFR;
|
||||
|
||||
public class MFRDSUHandler implements IExternalStorageHandler
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean canHandle(TileEntity te, ForgeDirection d, StorageChannel chan)
|
||||
{
|
||||
return chan == StorageChannel.ITEMS && MFR.instance.isDSU( te );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMEInventory getInventory(TileEntity te, ForgeDirection d, StorageChannel chan)
|
||||
{
|
||||
if ( chan == StorageChannel.ITEMS )
|
||||
return MFR.instance.getDSU( te );
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package appeng.integration.modules.helpers;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import appeng.container.slot.SlotCraftingMatrix;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.api.IOverlayHandler;
|
||||
import codechicken.nei.recipe.IRecipeHandler;
|
||||
import cpw.mods.fml.common.network.PacketDispatcher;
|
||||
|
||||
public class NEICraftingTerminalOverlayHandler implements IOverlayHandler
|
||||
{
|
||||
|
||||
public NEICraftingTerminalOverlayHandler(int x, int y) {
|
||||
offsetx = x;
|
||||
offsety = y;
|
||||
}
|
||||
|
||||
int offsetx;
|
||||
int offsety;
|
||||
|
||||
// @override
|
||||
public void overlayRecipe(GuiContainer gui, IRecipeHandler recipe, int recipeIndex, boolean shift)
|
||||
{
|
||||
try
|
||||
{
|
||||
List ingredients = recipe.getIngredientStacks( recipeIndex );
|
||||
overlayRecipe( gui, ingredients, shift );
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
}
|
||||
catch (Error err)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
// @override
|
||||
public void overlayRecipe(GuiContainer gui, List<PositionedStack> ingredients, boolean shift)
|
||||
{
|
||||
try
|
||||
{
|
||||
NBTTagCompound recipe = new NBTTagCompound();
|
||||
|
||||
if ( gui instanceof GuiTerminal )
|
||||
{
|
||||
for (int i = 0; i < ingredients.size(); i++)// identify slots
|
||||
{
|
||||
LinkedList<Slot> recipeSlots = new LinkedList<Slot>();
|
||||
PositionedStack pstack = ingredients.get( i );
|
||||
if ( pstack.item != null )
|
||||
{
|
||||
for (Slot slot : (List<Slot>) gui.inventorySlots.inventorySlots)
|
||||
{
|
||||
if ( slot.xDisplayPosition == pstack.relx + offsetx && slot.yDisplayPosition == pstack.rely + offsety )
|
||||
{
|
||||
if ( slot instanceof SlotCraftingMatrix )
|
||||
{
|
||||
NBTTagCompound inbt = new NBTTagCompound();
|
||||
pstack.item.writeToNBT( inbt );
|
||||
recipe.setCompoundTag( "#" + ((SlotCraftingMatrix) slot).matrixID, inbt );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PacketDispatcher.sendPacketToServer( (new PacketNEIRecipe( recipe )).getPacket() );
|
||||
}
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
}
|
||||
catch (Error err)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,209 @@
|
||||
package appeng.integration.modules.helpers;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.gui.inventory.GuiCrafting;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import appeng.recipes.AEShapedQuartzRecipe;
|
||||
import codechicken.nei.NEIClientUtils;
|
||||
import codechicken.nei.NEIServerUtils;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.api.DefaultOverlayRenderer;
|
||||
import codechicken.nei.api.IOverlayHandler;
|
||||
import codechicken.nei.api.IRecipeOverlayRenderer;
|
||||
import codechicken.nei.api.IStackPositioner;
|
||||
import codechicken.nei.recipe.RecipeInfo;
|
||||
import codechicken.nei.recipe.TemplateRecipeHandler;
|
||||
|
||||
public class NEIQuartzShapedRecipeHandler extends TemplateRecipeHandler
|
||||
{
|
||||
|
||||
public void loadTransferRects()
|
||||
{
|
||||
this.transferRects.add( new TemplateRecipeHandler.RecipeTransferRect( new Rectangle( 84, 23, 24, 18 ), "crafting", new Object[0] ) );
|
||||
}
|
||||
|
||||
public Class<? extends GuiContainer> getGuiClass()
|
||||
{
|
||||
return GuiCrafting.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeName()
|
||||
{
|
||||
return NEIClientUtils.translate( "recipe.shaped", new Object[0] );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCraftingRecipes(String outputId, Object[] results)
|
||||
{
|
||||
if ( (outputId.equals( "crafting" )) && (getClass() == NEIQuartzShapedRecipeHandler.class) )
|
||||
{
|
||||
List<IRecipe> allrecipes = CraftingManager.getInstance().getRecipeList();
|
||||
for (IRecipe irecipe : allrecipes)
|
||||
{
|
||||
CachedShapedRecipe recipe = null;
|
||||
if ( (irecipe instanceof AEShapedQuartzRecipe) )
|
||||
recipe = new CachedShapedRecipe( (AEShapedQuartzRecipe) irecipe );
|
||||
|
||||
if ( recipe != null )
|
||||
{
|
||||
recipe.computeVisuals();
|
||||
this.arecipes.add( recipe );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
super.loadCraftingRecipes( outputId, results );
|
||||
}
|
||||
}
|
||||
|
||||
public void loadCraftingRecipes(ItemStack result)
|
||||
{
|
||||
List<IRecipe> allrecipes = CraftingManager.getInstance().getRecipeList();
|
||||
for (IRecipe irecipe : allrecipes)
|
||||
{
|
||||
if ( NEIServerUtils.areStacksSameTypeCrafting( irecipe.getRecipeOutput(), result ) )
|
||||
{
|
||||
CachedShapedRecipe recipe = null;
|
||||
if ( (irecipe instanceof AEShapedQuartzRecipe) )
|
||||
recipe = new CachedShapedRecipe( (AEShapedQuartzRecipe) irecipe );
|
||||
|
||||
if ( recipe != null )
|
||||
{
|
||||
recipe.computeVisuals();
|
||||
this.arecipes.add( recipe );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void loadUsageRecipes(ItemStack ingredient)
|
||||
{
|
||||
List<IRecipe> allrecipes = CraftingManager.getInstance().getRecipeList();
|
||||
for (IRecipe irecipe : allrecipes)
|
||||
{
|
||||
CachedShapedRecipe recipe = null;
|
||||
if ( (irecipe instanceof AEShapedQuartzRecipe) )
|
||||
recipe = new CachedShapedRecipe( (AEShapedQuartzRecipe) irecipe );
|
||||
|
||||
if ( (recipe != null) && (recipe.contains( recipe.ingredients, ingredient.itemID )) )
|
||||
{
|
||||
recipe.computeVisuals();
|
||||
if ( recipe.contains( recipe.ingredients, ingredient ) )
|
||||
{
|
||||
recipe.setIngredientPermutation( recipe.ingredients, ingredient );
|
||||
this.arecipes.add( recipe );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String getGuiTexture()
|
||||
{
|
||||
return "textures/gui/container/crafting_table.png";
|
||||
}
|
||||
|
||||
public String getOverlayIdentifier()
|
||||
{
|
||||
return "crafting";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasOverlay(GuiContainer gui, Container container, int recipe)
|
||||
{
|
||||
return (super.hasOverlay( gui, container, recipe )) || ((isRecipe2x2( recipe )) && (RecipeInfo.hasDefaultOverlay( gui, "crafting2x2" )));
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRecipeOverlayRenderer getOverlayRenderer(GuiContainer gui, int recipe)
|
||||
{
|
||||
IRecipeOverlayRenderer renderer = super.getOverlayRenderer( gui, recipe );
|
||||
if ( renderer != null )
|
||||
{
|
||||
return renderer;
|
||||
}
|
||||
IStackPositioner positioner = RecipeInfo.getStackPositioner( gui, "crafting2x2" );
|
||||
if ( positioner == null )
|
||||
return null;
|
||||
return new DefaultOverlayRenderer( getIngredientStacks( recipe ), positioner );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IOverlayHandler getOverlayHandler(GuiContainer gui, int recipe)
|
||||
{
|
||||
IOverlayHandler handler = super.getOverlayHandler( gui, recipe );
|
||||
if ( handler != null )
|
||||
{
|
||||
return handler;
|
||||
}
|
||||
return RecipeInfo.getOverlayHandler( gui, "crafting2x2" );
|
||||
}
|
||||
|
||||
public boolean isRecipe2x2(int recipe)
|
||||
{
|
||||
for (PositionedStack stack : getIngredientStacks( recipe ))
|
||||
{
|
||||
if ( (stack.relx > 43) || (stack.rely > 24) )
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public class CachedShapedRecipe extends TemplateRecipeHandler.CachedRecipe
|
||||
{
|
||||
|
||||
public ArrayList<PositionedStack> ingredients;
|
||||
public PositionedStack result;
|
||||
|
||||
public CachedShapedRecipe(AEShapedQuartzRecipe irecipe) {
|
||||
result = new PositionedStack( irecipe.getRecipeOutput(), 119, 24 );
|
||||
ingredients = new ArrayList<PositionedStack>();
|
||||
setIngredients( irecipe.getWidth(), irecipe.getHeight(), irecipe.getIngredients() );
|
||||
}
|
||||
|
||||
public void setIngredients(int width, int height, Object[] items)
|
||||
{
|
||||
for (int x = 0; x < width; x++)
|
||||
{
|
||||
for (int y = 0; y < height; y++)
|
||||
{
|
||||
if ( items[(y * width + x)] != null )
|
||||
{
|
||||
PositionedStack stack = new PositionedStack( items[(y * width + x)], 25 + x * 18, 6 + y * 18, false );
|
||||
stack.setMaxSize( 1 );
|
||||
this.ingredients.add( stack );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getIngredients()
|
||||
{
|
||||
return getCycledIngredients( cycleticks / 20, this.ingredients );
|
||||
}
|
||||
|
||||
@Override
|
||||
public PositionedStack getResult()
|
||||
{
|
||||
return this.result;
|
||||
}
|
||||
|
||||
public void computeVisuals()
|
||||
{
|
||||
for (PositionedStack p : this.ingredients)
|
||||
{
|
||||
p.generatePermutations();
|
||||
}
|
||||
this.result.generatePermutations();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user