Examples of IFluidHandler


Examples of net.minecraftforge.fluids.IFluidHandler

        }
    }

    public void outputLiquid(IFluidHandler[] outputs, int tankIndex, int amount) {
        for (int side = 0; side < 6; side++) {
            IFluidHandler nearbyTank = outputs[side];
            if (nearbyTank != null)
                outputLiquid(nearbyTank, ForgeDirection.getOrientation(side), tankIndex, amount);
        }
    }
View Full Code Here

Examples of net.minecraftforge.fluids.IFluidHandler

                outputLiquid(nearbyTank, ForgeDirection.getOrientation(side), tankIndex, amount);
        }
    }

    public static IFluidHandler getTankFromTile(TileEntity tile) {
        IFluidHandler tank = null;
        if (tile instanceof IFluidHandler)
            tank = (IFluidHandler) tile;
        return tank;
    }
View Full Code Here

Examples of net.minecraftforge.fluids.IFluidHandler

            if (side == ForgeDirection.UNKNOWN) {
                continue;
            }
            TileEntity tile = tileCache.getTileOnSide(side);
            if (tile instanceof IFluidHandler) {
                IFluidHandler nearbyTank = (IFluidHandler) tile;
                if (PipeManager.canExtractFluids(this, worldObj, MiscTools.getXOnSide(xCoord, side), MiscTools.getYOnSide(yCoord, side), MiscTools.getZOnSide(zCoord, side))) {
                    side = side.getOpposite();
                    FluidStack drained = nearbyTank.drain(side, TRANSFER_RATE, false);
                    int used = tank.fill(drained, true);
                    nearbyTank.drain(side, used, true);
                }
            }
        }

        boolean needsPipe = false;
View Full Code Here

Examples of net.minecraftforge.fluids.IFluidHandler

  }

  @Override
  public boolean isTriggerActive(TileEntity tile, ForgeDirection side, IStatementContainer statementContainer, IStatementParameter[] parameters) {
    if (tile instanceof IFluidHandler) {
      IFluidHandler container = (IFluidHandler) tile;

      FluidStack searchedFluid = null;

      if (parameters != null && parameters.length >= 1 && parameters[0] != null && parameters[0].getItemStack() != null) {
        searchedFluid = FluidContainerRegistry.getFluidForFilledItem(parameters[0].getItemStack());
      }

      if (searchedFluid != null) {
        searchedFluid.amount = 1;
      }

      FluidTankInfo[] liquids = container.getTankInfo(side);
      if (liquids == null || liquids.length == 0) {
        return false;
      }

      switch (state) {
        case Empty:
          for (FluidTankInfo c : liquids) {
            if (c.fluid != null && c.fluid.amount > 0 && (searchedFluid == null || searchedFluid.isFluidEqual(c.fluid))) {
              return false;
            }
          }
          return true;
        case Contains:
          for (FluidTankInfo c : liquids) {
            if (c.fluid != null && c.fluid.amount > 0 && (searchedFluid == null || searchedFluid.isFluidEqual(c.fluid))) {
              return true;
            }
          }
          return false;
        case Space:
          if (searchedFluid == null) {
            for (FluidTankInfo c : liquids) {
              if (c.fluid == null || c.fluid.amount < c.capacity) {
                return true;
              }
            }
            return false;
          }
          return container.fill(side, searchedFluid, false) > 0;
        case Full:
          if (searchedFluid == null) {
            for (FluidTankInfo c : liquids) {
              if (c.fluid == null || c.fluid.amount < c.capacity) {
                return false;
              }
            }
            return true;
          }
          return container.fill(side, searchedFluid, false) <= 0;
      }
    }

    return false;
  }
View Full Code Here

Examples of net.minecraftforge.fluids.IFluidHandler

  }

  @Override
  public boolean isTriggerActive(TileEntity tile, ForgeDirection side, IStatementContainer statementContainer, IStatementParameter[] parameters) {
    if (tile instanceof IFluidHandler) {
      IFluidHandler container = (IFluidHandler) tile;

      FluidStack searchedFluid = null;

      if (parameters != null && parameters.length >= 1 && parameters[0] != null && parameters[0].getItemStack() != null) {
        searchedFluid = FluidContainerRegistry.getFluidForFilledItem(parameters[0].getItemStack());
      }

      if (searchedFluid != null) {
        searchedFluid.amount = 1;
      }

      FluidTankInfo[] liquids = container.getTankInfo(side);
      if (liquids == null || liquids.length == 0) {
        return false;
      }

      for (FluidTankInfo c : liquids) {
        if (c.fluid == null) {
          if (searchedFluid == null) {
            return true;
          }
          return container.fill(side, searchedFluid, false) > 0;
        }

        if (searchedFluid == null || searchedFluid.isFluidEqual(c.fluid)) {
          float percentage = (float) c.fluid.amount / (float) c.capacity;
          return percentage < type.level;
View Full Code Here

Examples of net.minecraftforge.fluids.IFluidHandler

        TileEntity nearbyTile = robot.worldObj.getTileEntity(station.x() + dir.offsetX, station.y()
            + dir.offsetY, station.z()
            + dir.offsetZ);

        if (nearbyTile != null && nearbyTile instanceof IFluidHandler) {
          IFluidHandler handler = (IFluidHandler) nearbyTile;

          FluidStack drainable = robot.drain(ForgeDirection.UNKNOWN, 1, false);

          int filledAmount = handler.fill(station.side, drainable, false);

          if (filledAmount > 0) {
            return true;
          }
        }
View Full Code Here

Examples of net.minecraftforge.fluids.IFluidHandler

        TileEntity nearbyTile = robot.worldObj.getTileEntity(station.x() + dir.offsetX, station.y()
            + dir.offsetY, station.z()
            + dir.offsetZ);

        if (nearbyTile != null && nearbyTile instanceof IFluidHandler) {
          IFluidHandler handler = (IFluidHandler) nearbyTile;
          FluidStack drainable = handler.drain(station.side, 1, false);

          // TODO: there is no account taken for the filter on the
          // gate here. See LoadFluid, GotoStationToLoad and Load for
          // items as well.
          if (drainable != null
View Full Code Here

Examples of net.minecraftforge.fluids.IFluidHandler

        return false;
      }
    }

    if (tile instanceof IFluidHandler) {
      IFluidHandler liq = (IFluidHandler) tile;

      FluidTankInfo[] tankInfo = liq.getTankInfo(side.getOpposite());
      if (tankInfo != null && tankInfo.length > 0) {
        return true;
      }
    }
View Full Code Here

Examples of net.minecraftforge.fluids.IFluidHandler

        TileEntity nearbyTile = robot.worldObj.getTileEntity(station.x() + dir.offsetX, station.y()
            + dir.offsetY, station.z()
            + dir.offsetZ);

        if (nearbyTile != null && nearbyTile instanceof IFluidHandler) {
          IFluidHandler handler = (IFluidHandler) nearbyTile;
          FluidStack drainable = handler.drain(station.side, FluidContainerRegistry.BUCKET_VOLUME, false);

          if (drainable != null
              && filter.matches(drainable.getFluid())) {

            drainable = drainable.copy();

            int filled = robot.fill(ForgeDirection.UNKNOWN, drainable, true);

            if (filled > 0) {
              drainable.amount = filled;
              handler.drain(station.side, drainable, true);
              loaded += filled;
              return;
            }
          }
        }
View Full Code Here

Examples of net.minecraftforge.fluids.IFluidHandler

    if (liquidToExtract > 0 && meta < 6) {
      ForgeDirection side = ForgeDirection.getOrientation(meta);
      TileEntity tile = container.getTile(side);

      if (tile instanceof IFluidHandler) {
        IFluidHandler fluidHandler = (IFluidHandler) tile;

        int flowRate = transport.flowRate;

        FluidStack extracted = fluidHandler.drain(side.getOpposite(), liquidToExtract > flowRate ? flowRate : liquidToExtract, false);

        int inserted = 0;
        if (extracted != null) {
          inserted = transport.fill(side, extracted, true);

          fluidHandler.drain(side.getOpposite(), inserted, true);
        }

        liquidToExtract -= inserted;
      }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.