Package net.minecraftforge.fluids

Examples of net.minecraftforge.fluids.FluidStack


    } else {
      tank = new FluidTankEio(16000);
    }
   
    if(nbtRoot.hasKey("tankContents")) {
      FluidStack fl = FluidStack.loadFluidStackFromNBT((NBTTagCompound) nbtRoot.getTag("tankContents"));
      tank.setFluid(fl);
    } else {
      tank.setFluid(null);
    }
  }
View Full Code Here


        doUpdateTankNeighbours();
      }
      if(autoEject && tankNeighbours != null && !tankNeighbours.isEmpty() && tank.getAmount() > 0) {
        int ejectable = tank.getAmount();
        int amountPerNeighbour = ejectable / tankNeighbours.size();
        FluidStack source = WATER_BUCKET.copy();
        int used = 0;
        for (TankNeighbour tc : tankNeighbours) {
          source.amount = amountPerNeighbour;
          used += tc.container.fill(tc.fillFromDir, source, true);
        }
View Full Code Here

    right = ForgeDirection.getOrientation(nbtRoot.getShort("right"));
    pos = Pos.values()[nbtRoot.getShort("pos")];

    autoEject = nbtRoot.getBoolean("autoEject");

    FluidStack liquid = FluidStack.loadFluidStackFromNBT(nbtRoot.getCompoundTag("tank"));
    FluidStack regenLiquid = FluidStack.loadFluidStackFromNBT(nbtRoot.getCompoundTag("regenTank"));

    tank.setCapacity(regenLiquid == null ? BUCKET_VOLUME : BUCKET_VOLUME * 2);
    if(liquid != null) {
      tank.setFluid(liquid);
    } else {
View Full Code Here

    tankDirty = doFill;
    return ret;
  }

  protected FluidStack doDrain(ForgeDirection from, int maxDrain, boolean doDrain) {
    FluidStack ret = tank.drain(maxDrain, doDrain);
    tankDirty = doDrain;
    return ret;
  }
View Full Code Here

      regenTank = new ReservoirTank(BUCKET_VOLUME * 2);
      tank.setCapacity(BUCKET_VOLUME * 2);
      for (BlockCoord bc : multiblock) {
        TileReservoir res = getReservoir(bc);
        if(res != null) {
          FluidStack drained = res.doDrain(ForgeDirection.UNKNOWN, regenTank.getAvailableSpace(), true);
          if(drained != null) {
            regenTank.addAmount(drained.amount);
          }
          // incase regen tank is full, add to normal tank
          drained = res.doDrain(ForgeDirection.UNKNOWN, tank.getAvailableSpace(), true);
View Full Code Here

      FluidTankInfo[] infos = target.getTankInfo(dir.getOpposite());
      if(infos != null) {
        for (FluidTankInfo info : infos) {
          if(info.fluid != null && info.fluid.amount > 0) {
            if(canFill(dir, info.fluid.getFluid())) {
              FluidStack canPull = info.fluid.copy();
              canPull.amount = Math.min(IO_MB_TICK, canPull.amount);
              FluidStack drained = target.drain(dir.getOpposite(), canPull, false);
              if(drained != null && drained.amount > 0) {
                int filled = fill(dir, drained, false);
                if(filled > 0) {
                  drained = target.drain(dir.getOpposite(), filled, true);
                  fill(dir, drained, true);
View Full Code Here

  public List<MachineRecipeInput> getQuantitiesConsumed(MachineRecipeInput[] inputs) {

    List<MachineRecipeInput> result = new ArrayList<MachineRecipeInput>();

    VatRecipe rec = (VatRecipe) getRecipeForInputs(inputs);
    FluidStack inputFluidStack = rec.getRequiredFluidInput(inputs);
    result.add(new MachineRecipeInput(0, inputFluidStack));

    for (MachineRecipeInput ri : inputs) {
      if(!ri.isFluid() && ri.item != null) {
        ItemStack st = ri.item.copy();
View Full Code Here

    if(item == null) {
      return super.onBlockActivated(world, x, y, z, entityPlayer, par6, par7, par8, par9);
    }

    //check for filled fluid containers and see if we can empty them into our input tank
    FluidStack fluid = FluidUtil.getFluidFromItem(item);
    if(fluid != null) {
      int filled = vat.fill(ForgeDirection.UP, fluid, false);
      if(filled >= fluid.amount) {
        vat.fill(ForgeDirection.UP, fluid, true);
        if(!entityPlayer.capabilities.isCreativeMode) {
          entityPlayer.inventory.setInventorySlotContents(entityPlayer.inventory.currentItem, Util.consumeItem(item));
        }
        return true;
      }
    }

    //now check for empty fluid containers to fill
    FluidStack available = vat.outputTank.getFluid();
    if(available != null) {
      ItemStack res = FluidContainerRegistry.fillFluidContainer(available.copy(), item);
      FluidStack filled = FluidContainerRegistry.getFluidForFilledItem(res);

      if(filled == null) { //this shouldn't be necessary but it appears to be a bug as the above method doesnt work
        FluidContainerData[] datas = FluidContainerRegistry.getRegisteredFluidContainerData();
        for (FluidContainerData data : datas) {
          if(data != null && data.fluid.getFluid().getName().equals(available.getFluid().getName()) && data.emptyContainer.isItemEqual(item)) {
View Full Code Here

    if(result == null) {
      return;
    }
    if(FluidContainerRegistry.isFilledContainer(result)) {
      FluidStack fluid = FluidContainerRegistry.getFluidForFilledItem(result);
      if(fluid != null) {
        List<IRecipe> recipes = VatRecipeManager.getInstance().getRecipes();
        for (IRecipe recipe : recipes) {
          FluidStack output = recipe.getOutputs()[0].getFluidOutput();
          if(output.isFluidEqual(fluid)) {
            InnerVatRecipe res = new InnerVatRecipe(recipe.getEnergyRequired(), recipe.getInputs(), output);
            arecipes.add(res);
          }
        }
      }
View Full Code Here

  @Override
  public void loadCraftingRecipes(String outputId, Object... results) {
    if(outputId.equals("EnderIOVat") && getClass() == VatRecipeHandler.class) {
      List<IRecipe> recipes = VatRecipeManager.getInstance().getRecipes();
      for (IRecipe recipe : recipes) {
        FluidStack output = recipe.getOutputs()[0].getFluidOutput();
        InnerVatRecipe res = new InnerVatRecipe(recipe.getEnergyRequired(), recipe.getInputs(), output);
        arecipes.add(res);
      }

    } else {
View Full Code Here

TOP

Related Classes of net.minecraftforge.fluids.FluidStack

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.