This commit is contained in:
asiekierka 2014-12-09 19:39:38 +01:00
parent b498bff9bd
commit 47a09b3a2a
4 changed files with 16 additions and 20 deletions

View file

@ -722,6 +722,7 @@ public class TileBuilder extends TileAbstractBuilder implements IHasWork, IFluid
public void updateRequirements() {
ArrayList<ItemStack> reqCopy = null;
if (currentBuilder instanceof BptBuilderBlueprint) {
currentBuilder.initialize();
reqCopy = ((BptBuilderBlueprint) currentBuilder).neededItems;
}
@ -733,6 +734,7 @@ public class TileBuilder extends TileAbstractBuilder implements IHasWork, IFluid
public void updateRequirements(EntityPlayer caller) {
ArrayList<ItemStack> reqCopy = null;
if (currentBuilder instanceof BptBuilderBlueprint) {
currentBuilder.initialize();
reqCopy = ((BptBuilderBlueprint) currentBuilder).neededItems;
}

View file

@ -62,17 +62,21 @@ public abstract class BptBuilderBase implements IAreaProvider {
context = bluePrint.getContext(world, box);
}
protected abstract void initialize ();
public void initialize() {
if (!initialized) {
internalInit();
initialized = true;
}
}
protected abstract void internalInit();
protected abstract BuildingSlot reserveNextBlock(World world);
protected abstract BuildingSlot getNextBlock(World world, TileAbstractBuilder inv);
public boolean buildNextSlot(World world, TileAbstractBuilder builder, double x, double y, double z) {
if (!initialized) {
initialize();
initialized = true;
}
initialize();
if (world.getTotalWorldTime() < nextBuildDate) {
return false;
@ -90,11 +94,7 @@ public abstract class BptBuilderBase implements IAreaProvider {
public boolean buildSlot(World world, IBuildingItemsProvider builder, BuildingSlot slot, double x, double y,
double z) {
if (!initialized) {
initialize();
initialized = true;
}
initialize();
if (slot != null) {
slot.built = true;
@ -113,10 +113,7 @@ public abstract class BptBuilderBase implements IAreaProvider {
}
public BuildingSlot reserveNextSlot(World world) {
if (!initialized) {
initialize();
initialized = true;
}
initialize();
return reserveNextBlock(world);
}

View file

@ -69,7 +69,7 @@ public class BptBuilderBlueprint extends BptBuilderBase {
}
@Override
protected void initialize () {
protected void internalInit () {
for (int j = blueprint.sizeY - 1; j >= 0; --j) {
for (int i = 0; i < blueprint.sizeX; ++i) {
for (int k = 0; k < blueprint.sizeZ; ++k) {
@ -192,10 +192,7 @@ public class BptBuilderBlueprint extends BptBuilderBase {
}
public void deploy () {
if (!initialized) {
initialize();
initialized = true;
}
initialize();
for (BuildingSlotBlock b : buildList) {
if (b.mode == Mode.ClearIfInvalid) {

View file

@ -36,7 +36,7 @@ public class BptBuilderTemplate extends BptBuilderBase {
}
@Override
protected void initialize () {
protected void internalInit () {
if (blueprint.excavate) {
for (int j = blueprint.sizeY - 1; j >= 0; --j) {
for (int i = 0; i < blueprint.sizeX; ++i) {