Skip to content

Commit

Permalink
fix: Items voiding in filters
Browse files Browse the repository at this point in the history
Also reduce count to 1, as it is not needed on filters.

Closes: GH-769
  • Loading branch information
Rover656 committed Sep 29, 2024
1 parent 88c01d9 commit f8cd179
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,14 @@ public void setInverted(Boolean inverted) {
@Override
public void doClick(int slotId, int button, ClickType clickType, Player player) {
if (slotId >= 0 && slotId < capability.size()) {
if (clickType == ClickType.PICKUP) {
if (!capability.getEntry(slotId).isEmpty()) {
capability.setEntry(slotId, FluidStack.EMPTY);
}
} else if (clickType == ClickType.SWAP) {
// Only allow PICKUP (click) or QUICK_MOVE (shift + click) events.
if (clickType != ClickType.PICKUP && clickType != ClickType.QUICK_MOVE) {
return;
}

if (!capability.getEntry(slotId).isEmpty()) {
capability.setEntry(slotId, FluidStack.EMPTY);
}
}

super.doClick(slotId, button, clickType, player);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public ItemFilterMenu(int pContainerId, Inventory inventory, ItemStack stack) {
this(EIOMenus.ITEM_FILTER.get(), pContainerId, inventory, stack);
}

public static ItemFilterMenu factory(int pContainerId, Inventory inventory, FriendlyByteBuf buf) {
public static ItemFilterMenu factory(int pContainerId, Inventory inventory, FriendlyByteBuf buf) {
return new ItemFilterMenu(EIOMenus.ITEM_FILTER.get(), pContainerId, inventory, inventory.player.getMainHandItem());
}

Expand Down Expand Up @@ -94,13 +94,14 @@ public void setInverted(Boolean inverted) {
@Override
public void doClick(int slotId, int button, ClickType clickType, Player player) {
if (slotId >= 0 && slotId < capability.size()) {
if (clickType == ClickType.PICKUP) {
if (!capability.getEntry(slotId).isEmpty()) {
capability.setEntry(slotId, ItemStack.EMPTY);
}
} else if (clickType == ClickType.SWAP) {
// Only allow PICKUP (click) or QUICK_MOVE (shift + click) events.
if (clickType != ClickType.PICKUP && clickType != ClickType.QUICK_MOVE) {
return;
}

if (!capability.getEntry(slotId).isEmpty()) {
capability.setEntry(slotId, ItemStack.EMPTY);
}
}

super.doClick(slotId, button, clickType, player);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public ItemStack getItem() {

@Override
public void set(ItemStack pStack) {
consumer.accept(pStack);
consumer.accept(pStack.copyWithCount(1));
setChanged();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,14 @@ public void setInverted(Boolean inverted) {
@Override
public void doClick(int slotId, int button, ClickType clickType, Player player) {
if (slotId >= 0 && slotId < capability.size()) {
if (clickType == ClickType.PICKUP) {
if (!capability.getEntry(slotId).isEmpty()) {
capability.setEntry(slotId, ChemicalStack.EMPTY);
}
} else if (clickType == ClickType.SWAP) {
// Only allow PICKUP (click) or QUICK_MOVE (shift + click) events.
if (clickType != ClickType.PICKUP && clickType != ClickType.QUICK_MOVE) {
return;
}

if (!capability.getEntry(slotId).isEmpty()) {
capability.setEntry(slotId, ChemicalStack.EMPTY);
}
}

super.doClick(slotId, button, clickType, player);
Expand Down

0 comments on commit f8cd179

Please sign in to comment.