@RPC(RPCSide.CLIENT)
  public void requestSelectedBlueprint() {
    if (isOutputConsistent()) {
      if (selected > -1 && selected < currentPage.size()) {
        BlueprintBase bpt = BuildCraftBuilders.clientDB.load(currentPage.get(selected));

        RPCHandler.rpcServer(this, "uploadBlueprintToServer", bpt.id, bpt.getData());
      } else {
        RPCHandler.rpcServer(this, "uploadBlueprintToServer", null, null);
      }
    }
  }
  @RPC(RPCSide.CLIENT)
  public void downloadBlueprintToClient(BlueprintId id, byte[] data) {
    try {
      NBTTagCompound nbt = CompressedStreamTools.func_152457_a(data, NBTSizeTracker.field_152451_a);
      BlueprintBase bpt = BlueprintBase.loadBluePrint(nbt);
      bpt.setData(data);
      bpt.id = id;

      BuildCraftBuilders.clientDB.add(bpt);
      setCurrentPage(BuildCraftBuilders.clientDB.getPage(pageId));
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
Exemple #3
0
  @Deprecated
  public BptBuilderBase instanciateBluePrintBuilder(int x, int y, int z, ForgeDirection o) {
    BlueprintBase bpt = instanciateBlueprint();
    if (bpt == null) {
      return null;
    }

    bpt = bpt.adjustToWorld(worldObj, x, y, z, o);

    if (bpt != null) {
      if (getStackInSlot(0).getItem() instanceof ItemBlueprintStandard) {
        return new BptBuilderBlueprint((Blueprint) bpt, worldObj, x, y, z);
      } else if (getStackInSlot(0).getItem() instanceof ItemBlueprintTemplate) {
        return new BptBuilderTemplate(bpt, worldObj, x, y, z);
      }
    }
    return null;
  }
  @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;
    }
  }
  @RPC(RPCSide.SERVER)
  public void uploadBlueprintToServer(BlueprintId id, byte[] data) {
    try {
      if (data != null) {
        NBTTagCompound nbt =
            CompressedStreamTools.func_152457_a(data, NBTSizeTracker.field_152451_a);
        BlueprintBase bpt = BlueprintBase.loadBluePrint(nbt);
        bpt.setData(data);
        bpt.id = id;
        BuildCraftBuilders.serverDB.add(bpt);
        setInventorySlotContents(3, bpt.getStack());
      } else {
        setInventorySlotContents(3, getStackInSlot(2));
      }

      setInventorySlotContents(2, null);

      downloadingPlayer = null;
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }