Item Tunnels now cycle Outputs.

This commit is contained in:
AlgorithmX2
2014-06-08 18:54:38 -05:00
parent 3d8a129531
commit 76de1cf185
4 changed files with 69 additions and 27 deletions
+25 -20
View File
@@ -2,41 +2,46 @@ package appeng.core.settings;
import appeng.core.AEConfig;
public enum TickRates {
public enum TickRates
{
Interface(5, 120),
Interface(5,120),
ImportBus(5, 40),
ExportBus(5, 60),
AnnihilationPlane(2, 120),
MJTunnel(1, 20),
METunnel(5, 20),
Inscriber(1, 1),
IOPort(1, 5),
VibrationChamber(10, 40),
StorageBus(5, 60);
StorageBus(5, 60),
ItemTunnel(5, 60);
public int min;
public int max;
private TickRates( int min, int max ) {
private TickRates(int min, int max) {
this.min = min;
this.max = max;
}
public void Load( AEConfig config )
public void Load(AEConfig config)
{
config.addCustomCategoryComment("TickRates", " Min / Max Tickrates for dynamic ticking, most of these components also use sleeping, to prevent constant ticking, adjust with care, non standard rates are not supported or tested." );
min = config.get( "TickRates", name()+".min", min ).getInt(min);
max = config.get( "TickRates", name()+".max", max ).getInt(max);
config.addCustomCategoryComment(
"TickRates",
" Min / Max Tickrates for dynamic ticking, most of these components also use sleeping, to prevent constant ticking, adjust with care, non standard rates are not supported or tested." );
min = config.get( "TickRates", name() + ".min", min ).getInt( min );
max = config.get( "TickRates", name() + ".max", max ).getInt( max );
}
}
+2 -2
View File
@@ -38,7 +38,7 @@ public class LayerISidedInventory extends LayerBase implements ISidedInventory
* Recalculate inventory wrapper cache.
*/
@Override
public void partChanged()
public void notifyNeighbors()
{
invs = new ArrayList();
int slotCount = 0;
@@ -90,7 +90,7 @@ public class LayerISidedInventory extends LayerBase implements ISidedInventory
}
// make sure inventory is updated before we call FMP.
super.partChanged();
super.notifyNeighbors();
}
/**
+29 -5
View File
@@ -13,11 +13,16 @@ import net.minecraft.tileentity.TileEntityChest;
import net.minecraft.util.IIcon;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.config.TunnelType;
import appeng.api.networking.IGridNode;
import appeng.api.networking.events.MENetworkBootingStatusChange;
import appeng.api.networking.events.MENetworkChannelsChanged;
import appeng.api.networking.events.MENetworkEventSubscribe;
import appeng.api.networking.events.MENetworkPowerStatusChange;
import appeng.api.networking.ticking.IGridTickable;
import appeng.api.networking.ticking.TickRateModulation;
import appeng.api.networking.ticking.TickingRequest;
import appeng.core.AppEng;
import appeng.core.settings.TickRates;
import appeng.integration.abstraction.IBC;
import appeng.me.GridAccessException;
import appeng.me.cache.helpers.TunnelCollection;
@@ -34,7 +39,7 @@ import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@Interface(iface = "buildcraft.api.transport.IPipeConnection", iname = "BC")
public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements IPipeConnection, IInventory, ISidedInventory
public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements IPipeConnection, IInventory, ISidedInventory, IGridTickable
{
public TunnelType getTunnelType()
@@ -47,6 +52,7 @@ public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements IPipeCo
}
int oldSize = 0;
boolean requsted;
IInventory cachedInv;
LinkedList<IInventory> which = new LinkedList<IInventory>();
@@ -119,8 +125,28 @@ public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements IPipeCo
input.onTunnelNetworkChange();
}
@Override
public TickingRequest getTickingRequest(IGridNode node)
{
return new TickingRequest( TickRates.ItemTunnel.min, TickRates.ItemTunnel.max, false, false );
}
@Override
public TickRateModulation tickingRequest(IGridNode node, int TicksSinceLastCall)
{
boolean wasReq = requsted;
if ( requsted && cachedInv != null )
((WrapperChainedInventory) cachedInv).cycleOrder();
requsted = false;
return wasReq ? TickRateModulation.FASTER : TickRateModulation.SLOWER;
}
IInventory getDest()
{
requsted = true;
if ( cachedInv != null )
return cachedInv;
@@ -191,8 +217,7 @@ public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements IPipeCo
oldSize = getDest().getSizeInventory();
if ( olderSize != oldSize )
{
getHost().partChanged();
tile.getWorldObj().notifyBlocksOfNeighborChange( tile.xCoord, tile.yCoord, tile.zCoord, Platform.air );
getHost().notifyNeighbors();
}
}
}
@@ -207,8 +232,7 @@ public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements IPipeCo
oldSize = getDest().getSizeInventory();
if ( olderSize != oldSize )
{
getHost().partChanged();
tile.getWorldObj().notifyBlocksOfNeighborChange( tile.xCoord, tile.yCoord, tile.zCoord, Platform.air );
getHost().notifyNeighbors();
}
}
else
+13
View File
@@ -32,6 +32,18 @@ public class WrapperChainedInventory implements IInventory
setInventory( ilist );
}
public void cycleOrder()
{
if ( l.size() > 1 )
{
List<IInventory> newOrder = new ArrayList( l.size() );
newOrder.add( l.get( l.size() - 1 ) );
for (int x = 0; x < l.size() - 1; x++)
newOrder.add( l.get( x ) );
setInventory( newOrder );
}
}
public void calculateSizes()
{
offsets = new HashMap<Integer, WrapperChainedInventory.InvOffset>();
@@ -195,4 +207,5 @@ public class WrapperChainedInventory implements IInventory
}
return false;
}
}