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.Collections;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import appeng.api.AEApi; import appeng.api.AEApi;
import appeng.api.config.FuzzyMode;
import appeng.api.config.SearchBoxMode; import appeng.api.config.SearchBoxMode;
import appeng.api.config.Settings; import appeng.api.config.Settings;
import appeng.api.config.SortOrder; import appeng.api.config.SortOrder;
import appeng.api.config.Upgrades;
import appeng.api.config.ViewItems; import appeng.api.config.ViewItems;
import appeng.api.config.YesNo; import appeng.api.config.YesNo;
import appeng.api.implementations.items.IUpgradeModule;
import appeng.api.storage.data.IAEItemStack; import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList; import appeng.api.storage.data.IItemList;
import appeng.client.gui.widgets.IScrollSource; import appeng.client.gui.widgets.IScrollSource;
@ -25,11 +21,7 @@ import appeng.core.AEConfig;
import appeng.items.storage.ItemViewCell; import appeng.items.storage.ItemViewCell;
import appeng.util.ItemSorters; import appeng.util.ItemSorters;
import appeng.util.Platform; import appeng.util.Platform;
import appeng.util.item.AEItemStack;
import appeng.util.prioitylist.FuzzyPriorityList;
import appeng.util.prioitylist.IPartitionList; import appeng.util.prioitylist.IPartitionList;
import appeng.util.prioitylist.MergedPriorityList;
import appeng.util.prioitylist.PrecisePriorityList;
import cpw.mods.fml.relauncher.ReflectionHelper; import cpw.mods.fml.relauncher.ReflectionHelper;
public class ItemRepo public class ItemRepo
@ -46,7 +38,8 @@ public class ItemRepo
public String searchString = ""; public String searchString = "";
private String innerSearch = ""; private String innerSearch = "";
public ItemRepo(IScrollSource src, ISortSource sortSrc) { public ItemRepo(IScrollSource src, ISortSource sortSrc)
{
this.src = src; this.src = src;
this.sortSrc = sortSrc; this.sortSrc = sortSrc;
} }
@ -91,69 +84,7 @@ public class ItemRepo
public void setViewCell(ItemStack[] list) public void setViewCell(ItemStack[] list)
{ {
myPartitionList = null; myPartitionList = ItemViewCell.createFilter( list );
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;
}
}
}
updateView(); updateView();
} }

View file

@ -49,7 +49,7 @@ public class ContainerCraftingTerm extends ContainerMEMonitorable implements IAE
for (int x = 0; x < 3; x++) 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( 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 ); bindPlayerInventory( ip, 0, 0 );

View file

@ -1,347 +1,357 @@
package appeng.container.implementations; package appeng.container.implementations;
import java.io.IOException; import java.io.IOException;
import java.nio.BufferOverflowException; import java.nio.BufferOverflowException;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.ICrafting; import net.minecraft.inventory.ICrafting;
import net.minecraft.tileentity.TileEntity; import net.minecraft.item.ItemStack;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraft.tileentity.TileEntity;
import appeng.api.AEApi; import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.config.Actionable; import appeng.api.AEApi;
import appeng.api.config.PowerMultiplier; import appeng.api.config.Actionable;
import appeng.api.config.SecurityPermissions; import appeng.api.config.PowerMultiplier;
import appeng.api.config.Settings; import appeng.api.config.SecurityPermissions;
import appeng.api.config.SortDir; import appeng.api.config.Settings;
import appeng.api.config.SortOrder; import appeng.api.config.SortDir;
import appeng.api.config.ViewItems; import appeng.api.config.SortOrder;
import appeng.api.implementations.guiobjects.IPortableCell; import appeng.api.config.ViewItems;
import appeng.api.implementations.tiles.IMEChest; import appeng.api.implementations.guiobjects.IPortableCell;
import appeng.api.implementations.tiles.IViewCellStorage; import appeng.api.implementations.tiles.IMEChest;
import appeng.api.networking.IGrid; import appeng.api.implementations.tiles.IViewCellStorage;
import appeng.api.networking.IGridHost; import appeng.api.networking.IGrid;
import appeng.api.networking.IGridNode; import appeng.api.networking.IGridHost;
import appeng.api.networking.energy.IEnergyGrid; import appeng.api.networking.IGridNode;
import appeng.api.networking.security.BaseActionSource; import appeng.api.networking.energy.IEnergyGrid;
import appeng.api.networking.storage.IBaseMonitor; import appeng.api.networking.security.BaseActionSource;
import appeng.api.parts.IPart; import appeng.api.networking.storage.IBaseMonitor;
import appeng.api.storage.IMEMonitor; import appeng.api.parts.IPart;
import appeng.api.storage.IMEMonitorHandlerReceiver; import appeng.api.storage.IMEMonitor;
import appeng.api.storage.ITerminalHost; import appeng.api.storage.IMEMonitorHandlerReceiver;
import appeng.api.storage.data.IAEItemStack; import appeng.api.storage.ITerminalHost;
import appeng.api.storage.data.IItemList; import appeng.api.storage.data.IAEItemStack;
import appeng.api.util.IConfigManager; import appeng.api.storage.data.IItemList;
import appeng.api.util.IConfigureableObject; import appeng.api.util.IConfigManager;
import appeng.container.AEBaseContainer; import appeng.api.util.IConfigureableObject;
import appeng.container.guisync.GuiSync; import appeng.container.AEBaseContainer;
import appeng.container.slot.SlotRestrictedInput; import appeng.container.guisync.GuiSync;
import appeng.container.slot.SlotRestrictedInput.PlaceableItemType; import appeng.container.slot.SlotRestrictedInput;
import appeng.core.AELog; import appeng.container.slot.SlotRestrictedInput.PlaceableItemType;
import appeng.core.sync.network.NetworkHandler; import appeng.core.AELog;
import appeng.core.sync.packets.PacketMEInventoryUpdate; import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketValueConfig; import appeng.core.sync.packets.PacketMEInventoryUpdate;
import appeng.me.helpers.ChannelPowerSrc; import appeng.core.sync.packets.PacketValueConfig;
import appeng.util.ConfigManager; import appeng.me.helpers.ChannelPowerSrc;
import appeng.util.IConfigManagerHost; import appeng.util.ConfigManager;
import appeng.util.Platform; import appeng.util.IConfigManagerHost;
import appeng.util.Platform;
public class ContainerMEMonitorable extends AEBaseContainer implements IConfigManagerHost, IConfigureableObject, IMEMonitorHandlerReceiver<IAEItemStack>
{ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigManagerHost, IConfigureableObject, IMEMonitorHandlerReceiver<IAEItemStack>
{
final IMEMonitor<IAEItemStack> monitor;
final IItemList<IAEItemStack> items = AEApi.instance().storage().createItemList(); final IMEMonitor<IAEItemStack> monitor;
final IItemList<IAEItemStack> items = AEApi.instance().storage().createItemList();
IConfigManager serverCM;
IConfigManager clientCM; IConfigManager serverCM;
IConfigManager clientCM;
@GuiSync(99)
public boolean canAccessViewCells = false; @GuiSync(99)
public boolean canAccessViewCells = false;
@GuiSync(98)
public boolean hasPower = false; @GuiSync(98)
public boolean hasPower = false;
public SlotRestrictedInput cellView[] = new SlotRestrictedInput[5];
public SlotRestrictedInput cellView[] = new SlotRestrictedInput[5];
public IConfigManagerHost gui;
private IGridNode networkNode; public IConfigManagerHost gui;
private IGridNode networkNode;
public IGridNode getNetworkNode()
{ public IGridNode getNetworkNode()
return networkNode; {
} return networkNode;
}
protected ContainerMEMonitorable(InventoryPlayer ip, ITerminalHost montiorable, boolean bindInventory) { protected ContainerMEMonitorable(InventoryPlayer ip, ITerminalHost montiorable, boolean bindInventory) {
super( ip, montiorable instanceof TileEntity ? (TileEntity) montiorable : null, montiorable instanceof IPart ? (IPart) montiorable : null ); super( ip, montiorable instanceof TileEntity ? (TileEntity) montiorable : null, montiorable instanceof IPart ? (IPart) montiorable : null );
clientCM = new ConfigManager( this ); clientCM = new ConfigManager( this );
clientCM.registerSetting( Settings.SORT_BY, SortOrder.NAME ); clientCM.registerSetting( Settings.SORT_BY, SortOrder.NAME );
clientCM.registerSetting( Settings.VIEW_MODE, ViewItems.ALL ); clientCM.registerSetting( Settings.VIEW_MODE, ViewItems.ALL );
clientCM.registerSetting( Settings.SORT_DIRECTION, SortDir.ASCENDING ); clientCM.registerSetting( Settings.SORT_DIRECTION, SortDir.ASCENDING );
if ( Platform.isServer() ) if ( Platform.isServer() )
{ {
serverCM = montiorable.getConfigManager(); serverCM = montiorable.getConfigManager();
monitor = montiorable.getItemInventory(); monitor = montiorable.getItemInventory();
if ( monitor != null ) if ( monitor != null )
{ {
monitor.addListener( this, null ); monitor.addListener( this, null );
cellInv = monitor; cellInv = monitor;
if ( montiorable instanceof IPortableCell ) if ( montiorable instanceof IPortableCell )
powerSrc = (IPortableCell) montiorable; powerSrc = (IPortableCell) montiorable;
else if ( montiorable instanceof IMEChest ) else if ( montiorable instanceof IMEChest )
powerSrc = (IMEChest) montiorable; powerSrc = (IMEChest) montiorable;
else if ( montiorable instanceof IGridHost ) else if ( montiorable instanceof IGridHost )
{ {
IGridNode node = ((IGridHost) montiorable).getGridNode( ForgeDirection.UNKNOWN ); IGridNode node = ((IGridHost) montiorable).getGridNode( ForgeDirection.UNKNOWN );
if ( node != null ) if ( node != null )
{ {
networkNode = node; networkNode = node;
IGrid g = node.getGrid(); IGrid g = node.getGrid();
if ( g != null ) if ( g != null )
powerSrc = new ChannelPowerSrc( networkNode, (IEnergyGrid) g.getCache( IEnergyGrid.class ) ); powerSrc = new ChannelPowerSrc( networkNode, (IEnergyGrid) g.getCache( IEnergyGrid.class ) );
} }
} }
} }
else else
isContainerValid = false; isContainerValid = false;
} }
else else
monitor = null; monitor = null;
canAccessViewCells = false; canAccessViewCells = false;
if ( montiorable instanceof IViewCellStorage ) if ( montiorable instanceof IViewCellStorage )
{ {
for (int y = 0; y < 5; y++) for (int y = 0; y < 5; y++)
{ {
cellView[y] = new SlotRestrictedInput( PlaceableItemType.VIEWCELL, ((IViewCellStorage) montiorable).getViewCellStorage(), y, 206, y * 18 + 8, cellView[y] = new SlotRestrictedInput( PlaceableItemType.VIEWCELL, ((IViewCellStorage) montiorable).getViewCellStorage(), y, 206, y * 18 + 8,
invPlayer ); invPlayer );
cellView[y].allowEdit = canAccessViewCells; cellView[y].allowEdit = canAccessViewCells;
addSlotToContainer( cellView[y] ); addSlotToContainer( cellView[y] );
} }
} }
if ( bindInventory ) if ( bindInventory )
bindPlayerInventory( ip, 0, 0 ); bindPlayerInventory( ip, 0, 0 );
} }
public ContainerMEMonitorable(InventoryPlayer ip, ITerminalHost montiorable) { public ContainerMEMonitorable(InventoryPlayer ip, ITerminalHost montiorable) {
this( ip, montiorable, true ); this( ip, montiorable, true );
} }
@Override @Override
public void detectAndSendChanges() public void detectAndSendChanges()
{ {
if ( Platform.isServer() ) if ( Platform.isServer() )
{ {
for (Enum set : serverCM.getSettings()) for (Enum set : serverCM.getSettings())
{ {
Enum sideLocal = serverCM.getSetting( set ); Enum sideLocal = serverCM.getSetting( set );
Enum sideRemote = clientCM.getSetting( set ); Enum sideRemote = clientCM.getSetting( set );
if ( sideLocal != sideRemote ) if ( sideLocal != sideRemote )
{ {
clientCM.putSetting( set, sideLocal ); clientCM.putSetting( set, sideLocal );
for (int j = 0; j < this.crafters.size(); ++j) for (int j = 0; j < this.crafters.size(); ++j)
{ {
try try
{ {
NetworkHandler.instance.sendTo( new PacketValueConfig( set.name(), sideLocal.name() ), (EntityPlayerMP) this.crafters.get( j ) ); NetworkHandler.instance.sendTo( new PacketValueConfig( set.name(), sideLocal.name() ), (EntityPlayerMP) this.crafters.get( j ) );
} }
catch (IOException e) catch (IOException e)
{ {
AELog.error( e ); AELog.error( e );
} }
} }
} }
} }
if ( !items.isEmpty() ) if ( !items.isEmpty() )
{ {
try try
{ {
IItemList<IAEItemStack> monitorCache = monitor.getStorageList(); IItemList<IAEItemStack> monitorCache = monitor.getStorageList();
PacketMEInventoryUpdate piu = new PacketMEInventoryUpdate(); PacketMEInventoryUpdate piu = new PacketMEInventoryUpdate();
for (IAEItemStack is : items) for (IAEItemStack is : items)
{ {
IAEItemStack send = monitorCache.findPrecise( is ); IAEItemStack send = monitorCache.findPrecise( is );
if ( send == null ) if ( send == null )
{ {
is.setStackSize( 0 ); is.setStackSize( 0 );
piu.appendItem( is ); piu.appendItem( is );
} }
else else
piu.appendItem( send ); piu.appendItem( send );
} }
if ( !piu.isEmpty() ) if ( !piu.isEmpty() )
{ {
items.resetStatus(); items.resetStatus();
for (Object c : this.crafters) for (Object c : this.crafters)
{ {
if ( c instanceof EntityPlayer ) if ( c instanceof EntityPlayer )
NetworkHandler.instance.sendTo( piu, (EntityPlayerMP) c ); NetworkHandler.instance.sendTo( piu, (EntityPlayerMP) c );
} }
} }
} }
catch (IOException e) catch (IOException e)
{ {
AELog.error( e ); AELog.error( e );
} }
} }
updatePowerStatus(); updatePowerStatus();
boolean oldCanAccessViewCells = canAccessViewCells; boolean oldCanAccessViewCells = canAccessViewCells;
canAccessViewCells = hasAccess( SecurityPermissions.BUILD, false ); canAccessViewCells = hasAccess( SecurityPermissions.BUILD, false );
if ( canAccessViewCells != oldCanAccessViewCells ) if ( canAccessViewCells != oldCanAccessViewCells )
{ {
for (int y = 0; y < 5; y++) for (int y = 0; y < 5; y++)
{ {
if ( cellView[y] != null ) if ( cellView[y] != null )
cellView[y].allowEdit = canAccessViewCells; cellView[y].allowEdit = canAccessViewCells;
} }
} }
super.detectAndSendChanges(); super.detectAndSendChanges();
} }
} }
protected void updatePowerStatus() protected void updatePowerStatus()
{ {
try try
{ {
if ( networkNode != null ) if ( networkNode != null )
hasPower = networkNode.isActive(); hasPower = networkNode.isActive();
else if ( powerSrc instanceof IEnergyGrid ) else if ( powerSrc instanceof IEnergyGrid )
hasPower = ((IEnergyGrid) powerSrc).isNetworkPowered(); hasPower = ((IEnergyGrid) powerSrc).isNetworkPowered();
else else
hasPower = powerSrc.extractAEPower( 1, Actionable.SIMULATE, PowerMultiplier.CONFIG ) > 0.8; hasPower = powerSrc.extractAEPower( 1, Actionable.SIMULATE, PowerMultiplier.CONFIG ) > 0.8;
} }
catch (Throwable t) catch (Throwable t)
{ {
// :P // :P
} }
} }
@Override @Override
public void addCraftingToCrafters(ICrafting c) public void addCraftingToCrafters(ICrafting c)
{ {
super.addCraftingToCrafters( c ); super.addCraftingToCrafters( c );
queueInventory( c ); queueInventory( c );
} }
public void queueInventory(ICrafting c) public void queueInventory(ICrafting c)
{ {
if ( Platform.isServer() && c instanceof EntityPlayer && monitor != null ) if ( Platform.isServer() && c instanceof EntityPlayer && monitor != null )
{ {
try try
{ {
PacketMEInventoryUpdate piu = new PacketMEInventoryUpdate(); PacketMEInventoryUpdate piu = new PacketMEInventoryUpdate();
IItemList<IAEItemStack> monitorCache = monitor.getStorageList(); IItemList<IAEItemStack> monitorCache = monitor.getStorageList();
for (IAEItemStack send : monitorCache) for (IAEItemStack send : monitorCache)
{ {
try try
{ {
piu.appendItem( send ); piu.appendItem( send );
} }
catch (BufferOverflowException boe) catch (BufferOverflowException boe)
{ {
NetworkHandler.instance.sendTo( piu, (EntityPlayerMP) c ); NetworkHandler.instance.sendTo( piu, (EntityPlayerMP) c );
piu = new PacketMEInventoryUpdate(); piu = new PacketMEInventoryUpdate();
piu.appendItem( send ); piu.appendItem( send );
} }
} }
NetworkHandler.instance.sendTo( piu, (EntityPlayerMP) c ); NetworkHandler.instance.sendTo( piu, (EntityPlayerMP) c );
} }
catch (IOException e) catch (IOException e)
{ {
AELog.error( e ); AELog.error( e );
} }
} }
} }
@Override @Override
public void onListUpdate() public void onListUpdate()
{ {
for (Object c : this.crafters) for (Object c : this.crafters)
{ {
if ( c instanceof ICrafting ) if ( c instanceof ICrafting )
{ {
ICrafting cr = (ICrafting) c; ICrafting cr = (ICrafting) c;
queueInventory( cr ); queueInventory( cr );
} }
} }
} }
@Override @Override
public void onUpdate(String field, Object oldValue, Object newValue) public void onUpdate(String field, Object oldValue, Object newValue)
{ {
if ( field.equals( "canAccessViewCells" ) ) if ( field.equals( "canAccessViewCells" ) )
{ {
for (int y = 0; y < 5; y++) for (int y = 0; y < 5; y++)
if ( cellView[y] != null ) if ( cellView[y] != null )
cellView[y].allowEdit = canAccessViewCells; cellView[y].allowEdit = canAccessViewCells;
} }
super.onUpdate( field, oldValue, newValue ); super.onUpdate( field, oldValue, newValue );
} }
@Override @Override
public void onContainerClosed(EntityPlayer player) public void onContainerClosed(EntityPlayer player)
{ {
super.onContainerClosed( player ); super.onContainerClosed( player );
if ( monitor != null ) if ( monitor != null )
monitor.removeListener( this ); monitor.removeListener( this );
} }
@Override @Override
public void removeCraftingFromCrafters(ICrafting c) public void removeCraftingFromCrafters(ICrafting c)
{ {
super.removeCraftingFromCrafters( c ); super.removeCraftingFromCrafters( c );
if ( this.crafters.isEmpty() && monitor != null ) if ( this.crafters.isEmpty() && monitor != null )
monitor.removeListener( this ); monitor.removeListener( this );
} }
@Override @Override
public void postChange(IBaseMonitor<IAEItemStack> monitor, Iterable<IAEItemStack> change, BaseActionSource source) public void postChange(IBaseMonitor<IAEItemStack> monitor, Iterable<IAEItemStack> change, BaseActionSource source)
{ {
for (IAEItemStack is : change) for (IAEItemStack is : change)
items.add( is ); items.add( is );
} }
@Override @Override
public boolean isValid(Object verificationToken) public boolean isValid(Object verificationToken)
{ {
return true; return true;
} }
@Override @Override
public void updateSetting(IConfigManager manager, Enum settingName, Enum newValue) public void updateSetting(IConfigManager manager, Enum settingName, Enum newValue)
{ {
if ( gui != null ) if ( gui != null )
gui.updateSetting( manager, settingName, newValue ); gui.updateSetting( manager, settingName, newValue );
} }
@Override @Override
public IConfigManager getConfigManager() public IConfigManager getConfigManager()
{ {
if ( Platform.isServer() ) if ( Platform.isServer() )
return serverCM; return serverCM;
return clientCM; 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.container.slot.SlotRestrictedInput.PlaceableItemType;
import appeng.core.sync.packets.PacketPatternSlot; import appeng.core.sync.packets.PacketPatternSlot;
import appeng.helpers.IContainerCraftingPacket; import appeng.helpers.IContainerCraftingPacket;
import appeng.items.storage.ItemViewCell;
import appeng.parts.reporting.PartPatternTerminal; import appeng.parts.reporting.PartPatternTerminal;
import appeng.tile.inventory.AppEngInternalInventory; import appeng.tile.inventory.AppEngInternalInventory;
import appeng.tile.inventory.IAEAppEngInventory; import appeng.tile.inventory.IAEAppEngInventory;
@ -61,7 +62,8 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
public PartPatternTerminal ct; public PartPatternTerminal ct;
public ContainerPatternTerm(InventoryPlayer ip, ITerminalHost montiorable) { public ContainerPatternTerm(InventoryPlayer ip, ITerminalHost montiorable)
{
super( ip, montiorable, false ); super( ip, montiorable, false );
ct = (PartPatternTerminal) montiorable; ct = (PartPatternTerminal) montiorable;
@ -73,7 +75,7 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
for (int x = 0; x < 3; x++) 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( 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; craftSlot.IIcon = -1;
for (int y = 0; y < 3; y++) for (int y = 0; y < 3; y++)
@ -352,7 +354,7 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
if ( ic.getStackInSlot( x ) != null ) if ( ic.getStackInSlot( x ) != null )
{ {
ItemStack pulled = Platform.extractItemsByRecipe( powerSrc, mySrc, storage, p.worldObj, r, is, ic, ic.getStackInSlot( x ), x, all, 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 ); 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.IAEItemStack;
import appeng.api.storage.data.IItemList; import appeng.api.storage.data.IItemList;
import appeng.container.ContainerNull; import appeng.container.ContainerNull;
import appeng.helpers.IContainerCraftingPacket;
import appeng.helpers.InventoryAction; import appeng.helpers.InventoryAction;
import appeng.items.storage.ItemViewCell;
import appeng.util.InventoryAdaptor; import appeng.util.InventoryAdaptor;
import appeng.util.Platform; import appeng.util.Platform;
import appeng.util.inv.AdaptorPlayerHand; import appeng.util.inv.AdaptorPlayerHand;
@ -32,15 +34,18 @@ public class SlotCraftingTerm extends AppEngCraftingSlot
private final BaseActionSource mySrc; private final BaseActionSource mySrc;
private final IEnergySource energySrc; private final IEnergySource energySrc;
private final IStorageMonitorable storage; private final IStorageMonitorable storage;
private final IContainerCraftingPacket container;
public SlotCraftingTerm(EntityPlayer player, BaseActionSource mySrc, IEnergySource energySrc, IStorageMonitorable storage, IInventory cMatrix, 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 ); super( player, cMatrix, output, 0, x, y );
this.energySrc = energySrc; this.energySrc = energySrc;
this.storage = storage; this.storage = storage;
this.mySrc = mySrc; this.mySrc = mySrc;
pattern = cMatrix; pattern = cMatrix;
craftInv = secondMatrix; craftInv = secondMatrix;
container = ccp;
} }
public IInventory getCraftingMatrix() public IInventory getCraftingMatrix()
@ -114,7 +119,7 @@ public class SlotCraftingTerm extends AppEngCraftingSlot
if ( pattern.getStackInSlot( x ) != null ) if ( pattern.getStackInSlot( x ) != null )
{ {
set[x] = Platform.extractItemsByRecipe( energySrc, mySrc, inv, p.worldObj, r, is, ic, pattern.getStackInSlot( x ), x, all, 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] ); ic.setInventorySlotContents( x, set[x] );
} }
} }

View file

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

View file

@ -39,7 +39,7 @@ public class ColoredItemDefinition implements AEColoredItemDefinition
{ {
ItemStackSrc is = colors[color.ordinal()]; ItemStackSrc is = colors[color.ordinal()];
if ( comparableItem == null ) if ( comparableItem == null || is == null )
return false; return false;
return comparableItem.getItem() == is.item && comparableItem.getItemDamage() == is.damage; 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.AppEngPacket;
import appeng.core.sync.network.INetworkInfo; import appeng.core.sync.network.INetworkInfo;
import appeng.helpers.IContainerCraftingPacket; import appeng.helpers.IContainerCraftingPacket;
import appeng.items.storage.ItemViewCell;
import appeng.util.Platform; import appeng.util.Platform;
import appeng.util.item.AEItemStack; import appeng.util.item.AEItemStack;
import appeng.util.prioitylist.IPartitionList;
public class PacketNEIRecipe extends AppEngPacket public class PacketNEIRecipe extends AppEngPacket
{ {
@ -41,7 +43,8 @@ public class PacketNEIRecipe extends AppEngPacket
ItemStack[][] recipe; ItemStack[][] recipe;
// automatic. // automatic.
public PacketNEIRecipe(ByteBuf stream) throws IOException { public PacketNEIRecipe(ByteBuf stream) throws IOException
{
ByteArrayInputStream bytes = new ByteArrayInputStream( stream.array() ); ByteArrayInputStream bytes = new ByteArrayInputStream( stream.array() );
bytes.skip( stream.readerIndex() ); bytes.skip( stream.readerIndex() );
NBTTagCompound comp = CompressedStreamTools.readCompressed( bytes ); NBTTagCompound comp = CompressedStreamTools.readCompressed( bytes );
@ -50,13 +53,13 @@ public class PacketNEIRecipe extends AppEngPacket
recipe = new ItemStack[9][]; recipe = new ItemStack[9][];
for (int x = 0; x < recipe.length; x++) for (int x = 0; x < recipe.length; x++)
{ {
NBTTagList list = comp.getTagList( "#"+x, 10 ); NBTTagList list = comp.getTagList( "#" + x, 10 );
if ( list.tagCount() > 0 ) if ( list.tagCount() > 0 )
{ {
recipe[x] = new ItemStack[ list.tagCount() ]; recipe[x] = new ItemStack[list.tagCount()];
for ( int y = 0; y < list.tagCount(); y++ ) 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,12 +94,12 @@ public class PacketNEIRecipe extends AppEngPacket
InventoryCrafting ic = new InventoryCrafting( new ContainerNull(), 3, 3 ); InventoryCrafting ic = new InventoryCrafting( new ContainerNull(), 3, 3 );
for (int x = 0; x < 9; x++) 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] ); ic.setInventorySlotContents( x, recipe[x][0] );
} }
} }
IRecipe r = Platform.findMatchingRecipe( ic, pmp.worldObj ); IRecipe r = Platform.findMatchingRecipe( ic, pmp.worldObj );
if ( r != null && security.hasPermission( player, SecurityPermissions.EXTRACT ) ) if ( r != null && security.hasPermission( player, SecurityPermissions.EXTRACT ) )
@ -107,6 +110,7 @@ public class PacketNEIRecipe extends AppEngPacket
{ {
IMEMonitor<IAEItemStack> stor = inv.getItemInventory(); IMEMonitor<IAEItemStack> stor = inv.getItemInventory();
IItemList all = stor.getStorageList(); IItemList all = stor.getStorageList();
IPartitionList<IAEItemStack> filter = ItemViewCell.createFilter( cct.getViewCells() );
for (int x = 0; x < craftMatrix.getSizeInventory(); x++) for (int x = 0; x < craftMatrix.getSizeInventory(); x++)
{ {
@ -138,27 +142,30 @@ public class PacketNEIRecipe extends AppEngPacket
if ( PatternItem != null && currentItem == null ) if ( PatternItem != null && currentItem == null )
{ {
ItemStack whichItem = Platform.extractItemsByRecipe( energy, cct.getSource(), stor, player.worldObj, r, ItemStack whichItem = Platform.extractItemsByRecipe( energy, cct.getSource(), stor, player.worldObj, r, is, ic,
is, ic, PatternItem, x, all, realForFake ); PatternItem, x, all, realForFake, filter );
if ( whichItem == null ) 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] ); IAEItemStack request = AEItemStack.create( recipe[x][y] );
if ( request != null ) if ( request != null )
{ {
request.setStackSize( 1 ); if ( filter == null || filter.isListed( request ) )
IAEItemStack out = Platform.poweredExtraction( energy, stor, request, cct.getSource() );
if ( out != null )
{ {
whichItem = out.getItemStack(); request.setStackSize( 1 );
break; IAEItemStack out = Platform.poweredExtraction( energy, stor, request, cct.getSource() );
if ( out != null )
{
whichItem = out.getItemStack();
break;
}
} }
} }
} }
} }
craftMatrix.setInventorySlotContents( x, whichItem ); craftMatrix.setInventorySlotContents( x, whichItem );
} }
} }
@ -171,7 +178,8 @@ public class PacketNEIRecipe extends AppEngPacket
} }
// api // api
public PacketNEIRecipe(NBTTagCompound recipe) throws IOException { public PacketNEIRecipe(NBTTagCompound recipe) throws IOException
{
ByteBuf data = Unpooled.buffer(); ByteBuf data = Unpooled.buffer();
ByteArrayOutputStream bytes = new ByteArrayOutputStream(); ByteArrayOutputStream bytes = new ByteArrayOutputStream();

View file

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

View file

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

View file

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

View file

@ -4,18 +4,29 @@ import java.util.EnumSet;
import net.minecraft.inventory.IInventory; import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import appeng.api.AEApi;
import appeng.api.config.FuzzyMode; 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.ICellWorkbenchItem;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
import appeng.core.features.AEFeature; import appeng.core.features.AEFeature;
import appeng.items.AEBaseItem; import appeng.items.AEBaseItem;
import appeng.items.contents.CellConfig; import appeng.items.contents.CellConfig;
import appeng.items.contents.CellUpgrades; import appeng.items.contents.CellUpgrades;
import appeng.util.Platform; 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 class ItemViewCell extends AEBaseItem implements ICellWorkbenchItem
{ {
public ItemViewCell() { public ItemViewCell()
{
super( ItemViewCell.class ); super( ItemViewCell.class );
setfeature( EnumSet.of( AEFeature.Core ) ); setfeature( EnumSet.of( AEFeature.Core ) );
setMaxStackSize( 1 ); setMaxStackSize( 1 );
@ -58,4 +69,73 @@ public class ItemViewCell extends AEBaseItem implements ICellWorkbenchItem
{ {
Platform.openNbtData( is ).setString( "FuzzyMode", fzMode.name() ); 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.ImmutableCollection;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSortedSet;
import com.google.common.collect.SetMultimap; import com.google.common.collect.SetMultimap;
public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper, ICellProvider, IMEInventoryHandler public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper, ICellProvider, IMEInventoryHandler
@ -78,7 +77,7 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
IEnergyGrid eg; IEnergyGrid eg;
HashMap<ICraftingPatternDetails, List<ICraftingMedium>> craftingMethods = new HashMap(); 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(); HashSet<IAEItemStack> emitableItems = new HashSet();
HashMap<String, CraftingLinkNexus> links = new HashMap(); HashMap<String, CraftingLinkNexus> links = new HashMap();
@ -92,7 +91,8 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
final Iterator<CraftingCPUCluster> i; final Iterator<CraftingCPUCluster> i;
CraftingCPUCluster c = null; CraftingCPUCluster c = null;
public ActiveCpuIterator(Collection<CraftingCPUCluster> o) { public ActiveCpuIterator(Collection<CraftingCPUCluster> o)
{
i = o.iterator(); i = o.iterator();
} }
@ -135,7 +135,8 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
return ImmutableSet.copyOf( new ActiveCpuIterator( cpuClusters ) ); return ImmutableSet.copyOf( new ActiveCpuIterator( cpuClusters ) );
} }
public CraftingGridCache(IGrid g) { public CraftingGridCache(IGrid g)
{
grid = g; grid = g;
} }
@ -287,7 +288,7 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
private void updatePatterns() private void updatePatterns()
{ {
HashMap<IAEItemStack, ImmutableSet<ICraftingPatternDetails>> oldItems = craftableItems; HashMap<IAEItemStack, ImmutableList<ICraftingPatternDetails>> oldItems = craftableItems;
// erase list. // erase list.
craftingMethods.clear(); craftingMethods.clear();
@ -323,7 +324,7 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
// make them immutable // make them immutable
for (Entry<IAEItemStack, Set<ICraftingPatternDetails>> e : tmpCraft.entrySet()) 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() ); sg.postAlterationOfStoredItems( StorageChannel.ITEMS, craftableItems.keySet(), new BaseActionSource() );
} }
@ -481,7 +482,7 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
@Override @Override
public ImmutableCollection<ICraftingPatternDetails> getCraftingFor(IAEItemStack whatToCraft, ICraftingPatternDetails details, int slotIndex, World world) 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 ) if ( res == null )
{ {

View file

@ -4,6 +4,7 @@ import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.NavigableMap;
import java.util.TreeMap; import java.util.TreeMap;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -29,7 +30,8 @@ public class MEMonitorIInventory implements IMEInventory<IAEItemStack>, IMEMonit
class CachedItemStack class CachedItemStack
{ {
public CachedItemStack(ItemStack is) { public CachedItemStack(ItemStack is)
{
if ( is == null ) if ( is == null )
{ {
itemStack = null; itemStack = null;
@ -67,7 +69,8 @@ public class MEMonitorIInventory implements IMEInventory<IAEItemStack>, IMEMonit
listeners.remove( l ); listeners.remove( l );
} }
public MEMonitorIInventory(InventoryAdaptor adaptor) { public MEMonitorIInventory(InventoryAdaptor adaptor)
{
this.adaptor = adaptor; this.adaptor = adaptor;
memory = new TreeMap(); memory = new TreeMap();
} }
@ -166,10 +169,13 @@ public class MEMonitorIInventory implements IMEInventory<IAEItemStack>, IMEMonit
LinkedList<IAEItemStack> changes = new LinkedList<IAEItemStack>(); LinkedList<IAEItemStack> changes = new LinkedList<IAEItemStack>();
int high = 0;
list.resetStatus(); list.resetStatus();
for (ItemSlot is : adaptor) for (ItemSlot is : adaptor)
{ {
CachedItemStack old = memory.get( is.slot ); 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 newIS = is == null || is.isExtractable == false && mode == StorageFilter.EXTACTABLE_ONLY ? null : is.getItemStack();
ItemStack oldIS = old == null ? null : old.itemStack; 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() ) if ( !changes.isEmpty() )
postDiffrence( changes ); postDiffrence( changes );

View file

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

View file

@ -62,19 +62,17 @@ public abstract class RotaryCraft extends IC2 implements ShaftPowerReceiver
alpha = io; alpha = io;
} }
@Override
final public int getMachineX() final public int getMachineX()
{ {
return xCoord; return xCoord;
} }
@Override
final public int getMachineY() final public int getMachineY()
{ {
return yCoord; return yCoord;
} }
@Override
final public int getMachineZ() final public int getMachineZ()
{ {
return zCoord; return zCoord;
@ -101,7 +99,6 @@ public abstract class RotaryCraft extends IC2 implements ShaftPowerReceiver
power = p; power = p;
} }
@Override
final public boolean canReadFromBlock(int x, int y, int z) final public boolean canReadFromBlock(int x, int y, int z)
{ {
ForgeDirection side = ForgeDirection.UNKNOWN; ForgeDirection side = ForgeDirection.UNKNOWN;
@ -136,4 +133,16 @@ public abstract class RotaryCraft extends IC2 implements ShaftPowerReceiver
omega = 0; 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.AESharedNBT;
import appeng.util.item.OreHelper; import appeng.util.item.OreHelper;
import appeng.util.item.OreRefrence; import appeng.util.item.OreRefrence;
import appeng.util.prioitylist.IPartitionList;
import buildcraft.api.tools.IToolWrench; import buildcraft.api.tools.IToolWrench;
import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Loader; 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, 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 ) if ( energySrc.extractAEPower( 1, Actionable.SIMULATE, PowerMultiplier.CONFIG ) > 0.9 )
{ {
@ -1649,14 +1651,17 @@ public class Platform
AEItemStack ae_req = AEItemStack.create( providedTemplate ); AEItemStack ae_req = AEItemStack.create( providedTemplate );
ae_req.setStackSize( 1 ); ae_req.setStackSize( 1 );
IAEItemStack ae_ext = src.extractItems( ae_req, realForFake, mySrc ); if ( filter == null || filter.isListed( ae_req ) )
if ( ae_ext != null )
{ {
ItemStack extracted = ae_ext.getItemStack(); IAEItemStack ae_ext = src.extractItems( ae_req, realForFake, mySrc );
if ( extracted != null ) if ( ae_ext != null )
{ {
energySrc.extractAEPower( 1, realForFake, PowerMultiplier.CONFIG ); ItemStack extracted = ae_ext.getItemStack();
return extracted; if ( extracted != null )
{
energySrc.extractAEPower( 1, realForFake, PowerMultiplier.CONFIG );
return extracted;
}
} }
} }
@ -1677,11 +1682,14 @@ public class Platform
{ {
IAEItemStack ax = x.copy(); IAEItemStack ax = x.copy();
ax.setStackSize( 1 ); ax.setStackSize( 1 );
IAEItemStack ex = src.extractItems( ax, realForFake, mySrc ); if ( filter == null || filter.isListed( ax ) )
if ( ex != null )
{ {
energySrc.extractAEPower( 1, realForFake, PowerMultiplier.CONFIG ); IAEItemStack ex = src.extractItems( ax, realForFake, mySrc );
return ex.getItemStack(); if ( ex != null )
{
energySrc.extractAEPower( 1, realForFake, PowerMultiplier.CONFIG );
return ex.getItemStack();
}
} }
} }
ci.setInventorySlotContents( slot, providedTemplate ); ci.setInventorySlotContents( slot, providedTemplate );
@ -1836,4 +1844,11 @@ public class Platform
// p.addStat( achivement, 1 ); // 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 );
}
} }