Examples of GasStack


Examples of mekanism.api.gas.GasStack

    super.destroyNetwork();
  }

  private void setConduitVolumes() {
    if(tank.containsValidGas() && !conduits.isEmpty()) {
      GasStack gasPerConduit = tank.getGas().copy();
      int numCons = conduits.size();
      int leftOvers = gasPerConduit.amount % numCons;
      gasPerConduit.amount = gasPerConduit.amount / numCons;

      for (GasConduit con : conduits) {
        GasStack f = gasPerConduit.copy();
        if(leftOvers > 0) {
          f.amount += 1;
          leftOvers--;
        }
        con.getTank().setGas(f);
View Full Code Here

Examples of mekanism.api.gas.GasStack

      }
      GasOutput output = outputIterator.next();
      if(output != null) {
        IGasHandler cont = getTankContainer(output.location);
        if(cont != null) {
          GasStack offer = tank.getGas().copy();
          int filled = cont.receiveGas(output.dir, offer);
          if(filled > 0) {
            tank.addAmount(-filled);

          }
View Full Code Here

Examples of mekanism.api.gas.GasStack

    if(resource == null || tank.isEmpty() || !tank.containsValidGas() || !GasConduitNetwork.areGassCompatable(getGasType(), resource)) {
      return null;
    }
    int amount = Math.min(resource.amount, tank.getStored());
    amount = Math.min(amount, GasConduit.MAX_IO_PER_TICK);
    GasStack result = resource.copy();
    result.amount = amount;
    if(doDrain) {
      tank.addAmount(-amount);
    }
    return result;
View Full Code Here

Examples of mekanism.api.gas.GasStack

  public GasStack drain(ForgeDirection from, int maxDrain, boolean doDrain) {
    if(tank.isEmpty() || !tank.containsValidGas()) {
      return null;
    }
    int amount = Math.min(maxDrain, tank.getStored());
    GasStack result = tank.getGas().copy();
    result.amount = amount;
    if(doDrain) {
      tank.addAmount(-amount);
    }
    return result;
View Full Code Here

Examples of mekanism.api.gas.GasStack

    IGasHandler extTank = getTankContainer(advancedGasConduit, dir);
    if(extTank != null) {
      int maxExtract = Math.min(maxExtractPerTick, tank.getAvailableSpace());

      if(gasType == null || !tank.containsValidGas()) {
        GasStack drained = extTank.drawGas(dir.getOpposite(), maxExtract);
        if(drained == null || drained.amount <= 0) {
          return false;
        }
        setGasType(drained);
        tank.setGas(drained.copy());
        return true;
      }

      GasStack couldDrain = gasType.copy();
      couldDrain.amount = maxExtract;

      //      GasStack drained = extTank.drain(dir.getOpposite(), couldDrain, true);
      //      if(drained == null || drained.amount <= 0) {
      //        return false;
      //      }
      //      tank.addAmount(drained.amount);    

      //Have to use this 'double handle' approach to work around an issue with TiC
      GasStack drained = extTank.drawGas(dir.getOpposite(), maxExtract);
      if(drained == null || drained.amount == 0) {
        return false;
      } else {
        if(drained.isGasEqual(getGasType())) {
          tank.addAmount(drained.amount);
        }
      }
      return true;
    }
View Full Code Here

Examples of mekanism.api.gas.GasStack

      if(leftTank.getGas() != null)
      {
        if(!dumpLeft)
        {
          GasStack toSend = new GasStack(leftTank.getGas().getGas(), Math.min(leftTank.getStored(), output));

          TileEntity tileEntity = Coord4D.get(this).getFromSide(MekanismUtils.getLeft(facing)).getTileEntity(worldObj);

          if(tileEntity instanceof IGasHandler)
          {
            if(((IGasHandler)tileEntity).canReceiveGas(MekanismUtils.getLeft(facing).getOpposite(), leftTank.getGas().getGas()))
            {
              leftTank.draw(((IGasHandler)tileEntity).receiveGas(MekanismUtils.getLeft(facing).getOpposite(), toSend), true);
            }
          }
        }
        else {
          leftTank.draw(8, true);

          if(worldObj.rand.nextInt(3) == 2)
          {
            Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getParticlePacket(0, new ArrayList())), new Range4D(Coord4D.get(this)));
          }
        }
      }

      if(rightTank.getGas() != null)
      {
        if(!dumpRight)
        {
          GasStack toSend = new GasStack(rightTank.getGas().getGas(), Math.min(rightTank.getStored(), output));

          TileEntity tileEntity = Coord4D.get(this).getFromSide(MekanismUtils.getRight(facing)).getTileEntity(worldObj);

          if(tileEntity instanceof IGasHandler)
          {
View Full Code Here

Examples of mekanism.api.gas.GasStack

        fluidTank.setFluid(null);
      }

      if(dataStream.readBoolean())
      {
        leftTank.setGas(new GasStack(GasRegistry.getGas(dataStream.readInt()), dataStream.readInt()));
      }
      else {
        leftTank.setGas(null);
      }

      if(dataStream.readBoolean())
      {
        rightTank.setGas(new GasStack(GasRegistry.getGas(dataStream.readInt()), dataStream.readInt()));
      }
      else {
        rightTank.setGas(null);
      }
View Full Code Here

Examples of mekanism.api.gas.GasStack

          gasTank.draw(GasTransmission.addGas(inventory[0], gasTank.getGas()), true);
        }

        if(gasTank.getGas() != null)
        {
          GasStack toSend = new GasStack(gasTank.getGas().getGas(), Math.min(gasTank.getGas().amount, gasOutput));

          TileEntity tileEntity = Coord4D.get(this).getFromSide(MekanismUtils.getLeft(facing)).getTileEntity(worldObj);

          if(tileEntity instanceof IGasHandler)
          {
            if(((IGasHandler)tileEntity).canReceiveGas(MekanismUtils.getLeft(facing).getOpposite(), gasTank.getGas().getGas()))
            {
              gasTank.draw(((IGasHandler)tileEntity).receiveGas(MekanismUtils.getLeft(facing).getOpposite(), toSend), true);
            }
          }
        }

        if(inventory[2] != null)
        {
          if(inventory[2].getItem() instanceof IFluidContainerItem)
          {
            fluidTank.fill(FluidContainerUtils.extractFluid(fluidTank, inventory[2]), true);
           
            if(((IFluidContainerItem)inventory[2].getItem()).getFluid(inventory[2]) == null || fluidTank.getFluidAmount() == fluidTank.getCapacity())
            {
              if(inventory[3] == null)
              {
                inventory[3] = inventory[2].copy();
                inventory[2] = null;
               
                markDirty();
              }
            }
          }
          else if(FluidContainerRegistry.isFilledContainer(inventory[2]))
          {
            FluidStack itemFluid = FluidContainerRegistry.getFluidForFilledItem(inventory[2]);
 
            if((fluidTank.getFluid() == null && itemFluid.amount <= MAX_FLUID) || fluidTank.getFluid().amount+itemFluid.amount <= MAX_FLUID)
            {
              if(fluidTank.getFluid() != null && !fluidTank.getFluid().isFluidEqual(itemFluid))
              {
                return;
              }
 
              ItemStack containerItem = inventory[2].getItem().getContainerItem(inventory[2]);
 
              boolean filled = false;
 
              if(containerItem != null)
              {
                if(inventory[3] == null || (inventory[3].isItemEqual(containerItem) && inventory[3].stackSize+1 <= containerItem.getMaxStackSize()))
                {
                  inventory[2] = null;
 
                  if(inventory[3] == null)
                  {
                    inventory[3] = containerItem;
                  }
                  else {
                    inventory[3].stackSize++;
                  }
 
                  filled = true;
                }
              }
              else {
                inventory[2].stackSize--;
 
                if(inventory[2].stackSize == 0)
                {
                  inventory[2] = null;
                }
 
                filled = true;
              }
 
              if(filled)
              {
                fluidTank.fill(itemFluid, true);
                markDirty();
              }
            }
          }
        }

        if(getEnergy() >= ENERGY_USAGE && MekanismUtils.canFunction(this) && isValidFluid(fluidTank.getFluid()) && (gasTank.getGas() == null || (gasTank.getStored() < MAX_FLUID && gasEquals(gasTank.getGas(), fluidTank.getFluid()))))
        {
          setActive(true);
          gasTank.receive(new GasStack(GasRegistry.getGas(fluidTank.getFluid().getFluid()), 1), true);
          fluidTank.drain(1, true);
          setEnergy(getEnergy() - ENERGY_USAGE);
        }
        else {
          if(prevEnergy >= getEnergy())
View Full Code Here

Examples of mekanism.api.gas.GasStack

      fluidTank.setFluid(null);
    }

    if(dataStream.readBoolean())
    {
      gasTank.setGas(new GasStack(GasRegistry.getGas(dataStream.readInt()), dataStream.readInt()));
    }
    else {
      gasTank.setGas(null);
    }
View Full Code Here

Examples of mekanism.api.gas.GasStack

  }

  @Override
  public GasStack getItemGas(ItemStack itemstack)
  {
    if(itemstack.isItemEqual(new ItemStack(Items.flint))) return new GasStack(GasRegistry.getGas("oxygen"), 10);
    if(Block.getBlockFromItem(itemstack.getItem()) == Mekanism.GasTank && ((IGasItem)itemstack.getItem()).getGas(itemstack) != null &&
        ((IGasItem)itemstack.getItem()).getGas(itemstack).getGas() == GasRegistry.getGas("oxygen")) return new GasStack(GasRegistry.getGas("oxygen"), 1);

    return null;
  }
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.