fixed stack limiters ignoring data filters

partially addresses #175
This commit is contained in:
Ell 2023-09-26 10:56:24 +02:00
parent 7d54b5d936
commit 2ab1b907de

View file

@ -4,6 +4,7 @@ import de.ellpeck.prettypipes.Registry;
import de.ellpeck.prettypipes.items.IModule; import de.ellpeck.prettypipes.items.IModule;
import de.ellpeck.prettypipes.items.ModuleItem; import de.ellpeck.prettypipes.items.ModuleItem;
import de.ellpeck.prettypipes.misc.ItemEquality; import de.ellpeck.prettypipes.misc.ItemEquality;
import de.ellpeck.prettypipes.misc.ItemFilter;
import de.ellpeck.prettypipes.pipe.PipeBlockEntity; import de.ellpeck.prettypipes.pipe.PipeBlockEntity;
import de.ellpeck.prettypipes.pipe.containers.AbstractPipeContainer; import de.ellpeck.prettypipes.pipe.containers.AbstractPipeContainer;
import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Inventory;
@ -42,6 +43,7 @@ public class StackSizeModuleItem extends ModuleItem {
@Override @Override
public int getMaxInsertionAmount(ItemStack module, PipeBlockEntity tile, ItemStack stack, IItemHandler destination) { public int getMaxInsertionAmount(ItemStack module, PipeBlockEntity tile, ItemStack stack, IItemHandler destination) {
var types = ItemFilter.getEqualityTypes(tile);
var max = StackSizeModuleItem.getMaxStackSizeForModule(module); var max = StackSizeModuleItem.getMaxStackSizeForModule(module);
if (StackSizeModuleItem.getLimitToMaxStackSize(module)) if (StackSizeModuleItem.getLimitToMaxStackSize(module))
max = Math.min(max, stack.getMaxStackSize()); max = Math.min(max, stack.getMaxStackSize());
@ -50,7 +52,7 @@ public class StackSizeModuleItem extends ModuleItem {
var stored = destination.getStackInSlot(i); var stored = destination.getStackInSlot(i);
if (stored.isEmpty()) if (stored.isEmpty())
continue; continue;
if (!ItemEquality.compareItems(stored, stack)) if (!ItemEquality.compareItems(stored, stack, types))
continue; continue;
amount += stored.getCount(); amount += stored.getCount();
if (amount >= max) if (amount >= max)
@ -73,4 +75,5 @@ public class StackSizeModuleItem extends ModuleItem {
public AbstractPipeContainer<?> getContainer(ItemStack module, PipeBlockEntity tile, int windowId, Inventory inv, Player player, int moduleIndex) { public AbstractPipeContainer<?> getContainer(ItemStack module, PipeBlockEntity tile, int windowId, Inventory inv, Player player, int moduleIndex) {
return new StackSizeModuleContainer(Registry.stackSizeModuleContainer, windowId, player, tile.getBlockPos(), moduleIndex); return new StackSizeModuleContainer(Registry.stackSizeModuleContainer, windowId, player, tile.getBlockPos(), moduleIndex);
} }
} }