added variable timeout for schematic, down to 1. close #1971

This commit is contained in:
SpaceToad 2014-09-14 20:52:53 +02:00
parent 2c5c282f2f
commit 1ec9d92699
11 changed files with 51 additions and 15 deletions

View file

@ -275,4 +275,12 @@ public abstract class Schematic {
public void readFromNBT(NBTTagCompound nbt, MappingRegistry registry) {
}
/**
* Returns the number of cycles to wait after building this schematic. Tiles
* and entities typically require more wait, around 5 cycles.
*/
public int buildTime() {
return 1;
}
}

View file

@ -214,4 +214,8 @@ public class SchematicEntity extends Schematic {
return false;
}
@Override
public int buildTime() {
return 5;
}
}

View file

@ -112,4 +112,9 @@ public class SchematicTile extends SchematicBlock {
tileNBT = nbt.getCompoundTag("blockCpt");
}
@Override
public int buildTime() {
return 5;
}
}

View file

@ -17,7 +17,6 @@ import net.minecraft.nbt.NBTTagCompound;
import buildcraft.api.blueprints.ITileBuilder;
import buildcraft.api.blueprints.SchematicRegistry;
import buildcraft.api.core.NetworkData;
import buildcraft.api.core.SafeTimeTracker;
import buildcraft.core.IBoxProvider;
import buildcraft.core.LaserData;
import buildcraft.core.RFBattery;
@ -42,8 +41,6 @@ public abstract class TileAbstractBuilder extends TileBuildCraft implements ITil
public ArrayList<BuildingItem> buildersInAction = new ArrayList<BuildingItem>();
protected SafeTimeTracker buildTracker = new SafeTimeTracker(5);
private int rfPrev = 0;
private int rfUnchangedCycles = 0;

View file

@ -695,14 +695,10 @@ public class TileBuilder extends TileAbstractBuilder implements IMachine, IFluid
}
public void build () {
if (!buildTracker.markTimeIfDelay(worldObj)) {
return;
}
if (currentBuilder != null) {
currentBuilder.buildNextSlot(worldObj, this, xCoord, yCoord, zCoord);
updateRequirements();
if (currentBuilder.buildNextSlot(worldObj, this, xCoord, yCoord, zCoord)) {
updateRequirements();
}
}
}

View file

@ -112,7 +112,7 @@ public class TileFiller extends TileAbstractBuilder implements IMachine, IAction
return;
}
if (getBattery().getEnergyStored() < POWER_ACTIVATION || !buildTracker.markTimeIfDelay(worldObj)) {
if (getBattery().getEnergyStored() < POWER_ACTIVATION) {
return;
}

View file

@ -46,6 +46,8 @@ public abstract class BptBuilderBase implements IAreaProvider {
protected int x, y, z;
protected boolean initialized = false;
private long nextBuildDate = 0;
public BptBuilderBase(BlueprintBase bluePrint, World world, int x, int y, int z) {
this.blueprint = bluePrint;
this.x = x;
@ -71,13 +73,23 @@ public abstract class BptBuilderBase implements IAreaProvider {
initialized = true;
}
if (world.getTotalWorldTime() < nextBuildDate) {
return false;
}
BuildingSlot slot = getNextBlock(world, builder);
return buildSlot(world, builder, slot, x + 0.5F, y + 0.5F, z + 0.5F);
if (buildSlot(world, builder, slot, x + 0.5F, y + 0.5F, z + 0.5F)) {
nextBuildDate = world.getTotalWorldTime() + slot.buildTime();
return true;
} else {
return false;
}
}
public boolean buildSlot(World world, IBuildingItemsProvider builder, BuildingSlot slot, double x, double y,
double z) {
if (!initialized) {
initialize();
initialized = true;

View file

@ -67,4 +67,6 @@ public abstract class BuildingSlot {
public abstract int getEnergyRequirement();
public abstract int buildTime();
}

View file

@ -176,4 +176,13 @@ public class BuildingSlotBlock extends BuildingSlot {
return schematic.getEnergyRequirement(stackConsumed);
}
@Override
public int buildTime() {
if (schematic == null) {
return 1;
} else {
return schematic.buildTime();
}
}
}

View file

@ -85,4 +85,9 @@ public class BuildingSlotEntity extends BuildingSlot {
public int getEnergyRequirement() {
return schematic.getEnergyRequirement(stackConsumed);
}
@Override
public int buildTime() {
return schematic.buildTime();
}
}

View file

@ -167,9 +167,7 @@ public class TileQuarry extends TileAbstractBuilder implements IMachine {
if (stage == Stage.BUILDING) {
if (builder != null && !builder.isDone(this)) {
if (buildTracker.markTimeIfDelay(worldObj)) {
builder.buildNextSlot(worldObj, this, xCoord, yCoord, zCoord);
}
builder.buildNextSlot(worldObj, this, xCoord, yCoord, zCoord);
} else {
stage = Stage.IDLE;
}