@Override public void process(double time) { ElectricalDrillDescriptor drill = (ElectricalDrillDescriptor) ElectricalDrillDescriptor.getDescriptor( miner.inventory.getStackInSlot(AutoMinerContainer.electricalDrillSlotId)); OreScanner scanner = (OreScanner) ElectricalDrillDescriptor.getDescriptor( miner.inventory.getStackInSlot(AutoMinerContainer.OreScannerSlotId)); MiningPipeDescriptor pipe = (MiningPipeDescriptor) ElectricalDrillDescriptor.getDescriptor( miner.inventory.getStackInSlot(AutoMinerContainer.MiningPipeSlotId)); energyCounter += miner.inPowerLoad.getRpPower() * time; if (job != jobType.none) { if (energyCounter >= energyTarget || (job == jobType.ore && drill == null)) { setupJob(); } if (energyCounter >= energyTarget) { switch (job) { case ore: Block block = Block.blocksList[jobCoord.world().getBlockId(jobCoord.x, jobCoord.y, jobCoord.z)]; int meta = jobCoord.world().getBlockMetadata(jobCoord.x, jobCoord.y, jobCoord.z); ArrayList<ItemStack> drop = block.getBlockDropped( jobCoord.world(), jobCoord.x, jobCoord.y, jobCoord.z, meta, 0); for (ItemStack stack : drop) { drop(stack); } jobCoord.world().setBlock(jobCoord.x, jobCoord.y, jobCoord.z, 0); energyCounter -= energyTarget; setupJob(); break; case pipeAdd: Eln.ghostManager.createGhost(jobCoord, miner.node.coordonate, jobCoord.y); miner.inventory.decrStackSize(AutoMinerContainer.MiningPipeSlotId, 1); pipeLength++; miner.needPublish(); energyCounter -= energyTarget; setupJob(); break; case pipeRemove: Eln.ghostManager.removeGhostAndBlock(jobCoord); if (miner.inventory.getStackInSlot(AutoMinerContainer.MiningPipeSlotId) == null) { miner.inventory.setInventorySlotContents( AutoMinerContainer.MiningPipeSlotId, Eln.miningPipeDescriptor.newItemStack(1)); } else { miner.inventory.decrStackSize(AutoMinerContainer.MiningPipeSlotId, -1); } pipeLength--; miner.needPublish(); energyCounter -= energyTarget; setupJob(); break; default: break; } } } else { setupJob(); } switch (job) { case none: miner.inPowerLoad.setRp(Double.POSITIVE_INFINITY); break; case ore: if (drill == null) { miner.inPowerLoad.setRp(Double.POSITIVE_INFINITY); } else { miner.inPowerLoad.setRp(drill.getRp(scanner != null ? scanner.OperationEnergy : 0)); } break; case pipeAdd: miner.inPowerLoad.setRp(miner.descriptor.pipeOperationRp); break; case pipeRemove: miner.inPowerLoad.setRp(miner.descriptor.pipeOperationRp); break; } }
void setupJob() { ElectricalDrillDescriptor drill = (ElectricalDrillDescriptor) ElectricalDrillDescriptor.getDescriptor( miner.inventory.getStackInSlot(AutoMinerContainer.electricalDrillSlotId)); OreScanner scanner = (OreScanner) ElectricalDrillDescriptor.getDescriptor( miner.inventory.getStackInSlot(AutoMinerContainer.OreScannerSlotId)); MiningPipeDescriptor pipe = (MiningPipeDescriptor) ElectricalDrillDescriptor.getDescriptor( miner.inventory.getStackInSlot(AutoMinerContainer.MiningPipeSlotId)); int scannerRadius = 0; double scannerEnergy = 0; if (scanner != null) { scannerRadius = scanner.radius; scannerEnergy = scanner.OperationEnergy; } World world = miner.node.coordonate.world(); jobCoord.dimention = miner.node.coordonate.dimention; jobCoord.x = miner.node.coordonate.x; jobCoord.y = miner.node.coordonate.y - pipeLength; jobCoord.z = miner.node.coordonate.z; /*for(jobCoord.y = miner.node.coordonate.y - 1; jobCoord.y > 0;jobCoord.y--) { GhostElement ghost = Eln.ghostManager.getGhost(jobCoord); if(ghost == null || ghost.getObservatorCoordonate().equals(miner.node.coordonate) != true) { jobCoord.y++; break; } }*/ // JobCoord at last pipe boolean jobFind = false; if (drill == null) { if (jobCoord.y != miner.node.coordonate.y) { ItemStack pipeStack = miner.inventory.getStackInSlot(AutoMinerContainer.MiningPipeSlotId); if (pipeStack == null || (pipeStack.stackSize != pipeStack.getMaxStackSize() && pipeStack.stackSize != miner.inventory.getInventoryStackLimit())) { jobFind = true; setJob(jobType.pipeRemove); } } } else if (pipe != null) { if (jobCoord.y < miner.node.coordonate.y - 1) { for (jobCoord.z = miner.node.coordonate.z - scannerRadius; jobCoord.z <= miner.node.coordonate.z + scannerRadius; jobCoord.z++) { for (jobCoord.x = miner.node.coordonate.x - scannerRadius; jobCoord.x <= miner.node.coordonate.x + scannerRadius; jobCoord.x++) { if (checkIsOre(jobCoord)) { jobFind = true; setJob(jobType.ore); break; } } if (jobFind == true) break; } } if (jobFind == false && jobCoord.y > 2) { jobCoord.x = miner.node.coordonate.x; jobCoord.y--; jobCoord.z = miner.node.coordonate.z; int blockId = jobCoord.world().getBlockId(jobCoord.x, jobCoord.y, jobCoord.z); if (blockId != 0 && blockId != Block.waterMoving.blockID && blockId != Block.waterStill.blockID && blockId != Block.lavaMoving.blockID && blockId != Block.lavaStill.blockID) { if (blockId != Block.obsidian.blockID && blockId != Block.bedrock.blockID) { jobFind = true; setJob(jobType.ore); } } else { jobFind = true; setJob(jobType.pipeAdd); } } } if (jobFind == false) setJob(jobType.none); switch (job) { case none: energyTarget = 0; break; case ore: energyTarget = drill.OperationEnergy + scannerEnergy; break; case pipeAdd: energyTarget = miner.descriptor.pipeOperationEnergy; break; case pipeRemove: energyTarget = miner.descriptor.pipeOperationEnergy; break; default: break; } }