Пример #1
0
  private static FluidTank readTank(ItemStack stack) {
    FluidTank tank = new FluidTank(TileEntityTank.getTankCapacity());

    final NBTTagCompound itemTag = stack.getTagCompound();
    if (itemTag != null && itemTag.hasKey(TANK_TAG)) {
      tank.readFromNBT(itemTag.getCompoundTag(TANK_TAG));
      return tank;
    }

    return tank;
  }
Пример #2
0
  public static ItemStack createFilledTank(Fluid fluid) {
    final int tankCapacity = TileEntityTank.getTankCapacity();
    FluidStack stack = FluidRegistry.getFluidStack(fluid.getName(), tankCapacity);
    if (stack == null) return null;

    FluidTank tank = new FluidTank(tankCapacity);
    tank.setFluid(stack);

    ItemStack item = new ItemStack(OpenBlocks.Blocks.tank);
    saveTank(item, tank);
    return item;
  }