Skip to content

Fix entity counts drifting above reality#273

Merged
tastybento merged 1 commit into
BentoBoxWorld:developfrom
daniel-skopek:develop
Jul 5, 2026
Merged

Fix entity counts drifting above reality#273
tastybento merged 1 commit into
BentoBoxWorld:developfrom
daniel-skopek:develop

Conversation

@daniel-skopek

@daniel-skopek daniel-skopek commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes persistent entity count drift where limits would show more mobs
than actually existed on the island. After a recount (/calc) the real
(lower) count would appear.

Changes

entityIslandMap + EntityAddToWorldEvent

Maps entity UUID to island ID so decrement always targets the correct
island, even when the entity wanders off-island before dying. The map
was transient — lost on every restart. An EntityAddToWorldEvent handler
now repopulates it when chunks load. A justPortaled debounce list
prevents double-decrement if EntityRemoveEvent fires for the
source-world removal during a portal teleport.

Entity change persistence

incrementEntity/decrementEntity called setChanged() but never triggered
a save — only block changes called updateSaveMap. Entity-only changes
were only persisted on onDisable(). Added markChanged() on
BlockLimitsListener so entity changes join the batch-save cycle
(every 10 changes), ensuring counts survive restarts even without
block activity on the island.

Testing

132 tests pass across EntityLimitListenerTest, BlockLimitsListenerTest,
JoinListenerTest, PaperShulkerLimitListenerTest, and others.

@tastybento tastybento self-assigned this Jul 5, 2026
@tastybento

Copy link
Copy Markdown
Member

Thanks!

@tastybento tastybento merged commit 9f0963d into BentoBoxWorld:develop Jul 5, 2026
1 check failed
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