fix #33 inventory desync

This commit is contained in:
Flemmli97 2021-04-11 23:14:38 +02:00
parent 5c9403cf7c
commit b5a560e11f

View File

@ -76,18 +76,19 @@ public abstract class ServerOnlyScreenHandler extends ScreenHandler {
if (this.isRightSlot(i)) if (this.isRightSlot(i))
this.handleSlotClicked((ServerPlayerEntity) playerEntity, i, slot, j); this.handleSlotClicked((ServerPlayerEntity) playerEntity, i, slot, j);
this.sendContentUpdates(); this.sendContentUpdates();
return ItemStack.EMPTY; ((ServerPlayerEntity) playerEntity).updateCursorStack();
return this.inventory.getStack(i);
} }
@Override @Override
public ItemStack transferSlot(PlayerEntity player, int index) { public ItemStack transferSlot(PlayerEntity player, int index) {
if (!(player instanceof ServerPlayerEntity)) if (index < 0)
return ItemStack.EMPTY; return ItemStack.EMPTY;
Slot slot = this.slots.get(index); Slot slot = this.slots.get(index);
if (this.isRightSlot(index)) if (this.isRightSlot(index))
this.handleSlotClicked((ServerPlayerEntity) player, index, slot, 0); this.handleSlotClicked((ServerPlayerEntity) player, index, slot, 0);
this.sendContentUpdates(); this.sendContentUpdates();
return ItemStack.EMPTY; return this.inventory.getStack(index);
} }
@Override @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); protected abstract boolean isRightSlot(int slot);
/** /**