Package net.minecraftforge.fluids

Examples of net.minecraftforge.fluids.FluidStack


  public Object toLua(ITypeConvertersRegistry registry, Object o) {
    if (o instanceof FluidTankInfo) {
      FluidTankInfo fti = (FluidTankInfo)o;
      Map map = new HashMap();
      map.put("capacity", fti.capacity);
      FluidStack fluidStack = fti.fluid;
      if (fluidStack != null) {
        map.put("amount", fluidStack.amount);
        map.put("id", fluidStack.fluidID);

        Fluid fluid = fluidStack.getFluid();
        if (fluid != null) {
          map.put("name", fluid.getName());
          map.put("rawName", fluid.getLocalizedName(fluidStack));
        }
      }
View Full Code Here


    ItemStack container = player.getCurrentEquippedItem();

    if (FluidContainerRegistry.isEmptyContainer(container)) {
      ItemStack returnStack = FluidContainerRegistry.fillFluidContainer(tankFluid, container);
      FluidStack fluid = FluidContainerRegistry.getFluidForFilledItem(returnStack);

      if (fluid == null || returnStack == null) {
        return false;
      }
      if (!player.capabilities.isCreativeMode) {
View Full Code Here

  }

  public static boolean fillHandlerWithContainer(World world, IFluidHandler handler, EntityPlayer player) {

    ItemStack container = player.getCurrentEquippedItem();
    FluidStack fluid = FluidContainerRegistry.getFluidForFilledItem(container);

    if (fluid != null) {
      if (handler.fill(ForgeDirection.UNKNOWN, fluid, false) == fluid.amount || player.capabilities.isCreativeMode) {
        if (ServerHelper.isClientWorld(world)) {
          return true;
View Full Code Here

  @Override
  public void renderItem(ItemRenderType type, ItemStack stack, Object... data) {

    Item item = stack.getItem();
    FluidStack fluid = null;
    if (item instanceof IFluidContainerItem) {
      IFluidContainerItem fluidItem = (IFluidContainerItem) item;
      fluid = fluidItem.getFluid(stack);
    } else if (item instanceof IFluidOverlayItem) {
      if (item.getRenderPasses(ItemHelper.getItemDamage(stack)) == 2) {
View Full Code Here

        this.amount = amount;
    }

    @Override
    public boolean matches(ItemStack subject) {
        FluidStack fs = FluidContainerRegistry.getFluidForFilledItem(subject);
        if (fs == null) return false;

        return fs.getFluid() == fluid;
    }
View Full Code Here

    }
    return null;
  }

  public static FluidStack getFluidFromItem(ItemStack item) {
    FluidStack fluid = FluidContainerRegistry.getFluidForFilledItem(item);
    if(fluid == null) {
      if(item.getItem() == Items.water_bucket) {
        fluid = new FluidStack(FluidRegistry.WATER, 1000);
      } else if(item.getItem() == Items.lava_bucket) {
        fluid = new FluidStack(FluidRegistry.LAVA, 1000);
      }
    }
    return fluid;
  }
View Full Code Here

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

    FluidTankInfo[] infos = from.getTankInfo(fromDir);
    boolean res = false;
    if(infos != null) {     
      for (FluidTankInfo info : infos) {
        if(info.fluid != null && info.fluid.amount > 0 && from.canDrain(fromDir, info.fluid.getFluid())) {
          FluidStack maxDrain = new FluidStack(info.fluid.getFluid(), maxVolume);
          FluidStack canDrain = from.drain(fromDir, maxDrain, false);
          if(canDrain != null && canDrain.amount > 0) {
            int filled = target.fill(fromDir.getOpposite(), canDrain, true);
            from.drain(fromDir, new FluidStack(info.fluid.getFluid(), filled), true);
            res |= true;
          }
        }
      }
    }
View Full Code Here

  }

  public static MachineRecipeInput readFromNBT(NBTTagCompound root) {
    int slotNum = root.getInteger("slotNum");
    ItemStack item = null;
    FluidStack fluid = null;
    if(root.hasKey("itemStack")) {
      NBTTagCompound stackRoot = root.getCompoundTag("itemStack");
      item = ItemStack.loadItemStackFromNBT(stackRoot);
    } else if(root.hasKey("fluidStack")) {
      NBTTagCompound stackRoot = root.getCompoundTag("fluidStack");
View Full Code Here

  protected boolean doPush(ForgeDirection dir) {
    boolean res = super.doPush(dir);
    BlockCoord loc = getLocation().getLocation(dir);
    IFluidHandler target = FluidUtil.getFluidHandler(worldObj, loc);
    if(target != null) {
      FluidStack canDrain = drain(dir, IO_MB_TICK, false);
      if(canDrain != null && canDrain.amount > 0) {
        int drained = target.fill(dir.getOpposite(), canDrain, true);
        if(drained > 0) {
          drain(dir, drained, true);
        }
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.