Re-add update function

Some weirdness occurs with some applications without it unfortunately.
This commit is contained in:
CovertJaguar 2013-07-01 15:53:05 -07:00
parent 9daec45638
commit 499b6f342d
3 changed files with 38 additions and 15 deletions

View file

@ -171,6 +171,21 @@ public final class PowerHandler {
return perdition;
}
/**
* Ticks the power handler. You should call this if you can, but its not
* required.
*
* If you don't call it, the possibility exists for some weirdness with the
* perdition algorithm and work callback as its possible they will not be
* called on every tick they otherwise would be. You should be able to
* design around this though if you are aware of the limitations.
*/
public void update() {
applyPerdition();
applyWork();
validateEnergy();
}
private void applyPerdition() {
if (perditionTracker.markTimeIfDelay(receptor.getWorldObj(), 1) && energyStored > 0) {
float newEnergy = getPerdition().applyPerdition(this, energyStored, perditionTracker.durationOfLastDelay());
@ -286,6 +301,10 @@ public final class PowerHandler {
return type;
}
public void update() {
PowerHandler.this.update();
}
/**
* The amount of power that this PowerHandler currently needs.
*

View file

@ -1,12 +1,10 @@
/**
* Copyright (c) SpaceToad, 2011
* http://www.mod-buildcraft.com
* Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* BuildCraft is distributed under the terms of the Minecraft Mod Public License
* 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.core;
import java.util.HashMap;
@ -30,10 +28,8 @@ public abstract class TileBuildCraft extends TileEntity implements ISynchronized
private static Map<Class, TilePacketWrapper> updateWrappers = new HashMap<Class, TilePacketWrapper>();
@SuppressWarnings("rawtypes")
private static Map<Class, TilePacketWrapper> descriptionWrappers = new HashMap<Class, TilePacketWrapper>();
private final TilePacketWrapper descriptionPacket;
private final TilePacketWrapper updatePacket;
private boolean init = false;
public TileBuildCraft() {
@ -56,6 +52,11 @@ public abstract class TileBuildCraft extends TileEntity implements ISynchronized
initialize();
init = true;
}
if (this instanceof IPowerReceptor) {
IPowerReceptor receptor = ((IPowerReceptor) this);
receptor.getPowerReceiver(null).update();
}
}
@Override
@ -69,7 +70,6 @@ public abstract class TileBuildCraft extends TileEntity implements ISynchronized
}
public void destroy() {
}
public void sendNetworkUpdate() {
@ -105,13 +105,10 @@ public abstract class TileBuildCraft extends TileEntity implements ISynchronized
@Override
public void postPacketHandling(PacketUpdate packet) {
}
public boolean isInvNameLocalized()
{
// TODO Auto-generated method stub
return false;
}
public boolean isInvNameLocalized() {
// TODO Auto-generated method stub
return false;
}
}

View file

@ -33,6 +33,7 @@ import buildcraft.api.gates.IOverrideDefaultTriggers;
import buildcraft.api.gates.ITrigger;
import buildcraft.api.power.IPowerReceptor;
import buildcraft.api.power.PowerHandler;
import buildcraft.api.power.PowerHandler.PowerReceiver;
import buildcraft.api.transport.IPipe;
import buildcraft.api.transport.IPipeConnection;
import buildcraft.api.transport.IPipeEntry;
@ -189,6 +190,12 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank
refreshRenderState = false;
}
PowerReceiver provider = getPowerReceiver(null);
if (provider != null) {
provider.update();
}
if (pipe != null) {
pipe.updateEntity();
}