Restore DSU Api, mark all other api's as dead.

This commit is contained in:
AlgorithmX2
2014-02-15 00:40:02 -06:00
parent 91de4d56e4
commit 109fef1821
34 changed files with 2197 additions and 2196 deletions
@@ -5,7 +5,7 @@ import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.storage.IExternalStorageHandler;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.StorageChannel;
import appeng.integration.modules.MFR;
import appeng.integration.modules.DSU;
public class MFRDSUHandler implements IExternalStorageHandler
{
@@ -13,14 +13,14 @@ public class MFRDSUHandler implements IExternalStorageHandler
@Override
public boolean canHandle(TileEntity te, ForgeDirection d, StorageChannel chan)
{
return chan == StorageChannel.ITEMS && MFR.instance.isDSU( te );
return chan == StorageChannel.ITEMS && DSU.instance.isDSU( te );
}
@Override
public IMEInventory getInventory(TileEntity te, ForgeDirection d, StorageChannel chan)
{
if ( chan == StorageChannel.ITEMS )
return MFR.instance.getDSU( te );
return DSU.instance.getDSU( te );
return null;
}
@@ -1,60 +1,60 @@
package appeng.integration.modules.helpers;
import net.minecraft.nbt.NBTTagCompound;
import buildcraft.api.power.IPowerReceptor;
import buildcraft.api.power.PowerHandler;
import buildcraft.api.power.PowerHandler.PowerReceiver;
import buildcraft.api.power.PowerHandler.Type;
public class BCPerdition extends BaseBCperdition
{
final protected PowerHandler bcPowerHandler;
public BCPerdition(IPowerReceptor te) {
bcPowerHandler = new PowerHandler( te, Type.MACHINE );
}
@Override
public void Tick()
{
bcPowerHandler.update();
}
@Override
public void writeToNBT(NBTTagCompound data)
{
bcPowerHandler.writeToNBT( data, "bcPowerHandler" );
}
@Override
public void readFromNBT(NBTTagCompound data)
{
bcPowerHandler.readFromNBT( data, "bcPowerHandler" );
}
@Override
public PowerReceiver getPowerReceiver()
{
return bcPowerHandler.getPowerReceiver();
}
@Override
public double useEnergy(float min, float max, boolean doUse)
{
return bcPowerHandler.useEnergy( min, max, doUse );
}
@Override
public void addEnergy(float failed)
{
bcPowerHandler.addEnergy( failed );
}
@Override
public void configure(int i, int j, float f, int k)
{
bcPowerHandler.configure( i, j, f, k );
}
package appeng.integration.modules.helpers.dead;
import net.minecraft.nbt.NBTTagCompound;
import buildcraft.api.power.IPowerReceptor;
import buildcraft.api.power.PowerHandler;
import buildcraft.api.power.PowerHandler.PowerReceiver;
import buildcraft.api.power.PowerHandler.Type;
public class BCPerdition extends BaseBCperdition
{
final protected PowerHandler bcPowerHandler;
public BCPerdition(IPowerReceptor te) {
bcPowerHandler = new PowerHandler( te, Type.MACHINE );
}
@Override
public void Tick()
{
bcPowerHandler.update();
}
@Override
public void writeToNBT(NBTTagCompound data)
{
bcPowerHandler.writeToNBT( data, "bcPowerHandler" );
}
@Override
public void readFromNBT(NBTTagCompound data)
{
bcPowerHandler.readFromNBT( data, "bcPowerHandler" );
}
@Override
public PowerReceiver getPowerReceiver()
{
return bcPowerHandler.getPowerReceiver();
}
@Override
public double useEnergy(float min, float max, boolean doUse)
{
return bcPowerHandler.useEnergy( min, max, doUse );
}
@Override
public void addEnergy(float failed)
{
bcPowerHandler.addEnergy( failed );
}
@Override
public void configure(int i, int j, float f, int k)
{
bcPowerHandler.configure( i, j, f, k );
}
}
@@ -1,27 +1,27 @@
package appeng.integration.modules.helpers;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.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;
}
}
package appeng.integration.modules.helpers.dead;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.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;
}
}
@@ -1,57 +1,57 @@
package appeng.integration.modules.helpers;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.config.Actionable;
import appeng.api.networking.security.BaseActionSource;
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, BaseActionSource src)
{
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, BaseActionSource src)
{
return null;
}
@Override
public IItemList<IAEItemStack> getAvailableItems(IItemList out)
{
return out;
}
}
package appeng.integration.modules.helpers.dead;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.config.Actionable;
import appeng.api.networking.security.BaseActionSource;
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, BaseActionSource src)
{
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, BaseActionSource src)
{
return null;
}
@Override
public IItemList<IAEItemStack> getAvailableItems(IItemList out)
{
return out;
}
}
@@ -1,67 +1,67 @@
package appeng.integration.modules.helpers;
import net.mcft.copy.betterstorage.api.ICrateStorage;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.config.Actionable;
import appeng.api.networking.security.BaseActionSource;
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, BaseActionSource src)
{
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, BaseActionSource src)
{
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;
}
}
package appeng.integration.modules.helpers.dead;
import net.mcft.copy.betterstorage.api.ICrateStorage;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.config.Actionable;
import appeng.api.networking.security.BaseActionSource;
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, BaseActionSource src)
{
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, BaseActionSource src)
{
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;
}
}
@@ -1,27 +1,27 @@
package appeng.integration.modules.helpers;
import net.mcft.copy.betterstorage.api.ICrateStorage;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.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;
}
}
package appeng.integration.modules.helpers.dead;
import net.mcft.copy.betterstorage.api.ICrateStorage;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.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;
}
}
@@ -1,185 +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.util.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() );
}
}
package appeng.integration.modules.helpers.dead;
import java.util.Iterator;
import net.mcft.copy.betterstorage.api.ICrateStorage;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.util.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() );
}
}
@@ -1,15 +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;
}
}
package appeng.integration.modules.helpers.dead;
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;
}
}
@@ -1,133 +1,133 @@
package appeng.integration.modules.helpers;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import appeng.api.config.Actionable;
import appeng.api.networking.security.BaseActionSource;
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, BaseActionSource src)
{
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, BaseActionSource src)
{
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;
}
package appeng.integration.modules.helpers.dead;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import appeng.api.config.Actionable;
import appeng.api.networking.security.BaseActionSource;
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, BaseActionSource src)
{
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, BaseActionSource src)
{
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;
}
}
@@ -1,27 +1,27 @@
package appeng.integration.modules.helpers;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.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;
}
}
package appeng.integration.modules.helpers.dead;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.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;
}
}
@@ -1,47 +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;
}
}
package appeng.integration.modules.helpers.dead;
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;
}
}
@@ -1,32 +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;
}
}
package appeng.integration.modules.helpers.dead;
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;
}
}
@@ -1,27 +1,27 @@
package appeng.integration.modules.helpers;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.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;
}
}
package appeng.integration.modules.helpers.dead;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.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;
}
}
@@ -1,104 +1,104 @@
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.networking.security.BaseActionSource;
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, BaseActionSource src)
{
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, src );
}
if ( mode == Actionable.MODULATE )
qc.setItemCount( type.stackSize + (int) input.getStackSize() );
return null;
}
return super.injectItems( input, mode, src );
}
return input;
}
@Override
public IAEItemStack extractItems(IAEItemStack i, Actionable mode, BaseActionSource src)
{
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, src );
}
@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;
}
package appeng.integration.modules.helpers.dead;
import gregtechmod.api.interfaces.IDigitalChest;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import appeng.api.config.Actionable;
import appeng.api.networking.security.BaseActionSource;
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, BaseActionSource src)
{
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, src );
}
if ( mode == Actionable.MODULATE )
qc.setItemCount( type.stackSize + (int) input.getStackSize() );
return null;
}
return super.injectItems( input, mode, src );
}
return input;
}
@Override
public IAEItemStack extractItems(IAEItemStack i, Actionable mode, BaseActionSource src)
{
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, src );
}
@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;
}
}
@@ -1,209 +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();
}
}
package appeng.integration.modules.helpers.dead;
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();
}
}
}