Resolved #0202 - The question of cable power usage.

Cables no longer use power.
Each channel on a block now consumes 1 / 128 AE/t
This commit is contained in:
AlgorithmX2 2014-03-17 22:58:58 -05:00
parent b226b5bb49
commit a475a3e91f
6 changed files with 51 additions and 19 deletions

View file

@ -21,9 +21,11 @@ import appeng.api.networking.energy.IEnergyGridProvider;
import appeng.api.networking.energy.IEnergyWatcher;
import appeng.api.networking.energy.IEnergyWatcherHost;
import appeng.api.networking.events.MENetworkEventSubscribe;
import appeng.api.networking.events.MENetworkPostCacheConstruction;
import appeng.api.networking.events.MENetworkPowerIdleChange;
import appeng.api.networking.events.MENetworkPowerStatusChange;
import appeng.api.networking.events.MENetworkPowerStorage;
import appeng.api.networking.pathing.IPathingGrid;
import appeng.api.networking.storage.IStackWatcherHost;
import appeng.me.GridNode;
import appeng.me.energy.EnergyThreshold;
@ -108,11 +110,18 @@ public class EnergyGridCache implements IEnergyGrid
Set<IEnergyGridProvider> gproviders = new LinkedHashSet();
final IGrid myGrid;
PathGridCache pgc;
public EnergyGridCache(IGrid g) {
myGrid = g;
}
@MENetworkEventSubscribe
public void postInit(MENetworkPostCacheConstruction pcc)
{
pgc = myGrid.getCache( IPathingGrid.class );
}
@MENetworkEventSubscribe
public void EnergyNodeChanges(MENetworkPowerIdleChange ev)
{
@ -491,7 +500,7 @@ public class EnergyGridCache implements IEnergyGrid
@Override
public double getIdlePowerUsage()
{
return drainPerTick;
return drainPerTick + pgc.channelPowerUsage;
}
@Override

View file

@ -52,6 +52,9 @@ public class PathGridCache implements IPathingGrid
private HashSet<IPathItem> semiOpen = new HashSet();
private HashSet<IPathItem> closedList = new HashSet();
public int channelsByBlocks = 0;
public double channelPowerUsage = 0.0;
public PathGridCache(IGrid g) {
myGrid = g;
}
@ -82,6 +85,8 @@ public class PathGridCache implements IPathingGrid
int nodes = myGrid.getNodes().size();
ticksUntilReady = 20 + (nodes / 10);
channelsByBlocks = nodes * used;
channelPowerUsage = (double) channelsByBlocks / 128.0;
myGrid.getPivot().beginVisition( new AdHocChannelUpdater( used ) );
}
@ -111,7 +116,7 @@ public class PathGridCache implements IPathingGrid
closedList.add( gc );
open.add( gc );
gc.setControllerRoute( (GridNode) node, true );
active.add( new PathSegment( open, semiOpen, closedList ) );
active.add( new PathSegment( this, open, semiOpen, closedList ) );
}
}
}
@ -145,6 +150,7 @@ public class PathGridCache implements IPathingGrid
}
booting = false;
channelPowerUsage = (double) channelsByBlocks / 128.0;
myGrid.postEvent( new MENetworkBootingStatusChange() );
}
}
@ -181,6 +187,7 @@ public class PathGridCache implements IPathingGrid
// clean up...
active.clear();
channelsByBlocks = 0;
updateNetwork = true;
}

View file

@ -9,6 +9,7 @@ import java.util.Set;
import appeng.api.networking.GridFlags;
import appeng.api.networking.IGridMultiblock;
import appeng.api.networking.IGridNode;
import appeng.me.cache.PathGridCache;
public class PathSegment
{
@ -22,10 +23,13 @@ public class PathSegment
};
public PathSegment(List open, Set semiopen, Set closed) {
PathGridCache pgc;
public PathSegment(PathGridCache myPGC, List open, Set semiopen, Set closed) {
this.open = open;
this.semiopen = semiopen;
this.closed = closed;
pgc = myPGC;
isDead = false;
}
@ -101,6 +105,7 @@ public class PathSegment
pi = start;
while (pi != null)
{
pgc.channelsByBlocks++;
pi.incrementChannelCount( 1 );
pi = pi.getControllerRoute();
}
@ -122,6 +127,7 @@ public class PathSegment
pi = start;
while (pi != null)
{
pgc.channelsByBlocks++;
pi.incrementChannelCount( 1 );
pi = pi.getControllerRoute();
}

View file

@ -50,7 +50,7 @@ public class PartCable extends AEBasePart implements IPartCable
public PartCable(Class c, ItemStack is) {
super( c, is );
proxy.setIdlePowerUsage( 1.0 / 16.0 );
proxy.setIdlePowerUsage( 0.0 );
proxy.myColor = AEColor.values()[((ItemPart) is.getItem()).varientOf( is.getItemDamage() )];
}

View file

@ -8,6 +8,7 @@ import appeng.api.exceptions.RecipeError;
import appeng.api.exceptions.RegistrationError;
import appeng.api.recipes.ICraftHandler;
import appeng.api.recipes.IIngredient;
import appeng.core.AELog;
import appeng.core.AppEng;
import appeng.integration.abstraction.IIC2;
import appeng.recipes.RecipeHandler;
@ -42,20 +43,29 @@ public class Macerator implements ICraftHandler, IWebsiteSeralizer
{
IIC2 ic2 = (IIC2) AppEng.instance.getIntegration( "IC2" );
for (ItemStack is : pro_input.getItemStackSet())
{
try
{
ic2.maceratorRecipe( is, pro_output[0].getItemStack() );
}
catch (java.lang.RuntimeException err)
{
AELog.info( "IC2 not happy - " + err.getMessage() );
}
}
}
}
@Override
public boolean canCraft(ItemStack output) throws RegistrationError, MissingIngredientError {
public boolean canCraft(ItemStack output) throws RegistrationError, MissingIngredientError
{
return Platform.isSameItemPrecise( pro_output[0].getItemStack(), output );
}
@Override
public String getPattern( RecipeHandler h ) {
return "macerator\n"+
h.getName(pro_input)+"\n"+
h.getName(pro_output[0]);
public String getPattern(RecipeHandler h)
{
return null;
}
}

View file

@ -53,15 +53,15 @@ public class Pulverizer implements ICraftHandler, IWebsiteSeralizer
}
@Override
public boolean canCraft(ItemStack output) throws RegistrationError, MissingIngredientError {
public boolean canCraft(ItemStack output) throws RegistrationError, MissingIngredientError
{
return Platform.isSameItemPrecise( pro_output[0].getItemStack(), output );
}
@Override
public String getPattern( RecipeHandler h ) {
return "pulverizer\n"+
h.getName(pro_input)+"\n"+
h.getName(pro_output[0]);
public String getPattern(RecipeHandler h)
{
return null;
}
}