diff --git a/common/net/minecraft/src/BuildCraftCore.java b/common/net/minecraft/src/BuildCraftCore.java index b2633c5c..1ac759de 100644 --- a/common/net/minecraft/src/BuildCraftCore.java +++ b/common/net/minecraft/src/BuildCraftCore.java @@ -125,15 +125,14 @@ public class BuildCraftCore { public static BptItem[] itemBptProps = new BptItem[Item.itemsList.length]; public static void load() { - // Register connection handler + MinecraftForge.registerConnectionHandler(new ConnectionHandler()); - MinecraftForge.registerEntity(EntityRobot.class, mod_BuildCraftCore.instance, EntityIds.ROBOT, 50, 10, true); - //MinecraftForge.registerEntity(EntityBlock.class, mod_BuildCraftCore.instance, EntityIds.BLOCK, 50, 10, true); - MinecraftForge.registerEntity(EntityLaser.class, mod_BuildCraftCore.instance, EntityIds.LASER, 50, 10, true); + //MinecraftForge.registerEntity(EntityBlock.class, mod_BuildCraftCore.instance, EntityIds.BLOCK, 64, 10, true); + MinecraftForge.registerEntity(EntityRobot.class, mod_BuildCraftCore.instance, EntityIds.ROBOT, 64, 3, true); + MinecraftForge.registerEntity(EntityLaser.class, mod_BuildCraftCore.instance, EntityIds.LASER, 64, 10, false); } - @SuppressWarnings({ "all" }) public static void initialize () { if (initialized) return; diff --git a/common/net/minecraft/src/buildcraft/api/IBox.java b/common/net/minecraft/src/buildcraft/api/IBox.java index ded73a66..289d25d7 100644 --- a/common/net/minecraft/src/buildcraft/api/IBox.java +++ b/common/net/minecraft/src/buildcraft/api/IBox.java @@ -10,11 +10,15 @@ package net.minecraft.src.buildcraft.api; import net.minecraft.src.World; -import net.minecraft.src.buildcraft.api.LaserKind; -import net.minecraft.src.buildcraft.api.Position; public interface IBox { - + + public void expand(int amount); + + public void contract(int amount); + + public boolean contains(int x, int y, int z); + public Position pMin (); public Position pMax (); diff --git a/common/net/minecraft/src/buildcraft/builders/TileBuilder.java b/common/net/minecraft/src/buildcraft/builders/TileBuilder.java index fa9acab3..f8083664 100644 --- a/common/net/minecraft/src/buildcraft/builders/TileBuilder.java +++ b/common/net/minecraft/src/buildcraft/builders/TileBuilder.java @@ -27,27 +27,26 @@ import net.minecraft.src.buildcraft.api.Orientations; import net.minecraft.src.buildcraft.api.PowerFramework; import net.minecraft.src.buildcraft.api.PowerProvider; import net.minecraft.src.buildcraft.api.TileNetworkData; +import net.minecraft.src.buildcraft.core.BlockIndex; import net.minecraft.src.buildcraft.core.Box; +import net.minecraft.src.buildcraft.core.BptBase; import net.minecraft.src.buildcraft.core.BptBlueprint; +import net.minecraft.src.buildcraft.core.BptBuilderBase; import net.minecraft.src.buildcraft.core.BptBuilderBlueprint; import net.minecraft.src.buildcraft.core.BptBuilderTemplate; -import net.minecraft.src.buildcraft.core.BlockIndex; -import net.minecraft.src.buildcraft.core.BptBase; -import net.minecraft.src.buildcraft.core.BptBuilderBase; import net.minecraft.src.buildcraft.core.BptContext; -import net.minecraft.src.buildcraft.core.EntityRobot; import net.minecraft.src.buildcraft.core.EntityLaser; +import net.minecraft.src.buildcraft.core.EntityRobot; import net.minecraft.src.buildcraft.core.IBuilderInventory; import net.minecraft.src.buildcraft.core.IMachine; import net.minecraft.src.buildcraft.core.SurroundingInventory; import net.minecraft.src.buildcraft.core.TileBuildCraft; import net.minecraft.src.buildcraft.core.Utils; -import net.minecraft.src.buildcraft.core.network.PacketTileUpdate; import net.minecraft.src.buildcraft.core.network.PacketUpdate; public class TileBuilder extends TileBuildCraft implements IBuilderInventory, IPowerReceptor, IMachine { - private ItemStack items [] = new ItemStack [28]; + private final ItemStack items [] = new ItemStack [28]; private BptBuilderBase bluePrintBuilder; @@ -251,7 +250,7 @@ public class TileBuilder extends TileBuildCraft implements IBuilderInventory, IP return null; } - bpt = (BptBase) bpt.clone (); + bpt = bpt.clone (); BptContext context = new BptContext(worldObj, null, bpt.getBoxForPos (x, y, z)); @@ -493,7 +492,7 @@ public class TileBuilder extends TileBuildCraft implements IBuilderInventory, IP if (box.isInitialized()) { NBTTagCompound boxStore = new NBTTagCompound(); - ((Box)box).writeToNBT(boxStore); + box.writeToNBT(boxStore); nbttagcompound.setTag("box", boxStore); } @@ -587,7 +586,7 @@ public class TileBuilder extends TileBuildCraft implements IBuilderInventory, IP super.updateEntity(); if (builderRobot != null) { - builderRobot.update(); + //builderRobot.update(); } if ((bluePrintBuilder == null || bluePrintBuilder.done) diff --git a/common/net/minecraft/src/buildcraft/core/BlockIndex.java b/common/net/minecraft/src/buildcraft/core/BlockIndex.java index 0e878118..19d09c72 100644 --- a/common/net/minecraft/src/buildcraft/core/BlockIndex.java +++ b/common/net/minecraft/src/buildcraft/core/BlockIndex.java @@ -10,12 +10,14 @@ package net.minecraft.src.buildcraft.core; import net.minecraft.src.NBTTagCompound; +import net.minecraft.src.World; /** * This class is a comparable container for block positions. * TODO: should this be merged with position? */ public class BlockIndex implements Comparable { + public int i; public int j; public int k; @@ -24,12 +26,14 @@ public class BlockIndex implements Comparable { * Creates an index for a block located on i, j. k */ public BlockIndex (int i, int j, int k) { + this.i = i; this.j = j; this.k = k; } public BlockIndex (NBTTagCompound c) { + this.i = c.getInteger("i"); this.j = c.getInteger("j"); this.k = c.getInteger("k"); @@ -40,6 +44,7 @@ public class BlockIndex implements Comparable { */ @Override public int compareTo(BlockIndex o) { + if (o.i < i) return 1; else if (o.i > i) @@ -57,10 +62,15 @@ public class BlockIndex implements Comparable { } public void writeTo (NBTTagCompound c) { + c.setInteger("i", i); c.setInteger("j", j); c.setInteger("k", k); } + + public int getBlockId(World world) { + return world.getBlockId(i, j, k); + } @Override public String toString () { diff --git a/common/net/minecraft/src/buildcraft/core/Box.java b/common/net/minecraft/src/buildcraft/core/Box.java index 30ff3c8d..08dc5a57 100644 --- a/common/net/minecraft/src/buildcraft/core/Box.java +++ b/common/net/minecraft/src/buildcraft/core/Box.java @@ -9,6 +9,9 @@ package net.minecraft.src.buildcraft.core; +import java.util.ArrayList; +import java.util.List; + import net.minecraft.src.NBTTagCompound; import net.minecraft.src.World; import net.minecraft.src.buildcraft.api.APIProxy; @@ -20,55 +23,19 @@ import net.minecraft.src.buildcraft.api.TileNetworkData; public class Box implements IBox { - public @TileNetworkData int xMin, yMin, zMin, xMax, yMax, zMax; + public @TileNetworkData + int xMin, yMin, zMin, xMax, yMax, zMax; + private boolean initialized; - private EntityBlock lasers []; - - public void initialize (Box box) { - this.xMin = box.xMin; - this.yMin = box.yMin; - this.zMin = box.zMin; - this.xMax = box.xMax; - this.yMax = box.yMax; - this.zMax = box.zMax; - } - - public void initialize (int xMin, int yMin, int zMin, int xMax, int yMax, int zMax) { - this.xMin = xMin; - this.yMin = yMin; - this.zMin = zMin; - this.xMax = xMax; - this.yMax = yMax; - this.zMax = zMax; - } - - public void initialize (IAreaProvider area) { - xMin = area.xMin(); - yMin = area.yMin(); - zMin = area.zMin(); - xMax = area.xMax(); - yMax = area.yMax(); - zMax = area.zMax(); - } - - public void initialize (NBTTagCompound nbttagcompound) { - xMin = nbttagcompound.getInteger("xMin"); - yMin = nbttagcompound.getInteger("yMin"); - zMin = nbttagcompound.getInteger("zMin"); - xMax = nbttagcompound.getInteger("xMax"); - yMax = nbttagcompound.getInteger("yMax"); - zMax = nbttagcompound.getInteger("zMax"); - } + private EntityBlock lasers[]; public Box() { - reset (); + reset(); } - public boolean isInitialized () { - return xMin != Integer.MAX_VALUE; - } + public void reset() { - public void reset () { + initialized = false; xMin = Integer.MAX_VALUE; yMin = Integer.MAX_VALUE; zMin = Integer.MAX_VALUE; @@ -77,66 +44,130 @@ public class Box implements IBox { zMax = Integer.MAX_VALUE; } - public static int packetSize () { - return 6; + public boolean isInitialized() { + return initialized; } - @Override - public Position pMin () { - return new Position (xMin, yMin, zMin); + public void initialize(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax) { + + this.xMin = xMin; + this.yMin = yMin; + this.zMin = zMin; + this.xMax = xMax; + this.yMax = yMax; + this.zMax = zMax; + initialized = true; } - @Override - public Position pMax () { - return new Position (xMax, yMax, zMax); + public void initialize(Box box) { + + initialize(box.xMin, box.yMin, box.zMin, box.xMax, box.yMax, box.zMax); } - @Override - public void createLasers (World world, LaserKind kind) { - if (lasers == null) - lasers = Utils.createLaserBox(world, xMin, yMin, zMin, xMax, yMax, - zMax, kind); + public void initialize(IAreaProvider a) { + + initialize(a.xMin(), a.yMin(), a.zMin(), a.xMax(), a.yMax(), a.zMax()); } - @Override - public void deleteLasers () { - if (lasers != null) { - for (EntityBlock b : lasers) - APIProxy.removeEntity(b); + public void initialize(NBTTagCompound nbttagcompound) { - lasers = null; + initialize( + nbttagcompound.getInteger("xMin"), + nbttagcompound.getInteger("yMin"), + nbttagcompound.getInteger("zMin"), + nbttagcompound.getInteger("xMax"), + nbttagcompound.getInteger("yMax"), + nbttagcompound.getInteger("zMax")); + } + + public void initialize(int centerX, int centerY, int centerZ, int size) { + + initialize( + centerX - size, + centerY - size, + centerZ - size, + centerX + size, + centerY + size, + centerZ + size); + + } + + public List getBlocksInArea() { + + List blocks = new ArrayList(); + + for (int x = xMin; x <= xMax; x++) { + for (int y = yMin; y <= yMax; y++) { + for (int z = zMin; z <= zMax; z++) { + blocks.add(new BlockIndex(x, y, z)); + } + } + } + + return blocks; + } + + @Override + public void expand(int amount) { + + xMin += amount; + yMin += amount; + zMin += amount; + xMax += amount; + yMax += amount; + zMax += amount; } - public void writeToNBT(NBTTagCompound nbttagcompound) { - nbttagcompound.setInteger("xMin", xMin); - nbttagcompound.setInteger("yMin", yMin); - nbttagcompound.setInteger("zMin", zMin); - - nbttagcompound.setInteger("xMax", xMax); - nbttagcompound.setInteger("yMax", yMax); - nbttagcompound.setInteger("zMax", zMax); - + @Override + public void contract(int amount) { + expand(-amount); } - public int sizeX () { + + @Override + public boolean contains(int x, int y, int z) { + + if (x >= xMin && x <= xMax && + y >= yMin && y <= yMax && + z >= zMin && z <= zMax) { + + return true; + } + + return false; + } + + public boolean contains(Position p) { + return contains((int)p.x, (int)p.y, (int)p.z); + } + + public boolean contains(BlockIndex i) { + return contains(i.i, i.j, i.k); + } + + @Override + public Position pMin() { + return new Position(xMin, yMin, zMin); + } + + @Override + public Position pMax() { + return new Position(xMax, yMax, zMax); + } + + public int sizeX() { return xMax - xMin + 1; } - public int sizeY () { + public int sizeY() { return yMax - yMin + 1; } - public int sizeZ () { + public int sizeZ() { return zMax - zMin + 1; } - - @Override - public String toString () { - return "{" + xMin + ", " + xMax + "}, {" + yMin + ", " + yMax + "}, {" - + zMin + ", " + zMax + "}"; - } - + public double centerX() { return xMin + sizeX() / 2.0; } @@ -148,9 +179,10 @@ public class Box implements IBox { public double centerZ() { return zMin + sizeZ() / 2.0; } + + public Box rotateLeft() { - public Box rotateLeft () { - Box nBox = new Box (); + Box nBox = new Box(); nBox.xMin = (sizeZ() - 1) - zMin; nBox.yMin = yMin; nBox.zMin = xMin; @@ -159,12 +191,13 @@ public class Box implements IBox { nBox.yMax = yMax; nBox.zMax = xMax; - nBox.reorder (); + nBox.reorder(); return nBox; } - public void reorder () { + public void reorder() { + int tmp; if (xMin > xMax) { @@ -185,4 +218,39 @@ public class Box implements IBox { zMax = tmp; } } + + @Override + public void createLasers(World world, LaserKind kind) { + + if (lasers == null) + lasers = Utils.createLaserBox(world, xMin, yMin, zMin, xMax, yMax, zMax, kind); + } + + @Override + public void deleteLasers() { + + if (lasers != null) { + for (EntityBlock b : lasers) + APIProxy.removeEntity(b); + + lasers = null; + } + } + + public void writeToNBT(NBTTagCompound nbttagcompound) { + + nbttagcompound.setInteger("xMin", xMin); + nbttagcompound.setInteger("yMin", yMin); + nbttagcompound.setInteger("zMin", zMin); + + nbttagcompound.setInteger("xMax", xMax); + nbttagcompound.setInteger("yMax", yMax); + nbttagcompound.setInteger("zMax", zMax); + } + + @Override + public String toString() { + return "{" + xMin + ", " + xMax + "}, {" + yMin + ", " + yMax + "}, {" + zMin + ", " + zMax + "}"; + } + } diff --git a/common/net/minecraft/src/buildcraft/core/EntityLaser.java b/common/net/minecraft/src/buildcraft/core/EntityLaser.java index af97a5f3..cb385275 100644 --- a/common/net/minecraft/src/buildcraft/core/EntityLaser.java +++ b/common/net/minecraft/src/buildcraft/core/EntityLaser.java @@ -21,17 +21,6 @@ public class EntityLaser extends Entity { public String texture; - /** - * Constructor for Forge netcode. - * @param world - * @param xPos - * @param yPos - * @param zPos - */ - public EntityLaser(World world, double xPos, double yPos, double zPos) { - super(world); - setPosition(xPos, yPos, zPos); - } public EntityLaser(World world) { super(world); @@ -62,6 +51,7 @@ public class EntityLaser extends Entity { @Override public void setPosition(double d, double d1, double d2) { + posX = d; posY = d1; posZ = d2; @@ -90,6 +80,7 @@ public class EntityLaser extends Entity { double angleZ = 0; public void updateGraphicData () { + double dx = x1 - x2; double dy = y1 - y2; double dz = z1 - z2; @@ -105,22 +96,13 @@ public class EntityLaser extends Entity { @Override - protected void entityInit() { - // TODO Auto-generated method stub - - } + protected void entityInit() {} @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - // TODO Auto-generated method stub - - } + protected void readEntityFromNBT(NBTTagCompound nbttagcompound) {} @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - // TODO Auto-generated method stub - - } + protected void writeEntityToNBT(NBTTagCompound nbttagcompound) {} public String getTexture () { return texture; diff --git a/common/net/minecraft/src/buildcraft/core/EntityRobot.java b/common/net/minecraft/src/buildcraft/core/EntityRobot.java index 2780b81a..661948e1 100644 --- a/common/net/minecraft/src/buildcraft/core/EntityRobot.java +++ b/common/net/minecraft/src/buildcraft/core/EntityRobot.java @@ -9,28 +9,36 @@ package net.minecraft.src.buildcraft.core; +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.ArrayList; import java.util.LinkedList; +import java.util.List; import net.minecraft.src.Entity; import net.minecraft.src.ModLoader; import net.minecraft.src.NBTTagCompound; import net.minecraft.src.World; +import net.minecraft.src.buildcraft.api.APIProxy; import net.minecraft.src.buildcraft.api.BptSlotInfo; import net.minecraft.src.buildcraft.api.BuildCraftAPI; import net.minecraft.src.buildcraft.core.BptSlot.Mode; +import net.minecraft.src.forge.ISpawnHandler; -public class EntityRobot extends Entity { +public class EntityRobot extends Entity implements ISpawnHandler { - Box box; - - int destX, destY, destZ; - double vX, vY, vZ; + private Box box; + private int destX, destY, destZ; EntityEnergyLaser laser; + public LinkedList targets = new LinkedList(); + public static int MAX_TARGETS = 20; public int wait = 0; - + private class Action { + public Action (BptSlot slot, BptContext context) { this.slot = slot; this.context = context; @@ -45,88 +53,181 @@ public class EntityRobot extends Entity { BptContext context; } - public LinkedList targets = new LinkedList (); - - public static int MAX_SIZE = 20; - public EntityRobot(World world) { super(world); } public EntityRobot(World world, Box box) { + super(world); - + this.box = box; - + init(); + } + + protected void init() { + destX = (int) box.centerX(); destY = (int) box.centerY(); destZ = (int) box.centerZ(); - vX = 0; - vY = 0; - vZ = 0; + motionX = 0; + motionY = 0; + motionZ = 0; - setPosition(destX + 0.5, destY + 0.5, destZ + 0.5); + setPosition(destX, destY, destZ); laser = new EntityEnergyLaser(worldObj); laser.hidden = true; laser.setPositions(posX, posY, posZ, posX, posY, posZ); - world.spawnEntityInWorld(laser); + worldObj.spawnEntityInWorld(laser); + } + + @Override + public void writeSpawnData(DataOutputStream data) throws IOException { + + data.writeInt(box.xMin); + data.writeInt(box.yMin); + data.writeInt(box.zMin); + data.writeInt(box.xMax); + data.writeInt(box.yMax); + data.writeInt(box.zMax); } @Override - protected void entityInit() { - // TODO Auto-generated method stub - + public void readSpawnData(DataInputStream data) throws IOException { + + box = new Box(); + box.xMin = data.readInt(); + box.yMin = data.readInt(); + box.zMin = data.readInt(); + box.xMax = data.readInt(); + box.yMax = data.readInt(); + box.zMax = data.readInt(); + + init(); } @Override - protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - // TODO Auto-generated method stub - - } + protected void entityInit() {} @Override - protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { - // TODO Auto-generated method stub + protected void readEntityFromNBT(NBTTagCompound nbttagcompound) {} + @Override + protected void writeEntityToNBT(NBTTagCompound nbttagcompound) {} + + @Override + public void onUpdate() { + + move(); + } + + protected void move() { + + if (!reachedDesination()) { + + setPosition(posX + motionX, + posY + motionY, + posZ + motionZ); + + return; + } + + if (APIProxy.isClient(worldObj)) + return; + + BlockIndex newDesination = getNewDesination(); + if (newDesination != null) { + + setDestination(newDesination.i, newDesination.j, newDesination.k); + } + + } + + protected BlockIndex getNewDesination() { + + Box movementBoundary = new Box(); + movementBoundary.initialize(box); + movementBoundary.expand(1); + + Box moveArea = new Box(); + moveArea.initialize(destX, destY, destZ, 1); + + List potentialDestinations = new ArrayList(); + for (BlockIndex blockIndex : moveArea.getBlocksInArea()) { + + if (BuildCraftAPI.softBlock(blockIndex.getBlockId(worldObj)) && movementBoundary.contains(blockIndex)) { + potentialDestinations.add(blockIndex); + } + } + + if (!potentialDestinations.isEmpty()) { + + int i = worldObj.rand.nextInt(potentialDestinations.size()); + return potentialDestinations.get(i); + } + + return null; + } + + protected void setDestination (int x, int y, int z) { + + destX = x; + destY = y; + destZ = z; + + motionX = (destX - posX) / 75 * 1; + motionY = (destY - posY) / 75 * 1; + motionZ = (destZ - posZ) / 75 * 1; + } + + protected boolean reachedDesination() { + + if (getDistance(destX, destY, destZ) <= .2) + return true; + + return false; } - public void update () { - moveRobot(); + public void updateOLD () { + + move(); updateWait(); if (targets.size() > 0) { + Action a = targets.getFirst(); - if (a.slot != null) { + BptSlot target = a.slot; - if (wait <= 0) { + if (target.mode == Mode.ClearIfInvalid) { + if (!target.isValid(a.context)) - worldObj.setBlockAndMetadataWithNotify(target.x, - target.y, target.z, 0, 0); + worldObj.setBlockAndMetadataWithNotify(target.x, target.y, target.z, 0, 0); + } else if (target.stackToUse != null) { - worldObj.setBlockWithNotify(target.x, target.y, - target.z, 0); - target.stackToUse.getItem().onItemUse( - target.stackToUse, - BuildCraftAPI.getBuildCraftPlayer(worldObj), - worldObj, target.x, target.y - 1, target.z, - 1); - } else + + worldObj.setBlockWithNotify(target.x, target.y, target.z, 0); + target.stackToUse.getItem().onItemUse(target.stackToUse, + BuildCraftAPI.getBuildCraftPlayer(worldObj), worldObj, target.x, target.y - 1, + target.z, 1); + } else { + try { - target.buildBlock (a.context); + target.buildBlock(a.context); } catch (Throwable t) { // Defensive code against errors in implementers t.printStackTrace(); - ModLoader.getLogger().throwing("EntityRobot", - "update", t); + ModLoader.getLogger().throwing("EntityRobot", "update", t); } + } targets.pop(); } + } else if (a.builder != null) { a.builder.postProcessing(worldObj); targets.pop(); @@ -137,38 +238,17 @@ public class EntityRobot extends Entity { updateLaser(); } - public void moveRobot () { - if (Math.abs(posX - destX - 0.5) < 0.1 && Math.abs(posY - destY - 0.5) < 0.1 && Math.abs(posZ - destZ - 0.5) < 0.1) { - LinkedList potentialDirs = new LinkedList (); - - for (int x = destX - 1; x <= destX + 1; ++x) - for (int y = destY - 1; y <= destY + 1; ++y) - for (int z = destZ - 1; z <= destZ + 1; ++z) - if (x >= box.xMin - 1 && x <= box.xMax + 1 - && y >= box.yMin - 1 && y <= box.yMax + 1 - && z >= box.zMin - 1 && z <= box.zMax + 1 - && BuildCraftAPI.softBlock(worldObj.getBlockId(x, y, z))) - potentialDirs.add(new BlockIndex(x, y, z)); - - if (potentialDirs.size() > 0) { - BlockIndex b = potentialDirs.get(worldObj.rand.nextInt(potentialDirs.size())); - setDestination (b.i, b.j, b.k); - } - } else - setPosition(posX + vX * (laser.getPowerAverage() + 1), posY + vY - * (laser.getPowerAverage() + 1), - posZ + vZ * (laser.getPowerAverage() + 1)); - } - public void updateWait () { + if (targets.size() > 0) if (wait == 0) - wait = MAX_SIZE - targets.size() + 2; + wait = MAX_TARGETS - targets.size() + 2; else wait--; } private void updateLaser () { + BptSlotInfo target = null; if (targets.size() > 0) { @@ -181,10 +261,11 @@ public class EntityRobot extends Entity { else laser.hidden = true; - laser.pushPower (((float) targets.size ()) / ((float) MAX_SIZE) * 4F); + laser.pushPower (((float) targets.size ()) / ((float) MAX_TARGETS) * 4F); } public void scheduleContruction (BptSlot slot, BptContext context) { + if (slot != null) { targets.add(new Action (slot, context)); laser.hidden = false; @@ -196,40 +277,26 @@ public class EntityRobot extends Entity { } public boolean readyToBuild () { - return targets.size() < MAX_SIZE; + return targets.size() < MAX_TARGETS; } public boolean done () { - return targets.size() == 0; + return targets.isEmpty(); } public void setBox(Box box) { + this.box = box; - setDestination((int) box.centerX(), (int) box.centerY(), (int) box.centerZ()); } - public void setDestination (int x, int y, int z) { - destX = x; - destY = y; - destZ = z; - - double dX = destX - posX + 0.5; - double dY = destY - posY + 0.5; - double dZ = destZ - posZ + 0.5; - - double size = Math.sqrt(dX * dX + dY * dY + dZ * dZ); - - vX = dX / size / 50.0; - vY = dY / size / 50.0; - vZ = dZ / size / 50.0; - } - @Override public void setDead() { + if (laser != null) laser.setDead(); super.setDead(); } + } diff --git a/common/net/minecraft/src/buildcraft/factory/TileQuarry.java b/common/net/minecraft/src/buildcraft/factory/TileQuarry.java index fe0a7811..07e0d3c2 100644 --- a/common/net/minecraft/src/buildcraft/factory/TileQuarry.java +++ b/common/net/minecraft/src/buildcraft/factory/TileQuarry.java @@ -126,8 +126,7 @@ public class TileQuarry extends TileMachine implements IArmListener, arm.speed = 0; float energyToUse = 2 + powerProvider.energyStored / 1000; - float energy = powerProvider - .useEnergy(energyToUse, energyToUse, true); + float energy = powerProvider.useEnergy(energyToUse, energyToUse, true); if (energy > 0) { arm.doMove(0.015 + energy / 200F); @@ -143,7 +142,7 @@ public class TileQuarry extends TileMachine implements IArmListener, } if (builder != null) { - builder.update(); + //builder.update(); } } @@ -167,6 +166,7 @@ public class TileQuarry extends TileMachine implements IArmListener, createUtilsIfNeeded(); if (bluePrintBuilder != null) { + if (!builderDone) { // configuration for building phase powerProvider.configure(20, 25, 25, 25, MAX_ENERGY); @@ -188,7 +188,9 @@ public class TileQuarry extends TileMachine implements IArmListener, } return; + } else { + if (builder != null && builder.done ()) { box.deleteLasers(); builder.setDead(); @@ -535,6 +537,7 @@ public class TileQuarry extends TileMachine implements IArmListener, } private void initializeBluePrintBuilder () { + BptBlueprint bluePrint = new BptBlueprint(box.sizeX(), box.sizeY(), box.sizeZ()); for (int i = 0; i < bluePrint.sizeX; ++i) {