Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send the inventory after the action has been processed in case the action is cancelled #882

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions server/session/handler_inventory_transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ func (h *InventoryTransactionHandler) handleUseItemOnEntityTransaction(data *pro
}
if !valid {
slot := int(s.heldSlot.Load())
item, _ := s.inv.Item(slot)
s.sendItem(item, slot, protocol.WindowIDInventory)
i, _ := s.inv.Item(slot)
s.sendItem(i, slot, protocol.WindowIDInventory)
}
return nil
}
Expand All @@ -147,11 +147,11 @@ func (h *InventoryTransactionHandler) handleUseItemTransaction(data *protocol.Us
s.swingingArm.Store(true)
defer s.swingingArm.Store(false)

// We reset the inventory so that we can send the held item update without the client already
// having done that client-side.
// Because of the new inventory system, the client will expect a transaction confirmation, but instead of doing that
// We reset the inventory so that we can send the held item update without the client having already done that client-side.
// Due to the new inventory system, the client will expect a transaction confirmation. However, instead of doing that,
// it's much easier to just resend the inventory.
h.resendInventories(s)
// This is also necessary in case the action is cancelled.
defer h.resendInventories(s)

switch data.ActionType {
case protocol.UseItemActionBreakBlock:
Expand Down
Loading