From b5a560e11f9fc825c27154a3c5291105ae29944a Mon Sep 17 00:00:00 2001 From: Flemmli97 Date: Sun, 11 Apr 2021 23:14:38 +0200 Subject: [PATCH] fix #33 inventory desync --- .../flan/gui/ServerOnlyScreenHandler.java | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/flemmli97/flan/gui/ServerOnlyScreenHandler.java b/src/main/java/com/flemmli97/flan/gui/ServerOnlyScreenHandler.java index bf8f4e3..73bc7c8 100644 --- a/src/main/java/com/flemmli97/flan/gui/ServerOnlyScreenHandler.java +++ b/src/main/java/com/flemmli97/flan/gui/ServerOnlyScreenHandler.java @@ -76,18 +76,19 @@ public abstract class ServerOnlyScreenHandler extends ScreenHandler { if (this.isRightSlot(i)) this.handleSlotClicked((ServerPlayerEntity) playerEntity, i, slot, j); this.sendContentUpdates(); - return ItemStack.EMPTY; + ((ServerPlayerEntity) playerEntity).updateCursorStack(); + return this.inventory.getStack(i); } @Override public ItemStack transferSlot(PlayerEntity player, int index) { - if (!(player instanceof ServerPlayerEntity)) + if (index < 0) return ItemStack.EMPTY; Slot slot = this.slots.get(index); if (this.isRightSlot(index)) this.handleSlotClicked((ServerPlayerEntity) player, index, slot, 0); this.sendContentUpdates(); - return ItemStack.EMPTY; + return this.inventory.getStack(index); } @Override @@ -99,18 +100,6 @@ public abstract class ServerOnlyScreenHandler extends ScreenHandler { } } - @Override - public void sendContentUpdates() { - int j; - for (j = 0; j < this.slots.size(); ++j) { - ItemStack itemStack = this.slots.get(j).getStack(); - - for (ScreenHandlerListener screenHandlerListener : this.listeners) { - screenHandlerListener.onSlotUpdate(this, j, itemStack.copy()); - } - } - } - protected abstract boolean isRightSlot(int slot); /**