Made sure that blocks that are not build still issue breaking blocks.

Fix #1585 and #1622.
This commit is contained in:
SpaceToad 2014-04-27 16:20:59 +02:00
parent e0f0e1dab6
commit 8c16501ee5
8 changed files with 63 additions and 51 deletions

View file

@ -81,7 +81,7 @@ public class SchematicBlock extends SchematicBlockBase implements Comparable<Sc
* will not be asked on such a block, and building will not be called.
*/
@Override
public boolean ignoreBuilding() {
public boolean doNotBuild() {
return false;
}

View file

@ -42,7 +42,7 @@ public abstract class SchematicBlockBase extends Schematic {
* Return true if the block should not be placed to the world. Requirements
* will not be asked on such a block, and building will not be called.
*/
public boolean ignoreBuilding() {
public boolean doNotBuild() {
return false;
}

View file

@ -75,7 +75,7 @@ public class SchematicBed extends SchematicBlock {
}
@Override
public boolean ignoreBuilding() {
public boolean doNotBuild() {
return (meta & 8) != 0;
}
}

View file

@ -58,10 +58,15 @@ public class SchematicDoor extends SchematicBlock {
}
@Override
public boolean ignoreBuilding() {
public boolean doNotBuild() {
return (meta & 8) != 0;
}
@Override
public boolean isAlreadyBuilt(IBuilderContext context, int x, int y, int z) {
return block == context.world().getBlock(x, y, z);
}
@Override
public void writeToWorld(IBuilderContext context, int x, int y, int z, LinkedList <ItemStack> stacks) {
context.world().setBlock(x, y, z, block, meta, 3);

View file

@ -35,7 +35,7 @@ public class SchematicFluid extends SchematicBlock {
if (meta == 0) {
return block == context.world().getBlock(x, y, z) && context.world().getBlockMetadata(x, y, z) == 0;
} else {
return true;
return block == context.world().getBlock(x, y, z);
}
}
@ -45,7 +45,7 @@ public class SchematicFluid extends SchematicBlock {
}
@Override
public boolean ignoreBuilding() {
public boolean doNotBuild() {
return meta != 0;
}

View file

@ -32,7 +32,7 @@ public class SchematicIgnore extends SchematicBlock {
}
@Override
public boolean ignoreBuilding() {
public boolean doNotBuild() {
return true;
}

View file

@ -211,48 +211,53 @@ public class BptBuilderBlueprint extends BptBuilderBase {
return null;
}
boolean getNext = false;
try {
getNext = !slot.schematic.ignoreBuilding()
&& !slot.isAlreadyBuilt(context);
if (!slot.isAlreadyBuilt(context)) {
if (slot.mode == Mode.ClearIfInvalid) {
if (BuildCraftAPI.isSoftBlock(world, slot.x, slot.y,
slot.z)
|| BlockUtil.isUnbreakableBlock(world, slot.x,
slot.y, slot.z)) {
iterator.remove();
} else {
if (setupForDestroy(builder, context, slot)) {
iterator.remove();
postProcessing.add(slot);
clearedLocations.add(new BlockIndex(slot.x,
slot.y, slot.z));
return slot;
}
}
} else if (!slot.schematic.doNotBuild()) {
if (BuildCraftAPI.isSoftBlock(world, slot.x, slot.y,
slot.z)) {
if (checkRequirements(builder, slot.schematic)) {
useRequirements(builder, slot);
iterator.remove();
postProcessing.add(slot);
builtLocations.add(new BlockIndex(slot.x,
slot.y, slot.z));
return slot;
} else {
// the block is not soft anymore, we can't build
// here.
// forget about it.
iterator.remove();
}
}
} else {
iterator.remove();
}
} else {
iterator.remove();
}
} catch (Throwable t) {
// Defensive code against errors in implementers
t.printStackTrace();
BCLog.logger.throwing("BptBuilderBlueprint", "internalGetBlock", t);
getNext = false;
}
if (getNext) {
if (slot.mode == Mode.ClearIfInvalid) {
if (BuildCraftAPI.isSoftBlock(world, slot.x, slot.y, slot.z)
|| BlockUtil.isUnbreakableBlock(world, slot.x, slot.y, slot.z)) {
iterator.remove();
} else {
if (setupForDestroy(builder, context, slot)) {
iterator.remove();
postProcessing.add(slot);
clearedLocations.add(new BlockIndex(slot.x, slot.y, slot.z));
return slot;
}
}
} else {
if (BuildCraftAPI.isSoftBlock(world, slot.x, slot.y, slot.z)) {
if (checkRequirements(builder, slot.schematic)) {
useRequirements(builder, slot);
iterator.remove();
postProcessing.add(slot);
builtLocations.add(new BlockIndex(slot.x, slot.y, slot.z));
return slot;
} else {
// the block is not soft anymore, we can't build here.
// forget about it.
iterator.remove();
}
}
}
} else {
BCLog.logger.throwing("BptBuilderBlueprint",
"internalGetBlock", t);
iterator.remove();
}
}

View file

@ -114,12 +114,14 @@ public class TileQuarry extends TileAbstractBuilder implements IMachine {
}
private void createArm() {
worldObj.spawnEntityInWorld(new EntityMechanicalArm(worldObj, box.xMin
+ CoreConstants.PIPE_MAX_POS, yCoord + box.sizeY ()
- 1 + CoreConstants.PIPE_MIN_POS, box.zMin
+ CoreConstants.PIPE_MAX_POS, box.sizeX () - 2
+ CoreConstants.PIPE_MIN_POS * 2, box.sizeZ() - 2
+ CoreConstants.PIPE_MIN_POS * 2, this));
worldObj.spawnEntityInWorld
(new EntityMechanicalArm(worldObj,
box.xMin + CoreConstants.PIPE_MAX_POS,
yCoord + box.sizeY () - 1 + CoreConstants.PIPE_MIN_POS,
box.zMin + CoreConstants.PIPE_MAX_POS,
box.sizeX () - 2 + CoreConstants.PIPE_MIN_POS * 2,
box.sizeZ() - 2 + CoreConstants.PIPE_MIN_POS * 2,
this));
}
// Callback from the arm once it's created