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; import appeng.core.AEConfig;
public enum TickRates { public enum TickRates
{
Interface(5, 120),
Interface(5,120),
ImportBus(5, 40), ImportBus(5, 40),
ExportBus(5, 60), ExportBus(5, 60),
AnnihilationPlane(2, 120), AnnihilationPlane(2, 120),
MJTunnel(1, 20), MJTunnel(1, 20),
METunnel(5, 20), METunnel(5, 20),
Inscriber(1, 1), Inscriber(1, 1),
IOPort(1, 5), IOPort(1, 5),
VibrationChamber(10, 40), VibrationChamber(10, 40),
StorageBus(5, 60); StorageBus(5, 60),
ItemTunnel(5, 60);
public int min; public int min;
public int max; public int max;
private TickRates( int min, int max ) { private TickRates(int min, int max) {
this.min = min; this.min = min;
this.max = max; 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." ); config.addCustomCategoryComment(
min = config.get( "TickRates", name()+".min", min ).getInt(min); "TickRates",
max = config.get( "TickRates", name()+".max", max ).getInt(max); " 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. * Recalculate inventory wrapper cache.
*/ */
@Override @Override
public void partChanged() public void notifyNeighbors()
{ {
invs = new ArrayList(); invs = new ArrayList();
int slotCount = 0; int slotCount = 0;
@@ -90,7 +90,7 @@ public class LayerISidedInventory extends LayerBase implements ISidedInventory
} }
// make sure inventory is updated before we call FMP. // 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.minecraft.util.IIcon;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.config.TunnelType; import appeng.api.config.TunnelType;
import appeng.api.networking.IGridNode;
import appeng.api.networking.events.MENetworkBootingStatusChange; import appeng.api.networking.events.MENetworkBootingStatusChange;
import appeng.api.networking.events.MENetworkChannelsChanged; import appeng.api.networking.events.MENetworkChannelsChanged;
import appeng.api.networking.events.MENetworkEventSubscribe; import appeng.api.networking.events.MENetworkEventSubscribe;
import appeng.api.networking.events.MENetworkPowerStatusChange; 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.AppEng;
import appeng.core.settings.TickRates;
import appeng.integration.abstraction.IBC; import appeng.integration.abstraction.IBC;
import appeng.me.GridAccessException; import appeng.me.GridAccessException;
import appeng.me.cache.helpers.TunnelCollection; import appeng.me.cache.helpers.TunnelCollection;
@@ -34,7 +39,7 @@ import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
@Interface(iface = "buildcraft.api.transport.IPipeConnection", iname = "BC") @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() public TunnelType getTunnelType()
@@ -47,6 +52,7 @@ public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements IPipeCo
} }
int oldSize = 0; int oldSize = 0;
boolean requsted;
IInventory cachedInv; IInventory cachedInv;
LinkedList<IInventory> which = new LinkedList<IInventory>(); LinkedList<IInventory> which = new LinkedList<IInventory>();
@@ -119,8 +125,28 @@ public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements IPipeCo
input.onTunnelNetworkChange(); 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() IInventory getDest()
{ {
requsted = true;
if ( cachedInv != null ) if ( cachedInv != null )
return cachedInv; return cachedInv;
@@ -191,8 +217,7 @@ public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements IPipeCo
oldSize = getDest().getSizeInventory(); oldSize = getDest().getSizeInventory();
if ( olderSize != oldSize ) if ( olderSize != oldSize )
{ {
getHost().partChanged(); getHost().notifyNeighbors();
tile.getWorldObj().notifyBlocksOfNeighborChange( tile.xCoord, tile.yCoord, tile.zCoord, Platform.air );
} }
} }
} }
@@ -207,8 +232,7 @@ public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements IPipeCo
oldSize = getDest().getSizeInventory(); oldSize = getDest().getSizeInventory();
if ( olderSize != oldSize ) if ( olderSize != oldSize )
{ {
getHost().partChanged(); getHost().notifyNeighbors();
tile.getWorldObj().notifyBlocksOfNeighborChange( tile.xCoord, tile.yCoord, tile.zCoord, Platform.air );
} }
} }
else else
+13
View File
@@ -32,6 +32,18 @@ public class WrapperChainedInventory implements IInventory
setInventory( ilist ); 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() public void calculateSizes()
{ {
offsets = new HashMap<Integer, WrapperChainedInventory.InvOffset>(); offsets = new HashMap<Integer, WrapperChainedInventory.InvOffset>();
@@ -195,4 +207,5 @@ public class WrapperChainedInventory implements IInventory
} }
return false; return false;
} }
} }