Package forestry.core.fluids.tanks

Examples of forestry.core.fluids.tanks.StandardTank


    GL11.glPopAttrib();
  }

  @Override
  public ToolTip getToolTip() {
    StandardTank tank = getTank();
    if (tank == null)
      return null;
    return tank.getToolTip();
  }
View Full Code Here


      Proxies.net.sendToServer(new PacketUpdate(PacketIds.PIPETTE_CLICK, payload));
      return;
    }

    IToolPipette pipette = (IToolPipette) held;
    StandardTank tank = tile.getTankManager().get(slot);
    int liquidAmount = tank.getFluid().amount;

    if (pipette.canPipette(itemstack) && liquidAmount > 0) {
      if (liquidAmount > 0) {
        FluidStack fillAmount = tank.drain(1000, false);
        int filled = pipette.fill(itemstack, fillAmount, true);
        tank.drain(filled, true);
      }
    } else {
      FluidStack potential = pipette.drain(itemstack, pipette.getCapacity(itemstack), false);
      if (potential != null)
        pipette.drain(itemstack, tank.fill(potential, true), true);
    }
  }
View Full Code Here

  }

  public void writeTanksToNBT(NBTTagCompound data) {
    NBTTagList tagList = new NBTTagList();
    for (byte slot = 0; slot < tanks.size(); slot++) {
      StandardTank tank = tanks.get(slot);
      if (tank.getFluid() != null) {
        NBTTagCompound tag = new NBTTagCompound();
        tag.setByte("tank", slot);
        tank.writeToNBT(tag);
        tagList.appendTag(tag);
      }
    }
    data.setTag("tanks", tagList);
  }
View Full Code Here

  }

  public void writePacketData(DataOutputStream data, int tankIndex) throws IOException {
    if (tankIndex >= tanks.size())
      return;
    StandardTank tank = tanks.get(tankIndex);
    FluidStack fluidStack = tank.getFluid();
    if (fluidStack != null) {
      data.writeShort(fluidStack.fluidID);
      data.writeInt(fluidStack.amount);
      data.writeInt(fluidStack.getFluid().getColor(fluidStack));
    } else
View Full Code Here

  }

  public void readPacketData(DataInputStream data, int tankIndex) throws IOException {
    if (tankIndex >= tanks.size())
      return;
    StandardTank tank = tanks.get(tankIndex);
    int fluidId = data.readShort();
    if (fluidId != -1) {
      tank.setFluid(new FluidStack(fluidId, data.readInt()));
      tank.colorCache = data.readInt();
    } else
      tank.setFluid(null);
  }
View Full Code Here

    for (StandardTank tank : tanks)
      updateGuiData(container, crafters, tank.getTankIndex());
  }

  public void updateGuiData(Container container, List<EntityPlayerMP> crafters, int tankIndex) {
    StandardTank tank = tanks.get(tankIndex);
    FluidStack fluidStack = tank.getFluid();
    FluidStack prev = prevFluidStacks.get(tankIndex);
    int color = tank.getColor();
    int pColor = prevColor.get(tankIndex);

    for (EntityPlayerMP player : crafters) {
      if (fluidStack == null ^ prev == null) {
        int fluidId = -1;
        int fluidAmount = 0;
        if (fluidStack != null) {
          fluidId = fluidStack.fluidID;
          fluidAmount = fluidStack.amount;
        }
        player.sendProgressBarUpdate(container, tankIndex * NETWORK_DATA + 0, fluidId);
        PacketGuiInteger packet = new PacketGuiInteger(container.windowId, tankIndex * NETWORK_DATA + 1, fluidAmount);
        Proxies.net.sendToPlayer(packet, player);
      } else if (fluidStack != null && prev != null) {
        if (fluidStack.getFluid() != prev.getFluid())
          player.sendProgressBarUpdate(container, tankIndex * NETWORK_DATA + 0, fluidStack.fluidID);
        if (fluidStack.amount != prev.amount) {
          PacketGuiInteger packet = new PacketGuiInteger(container.windowId, tankIndex * NETWORK_DATA + 1, fluidStack.amount);
          Proxies.net.sendToPlayer(packet, player);
        }
        if (color != pColor) {
          PacketGuiInteger packet = new PacketGuiInteger(container.windowId, tankIndex * NETWORK_DATA + 2, color);
          Proxies.net.sendToPlayer(packet, player);
        }
      }
    }

    prevFluidStacks.set(tankIndex, tank.getFluid() == null ? null : tank.getFluid().copy());
    prevColor.set(tankIndex, color);
  }
View Full Code Here

  public void processGuiUpdate(int messageId, int data) {
    int tankIndex = messageId / NETWORK_DATA;

    if (tankIndex >= tanks.size())
      return;
    StandardTank tank = tanks.get(tankIndex);
    FluidStack fluidStack = tank.getFluid();
    if (fluidStack == null) {
      fluidStack = new FluidStack(-1, 0);
      tank.setFluid(fluidStack);
    }
    int fluidId = fluidStack.fluidID;
    int amount = fluidStack.amount;
    int color = tank.colorCache;
    boolean newLiquid = false;
    switch (messageId % NETWORK_DATA) {
    case 0:
      fluidId = data;
      newLiquid = true;
      break;
    case 1:
      amount = data;
      break;
    case 2:
      color = data;
      break;
    }
    if (newLiquid) {
      fluidStack = new FluidStack(fluidId, 0);
      tank.setFluid(fluidStack);
    }
    fluidStack.amount = amount;
    tank.colorCache = color;
  }
View Full Code Here

  public int fill(int tankIndex, FluidStack resource, boolean doFill) {
    if (tankIndex < 0 || tankIndex >= tanks.size() || resource == null)
      return 0;

    StandardTank tank = tanks.get(tankIndex);
    if (!tank.canBeFilledExternally())
      return 0;

    return tank.fill(resource, doFill);
  }
View Full Code Here

  public FluidStack drain(int tankIndex, int maxDrain, boolean doDrain) {
    if (tankIndex < 0 || tankIndex >= tanks.size())
      return null;

    StandardTank tank = tanks.get(tankIndex);
    if (!tank.canBeDrainedExternally())
      return null;

    return tank.drain(maxDrain, doDrain);
  }
View Full Code Here

  public StandardTank get(int tankIndex) {
    return tanks.get(tankIndex);
  }

  public void setCapacity(int tankIndex, int capacity) {
    StandardTank tank = get(tankIndex);
    tank.setCapacity(capacity);
    FluidStack fluidStack = tank.getFluid();
    if (fluidStack != null && fluidStack.amount > capacity)
      fluidStack.amount = capacity;
  }
View Full Code Here

TOP

Related Classes of forestry.core.fluids.tanks.StandardTank

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.