use of org.spongepowered.api.block.tileentity.carrier.Dropper in project modules-extra by CubeEngine.
the class Network method activate.
public void activate(Inventory inventory, List<ItemStack> filters) {
if (isStorage()) {
pullFromStorage(inventory, filters);
return;
}
for (Map.Entry<Location<World>, DuctData> entry : exitPoints.entrySet()) {
Inventory pollFrom = inventory;
Location<World> loc = entry.getKey();
DuctData data = entry.getValue();
Direction dir = loc.get(Keys.DIRECTION).orElse(Direction.NONE).getOpposite();
Location<World> targetLoc = loc.getRelative(dir.getOpposite());
TileEntity te = targetLoc.getTileEntity().get();
Inventory target = ((Carrier) te).getInventory();
if (te instanceof Dropper) {
Network nw = manager.findNetwork(targetLoc);
nw.transferToStorage(queryFiltered(filters, inventory), data.get(dir).get());
continue;
}
if (te instanceof Chest) {
target = ((Chest) te).getDoubleChestInventory().orElse(target);
}
Optional<List<ItemStack>> targetFilter = data.get(dir);
if (targetFilter.isPresent()) {
if (// Only allow to extract items in the filter
!filters.isEmpty()) {
// TODO more filters
pollFrom = queryFiltered(filters, inventory);
}
Inventory pollFromTo = pollFrom;
if (// Only allow to insert items in the filter
!targetFilter.get().isEmpty()) {
// TODO more filters
pollFromTo = queryFiltered(targetFilter.get(), inventory);
}
// For all filtered slots
doTransfer(pollFromTo, target);
}
}
}
Aggregations