示例#1
0
  public BlueprintBase instanciateBlueprint() {
    BlueprintBase bpt = null;

    try {
      bpt = ItemBlueprint.loadBlueprint(getStackInSlot(0));
    } catch (Throwable t) {
      t.printStackTrace();
      return null;
    }

    return bpt;
  }
  @Override
  public void updateEntity() {
    super.updateEntity();

    if (worldObj.isRemote) {
      return;
    }

    if (progressIn > 0 && progressIn < PROGRESS_TIME) {
      progressIn++;
    }

    if (progressOut > 0 && progressOut < PROGRESS_TIME) {
      if (selected == -1) {
        progressOut++;
      } else {
        progressOut = 1;
      }
    }

    // On progress IN, we'll download the blueprint from the server to the
    // client, and then store it to the client.
    if (progressIn == 100 && getStackInSlot(1) == null) {
      setInventorySlotContents(1, getStackInSlot(0));
      setInventorySlotContents(0, null);

      BlueprintBase bpt = ItemBlueprint.loadBlueprint(getStackInSlot(1));

      if (bpt != null && uploadingPlayer != null) {
        RPCHandler.rpcPlayer(
            uploadingPlayer, this, "downloadBlueprintToClient", bpt.id, bpt.getData());
        uploadingPlayer = null;
      }
    }

    if (progressOut == 100 && getStackInSlot(3) == null) {
      RPCHandler.rpcPlayer(downloadingPlayer, this, "requestSelectedBlueprint");
      progressOut = 0;
    }
  }