@Override
 public void writeToNBT(NBTTagCompound compound) {
   super.writeToNBT(compound);
   // LogHelper.debugInfo("write mode = " + mode.getID());
   compound.setInteger("mode", mode.getID());
   if (stack != null) compound.setTag("item", stack.serializeNBT());
 }
  @Override
  public void readFromNBT(NBTTagCompound compound) {
    super.readFromNBT(compound);
    // LogHelper.debugInfo("read mode = " + ModeProximityTrigger.get(compound.getInteger("mode")));
    mode = ModeProximityTrigger.get(compound.getInteger("mode"));

    if (compound.hasKey("item"))
      stack = ItemStack.loadItemStackFromNBT(compound.getCompoundTag("item"));
  }
 @Override
 public void checkStateServer() {
   super.checkStateServer();
   // if (canProceed())
   if (entityIsInMe) {
     if (timeCount >= DELAY_LENGTH) {
       if (oldCounter != counter) {
         oldCounter = counter;
         if (!isActive()) {
           setActive(true);
         }
       } else {
         setEntityIsInMe(false);
         setActive(false);
       }
       timeCount = 0;
     }
     timeCount++;
   }
 }