@Override
    void handleClicking(MovingObjectPosition r) {
      if (r == null) {
        setState(new StateNotifyAndQuit("e4"));
        return;
      }

      TileEntity tile = world.getTileEntity(r.blockX, r.blockY, r.blockZ);

      if (tile instanceof IWirelessUser) {
        State state = new StateNotify("e5");
        setState(state);
        Syncs.linkUserToNode(
            (IWirelessUser) tile,
            node,
            Future.create(
                (Object o) -> {
                  if (FreqTransmitterUI.this.current == state) {
                    boolean res = (boolean) o;
                    if (res) {
                      setState(new StateNotifyAndReturn("e6", StateDoNodeLink.this));
                    } else {
                      setState(new StateNotifyAndQuit("e3"));
                    }
                  }
                }));
      } else {
        setState(new StateNotifyAndQuit("e4"));
      }
    }
    @Override
    void handleClicking(MovingObjectPosition result) {
      TileEntity tile;

      if (result == null
          || !((tile = world.getTileEntity(result.blockX, result.blockY, result.blockZ))
              instanceof IWirelessNode)) {
        setState(new StateNotifyAndQuit("e4"));
      } else {
        IWirelessNode node = (IWirelessNode) tile;
        State state = new StateNotify("e5");
        setState(state);
        Syncs.linkNodeToMatrix(
            node,
            matrix,
            pass,
            Future.create(
                (Object o) -> {
                  if (FreqTransmitterUI.this.current == state) {
                    boolean res = (boolean) o;
                    if (res) {
                      setState(new StateNotifyAndReturn("e6", StateDoMatrixLink.this));
                    } else {
                      setState(new StateNotifyAndQuit("e2"));
                    }
                  }
                }));
      }
    }
 @Override
 void handleKeyInput(char ch, int kid) {
   if (ChatAllowedCharacters.isAllowedCharacter(ch)) {
     pass = pass + ch;
   } else if (kid == Keyboard.KEY_RETURN) {
     State state = new StateNotify("s1_1");
     setState(state);
     Syncs.authorizeMatrix(
         matrix,
         pass,
         Future.create(
             (Object o) -> {
               if (state == FreqTransmitterUI.this.current) {
                 boolean result = (boolean) o;
                 if (result) {
                   setState(new StateDoMatrixLink(matrix, pass));
                 } else {
                   setState(new StateNotifyAndQuit("e1"));
                 }
               }
             }));
   } else if (kid == Keyboard.KEY_BACK) {
     if (pass.length() > 0) pass = pass.substring(0, pass.length() - 1);
   }
 }
示例#4
0
  /** Make a sync query from client and call the callback when received sync. */
  @SideOnly(Side.CLIENT)
  public void querySync(final FutureCallback callback) {
    doQuerySync(
        Future.create(
            new FutureCallback() {

              @Override
              public void onReady(Object val) {
                callback.onReady(val);
                fromNBTSync((NBTTagCompound) val);
              }
            }));
  }
    @Override
    public void handleClicking(MovingObjectPosition result) {
      if (result == null) {
        setState(null);
        return;
      }
      if (started) return;
      int hx = result.blockX, hy = result.blockY, hz = result.blockZ;
      TileEntity te = world.getTileEntity(hx, hy, hz);
      if (te instanceof IWirelessNode) {

        setState(new StateDoNodeLink((IWirelessNode) te));

      } else if (te instanceof IWirelessMatrix) {

        started = true;
        IWirelessMatrix mat = (IWirelessMatrix) te;
        // BAD CODING STYLE: Hard coded BlockMulti processing
        Block block = world.getBlock(hx, hy, hz);
        if (block instanceof BlockMulti) {
          mat = (IWirelessMatrix) ((BlockMulti) block).getOriginTile(te);
        }

        final IWirelessMatrix mat2 = mat;
        Syncs.querySSID(
            mat,
            Future.create(
                (Object o) -> {
                  if (current == StateStart.this) {
                    if (o == null) {
                      setState(new StateNotifyAndQuit("e0"));
                    } else {
                      setState(new StateAuthorize(mat2, (String) o));
                    }
                  }
                }));
      } else {
        setState(new StateNotifyAndQuit("e4"));
      }
    }
示例#6
0
 @RegNetworkCall(side = Side.SERVER, thisStorage = StorageOption.Option.INSTANCE)
 private void doQuerySync(@Data Future future) {
   future.setAndSync(toNBTSync());
 }