* @param to has to provide {@link InventoryComponent} for a successful transfer
* @param toSlots slots that will be checked if they contain already the same type of item and have space
* @return true if any amount > 0 got moved to the target
*/
static boolean moveToExistingStacksInSlots(EntityRef from, int fromSlot, EntityRef to, List<Integer> toSlots) {
EntityRef fromItem = getItemAt(from, fromSlot);
ItemComponent fromItemComp = fromItem.getComponent(ItemComponent.class);
if (fromItemComp == null) {
return false;
}
int newFromStackCount = fromItemComp.stackCount;
int slotCount = getSlotCount(to);
for (int toSlot :toSlots) {
EntityRef toItem = getItemAt(to, toSlot);
if (isSameItem(toItem, fromItem)) {
ItemComponent toItemComp = toItem.getComponent(ItemComponent.class);
if (toItemComp == null) {
continue;
}
int spaceLeft = toItemComp.maxStackSize - toItemComp.stackCount ;
if (spaceLeft > 0) {