Compare commits

..

No commits in common. "5dfeb8ad482dfafde86d816286fd496b721bad03" and "27e6fa7f79205eb9434bf97e099e31100b88f280" have entirely different histories.

4 changed files with 18 additions and 13 deletions

View file

@ -13,7 +13,7 @@ apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'eclipse' apply plugin: 'eclipse'
apply plugin: 'maven-publish' apply plugin: 'maven-publish'
version = '1.10.2' version = '1.10.1'
group = 'de.ellpeck.prettypipes' // http://maven.apache.org/guides/mini/guide-naming-conventions.html group = 'de.ellpeck.prettypipes' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = 'PrettyPipes' archivesBaseName = 'PrettyPipes'

View file

@ -16,28 +16,28 @@ public class FilterSlot extends SlotItemHandler {
this.onlyOneItem = onlyOneItem; this.onlyOneItem = onlyOneItem;
} }
public static boolean checkFilter(AbstractContainerMenu menu, int slotId) { public static boolean checkFilter(AbstractContainerMenu container, int slotId, Player player) {
if (slotId >= 0 && slotId < menu.slots.size()) { if (slotId >= 0 && slotId < container.slots.size()) {
var slot = menu.getSlot(slotId); var slot = container.getSlot(slotId);
if (slot instanceof FilterSlot) { if (slot instanceof FilterSlot) {
((FilterSlot) slot).slotClick(menu); ((FilterSlot) slot).slotClick(player);
return true; return true;
} }
} }
return false; return false;
} }
private void slotClick(AbstractContainerMenu menu) { private void slotClick(Player player) {
var heldStack = menu.getCarried(); var heldStack = player.inventoryMenu.getCarried();
var stackInSlot = this.getItem(); var stackInSlot = this.getItem();
if (!stackInSlot.isEmpty() && heldStack.isEmpty()) { if (!stackInSlot.isEmpty() && heldStack.isEmpty()) {
this.set(ItemStack.EMPTY); this.safeInsert(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.set(s); this.safeInsert(s);
} }
} }
@ -46,6 +46,11 @@ 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;

View file

@ -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)) if (FilterSlot.checkFilter(this, slotId, player))
return; return;
super.clicked(slotId, dragType, clickTypeIn, player); super.clicked(slotId, dragType, clickTypeIn, player);
} }

View file

@ -27,14 +27,14 @@ public class CraftingTerminalContainer extends ItemTerminalContainer {
} }
@Override @Override
protected void addOwnSlots(Player player) { protected void addDataSlots(ContainerData data) {
this.craftInventory = new WrappedCraftingInventory(this.getTile().craftItems, this, 3, 3); this.craftInventory = new WrappedCraftingInventory(this.getTile().craftItems, this, 3, 3);
this.craftResult = new ResultContainer(); this.craftResult = new ResultContainer();
this.addSlot(new ResultSlot(player, this.craftInventory, this.craftResult, 0, 25, 77)); this.addSlot(new ResultSlot(this.player, this.craftInventory, this.craftResult, 0, 25, 77));
for (var i = 0; i < 3; i++) for (var i = 0; i < 3; i++)
for (var j = 0; j < 3; j++) for (var j = 0; j < 3; j++)
this.addSlot(new Slot(this.craftInventory, j + i * 3, 7 + j * 18, 18 + i * 18)); this.addSlot(new Slot(this.craftInventory, j + i * 3, 7 + j * 18, 18 + i * 18));
super.addOwnSlots(player); super.addDataSlots(data);
} }
@Override @Override