This commit is contained in:
AlgorithmX2 2014-09-17 11:25:30 -05:00
commit 306ee9e036
26 changed files with 606 additions and 838 deletions

View file

@ -6,17 +6,13 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.regex.Pattern;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import appeng.api.AEApi;
import appeng.api.config.FuzzyMode;
import appeng.api.config.SearchBoxMode;
import appeng.api.config.Settings;
import appeng.api.config.SortOrder;
import appeng.api.config.Upgrades;
import appeng.api.config.ViewItems;
import appeng.api.config.YesNo;
import appeng.api.implementations.items.IUpgradeModule;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
import appeng.client.gui.widgets.IScrollSource;
@ -25,11 +21,7 @@ import appeng.core.AEConfig;
import appeng.items.storage.ItemViewCell;
import appeng.util.ItemSorters;
import appeng.util.Platform;
import appeng.util.item.AEItemStack;
import appeng.util.prioitylist.FuzzyPriorityList;
import appeng.util.prioitylist.IPartitionList;
import appeng.util.prioitylist.MergedPriorityList;
import appeng.util.prioitylist.PrecisePriorityList;
import cpw.mods.fml.relauncher.ReflectionHelper;
public class ItemRepo
@ -46,7 +38,8 @@ public class ItemRepo
public String searchString = "";
private String innerSearch = "";
public ItemRepo(IScrollSource src, ISortSource sortSrc) {
public ItemRepo(IScrollSource src, ISortSource sortSrc)
{
this.src = src;
this.sortSrc = sortSrc;
}
@ -91,69 +84,7 @@ public class ItemRepo
public void setViewCell(ItemStack[] list)
{
myPartitionList = null;
MergedPriorityList<IAEItemStack> myMergedList = new MergedPriorityList<IAEItemStack>();
for (ItemStack currentViewCell : list)
{
if ( currentViewCell == null )
continue;
if ( (currentViewCell.getItem() instanceof ItemViewCell) )
{
boolean hasInverter = false;
boolean hasFuzzy = false;
IItemList<IAEItemStack> priorityList = AEApi.instance().storage().createItemList();
ItemViewCell vc = (ItemViewCell) currentViewCell.getItem();
IInventory upgrades = vc.getUpgradesInventory( currentViewCell );
IInventory config = vc.getConfigInventory( currentViewCell );
FuzzyMode fzMode = vc.getFuzzyMode( currentViewCell );
hasInverter = false;
hasFuzzy = false;
for (int x = 0; x < upgrades.getSizeInventory(); x++)
{
ItemStack is = upgrades.getStackInSlot( x );
if ( is != null && is.getItem() instanceof IUpgradeModule )
{
Upgrades u = ((IUpgradeModule) is.getItem()).getType( is );
if ( u != null )
{
switch (u)
{
case FUZZY:
hasFuzzy = true;
break;
case INVERTER:
hasInverter = true;
break;
default:
}
}
}
}
for (int x = 0; x < config.getSizeInventory(); x++)
{
ItemStack is = config.getStackInSlot( x );
if ( is != null )
priorityList.add( AEItemStack.create( is ) );
}
if ( !priorityList.isEmpty() )
{
if ( hasFuzzy )
myMergedList.addNewList( new FuzzyPriorityList<IAEItemStack>( priorityList, fzMode ), !hasInverter );
else
myMergedList.addNewList( new PrecisePriorityList<IAEItemStack>( priorityList ), !hasInverter );
myPartitionList = myMergedList;
}
}
}
myPartitionList = ItemViewCell.createFilter( list );
updateView();
}

View file

@ -49,7 +49,7 @@ public class ContainerCraftingTerm extends ContainerMEMonitorable implements IAE
for (int x = 0; x < 3; x++)
addSlotToContainer( craftingSlots[x + y * 3] = new SlotCraftingMatrix( this, crafting, x + y * 3, 37 + x * 18, -72 + y * 18 ) );
addSlotToContainer( outputSlot = new SlotCraftingTerm( getPlayerInv().player, mySrc, powerSrc, montiorable, crafting, crafting, output, 131, -72 + 18 ) );
addSlotToContainer( outputSlot = new SlotCraftingTerm( getPlayerInv().player, mySrc, powerSrc, montiorable, crafting, crafting, output, 131, -72 + 18, this ) );
bindPlayerInventory( ip, 0, 0 );

View file

@ -7,6 +7,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.ICrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.AEApi;
@ -344,4 +345,13 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa
return clientCM;
}
public ItemStack[] getViewCells()
{
ItemStack[] list = new ItemStack[cellView.length];
for (int x = 0; x < cellView.length; x++)
list[x] = cellView[x].getStack();
return list;
}
}

View file

@ -36,6 +36,7 @@ import appeng.container.slot.SlotRestrictedInput;
import appeng.container.slot.SlotRestrictedInput.PlaceableItemType;
import appeng.core.sync.packets.PacketPatternSlot;
import appeng.helpers.IContainerCraftingPacket;
import appeng.items.storage.ItemViewCell;
import appeng.parts.reporting.PartPatternTerminal;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.tile.inventory.IAEAppEngInventory;
@ -61,7 +62,8 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
public PartPatternTerminal ct;
public ContainerPatternTerm(InventoryPlayer ip, ITerminalHost montiorable) {
public ContainerPatternTerm(InventoryPlayer ip, ITerminalHost montiorable)
{
super( ip, montiorable, false );
ct = (PartPatternTerminal) montiorable;
@ -73,7 +75,7 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
for (int x = 0; x < 3; x++)
addSlotToContainer( craftingSlots[x + y * 3] = new SlotFakeCraftingMatrix( crafting, x + y * 3, 18 + x * 18, -76 + y * 18 ) );
addSlotToContainer( craftSlot = new SlotPatternTerm( ip.player, mySrc, powerSrc, montiorable, crafting, patternInv, cOut, 110, -76 + 18, this, 2 ) );
addSlotToContainer( craftSlot = new SlotPatternTerm( ip.player, mySrc, powerSrc, montiorable, crafting, patternInv, cOut, 110, -76 + 18, this, 2, this ) );
craftSlot.IIcon = -1;
for (int y = 0; y < 3; y++)
@ -352,7 +354,7 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
if ( ic.getStackInSlot( x ) != null )
{
ItemStack pulled = Platform.extractItemsByRecipe( powerSrc, mySrc, storage, p.worldObj, r, is, ic, ic.getStackInSlot( x ), x, all,
Actionable.MODULATE );
Actionable.MODULATE, ItemViewCell.createFilter( getViewCells() ) );
real.setInventorySlotContents( x, pulled );
}
}

View file

@ -17,7 +17,9 @@ import appeng.api.storage.IStorageMonitorable;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
import appeng.container.ContainerNull;
import appeng.helpers.IContainerCraftingPacket;
import appeng.helpers.InventoryAction;
import appeng.items.storage.ItemViewCell;
import appeng.util.InventoryAdaptor;
import appeng.util.Platform;
import appeng.util.inv.AdaptorPlayerHand;
@ -32,15 +34,18 @@ public class SlotCraftingTerm extends AppEngCraftingSlot
private final BaseActionSource mySrc;
private final IEnergySource energySrc;
private final IStorageMonitorable storage;
private final IContainerCraftingPacket container;
public SlotCraftingTerm(EntityPlayer player, BaseActionSource mySrc, IEnergySource energySrc, IStorageMonitorable storage, IInventory cMatrix,
IInventory secondMatrix, IInventory output, int x, int y) {
IInventory secondMatrix, IInventory output, int x, int y, IContainerCraftingPacket ccp)
{
super( player, cMatrix, output, 0, x, y );
this.energySrc = energySrc;
this.storage = storage;
this.mySrc = mySrc;
pattern = cMatrix;
craftInv = secondMatrix;
container = ccp;
}
public IInventory getCraftingMatrix()
@ -114,7 +119,7 @@ public class SlotCraftingTerm extends AppEngCraftingSlot
if ( pattern.getStackInSlot( x ) != null )
{
set[x] = Platform.extractItemsByRecipe( energySrc, mySrc, inv, p.worldObj, r, is, ic, pattern.getStackInSlot( x ), x, all,
Actionable.MODULATE );
Actionable.MODULATE, ItemViewCell.createFilter( container.getViewCells() ) );
ic.setInventorySlotContents( x, set[x] );
}
}

View file

@ -11,6 +11,7 @@ import appeng.api.networking.security.BaseActionSource;
import appeng.api.storage.IStorageMonitorable;
import appeng.core.sync.AppEngPacket;
import appeng.core.sync.packets.PacketPatternSlot;
import appeng.helpers.IContainerCraftingPacket;
public class SlotPatternTerm extends SlotCraftingTerm
{
@ -19,8 +20,9 @@ public class SlotPatternTerm extends SlotCraftingTerm
IOptionalSlotHost host;
public SlotPatternTerm(EntityPlayer player, BaseActionSource mySrc, IEnergySource energySrc, IStorageMonitorable storage, IInventory cMatrix,
IInventory secondMatrix, IInventory output, int x, int y, IOptionalSlotHost h, int grpnum) {
super( player, mySrc, energySrc, storage, cMatrix, secondMatrix, output, x, y );
IInventory secondMatrix, IInventory output, int x, int y, IOptionalSlotHost h, int grpnum, IContainerCraftingPacket c)
{
super( player, mySrc, energySrc, storage, cMatrix, secondMatrix, output, x, y, c );
host = h;
groupNum = grpnum;

View file

@ -39,7 +39,7 @@ public class ColoredItemDefinition implements AEColoredItemDefinition
{
ItemStackSrc is = colors[color.ordinal()];
if ( comparableItem == null )
if ( comparableItem == null || is == null )
return false;
return comparableItem.getItem() == is.item && comparableItem.getItemDamage() == is.damage;

View file

@ -32,8 +32,10 @@ import appeng.container.ContainerNull;
import appeng.core.sync.AppEngPacket;
import appeng.core.sync.network.INetworkInfo;
import appeng.helpers.IContainerCraftingPacket;
import appeng.items.storage.ItemViewCell;
import appeng.util.Platform;
import appeng.util.item.AEItemStack;
import appeng.util.prioitylist.IPartitionList;
public class PacketNEIRecipe extends AppEngPacket
{
@ -41,7 +43,8 @@ public class PacketNEIRecipe extends AppEngPacket
ItemStack[][] recipe;
// automatic.
public PacketNEIRecipe(ByteBuf stream) throws IOException {
public PacketNEIRecipe(ByteBuf stream) throws IOException
{
ByteArrayInputStream bytes = new ByteArrayInputStream( stream.array() );
bytes.skip( stream.readerIndex() );
NBTTagCompound comp = CompressedStreamTools.readCompressed( bytes );
@ -50,13 +53,13 @@ public class PacketNEIRecipe extends AppEngPacket
recipe = new ItemStack[9][];
for (int x = 0; x < recipe.length; x++)
{
NBTTagList list = comp.getTagList( "#"+x, 10 );
NBTTagList list = comp.getTagList( "#" + x, 10 );
if ( list.tagCount() > 0 )
{
recipe[x] = new ItemStack[ list.tagCount() ];
for ( int y = 0; y < list.tagCount(); y++ )
recipe[x] = new ItemStack[list.tagCount()];
for (int y = 0; y < list.tagCount(); y++)
{
recipe[x][y] = ItemStack.loadItemStackFromNBT( list.getCompoundTagAt(y) );
recipe[x][y] = ItemStack.loadItemStackFromNBT( list.getCompoundTagAt( y ) );
}
}
}
@ -91,7 +94,7 @@ public class PacketNEIRecipe extends AppEngPacket
InventoryCrafting ic = new InventoryCrafting( new ContainerNull(), 3, 3 );
for (int x = 0; x < 9; x++)
{
if ( recipe[x] != null && recipe[x].length > 0 )
if ( recipe[x] != null && recipe[x].length > 0 )
{
ic.setInventorySlotContents( x, recipe[x][0] );
}
@ -107,6 +110,7 @@ public class PacketNEIRecipe extends AppEngPacket
{
IMEMonitor<IAEItemStack> stor = inv.getItemInventory();
IItemList all = stor.getStorageList();
IPartitionList<IAEItemStack> filter = ItemViewCell.createFilter( cct.getViewCells() );
for (int x = 0; x < craftMatrix.getSizeInventory(); x++)
{
@ -138,22 +142,25 @@ public class PacketNEIRecipe extends AppEngPacket
if ( PatternItem != null && currentItem == null )
{
ItemStack whichItem = Platform.extractItemsByRecipe( energy, cct.getSource(), stor, player.worldObj, r,
is, ic, PatternItem, x, all, realForFake );
ItemStack whichItem = Platform.extractItemsByRecipe( energy, cct.getSource(), stor, player.worldObj, r, is, ic,
PatternItem, x, all, realForFake, filter );
if ( whichItem == null )
{
for ( int y = 0; y < recipe[x].length; y++ )
for (int y = 0; y < recipe[x].length; y++)
{
IAEItemStack request = AEItemStack.create( recipe[x][y] );
if ( request != null )
{
request.setStackSize( 1 );
IAEItemStack out = Platform.poweredExtraction( energy, stor, request, cct.getSource() );
if ( out != null )
if ( filter == null || filter.isListed( request ) )
{
whichItem = out.getItemStack();
break;
request.setStackSize( 1 );
IAEItemStack out = Platform.poweredExtraction( energy, stor, request, cct.getSource() );
if ( out != null )
{
whichItem = out.getItemStack();
break;
}
}
}
}
@ -171,7 +178,8 @@ public class PacketNEIRecipe extends AppEngPacket
}
// api
public PacketNEIRecipe(NBTTagCompound recipe) throws IOException {
public PacketNEIRecipe(NBTTagCompound recipe) throws IOException
{
ByteBuf data = Unpooled.buffer();
ByteArrayOutputStream bytes = new ByteArrayOutputStream();

View file

@ -64,26 +64,22 @@ public class CraftingTreeProcess
fullsimulation = true;
}
for (int x = 0; x < list.length; x++)
for ( IAEItemStack part : details.getCondencedInputs() )
{
IAEItemStack part = list[x];
if ( part != null )
ItemStack g = part.getItemStack();
boolean isAnInput = false;
for ( IAEItemStack a : details.getCondencedOutputs() )
{
ItemStack g = part.getItemStack();
boolean isAnInput = false;
for (IAEItemStack a : is)
{
if ( g != null && a != null && a.equals( g ) )
isAnInput = true;
}
if ( isAnInput )
limitQty = true;
if ( g.getItem().hasContainerItem( g ) )
limitQty = containerItems = true;
if ( g != null && a != null && a.equals( g ) )
isAnInput = true;
}
if ( isAnInput )
limitQty = true;
if ( g.getItem().hasContainerItem( g ) )
limitQty = containerItems = true;
}
boolean complicated = false;
@ -117,26 +113,19 @@ public class CraftingTreeProcess
}
else
{
IAEItemStack list[] = details.getInputs();
IAEItemStack[] is = details.getInputs();
for (int x = 0; x < list.length; x++)
for ( IAEItemStack part : details.getCondencedInputs() )
{
IAEItemStack part = list[x];
if ( part != null )
ItemStack g = part.getItemStack();
boolean isAnInput = false;
for (IAEItemStack a : details.getCondencedOutputs())
{
ItemStack g = part.getItemStack();
boolean isAnInput = false;
for (IAEItemStack a : is)
{
if ( g != null && a != null && a.equals( g ) )
isAnInput = true;
}
if ( isAnInput )
limitQty = true;
if ( g != null && a != null && a.equals( g ) )
isAnInput = true;
}
if ( isAnInput )
limitQty = true;
}
for (IAEItemStack part : details.getCondencedInputs())

View file

@ -1,6 +1,7 @@
package appeng.helpers;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import appeng.api.networking.IGridNode;
import appeng.api.networking.security.BaseActionSource;
@ -28,4 +29,9 @@ public interface IContainerCraftingPacket
*/
boolean useRealItems();
/**
* @return array of view cells
*/
ItemStack[] getViewCells();
}

View file

@ -1,9 +1,11 @@
package appeng.integration.modules.NEIHelpers;
import java.util.LinkedList;
import java.util.List;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import appeng.client.gui.implementations.GuiCraftingTerm;
@ -12,6 +14,7 @@ import appeng.container.slot.SlotCraftingMatrix;
import appeng.container.slot.SlotFakeCraftingMatrix;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketNEIRecipe;
import appeng.util.Platform;
import codechicken.nei.PositionedStack;
import codechicken.nei.api.IOverlayHandler;
import codechicken.nei.recipe.IRecipeHandler;
@ -19,7 +22,8 @@ import codechicken.nei.recipe.IRecipeHandler;
public class NEICraftingHandler implements IOverlayHandler
{
public NEICraftingHandler(int x, int y) {
public NEICraftingHandler(int x, int y)
{
offsetx = x;
offsety = y;
}
@ -66,12 +70,24 @@ public class NEICraftingHandler implements IOverlayHandler
if ( ctSlot.getSlotIndex() == col + row * 3 )
{
NBTTagList ilist = new NBTTagList();
List<ItemStack> list = new LinkedList();
// prefer pure crystals.
for (int x = 0; x < pstack.items.length; x++)
{
if ( Platform.isRecipePrioritized( pstack.items[x] ) )
list.add( 0, pstack.items[x] );
else
list.add( pstack.items[x] );
}
for (ItemStack is : list)
{
NBTTagCompound inbt = new NBTTagCompound();
pstack.items[x].writeToNBT( inbt );
is.writeToNBT( inbt );
ilist.appendTag( inbt );
}
recipe.setTag( "#" + ctSlot.getSlotIndex(), ilist );
break;
}

View file

@ -1,24 +0,0 @@
package appeng.integration.modules.dead;
import appeng.integration.IIntegrationModule;
public class Forestry implements IIntegrationModule
{
public static Forestry instance;
@Override
public void Init()
{
// TODO Auto-generated method stub
}
@Override
public void PostInit()
{
// TODO Auto-generated method stub
}
}

View file

@ -1,46 +0,0 @@
package appeng.integration.modules;
import gregtech.api.interfaces.tileentity.IDigitalChest;
import net.minecraft.inventory.IInventory;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.AEApi;
import appeng.api.storage.IMEInventory;
import appeng.integration.IIntegrationModule;
import appeng.integration.abstraction.IGT;
import appeng.integration.modules.helpers.GregTechHandler;
import appeng.integration.modules.helpers.GregTechQuantumChest;
import appeng.util.InventoryAdaptor;
public class GT implements IGT, IIntegrationModule
{
public static GT instance;
@Override
public IMEInventory getQuantumChest(TileEntity te)
{
return new GregTechQuantumChest( (IInventory) te, InventoryAdaptor.getAdaptor( te, ForgeDirection.NORTH ) );
}
@Override
public boolean isQuantumChest(TileEntity te)
{
if ( te instanceof IDigitalChest )
return ((IDigitalChest) te).isDigitalChest();
return false;
}
@Override
public void Init()
{
}
@Override
public void PostInit()
{
AEApi.instance().registries().externalStorage().addExternalStorageInterface( new GregTechHandler() );
}
}

View file

@ -1,24 +0,0 @@
package appeng.integration.modules.dead;
import appeng.integration.IIntegrationModule;
public class LP implements IIntegrationModule
{
public static LP instance;
@Override
public void Init()
{
// TODO Auto-generated method stub
}
@Override
public void PostInit()
{
// TODO Auto-generated method stub
}
}

View file

@ -1,24 +0,0 @@
package appeng.integration.modules.dead;
import appeng.integration.IIntegrationModule;
public class Mystcraft implements IIntegrationModule
{
public static Mystcraft instance;
@Override
public void Init()
{
// TODO Auto-generated method stub
}
@Override
public void PostInit()
{
// TODO Auto-generated method stub
}
}

View file

@ -1,47 +0,0 @@
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;
}
}

View file

@ -1,32 +0,0 @@
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;
}
}

View file

@ -1,30 +0,0 @@
package appeng.integration.modules.helpers;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.storage.IExternalStorageHandler;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.StorageChannel;
import appeng.integration.modules.GT;
import appeng.me.storage.MEMonitorIInventory;
import appeng.util.inv.IMEAdaptor;
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 channel, BaseActionSource src)
{
if ( channel == StorageChannel.ITEMS )
return new MEMonitorIInventory( new IMEAdaptor( GT.instance.getQuantumChest( te ) ) );
return null;
}
}

View file

@ -1,104 +0,0 @@
package appeng.integration.modules.helpers;
import gregtech.api.interfaces.tileentity.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].getItem() != null )
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;
}
}

View file

@ -28,7 +28,6 @@ import appeng.items.AEBaseItem;
import appeng.items.contents.CellConfig;
import appeng.items.contents.CellUpgrades;
import appeng.items.materials.MaterialType;
import appeng.me.storage.CellInventoryHandler;
import appeng.util.InventoryAdaptor;
import appeng.util.Platform;

View file

@ -4,18 +4,29 @@ import java.util.EnumSet;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import appeng.api.AEApi;
import appeng.api.config.FuzzyMode;
import appeng.api.config.Upgrades;
import appeng.api.implementations.items.IUpgradeModule;
import appeng.api.storage.ICellWorkbenchItem;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
import appeng.core.features.AEFeature;
import appeng.items.AEBaseItem;
import appeng.items.contents.CellConfig;
import appeng.items.contents.CellUpgrades;
import appeng.util.Platform;
import appeng.util.item.AEItemStack;
import appeng.util.prioitylist.FuzzyPriorityList;
import appeng.util.prioitylist.IPartitionList;
import appeng.util.prioitylist.MergedPriorityList;
import appeng.util.prioitylist.PrecisePriorityList;
public class ItemViewCell extends AEBaseItem implements ICellWorkbenchItem
{
public ItemViewCell() {
public ItemViewCell()
{
super( ItemViewCell.class );
setfeature( EnumSet.of( AEFeature.Core ) );
setMaxStackSize( 1 );
@ -58,4 +69,73 @@ public class ItemViewCell extends AEBaseItem implements ICellWorkbenchItem
{
Platform.openNbtData( is ).setString( "FuzzyMode", fzMode.name() );
}
public static IPartitionList<IAEItemStack> createFilter(ItemStack[] list)
{
IPartitionList<IAEItemStack> myPartitionList = null;
MergedPriorityList<IAEItemStack> myMergedList = new MergedPriorityList<IAEItemStack>();
for (ItemStack currentViewCell : list)
{
if ( currentViewCell == null )
continue;
if ( (currentViewCell.getItem() instanceof ItemViewCell) )
{
boolean hasInverter = false;
boolean hasFuzzy = false;
IItemList<IAEItemStack> priorityList = AEApi.instance().storage().createItemList();
ItemViewCell vc = (ItemViewCell) currentViewCell.getItem();
IInventory upgrades = vc.getUpgradesInventory( currentViewCell );
IInventory config = vc.getConfigInventory( currentViewCell );
FuzzyMode fzMode = vc.getFuzzyMode( currentViewCell );
hasInverter = false;
hasFuzzy = false;
for (int x = 0; x < upgrades.getSizeInventory(); x++)
{
ItemStack is = upgrades.getStackInSlot( x );
if ( is != null && is.getItem() instanceof IUpgradeModule )
{
Upgrades u = ((IUpgradeModule) is.getItem()).getType( is );
if ( u != null )
{
switch (u)
{
case FUZZY:
hasFuzzy = true;
break;
case INVERTER:
hasInverter = true;
break;
default:
}
}
}
}
for (int x = 0; x < config.getSizeInventory(); x++)
{
ItemStack is = config.getStackInSlot( x );
if ( is != null )
priorityList.add( AEItemStack.create( is ) );
}
if ( !priorityList.isEmpty() )
{
if ( hasFuzzy )
myMergedList.addNewList( new FuzzyPriorityList<IAEItemStack>( priorityList, fzMode ), !hasInverter );
else
myMergedList.addNewList( new PrecisePriorityList<IAEItemStack>( priorityList ), !hasInverter );
myPartitionList = myMergedList;
}
}
}
return myPartitionList;
}
}

View file

@ -62,7 +62,6 @@ import com.google.common.collect.HashMultimap;
import com.google.common.collect.ImmutableCollection;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSortedSet;
import com.google.common.collect.SetMultimap;
public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper, ICellProvider, IMEInventoryHandler
@ -78,7 +77,7 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
IEnergyGrid eg;
HashMap<ICraftingPatternDetails, List<ICraftingMedium>> craftingMethods = new HashMap();
HashMap<IAEItemStack, ImmutableSet<ICraftingPatternDetails>> craftableItems = new HashMap();
HashMap<IAEItemStack, ImmutableList<ICraftingPatternDetails>> craftableItems = new HashMap();
HashSet<IAEItemStack> emitableItems = new HashSet();
HashMap<String, CraftingLinkNexus> links = new HashMap();
@ -92,7 +91,8 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
final Iterator<CraftingCPUCluster> i;
CraftingCPUCluster c = null;
public ActiveCpuIterator(Collection<CraftingCPUCluster> o) {
public ActiveCpuIterator(Collection<CraftingCPUCluster> o)
{
i = o.iterator();
}
@ -135,7 +135,8 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
return ImmutableSet.copyOf( new ActiveCpuIterator( cpuClusters ) );
}
public CraftingGridCache(IGrid g) {
public CraftingGridCache(IGrid g)
{
grid = g;
}
@ -287,7 +288,7 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
private void updatePatterns()
{
HashMap<IAEItemStack, ImmutableSet<ICraftingPatternDetails>> oldItems = craftableItems;
HashMap<IAEItemStack, ImmutableList<ICraftingPatternDetails>> oldItems = craftableItems;
// erase list.
craftingMethods.clear();
@ -323,7 +324,7 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
// make them immutable
for (Entry<IAEItemStack, Set<ICraftingPatternDetails>> e : tmpCraft.entrySet())
craftableItems.put( e.getKey(), ImmutableSortedSet.copyOf( e.getValue() ) );
craftableItems.put( e.getKey(), ImmutableList.copyOf( e.getValue() ) );
sg.postAlterationOfStoredItems( StorageChannel.ITEMS, craftableItems.keySet(), new BaseActionSource() );
}
@ -481,7 +482,7 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
@Override
public ImmutableCollection<ICraftingPatternDetails> getCraftingFor(IAEItemStack whatToCraft, ICraftingPatternDetails details, int slotIndex, World world)
{
ImmutableSet<ICraftingPatternDetails> res = craftableItems.get( whatToCraft );
ImmutableList<ICraftingPatternDetails> res = craftableItems.get( whatToCraft );
if ( res == null )
{

View file

@ -4,6 +4,7 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map.Entry;
import java.util.NavigableMap;
import java.util.TreeMap;
import net.minecraft.item.ItemStack;
@ -29,7 +30,8 @@ public class MEMonitorIInventory implements IMEInventory<IAEItemStack>, IMEMonit
class CachedItemStack
{
public CachedItemStack(ItemStack is) {
public CachedItemStack(ItemStack is)
{
if ( is == null )
{
itemStack = null;
@ -67,7 +69,8 @@ public class MEMonitorIInventory implements IMEInventory<IAEItemStack>, IMEMonit
listeners.remove( l );
}
public MEMonitorIInventory(InventoryAdaptor adaptor) {
public MEMonitorIInventory(InventoryAdaptor adaptor)
{
this.adaptor = adaptor;
memory = new TreeMap();
}
@ -166,10 +169,13 @@ public class MEMonitorIInventory implements IMEInventory<IAEItemStack>, IMEMonit
LinkedList<IAEItemStack> changes = new LinkedList<IAEItemStack>();
int high = 0;
list.resetStatus();
for (ItemSlot is : adaptor)
{
CachedItemStack old = memory.get( is.slot );
high = Math.max( high, is.slot );
ItemStack newIS = is == null || is.isExtractable == false && mode == StorageFilter.EXTACTABLE_ONLY ? null : is.getItemStack();
ItemStack oldIS = old == null ? null : old.itemStack;
@ -217,6 +223,23 @@ public class MEMonitorIInventory implements IMEInventory<IAEItemStack>, IMEMonit
}
}
// detect dropped items; should fix non IISided Inventory Changes.
NavigableMap<Integer, CachedItemStack> end = memory.tailMap( high, false );
if ( !end.isEmpty() )
{
for (CachedItemStack cis : end.values())
{
if ( cis != null )
{
IAEItemStack a = cis.aeStack.copy();
a.setStackSize( -a.getStackSize() );
changes.add( a );
changed = true;
}
}
end.clear();
}
if ( !changes.isEmpty() )
postDiffrence( changes );

View file

@ -156,6 +156,9 @@ public class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicState
newType = AEApi.instance().parts().partP2PTunnelRedstone.stack( 1 );
break;
default:
break;
}
if ( newType != null && !Platform.isSameItem( newType, this.is ) )

View file

@ -62,19 +62,17 @@ public abstract class RotaryCraft extends IC2 implements ShaftPowerReceiver
alpha = io;
}
@Override
final public int getMachineX()
{
return xCoord;
}
@Override
final public int getMachineY()
{
return yCoord;
}
@Override
final public int getMachineZ()
{
return zCoord;
@ -101,7 +99,6 @@ public abstract class RotaryCraft extends IC2 implements ShaftPowerReceiver
power = p;
}
@Override
final public boolean canReadFromBlock(int x, int y, int z)
{
ForgeDirection side = ForgeDirection.UNKNOWN;
@ -136,4 +133,16 @@ public abstract class RotaryCraft extends IC2 implements ShaftPowerReceiver
omega = 0;
}
@Override
final public boolean canReadFrom(ForgeDirection side)
{
return internalCanAcceptPower && getPowerSides().contains( side );
}
@Override
final public int getMinTorque(int available)
{
return 0;
}
}

View file

@ -108,6 +108,7 @@ import appeng.util.item.AEItemStack;
import appeng.util.item.AESharedNBT;
import appeng.util.item.OreHelper;
import appeng.util.item.OreRefrence;
import appeng.util.prioitylist.IPartitionList;
import buildcraft.api.tools.IToolWrench;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Loader;
@ -1639,7 +1640,8 @@ public class Platform
}
public static ItemStack extractItemsByRecipe(IEnergySource energySrc, BaseActionSource mySrc, IMEMonitor<IAEItemStack> src, World w, IRecipe r,
ItemStack output, InventoryCrafting ci, ItemStack providedTemplate, int slot, IItemList<IAEItemStack> aitems, Actionable realForFake)
ItemStack output, InventoryCrafting ci, ItemStack providedTemplate, int slot, IItemList<IAEItemStack> aitems, Actionable realForFake,
IPartitionList<IAEItemStack> filter)
{
if ( energySrc.extractAEPower( 1, Actionable.SIMULATE, PowerMultiplier.CONFIG ) > 0.9 )
{
@ -1649,14 +1651,17 @@ public class Platform
AEItemStack ae_req = AEItemStack.create( providedTemplate );
ae_req.setStackSize( 1 );
IAEItemStack ae_ext = src.extractItems( ae_req, realForFake, mySrc );
if ( ae_ext != null )
if ( filter == null || filter.isListed( ae_req ) )
{
ItemStack extracted = ae_ext.getItemStack();
if ( extracted != null )
IAEItemStack ae_ext = src.extractItems( ae_req, realForFake, mySrc );
if ( ae_ext != null )
{
energySrc.extractAEPower( 1, realForFake, PowerMultiplier.CONFIG );
return extracted;
ItemStack extracted = ae_ext.getItemStack();
if ( extracted != null )
{
energySrc.extractAEPower( 1, realForFake, PowerMultiplier.CONFIG );
return extracted;
}
}
}
@ -1677,11 +1682,14 @@ public class Platform
{
IAEItemStack ax = x.copy();
ax.setStackSize( 1 );
IAEItemStack ex = src.extractItems( ax, realForFake, mySrc );
if ( ex != null )
if ( filter == null || filter.isListed( ax ) )
{
energySrc.extractAEPower( 1, realForFake, PowerMultiplier.CONFIG );
return ex.getItemStack();
IAEItemStack ex = src.extractItems( ax, realForFake, mySrc );
if ( ex != null )
{
energySrc.extractAEPower( 1, realForFake, PowerMultiplier.CONFIG );
return ex.getItemStack();
}
}
}
ci.setInventorySlotContents( slot, providedTemplate );
@ -1836,4 +1844,11 @@ public class Platform
// p.addStat( achivement, 1 );
}
}
public static boolean isRecipePrioritized(ItemStack what)
{
return AEApi.instance().materials().materialPureifiedCertusQuartzCrystal.sameAsStack( what )
|| AEApi.instance().materials().materialPureifiedFluixCrystal.sameAsStack( what )
|| AEApi.instance().materials().materialPureifiedNetherQuartzCrystal.sameAsStack( what );
}
}