AE2 First Commit, the dawn of 1.7 hast arrived.
This commit is contained in:
@@ -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