Convert TileQuarry and EntityRobot to new API

Note this breaks the builder.
This commit is contained in:
CovertJaguar 2013-06-30 17:49:20 -07:00
parent 705798b744
commit 4a1469a055
7 changed files with 133 additions and 165 deletions

View file

@ -6,6 +6,7 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory; import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -31,12 +32,11 @@ public class BlockHandler {
} }
public static BlockHandler getHandler(BlockSchematic schematic) { public static BlockHandler getHandler(BlockSchematic schematic) {
// BlockHandler handler = handlers.get(s); // TODO: replace with mapping -> id code BlockHandler handler = null; // TODO: replace with mapping -> id code
// if (handler == null) { if (handler == null) {
// return DEFAULT_HANDLER; return DEFAULT_HANDLER;
// } }
// return handler; return handler;
return null;
} }
public static void registerHandler(int blockId, BlockHandler handler) { public static void registerHandler(int blockId, BlockHandler handler) {
@ -83,8 +83,8 @@ public class BlockHandler {
if (block == null) { if (block == null) {
return null; return null;
} }
BlockSchematic schematic = new BlockSchematic(block.getUnlocalizedName()); BlockSchematic schematic = new BlockSchematic(block);
schematic.metadata = world.getBlockMetadata(x, y, z); schematic.blockMeta = world.getBlockMetadata(x, y, z);
return schematic; return schematic;
} }
@ -103,7 +103,7 @@ public class BlockHandler {
List<ItemStack> cost = new ArrayList<ItemStack>(); List<ItemStack> cost = new ArrayList<ItemStack>();
Block block = null; // TODO: replace with mapping -> id code Block block = null; // TODO: replace with mapping -> id code
if (block != null) { if (block != null) {
cost.add(new ItemStack(block.idDropped(schematic.metadata, Utils.RANDOM, 0), 1, block.damageDropped(schematic.metadata))); cost.add(new ItemStack(block.idDropped(schematic.blockMeta, Utils.RANDOM, 0), 1, block.damageDropped(schematic.blockMeta)));
} }
return cost; return cost;
} }
@ -157,14 +157,16 @@ public class BlockHandler {
} }
/** /**
* FEEDBACK REQUIRED: Should this place the block or should the block * This function handles the placement of the block in the world.
* already be placed and this just initializes it?
* *
* The ForgeDirection parameter can be use to determine the orientation of * The ForgeDirection parameter can be use to determine the orientation of
* the blueprint. Blueprints are always saved facing North. This function * the blueprint. Blueprints are always saved facing North. This function
* will have to rotate the block accordingly. * will have to rotate the block accordingly.
*/ */
public boolean readBlockFromSchematic(World world, int x, int y, int z, ForgeDirection blueprintOrientation, BlockSchematic schematic) { public boolean readBlockFromSchematic(World world, int x, int y, int z, ForgeDirection blueprintOrientation, BlockSchematic schematic, EntityPlayer bcPlayer) {
if (schematic.blockId != 0) {
return world.setBlock(x, y, z, schematic.blockId, schematic.blockMeta, 3);
}
return false; return false;
} }
@ -180,6 +182,6 @@ public class BlockHandler {
if (!schematic.blockName.equals(block.getUnlocalizedName())) { if (!schematic.blockName.equals(block.getUnlocalizedName())) {
return false; return false;
} }
return schematic.metadata == world.getBlockMetadata(x, y, z); return schematic.blockMeta == world.getBlockMetadata(x, y, z);
} }
} }

View file

@ -1,5 +1,6 @@
package buildcraft.api.builder; package buildcraft.api.builder;
import net.minecraft.block.Block;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
/** /**
@ -9,17 +10,27 @@ import net.minecraft.nbt.NBTTagCompound;
public final class BlockSchematic { public final class BlockSchematic {
public final String blockName; public final String blockName;
public int metadata = 0; public final int blockId;
public int blockMeta = 0;
public NBTTagCompound blockData = null; public NBTTagCompound blockData = null;
public int x, y, z; public int x, y, z;
public BlockSchematic(Block block) {
this(block.getUnlocalizedName(), block.blockID);
}
public BlockSchematic(String blockName) { public BlockSchematic(String blockName) {
this(blockName, 0); // TODO: Add block id from name
}
public BlockSchematic(String blockName, int blockId) {
this.blockName = blockName; this.blockName = blockName;
this.blockId = blockId;
} }
public void writeToNBT(NBTTagCompound nbt) { public void writeToNBT(NBTTagCompound nbt) {
nbt.setString("blockName", blockName); nbt.setString("blockName", blockName);
nbt.setByte("metadata", (byte) metadata); nbt.setByte("blockMeta", (byte) blockMeta);
nbt.setInteger("x", x); nbt.setInteger("x", x);
nbt.setInteger("y", y); nbt.setInteger("y", y);
nbt.setInteger("z", z); nbt.setInteger("z", z);
@ -28,7 +39,7 @@ public final class BlockSchematic {
public static BlockSchematic readFromNBT(NBTTagCompound nbt) { public static BlockSchematic readFromNBT(NBTTagCompound nbt) {
BlockSchematic block = new BlockSchematic(nbt.getString("blockName")); BlockSchematic block = new BlockSchematic(nbt.getString("blockName"));
block.metadata = nbt.getInteger("metadata"); block.blockMeta = nbt.getInteger("blockMeta");
block.x = nbt.getInteger("x"); block.x = nbt.getInteger("x");
block.y = nbt.getInteger("y"); block.y = nbt.getInteger("y");
block.z = nbt.getInteger("z"); block.z = nbt.getInteger("z");

View file

@ -74,8 +74,8 @@ public class Blueprint {
if (block == null) { if (block == null) {
return; return;
} }
BlockSchematic schematic = new BlockSchematic(block.getUnlocalizedName()); BlockSchematic schematic = new BlockSchematic(block);
schematic.metadata = meta; schematic.blockMeta = meta;
setBlock(x, y, z, schematic); setBlock(x, y, z, schematic);
} }
@ -101,7 +101,8 @@ public class Blueprint {
for (int y = 0; y < sizeY; y++) { for (int y = 0; y < sizeY; y++) {
for (int x = 0; x < sizeX; x++) { for (int x = 0; x < sizeX; x++) {
for (int z = 0; z < sizeZ; z++) { for (int z = 0; z < sizeZ; z++) {
list.add(blocks[x][y][z]); if (blocks[x][y][z] != null)
list.add(blocks[x][y][z]);
} }
} }
} }

View file

@ -13,6 +13,7 @@ import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory; import net.minecraft.inventory.IInventory;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
@ -100,7 +101,7 @@ public class BlueprintBuilder {
return handler.canPlaceNow(worldObj, getX(), getY(), getZ(), orientation, schematic); return handler.canPlaceNow(worldObj, getX(), getY(), getZ(), orientation, schematic);
} }
public boolean build() { public boolean build(EntityPlayer bcPlayer) {
// if (blockExists()) { // if (blockExists()) {
// markComplete(); // markComplete();
// return false; // return false;
@ -116,7 +117,7 @@ public class BlueprintBuilder {
return false; return false;
} }
boolean built = handler.readBlockFromSchematic(worldObj, getX(), getY(), getZ(), orientation, schematic); boolean built = handler.readBlockFromSchematic(worldObj, getX(), getY(), getZ(), orientation, schematic, bcPlayer);
if (built) { if (built) {
markComplete(); markComplete();

View file

@ -288,7 +288,7 @@ public class TileBuilder extends TileBuildCraft implements IBuilderInventory, IP
box.createLasers(worldObj, LaserKind.Stripes); box.createLasers(worldObj, LaserKind.Stripes);
builderRobot.scheduleContruction(bluePrintBuilder.getNextBlock(worldObj, this), bluePrintBuilder.getContext()); // builderRobot.scheduleContruction(bluePrintBuilder.getNextBlock(worldObj, this), bluePrintBuilder.getContext());
} }
} }
@ -325,7 +325,7 @@ public class TileBuilder extends TileBuildCraft implements IBuilderInventory, IP
} }
if (bluePrintBuilder != null && builderRobot != null) { if (bluePrintBuilder != null && builderRobot != null) {
builderRobot.markEndOfBlueprint(bluePrintBuilder); // builderRobot.markEndOfBlueprint(bluePrintBuilder);
} }
bluePrintBuilder = currentPathIterator.next(); bluePrintBuilder = currentPathIterator.next();
@ -351,7 +351,7 @@ public class TileBuilder extends TileBuildCraft implements IBuilderInventory, IP
} else { } else {
if (bluePrintBuilder != null && bluePrintBuilder.done) { if (bluePrintBuilder != null && bluePrintBuilder.done) {
if (builderRobot != null) { if (builderRobot != null) {
builderRobot.markEndOfBlueprint(bluePrintBuilder); // builderRobot.markEndOfBlueprint(bluePrintBuilder);
} }
done = true; done = true;

View file

@ -1,12 +1,10 @@
/** /**
* Copyright (c) SpaceToad, 2011-2012 * Copyright (c) SpaceToad, 2011-2012 http://www.mod-buildcraft.com
* http://www.mod-buildcraft.com
* *
* BuildCraft is distributed under the terms of the Minecraft Mod Public * BuildCraft is distributed under the terms of the Minecraft Mod Public License
* License 1.0, or MMPL. Please check the contents of the license located in * 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt * http://www.mod-buildcraft.com/MMPL-1.0.txt
*/ */
package buildcraft.core; package buildcraft.core;
import java.util.ArrayList; import java.util.ArrayList;
@ -17,12 +15,8 @@ import net.minecraft.entity.Entity;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World; import net.minecraft.world.World;
import buildcraft.BuildCraftCore; import buildcraft.BuildCraftCore;
import buildcraft.api.blueprints.BptSlotInfo; import buildcraft.api.builder.BlueprintBuilder.SchematicBuilder;
import buildcraft.api.core.Position; import buildcraft.api.core.Position;
import buildcraft.core.blueprints.BptBuilderBase;
import buildcraft.core.blueprints.BptContext;
import buildcraft.core.blueprints.BptSlot;
import buildcraft.core.blueprints.BptSlot.Mode;
import buildcraft.core.proxy.CoreProxy; import buildcraft.core.proxy.CoreProxy;
import buildcraft.core.utils.BlockUtil; import buildcraft.core.utils.BlockUtil;
@ -35,29 +29,11 @@ public class EntityRobot extends Entity implements IEntityAdditionalSpawnData {
private Box box; private Box box;
private int destX, destY, destZ; private int destX, destY, destZ;
EntityEnergyLaser laser; EntityEnergyLaser laser;
public LinkedList<SchematicBuilder> targets = new LinkedList<SchematicBuilder>();
public LinkedList<Action> targets = new LinkedList<Action>();
public static int MAX_TARGETS = 20; public static int MAX_TARGETS = 20;
public int wait = 0; public int wait = 0;
private class Action {
public Action(BptSlot slot, BptContext context) {
this.slot = slot;
this.context = context;
}
public Action(BptBuilderBase builder) {
this.builder = builder;
}
BptSlot slot;
BptBuilderBase builder;
BptContext context;
}
public EntityRobot(World world) { public EntityRobot(World world) {
super(world); super(world);
} }
@ -129,6 +105,8 @@ public class EntityRobot extends Entity implements IEntityAdditionalSpawnData {
@Override @Override
public void onUpdate() { public void onUpdate() {
if (CoreProxy.proxy.isRenderWorld(worldObj))
return;
move(); move();
build(); build();
@ -199,48 +177,31 @@ public class EntityRobot extends Entity implements IEntityAdditionalSpawnData {
updateWait(); updateWait();
if (targets.size() > 0) { if (wait <= 0 && !targets.isEmpty()) {
Action a = targets.getFirst(); SchematicBuilder target = targets.peek();
if (a.slot != null) { if (target.blockExists()) {
target.markComplete();
BptSlot target = a.slot;
//System.out.printf("RobotChanging %d %d %d %s\n",target.x, target.y, target.z, target.mode);
if (wait <= 0 && BlockUtil.canChangeBlock(worldObj, target.x, target.y, target.z)) {
if (!CoreProxy.proxy.isRenderWorld(worldObj)) {
if (target.mode == Mode.ClearIfInvalid) {
if (!target.isValid(a.context)) {
worldObj.setBlock(target.x, target.y, target.z, 0, 0,3);
}
} else if (target.stackToUse != null) {
worldObj.setBlock(target.x, target.y, target.z, 0);
throw new RuntimeException("NOT IMPLEMENTED");
// target.stackToUse.getItem().onItemUse(target.stackToUse,
// CoreProxy.getBuildCraftPlayer(worldObj), worldObj, target.x, target.y - 1,
// target.z, 1);
} else {
try {
target.buildBlock(a.context);
} catch (Throwable t) {
// Defensive code against errors in implementers
t.printStackTrace();
BuildCraftCore.bcLog.throwing("EntityRobot", "update", t);
}
}
}
targets.pop();
}
} else if (a.builder != null) {
a.builder.postProcessing(worldObj);
targets.pop(); targets.pop();
} else if (BlockUtil.canChangeBlock(worldObj, target.getX(), target.getY(), target.getZ())) {
//System.out.printf("RobotChanging %d %d %d %s\n",target.x, target.y, target.z, target.mode);
if (!worldObj.isAirBlock(target.getX(), target.getY(), target.getZ())) {
BlockUtil.breakBlock(worldObj, target.getX(), target.getY(), target.getZ());
} else {
targets.pop();
try {
target.build(CoreProxy.proxy.getBuildCraftPlayer(worldObj, target.getX(), target.getY() + 2, target.getZ()));
} catch (Throwable t) {
target.markComplete();
targets.pop();
// Defensive code against errors in implementers
t.printStackTrace();
BuildCraftCore.bcLog.throwing("EntityRobot", "update", t);
}
if (!target.isComplete()) {
targets.addLast(target);
}
}
} }
} }
} }
@ -262,12 +223,10 @@ public class EntityRobot extends Entity implements IEntityAdditionalSpawnData {
if (targets.size() > 0) { if (targets.size() > 0) {
Action a = targets.getFirst(); SchematicBuilder target = targets.getFirst();
BptSlotInfo target = a.slot;
if (target != null) { if (target != null) {
laser.setPositions(new Position(posX, posY, posZ), new Position(target.getX() + 0.5, target.getY() + 0.5, target.getZ() + 0.5));
laser.setPositions(new Position(posX, posY, posZ), new Position(target.x + 0.5, target.y + 0.5, target.z + 0.5));
laser.show(); laser.show();
} }
} else { } else {
@ -277,16 +236,14 @@ public class EntityRobot extends Entity implements IEntityAdditionalSpawnData {
laser.pushPower(((float) targets.size()) / ((float) MAX_TARGETS) * 4F); laser.pushPower(((float) targets.size()) / ((float) MAX_TARGETS) * 4F);
} }
public void scheduleContruction(BptSlot slot, BptContext context) { public boolean scheduleContruction(SchematicBuilder schematic) {
if (!readyToBuild()) {
if (slot != null) { return false;
targets.add(new Action(slot, context));
} }
} if (schematic != null && !schematic.blockExists()) {
return targets.add(schematic);
public void markEndOfBlueprint(BptBuilderBase builder) { }
targets.add(new Action(builder)); return false;
} }
public boolean readyToBuild() { public boolean readyToBuild() {
@ -298,19 +255,15 @@ public class EntityRobot extends Entity implements IEntityAdditionalSpawnData {
} }
public void setBox(Box box) { public void setBox(Box box) {
this.box = box; this.box = box;
setDestination((int) box.centerX(), (int) box.centerY(), (int) box.centerZ()); setDestination((int) box.centerX(), (int) box.centerY(), (int) box.centerZ());
} }
@Override @Override
public void setDead() { public void setDead() {
if (laser != null) { if (laser != null) {
laser.setDead(); laser.setDead();
} }
super.setDead(); super.setDead();
} }
} }

View file

@ -24,6 +24,9 @@ import net.minecraftforge.common.ForgeChunkManager.Type;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
import buildcraft.BuildCraftCore; import buildcraft.BuildCraftCore;
import buildcraft.BuildCraftFactory; import buildcraft.BuildCraftFactory;
import buildcraft.api.builder.Blueprint;
import buildcraft.api.builder.BlueprintBuilder;
import buildcraft.api.builder.BlueprintBuilder.SchematicBuilder;
import buildcraft.api.core.IAreaProvider; import buildcraft.api.core.IAreaProvider;
import buildcraft.api.core.LaserKind; import buildcraft.api.core.LaserKind;
import buildcraft.api.gates.IAction; import buildcraft.api.gates.IAction;
@ -36,9 +39,6 @@ import buildcraft.core.EntityRobot;
import buildcraft.core.IBuilderInventory; import buildcraft.core.IBuilderInventory;
import buildcraft.core.IMachine; import buildcraft.core.IMachine;
import buildcraft.core.TileBuildCraft; import buildcraft.core.TileBuildCraft;
import buildcraft.core.blueprints.BptBlueprint;
import buildcraft.core.blueprints.BptBuilderBase;
import buildcraft.core.blueprints.BptBuilderBlueprint;
import buildcraft.core.network.PacketUpdate; import buildcraft.core.network.PacketUpdate;
import buildcraft.core.network.TileNetworkData; import buildcraft.core.network.TileNetworkData;
import buildcraft.core.proxy.CoreProxy; import buildcraft.core.proxy.CoreProxy;
@ -50,6 +50,7 @@ import com.google.common.collect.Sets;
import cpw.mods.fml.common.network.PacketDispatcher; import cpw.mods.fml.common.network.PacketDispatcher;
import cpw.mods.fml.common.network.Player; import cpw.mods.fml.common.network.Player;
import java.util.ListIterator;
public class TileQuarry extends TileBuildCraft implements IMachine, IPowerReceptor, IPipeConnection, IBuilderInventory { public class TileQuarry extends TileBuildCraft implements IMachine, IPowerReceptor, IPipeConnection, IBuilderInventory {
@ -66,7 +67,8 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept
public @TileNetworkData public @TileNetworkData
boolean builderDone = false; boolean builderDone = false;
public EntityRobot builder; public EntityRobot builder;
BptBuilderBase bluePrintBuilder; private BlueprintBuilder blueprintBuilder;
private ListIterator<SchematicBuilder> blueprintIterator;
public EntityMechanicalArm arm; public EntityMechanicalArm arm;
public PowerProvider powerProvider; public PowerProvider powerProvider;
boolean isDigging = false; boolean isDigging = false;
@ -83,13 +85,13 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept
} }
public void createUtilsIfNeeded() { public void createUtilsIfNeeded() {
if (bluePrintBuilder == null) { if (blueprintBuilder == null) {
if (!box.isInitialized()) { if (!box.isInitialized()) {
setBoundaries(loadDefaultBoundaries); setBoundaries(loadDefaultBoundaries);
} }
initializeBluePrintBuilder(); initializeBlueprintBuilder();
} }
if (builderDone) { if (builderDone) {
@ -124,8 +126,8 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept
private void createArm() { private void createArm() {
worldObj.spawnEntityInWorld(new EntityMechanicalArm(worldObj, box.xMin + Utils.pipeMaxPos, yCoord + bluePrintBuilder.bluePrint.sizeY - 1 worldObj.spawnEntityInWorld(new EntityMechanicalArm(worldObj, box.xMin + Utils.pipeMaxPos, yCoord + blueprintBuilder.blueprint.sizeY - 1
+ Utils.pipeMinPos, box.zMin + Utils.pipeMaxPos, bluePrintBuilder.bluePrint.sizeX - 2 + Utils.pipeMinPos * 2, bluePrintBuilder.bluePrint.sizeZ + Utils.pipeMinPos, box.zMin + Utils.pipeMaxPos, blueprintBuilder.blueprint.sizeX - 2 + Utils.pipeMinPos * 2, blueprintBuilder.blueprint.sizeZ
- 2 + Utils.pipeMinPos * 2, this)); - 2 + Utils.pipeMinPos * 2, this));
} }
@ -136,15 +138,13 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept
@Override @Override
public void updateEntity() { public void updateEntity() {
super.updateEntity();
if (!isAlive && CoreProxy.proxy.isSimulating(worldObj)) { if (!isAlive && CoreProxy.proxy.isSimulating(worldObj)) {
super.updateEntity();
return; return;
} }
if (!CoreProxy.proxy.isSimulating(worldObj) && isAlive) { if (!CoreProxy.proxy.isSimulating(worldObj) && isAlive) {
super.updateEntity();
return; return;
} }
super.updateEntity();
if (inProcess) { if (inProcess) {
float energyToUse = 2 + powerProvider.getEnergyStored() / 500; float energyToUse = 2 + powerProvider.getEnergyStored() / 500;
@ -163,23 +163,16 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept
createUtilsIfNeeded(); createUtilsIfNeeded();
if (bluePrintBuilder != null) { if (blueprintBuilder != null) {
builderDone = bluePrintBuilder.done; builderDone = !blueprintIterator.hasNext();
if (!builderDone) { if (!builderDone) {
buildFrame(); buildFrame();
return; return;
} else if (builder != null && builder.done()) {
} else { killBuilder();
if (builder != null && builder.done()) {
box.deleteLasers();
builder.setDead();
builder = null;
}
} }
} }
if (builder == null) { if (builder == null) {
@ -188,6 +181,12 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept
} }
private void killBuilder() {
box.deleteLasers();
builder.setDead();
builder = null;
}
@Override @Override
public void doWork(PowerProvider workProvider) { public void doWork(PowerProvider workProvider) {
} }
@ -195,7 +194,11 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept
protected void buildFrame() { protected void buildFrame() {
powerProvider.configure(50, 100, 25, MAX_ENERGY); powerProvider.configure(50, 100, 25, MAX_ENERGY);
if (powerProvider.useEnergy(25, 25, true) != 25)
if (!blueprintIterator.hasNext())
return;
if (powerProvider.useEnergy(25, 25, false) != 25)
return; return;
if (builder == null) { if (builder == null) {
@ -204,7 +207,12 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept
} }
if (builder.readyToBuild()) { if (builder.readyToBuild()) {
builder.scheduleContruction(bluePrintBuilder.getNextBlock(worldObj, this), bluePrintBuilder.getContext()); while (blueprintIterator.hasNext()) {
if (builder.scheduleContruction(blueprintIterator.next())) {
powerProvider.useEnergy(0, 25, true);
break;
}
}
} }
} }
@ -275,17 +283,17 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept
private void createColumnVisitList() { private void createColumnVisitList() {
visitList.clear(); visitList.clear();
Integer[][] columnHeights = new Integer[bluePrintBuilder.bluePrint.sizeX - 2][bluePrintBuilder.bluePrint.sizeZ - 2]; Integer[][] columnHeights = new Integer[blueprintBuilder.blueprint.sizeX - 2][blueprintBuilder.blueprint.sizeZ - 2];
boolean[][] blockedColumns = new boolean[bluePrintBuilder.bluePrint.sizeX - 2][bluePrintBuilder.bluePrint.sizeZ - 2]; boolean[][] blockedColumns = new boolean[blueprintBuilder.blueprint.sizeX - 2][blueprintBuilder.blueprint.sizeZ - 2];
for (int searchY = yCoord + 3; searchY >= 0; --searchY) { for (int searchY = yCoord + 3; searchY >= 0; --searchY) {
int startX, endX, incX; int startX, endX, incX;
if (searchY % 2 == 0) { if (searchY % 2 == 0) {
startX = 0; startX = 0;
endX = bluePrintBuilder.bluePrint.sizeX - 2; endX = blueprintBuilder.blueprint.sizeX - 2;
incX = 1; incX = 1;
} else { } else {
startX = bluePrintBuilder.bluePrint.sizeX - 3; startX = blueprintBuilder.blueprint.sizeX - 3;
endX = -1; endX = -1;
incX = -1; incX = -1;
} }
@ -295,10 +303,10 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept
if (searchX % 2 == searchY % 2) { if (searchX % 2 == searchY % 2) {
startZ = 0; startZ = 0;
endZ = bluePrintBuilder.bluePrint.sizeZ - 2; endZ = blueprintBuilder.blueprint.sizeZ - 2;
incZ = 1; incZ = 1;
} else { } else {
startZ = bluePrintBuilder.bluePrint.sizeZ - 3; startZ = blueprintBuilder.blueprint.sizeZ - 3;
endZ = -1; endZ = -1;
incZ = -1; incZ = -1;
} }
@ -322,7 +330,7 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept
visitList.add(new int[]{bx, by, bz}); visitList.add(new int[]{bx, by, bz});
} }
// Stop at two planes - generally any obstructions will have been found and will force a recompute prior to this // Stop at two planes - generally any obstructions will have been found and will force a recompute prior to this
if (visitList.size() > bluePrintBuilder.bluePrint.sizeZ * bluePrintBuilder.bluePrint.sizeX * 2) if (visitList.size() > blueprintBuilder.blueprint.sizeZ * blueprintBuilder.blueprint.sizeX * 2)
return; return;
} }
} }
@ -593,38 +601,31 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept
forceChunkLoading(chunkTicket); forceChunkLoading(chunkTicket);
} }
private void initializeBluePrintBuilder() { private void initializeBlueprintBuilder() {
BptBlueprint bluePrint = new BptBlueprint(box.sizeX(), box.sizeY(), box.sizeZ()); Blueprint blueprint = new Blueprint(box.sizeX(), box.sizeY(), box.sizeZ());
for (int i = 0; i < bluePrint.sizeX; ++i) {
for (int j = 0; j < bluePrint.sizeY; ++j) {
for (int k = 0; k < bluePrint.sizeZ; ++k) {
bluePrint.setBlockId(i, j, k, 0);
}
}
}
for (int it = 0; it < 2; it++) { for (int it = 0; it < 2; it++) {
for (int i = 0; i < bluePrint.sizeX; ++i) { for (int i = 0; i < blueprint.sizeX; ++i) {
bluePrint.setBlockId(i, it * (box.sizeY() - 1), 0, BuildCraftFactory.frameBlock.blockID); blueprint.setBlock(i, it * (box.sizeY() - 1), 0, BuildCraftFactory.frameBlock.blockID, 0);
bluePrint.setBlockId(i, it * (box.sizeY() - 1), bluePrint.sizeZ - 1, BuildCraftFactory.frameBlock.blockID); blueprint.setBlock(i, it * (box.sizeY() - 1), blueprint.sizeZ - 1, BuildCraftFactory.frameBlock.blockID, 0);
} }
for (int k = 0; k < bluePrint.sizeZ; ++k) { for (int k = 0; k < blueprint.sizeZ; ++k) {
bluePrint.setBlockId(0, it * (box.sizeY() - 1), k, BuildCraftFactory.frameBlock.blockID); blueprint.setBlock(0, it * (box.sizeY() - 1), k, BuildCraftFactory.frameBlock.blockID, 0);
bluePrint.setBlockId(bluePrint.sizeX - 1, it * (box.sizeY() - 1), k, BuildCraftFactory.frameBlock.blockID); blueprint.setBlock(blueprint.sizeX - 1, it * (box.sizeY() - 1), k, BuildCraftFactory.frameBlock.blockID, 0);
} }
} }
for (int h = 1; h < box.sizeY(); ++h) { for (int h = 1; h < box.sizeY(); ++h) {
bluePrint.setBlockId(0, h, 0, BuildCraftFactory.frameBlock.blockID); blueprint.setBlock(0, h, 0, BuildCraftFactory.frameBlock.blockID, 0);
bluePrint.setBlockId(0, h, bluePrint.sizeZ - 1, BuildCraftFactory.frameBlock.blockID); blueprint.setBlock(0, h, blueprint.sizeZ - 1, BuildCraftFactory.frameBlock.blockID, 0);
bluePrint.setBlockId(bluePrint.sizeX - 1, h, 0, BuildCraftFactory.frameBlock.blockID); blueprint.setBlock(blueprint.sizeX - 1, h, 0, BuildCraftFactory.frameBlock.blockID, 0);
bluePrint.setBlockId(bluePrint.sizeX - 1, h, bluePrint.sizeZ - 1, BuildCraftFactory.frameBlock.blockID); blueprint.setBlock(blueprint.sizeX - 1, h, blueprint.sizeZ - 1, BuildCraftFactory.frameBlock.blockID, 0);
} }
bluePrintBuilder = new BptBuilderBlueprint(bluePrint, worldObj, box.xMin, yCoord, box.zMin); blueprintBuilder = new BlueprintBuilder(blueprint, worldObj, box.xMin, yCoord, box.zMin, ForgeDirection.NORTH, null);
blueprintIterator = blueprintBuilder.getBuilders().listIterator();
} }
@Override @Override
@ -659,11 +660,10 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept
public void reinitalize() { public void reinitalize() {
builderDone = false; builderDone = false;
initializeBluePrintBuilder(); initializeBlueprintBuilder();
isDigging = true; isDigging = true;
} }
@Override @Override
public PowerProvider getPowerProvider(ForgeDirection side) { public PowerProvider getPowerProvider(ForgeDirection side) {
return powerProvider; return powerProvider;