@Override
  public void initialize() {
    super.initialize();

    createUtilsIfNeeded();

    sendNetworkUpdate();
  }
  @Override
  public void postPacketHandling(PacketUpdate packet) {

    super.postPacketHandling(packet);

    createUtilsIfNeeded();
    //
    if (arm != null) {
      arm.setHead(headPosX, headPosY, headPosZ);
      //			arm.setTarget(targetX, targetY, targetZ);
      //			arm.setArmSpeed(speed);
    }
  }
  @Override
  public void writeToNBT(NBTTagCompound nbttagcompound) {
    super.writeToNBT(nbttagcompound);

    PowerFramework.currentFramework.savePowerProvider(this, nbttagcompound);

    nbttagcompound.setInteger("targetX", targetX);
    nbttagcompound.setInteger("targetY", targetY);
    nbttagcompound.setInteger("targetZ", targetZ);
    nbttagcompound.setDouble("headPosX", headPosX);
    nbttagcompound.setDouble("headPosY", headPosY);
    nbttagcompound.setDouble("headPosZ", headPosZ);

    NBTTagCompound boxTag = new NBTTagCompound();
    box.writeToNBT(boxTag);
    nbttagcompound.setTag("box", boxTag);
  }
  @Override
  public void readFromNBT(NBTTagCompound nbttagcompound) {
    super.readFromNBT(nbttagcompound);

    PowerFramework.currentFramework.loadPowerProvider(this, nbttagcompound);

    if (nbttagcompound.hasKey("box")) {
      box.initialize(nbttagcompound.getCompoundTag("box"));

      loadDefaultBoundaries = false;
    } else if (nbttagcompound.hasKey("xSize")) {
      // This is a legacy save, get old data

      int xMin = nbttagcompound.getInteger("xMin");
      int zMin = nbttagcompound.getInteger("zMin");

      int xSize = nbttagcompound.getInteger("xSize");
      int ySize = nbttagcompound.getInteger("ySize");
      int zSize = nbttagcompound.getInteger("zSize");

      box.initialize(xMin, yCoord, zMin, xMin + xSize - 1, yCoord + ySize - 1, zMin + zSize - 1);

      loadDefaultBoundaries = false;
    } else {
      // This is a legacy save, compute boundaries

      loadDefaultBoundaries = true;
    }

    targetX = nbttagcompound.getInteger("targetX");
    targetY = nbttagcompound.getInteger("targetY");
    targetZ = nbttagcompound.getInteger("targetZ");
    headPosX = nbttagcompound.getDouble("headPosX");
    headPosY = nbttagcompound.getDouble("headPosY");
    headPosZ = nbttagcompound.getDouble("headPosZ");
  }
  @Override
  public void invalidate() {

    super.invalidate();
    destroy();
  }
  @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();
    }
  }