mirror of
https://github.com/Ellpeck/PrettyPipes.git
synced 2024-11-22 11:53:29 +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;
|
this.onlyOneItem = onlyOneItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean checkFilter(AbstractContainerMenu container, int slotId, Player player) {
|
public static boolean checkFilter(AbstractContainerMenu menu, int slotId) {
|
||||||
if (slotId >= 0 && slotId < container.slots.size()) {
|
if (slotId >= 0 && slotId < menu.slots.size()) {
|
||||||
var slot = container.getSlot(slotId);
|
var slot = menu.getSlot(slotId);
|
||||||
if (slot instanceof FilterSlot) {
|
if (slot instanceof FilterSlot) {
|
||||||
((FilterSlot) slot).slotClick(player);
|
((FilterSlot) slot).slotClick(menu);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void slotClick(Player player) {
|
private void slotClick(AbstractContainerMenu menu) {
|
||||||
var heldStack = player.inventoryMenu.getCarried();
|
var heldStack = menu.getCarried();
|
||||||
var stackInSlot = this.getItem();
|
var stackInSlot = this.getItem();
|
||||||
|
|
||||||
if (!stackInSlot.isEmpty() && heldStack.isEmpty()) {
|
if (!stackInSlot.isEmpty() && heldStack.isEmpty()) {
|
||||||
this.safeInsert(ItemStack.EMPTY);
|
this.set(ItemStack.EMPTY);
|
||||||
} else if (!heldStack.isEmpty()) {
|
} else if (!heldStack.isEmpty()) {
|
||||||
var s = heldStack.copy();
|
var s = heldStack.copy();
|
||||||
if (this.onlyOneItem)
|
if (this.onlyOneItem)
|
||||||
s.setCount(1);
|
s.setCount(1);
|
||||||
this.safeInsert(s);
|
this.set(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,11 +46,6 @@ public class FilterSlot extends SlotItemHandler {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ItemStack safeInsert(ItemStack stack) {
|
|
||||||
return super.safeInsert(stack.copy());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean mayPickup(Player playerIn) {
|
public boolean mayPickup(Player playerIn) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -52,7 +52,7 @@ public abstract class AbstractPipeContainer<T extends IModule> extends AbstractC
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void clicked(int slotId, int dragType, ClickType clickTypeIn, Player player) {
|
public void clicked(int slotId, int dragType, ClickType clickTypeIn, Player player) {
|
||||||
if (FilterSlot.checkFilter(this, slotId, player))
|
if (FilterSlot.checkFilter(this, slotId))
|
||||||
return;
|
return;
|
||||||
super.clicked(slotId, dragType, clickTypeIn, player);
|
super.clicked(slotId, dragType, clickTypeIn, player);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue