mirror of
https://github.com/Ellpeck/PrettyPipes.git
synced 2024-12-22 15:39:22 +01:00
parent
27e6fa7f79
commit
87a3c2aed6
2 changed files with 9 additions and 14 deletions
|
@ -16,28 +16,28 @@ public class FilterSlot extends SlotItemHandler {
|
|||
this.onlyOneItem = onlyOneItem;
|
||||
}
|
||||
|
||||
public static boolean checkFilter(AbstractContainerMenu container, int slotId, Player player) {
|
||||
if (slotId >= 0 && slotId < container.slots.size()) {
|
||||
var slot = container.getSlot(slotId);
|
||||
public static boolean checkFilter(AbstractContainerMenu menu, int slotId) {
|
||||
if (slotId >= 0 && slotId < menu.slots.size()) {
|
||||
var slot = menu.getSlot(slotId);
|
||||
if (slot instanceof FilterSlot) {
|
||||
((FilterSlot) slot).slotClick(player);
|
||||
((FilterSlot) slot).slotClick(menu);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void slotClick(Player player) {
|
||||
var heldStack = player.inventoryMenu.getCarried();
|
||||
private void slotClick(AbstractContainerMenu menu) {
|
||||
var heldStack = menu.getCarried();
|
||||
var stackInSlot = this.getItem();
|
||||
|
||||
if (!stackInSlot.isEmpty() && heldStack.isEmpty()) {
|
||||
this.safeInsert(ItemStack.EMPTY);
|
||||
this.set(ItemStack.EMPTY);
|
||||
} else if (!heldStack.isEmpty()) {
|
||||
var s = heldStack.copy();
|
||||
if (this.onlyOneItem)
|
||||
s.setCount(1);
|
||||
this.safeInsert(s);
|
||||
this.set(s);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -46,11 +46,6 @@ public class FilterSlot extends SlotItemHandler {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack safeInsert(ItemStack stack) {
|
||||
return super.safeInsert(stack.copy());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mayPickup(Player playerIn) {
|
||||
return false;
|
||||
|
|
|
@ -52,7 +52,7 @@ public abstract class AbstractPipeContainer<T extends IModule> extends AbstractC
|
|||
|
||||
@Override
|
||||
public void clicked(int slotId, int dragType, ClickType clickTypeIn, Player player) {
|
||||
if (FilterSlot.checkFilter(this, slotId, player))
|
||||
if (FilterSlot.checkFilter(this, slotId))
|
||||
return;
|
||||
super.clicked(slotId, dragType, clickTypeIn, player);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue