@Override public synchronized void merge(FluidNetwork network) { if (network != null && network != this) { Set<FluidNetwork> networks = new HashSet<FluidNetwork>(); networks.add(this); networks.add(network); FluidNetwork newNetwork = create(networks); newNetwork.refresh(); } }
@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; }
@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; }
@Override public void preSingleMerge(FluidNetwork network) { if (cacheFluid != null) { if (network.fluidStored == null) { network.fluidStored = cacheFluid; } else { network.fluidStored.amount += cacheFluid.amount; } cacheFluid = null; } }
@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; }
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(); }