Skip to content

Fix container break#19

Closed
Janschuri wants to merge 1 commit intodevelopfrom
fix-container-break
Closed

Fix container break#19
Janschuri wants to merge 1 commit intodevelopfrom
fix-container-break

Conversation

@Janschuri
Copy link
Copy Markdown
Owner

No description provided.

Copilot AI review requested due to automatic review settings February 21, 2026 17:28
@Janschuri Janschuri changed the base branch from master to develop February 21, 2026 17:28
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adjusts how LunaticStorage updates storage state when a storage container block is broken, aiming to correctly account for items removed from the container at break time.

Changes:

  • Add debug logging when a storage container is broken.
  • Compute the “removed items” difference based on BlockDropItemEvent drops rather than the container inventory contents.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 144 to +146
StorageContainer storageContainer = StorageContainer.getStorageContainer(block);
Map<ItemStack, Integer> difference = Utils.itemStackArrayToMap(storageContainer.getInventory().getContents(), true);
ItemStack[] contents = event.getItems().stream().map(Item::getItemStack).toArray(ItemStack[]::new);
Map<ItemStack, Integer> difference = Utils.itemStackArrayToMap(contents, true);
Copy link

Copilot AI Feb 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

contents is derived from event.getItems(), which represents all drops (including the container block item itself) and may be empty/sanitized by gamerules or other plugins. That can cause difference to subtract the wrong items (e.g., remove a CHEST item that was never in the inventory) or fail to subtract anything when drops are suppressed, leaving storage totals inconsistent. Prefer reading the pre-break inventory from event.getBlockState() (cast to Container/Chest and use its inventory snapshot) so the update reflects the container’s actual contents independent of drop behavior.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 10aeeaf447

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +145 to +146
ItemStack[] contents = event.getItems().stream().map(Item::getItemStack).toArray(ItemStack[]::new);
Map<ItemStack, Integer> difference = Utils.itemStackArrayToMap(contents, true);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Exclude container block drop when building storage diff

Computing difference from event.getItems() includes every dropped entity from the break, including the storage container block itself, not just the container inventory contents. In updateStorage, that extra item is applied as a negative delta, so breaking a container subtracts one block item (e.g. chest/barrel) from the storage map every time and can even create negative counts when that block type was never stored. This corrupts storage totals and downstream item retrieval behavior for container-break events.

Useful? React with 👍 / 👎.

@Janschuri Janschuri closed this Feb 21, 2026
@Janschuri Janschuri deleted the fix-container-break branch February 21, 2026 20:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants