Compare commits

...

3 commits

Author SHA1 Message Date
Ell
5dfeb8ad48 update 2021-12-05 19:54:35 +01:00
Ell
416e5ced97 Fixed a crafting terminal exception
Closes #103
2021-12-05 19:50:26 +01:00
Ell
87a3c2aed6 fixed items not being placeable into filter slots
Closes #104
2021-12-05 19:41:59 +01:00
4 changed files with 13 additions and 18 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.1' version = '1.10.2'
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 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;

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, player)) if (FilterSlot.checkFilter(this, slotId))
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 addDataSlots(ContainerData data) { protected void addOwnSlots(Player player) {
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(this.player, this.craftInventory, this.craftResult, 0, 25, 77)); this.addSlot(new ResultSlot(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.addDataSlots(data); super.addOwnSlots(player);
} }
@Override @Override