Introduced a third phase in blueprint building, fix #1659.
Further refinements in builder processing.
This commit is contained in:
parent
43921bbba9
commit
31b578959d
5 changed files with 57 additions and 15 deletions
|
@ -42,6 +42,30 @@ import buildcraft.api.core.IInvSlot;
|
|||
*/
|
||||
public abstract class Schematic {
|
||||
|
||||
/**
|
||||
* Blocks are build in various stages, in order to make sure that a block
|
||||
* can indeed be placed, and that it's unlikely to disturb other blocks.
|
||||
*/
|
||||
public static enum BuildingStage {
|
||||
/**
|
||||
* Standalone blocks can be placed in the air, and they don't change
|
||||
* once placed.
|
||||
*/
|
||||
STANDALONE,
|
||||
|
||||
/**
|
||||
* Supported blocks may require to be placed on a standalone block,
|
||||
* e.g. a torch.
|
||||
*/
|
||||
SUPPORTED,
|
||||
|
||||
/**
|
||||
* Expanding blocks will grow and may disturb other block locations,
|
||||
* like e.g. water
|
||||
*/
|
||||
EXPANDING
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the block on the world correspond to the block stored in
|
||||
* the blueprint at the location given by the slot. By default, this
|
||||
|
@ -232,11 +256,9 @@ public abstract class Schematic {
|
|||
}
|
||||
|
||||
/**
|
||||
* Return true if this schematic is standalone, false if it needs other
|
||||
* blocks to be build on. Typically, solid blocks are standalone, others
|
||||
* are not. All standalone blocks are supposed to be built first.
|
||||
* Return the stage where this schematic has to be built.
|
||||
*/
|
||||
public boolean isStandalone () {
|
||||
return true;
|
||||
public BuildingStage getBuildStage () {
|
||||
return BuildingStage.STANDALONE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,11 +12,13 @@ import java.util.ArrayList;
|
|||
import java.util.LinkedList;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockLiquid;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import net.minecraftforge.fluids.BlockFluidBase;
|
||||
|
||||
public class SchematicBlock extends SchematicBlockBase {
|
||||
|
||||
|
@ -159,7 +161,13 @@ public class SchematicBlock extends SchematicBlockBase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isStandalone () {
|
||||
return block.isOpaqueCube();
|
||||
public BuildingStage getBuildStage () {
|
||||
if (block.isOpaqueCube()) {
|
||||
return BuildingStage.STANDALONE;
|
||||
} else if (block instanceof BlockFluidBase || block instanceof BlockLiquid) {
|
||||
return BuildingStage.EXPANDING;
|
||||
} else {
|
||||
return BuildingStage.SUPPORTED;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -368,6 +368,8 @@ public class TileBuilder extends TileAbstractBuilder implements IMachine {
|
|||
|
||||
if (currentPathIterator == null) {
|
||||
done = true;
|
||||
} else {
|
||||
done = false;
|
||||
}
|
||||
} else {
|
||||
if (bluePrintBuilder != null && bluePrintBuilder.isDone(this)) {
|
||||
|
@ -382,6 +384,7 @@ public class TileBuilder extends TileAbstractBuilder implements IMachine {
|
|||
if (bluePrintBuilder != null) {
|
||||
box.initialize(bluePrintBuilder);
|
||||
sendNetworkUpdate();
|
||||
done = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -398,6 +401,7 @@ public class TileBuilder extends TileAbstractBuilder implements IMachine {
|
|||
}
|
||||
|
||||
items[0] = null;
|
||||
box.reset();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -98,7 +98,8 @@ public class BptBuilderBlueprint extends BptBuilderBase {
|
|||
}
|
||||
|
||||
LinkedList<BuildingSlotBlock> tmpStandalone = new LinkedList<BuildingSlotBlock>();
|
||||
LinkedList<BuildingSlotBlock> tmpLastBlocks = new LinkedList<BuildingSlotBlock>();
|
||||
LinkedList<BuildingSlotBlock> tmpSupported = new LinkedList<BuildingSlotBlock>();
|
||||
LinkedList<BuildingSlotBlock> tmpExpanding = new LinkedList<BuildingSlotBlock>();
|
||||
|
||||
for (int j = 0; j < blueprint.sizeY; ++j) {
|
||||
for (int i = 0; i < blueprint.sizeX; ++i) {
|
||||
|
@ -122,13 +123,19 @@ public class BptBuilderBlueprint extends BptBuilderBase {
|
|||
|
||||
if (!builtLocations.contains(new BlockIndex(xCoord, yCoord,
|
||||
zCoord))) {
|
||||
|
||||
if (slot.isStandalone()) {
|
||||
switch (slot.getBuildStage()) {
|
||||
case STANDALONE:
|
||||
tmpStandalone.add(b);
|
||||
b.buildStage = 1;
|
||||
} else {
|
||||
tmpLastBlocks.add(b);
|
||||
break;
|
||||
case SUPPORTED:
|
||||
tmpSupported.add(b);
|
||||
b.buildStage = 2;
|
||||
break;
|
||||
case EXPANDING:
|
||||
tmpExpanding.add(b);
|
||||
b.buildStage = 3;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
postProcessing.add(b);
|
||||
|
@ -138,7 +145,8 @@ public class BptBuilderBlueprint extends BptBuilderBase {
|
|||
}
|
||||
|
||||
buildList.addAll(tmpStandalone);
|
||||
buildList.addAll(tmpLastBlocks);
|
||||
buildList.addAll(tmpSupported);
|
||||
buildList.addAll(tmpExpanding);
|
||||
|
||||
iterator = new BuildingSlotIterator(buildList);
|
||||
|
||||
|
|
|
@ -133,7 +133,7 @@ public class SchematicPipe extends SchematicTile {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isStandalone () {
|
||||
return true;
|
||||
public BuildingStage getBuildStage () {
|
||||
return BuildingStage.STANDALONE;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue