protected void buildFrame() { powerProvider.configure(20, 25, 25, 25, MAX_ENERGY); if (powerProvider.useEnergy(25, 25, true) != 25) { return; } powerProvider.getTimeTracker().markTime(worldObj); if (builder == null) { builder = new EntityRobot(worldObj, box); worldObj.spawnEntityInWorld(builder); } if (builder.readyToBuild()) { builder.scheduleContruction( bluePrintBuilder.getNextBlock(worldObj, this), bluePrintBuilder.getContext()); } }
@Override public void destroy() { if (box.isInitialized()) { box.deleteLasers(); } if (builderRobot != null) { builderRobot.setDead(); builderRobot = null; } cleanPathLasers(); }
@Override public void doWork() { if (CoreProxy.proxy.isRenderWorld(worldObj)) { return; } if (done) { return; } if (builderRobot != null && !builderRobot.readyToBuild()) { return; } if (powerProvider.useEnergy(25, 25, true) < 25) { return; } iterateBpt(); if (bluePrintBuilder != null && !bluePrintBuilder.done) { if (!box.isInitialized()) { box.initialize(bluePrintBuilder); } if (builderRobot == null) { builderRobot = new EntityRobot(worldObj, box); worldObj.spawnEntityInWorld(builderRobot); } box.createLasers(worldObj, LaserKind.Stripes); builderRobot.scheduleContruction( bluePrintBuilder.getNextBlock( worldObj, new SurroundingInventory(worldObj, xCoord, yCoord, zCoord)), bluePrintBuilder.getContext()); } }
@Override public void destroy() { if (arm != null) { arm.setDead(); } if (builder != null) { builder.setDead(); } box.deleteLasers(); arm = null; }
@Override public void updateEntity() { super.updateEntity(); if ((bluePrintBuilder == null || bluePrintBuilder.done) && box.isInitialized() && (builderRobot == null || builderRobot.done())) { box.deleteLasers(); box.reset(); if (CoreProxy.proxy.isSimulating(worldObj)) { sendNetworkUpdate(); } return; } if (!box.isInitialized() && bluePrintBuilder == null && builderRobot != null) { builderRobot.setDead(); builderRobot = null; } }
public void iterateBpt() { if (items[0] == null || !(items[0].getItem() instanceof ItemBptBase)) { if (bluePrintBuilder != null) { bluePrintBuilder = null; } if (builderRobot != null) { builderRobot.setDead(); builderRobot = null; } if (box.isInitialized()) { box.deleteLasers(); box.reset(); } if (currentPathIterator != null) { currentPathIterator = null; } return; } if (bluePrintBuilder == null || bluePrintBuilder.done) { if (path != null && path.size() > 1) { if (currentPathIterator == null) { Iterator<BlockIndex> it = path.iterator(); BlockIndex start = it.next(); currentPathIterator = new PathIterator(start, it); } if (bluePrintBuilder != null && builderRobot != null) { builderRobot.markEndOfBlueprint(bluePrintBuilder); } bluePrintBuilder = currentPathIterator.next(); if (bluePrintBuilder != null) { box.deleteLasers(); box.reset(); box.initialize(bluePrintBuilder); box.createLasers(worldObj, LaserKind.Stripes); } if (builderRobot != null) { builderRobot.setBox(box); } if (bluePrintBuilder == null) { currentPathIterator = currentPathIterator.iterate(); } if (currentPathIterator == null) { done = true; } } else { if (bluePrintBuilder != null && bluePrintBuilder.done) { if (builderRobot != null) { builderRobot.markEndOfBlueprint(bluePrintBuilder); } done = true; bluePrintBuilder = null; } else { bluePrintBuilder = instanciateBluePrint( xCoord, yCoord, zCoord, Orientations.values()[worldObj.getBlockMetadata(xCoord, yCoord, zCoord)] .reverse()); if (bluePrintBuilder != null) { box.initialize(bluePrintBuilder); box.createLasers(worldObj, LaserKind.Stripes); } } } } }
@Override public void updateEntity() { super.updateEntity(); if (inProcess && arm != null) { arm.setArmSpeed(0); float energyToUse = 2 + powerProvider.getEnergyStored() / 1000; boolean enoughStep = (0.015 + energyToUse / 200F) > (1F / 32F); // (otherwise the movement is rounded to 0 and the energy absorbed with no // movement) if (enoughStep) { float energy = powerProvider.useEnergy(energyToUse, energyToUse, true); if (energy > 0) { arm.doMove(0.015 + energy / 200F); } } } if (arm != null) { double[] head = arm.getHead(); headPosX = head[0]; headPosY = head[1]; headPosZ = head[2]; speed = arm.getArmSpeed(); } if (ProxyCore.proxy.isSimulating(worldObj)) { sendNetworkUpdate(); } if (inProcess || !isDigging) { return; } createUtilsIfNeeded(); if (bluePrintBuilder != null) { builderDone = bluePrintBuilder.done; if (!builderDone) { buildFrame(); return; } else { if (builder != null && builder.done()) { box.deleteLasers(); builder.setDead(); builder = null; } } } if (builder == null) { dig(); } }