Ejemplo n.º 1
0
  @Override
  public void onNetworksCreated(List<FluidNetwork> networks) {
    if (fluidStored != null && FMLCommonHandler.instance().getEffectiveSide().isServer()) {
      int[] caps = new int[networks.size()];
      int cap = 0;

      for (FluidNetwork network : networks) {
        caps[networks.indexOf(network)] = network.getCapacity();
        cap += network.getCapacity();
      }

      fluidStored.amount = Math.min(cap, fluidStored.amount);

      int[] values = ListUtils.calcPercentInt(ListUtils.percent(caps), fluidStored.amount);

      for (FluidNetwork network : networks) {
        int index = networks.indexOf(network);

        if (values[index] > 0) {
          network.fluidStored = new FluidStack(fluidStored.getFluid(), values[index]);
          network.fluidScale = network.getScale();
          network.refFluid = fluidStored.getFluid();
        }
      }
    }

    fluidScale = 0;
    fluidStored = null;
    refFluid = null;
  }
Ejemplo n.º 2
0
  public FluidNetwork(Set<FluidNetwork> networks) {
    for (FluidNetwork net : networks) {
      if (net != null) {
        if (FMLCommonHandler.instance().getEffectiveSide().isClient()) {
          if (net.refFluid != null && net.fluidScale > fluidScale) {
            refFluid = net.refFluid;
            fluidScale = net.fluidScale;
            fluidStored = net.fluidStored;

            net.fluidScale = 0;
            net.refFluid = null;
            net.fluidStored = null;
          }
        } else {
          if (net.fluidStored != null) {
            if (fluidStored == null) {
              fluidStored = net.fluidStored;
            } else {
              fluidStored.amount += net.fluidStored.amount;
            }

            net.fluidStored = null;
          }
        }

        addAllTransmitters(net.transmitters);
        net.deregister();
      }
    }

    fluidScale = getScale();

    refresh();
    register();
  }
Ejemplo n.º 3
0
  @Override
  protected FluidNetwork create(Collection<IGridTransmitter<FluidNetwork>> collection) {
    FluidNetwork network = new FluidNetwork(collection);
    network.refFluid = refFluid;

    if (fluidStored != null) {
      if (network.fluidStored == null) {
        network.fluidStored = fluidStored;
      } else {
        network.fluidStored.amount += fluidStored.amount;
      }
    }

    network.fluidScale = network.getScale();

    return network;
  }
Ejemplo n.º 4
0
  @Override
  protected FluidNetwork create(IGridTransmitter<FluidNetwork>... varTransmitters) {
    FluidNetwork network = new FluidNetwork(varTransmitters);
    network.refFluid = refFluid;

    if (fluidStored != null) {
      if (network.fluidStored == null) {
        network.fluidStored = fluidStored;
      } else {
        network.fluidStored.amount += fluidStored.amount;
      }
    }

    network.fluidScale = network.getScale();

    fluidScale = 0;
    refFluid = null;
    fluidStored = null;

    return network;
  }