make BuildCraft actually have a single maximum energy per tick count
This commit is contained in:
parent
dcccad0658
commit
a2a0143268
3 changed files with 21 additions and 2 deletions
|
@ -49,6 +49,8 @@ public abstract class TileBuildCraft extends TileEntity implements IEnergyHandle
|
|||
private String owner = "[BuildCraft]";
|
||||
private RFBattery battery;
|
||||
|
||||
private int receivedTick, extractedTick;
|
||||
|
||||
public String getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
@ -71,6 +73,11 @@ public abstract class TileBuildCraft extends TileEntity implements IEnergyHandle
|
|||
initialize();
|
||||
init = true;
|
||||
}
|
||||
|
||||
if (battery != null) {
|
||||
receivedTick = 0;
|
||||
extractedTick = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void initialize() {
|
||||
|
@ -172,7 +179,11 @@ public abstract class TileBuildCraft extends TileEntity implements IEnergyHandle
|
|||
public int receiveEnergy(ForgeDirection from, int maxReceive,
|
||||
boolean simulate) {
|
||||
if (battery != null && this.canConnectEnergy(from)) {
|
||||
return battery.receiveEnergy(maxReceive, simulate);
|
||||
int received = battery.receiveEnergy(maxReceive - receivedTick, simulate);
|
||||
if (!simulate) {
|
||||
receivedTick += received;
|
||||
}
|
||||
return received;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
@ -184,7 +195,11 @@ public abstract class TileBuildCraft extends TileEntity implements IEnergyHandle
|
|||
public int extractEnergy(ForgeDirection from, int maxExtract,
|
||||
boolean simulate) {
|
||||
if (battery != null && this.canConnectEnergy(from)) {
|
||||
return battery.extractEnergy(maxExtract, simulate);
|
||||
int extracted = battery.extractEnergy(maxExtract - extractedTick, simulate);
|
||||
if (!simulate) {
|
||||
extractedTick += extracted;
|
||||
}
|
||||
return extracted;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -37,6 +37,8 @@ public class TileMiningWell extends TileBuildCraft implements IHasWork, IPipeCon
|
|||
*/
|
||||
@Override
|
||||
public void updateEntity () {
|
||||
super.updateEntity();
|
||||
|
||||
if (worldObj.isRemote) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -110,6 +110,8 @@ public class TileRefinery extends TileBuildCraft implements IFluidHandler, IInve
|
|||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
|
||||
if (worldObj.isRemote) {
|
||||
simpleAnimationIterate();
|
||||
return;
|
||||
|
|
Loading…
Reference in a new issue