Skip to content

Fix leaf persistent/check-decay flags being swapped - #2289

Open
zisunny104 wants to merge 2 commits into
CloudburstMC:masterfrom
zisunny104:fix/leaf-persistent-flags
Open

zisunny104 wants to merge 2 commits into
CloudburstMC:masterfrom
zisunny104:fix/leaf-persistent-flags

Conversation

@zisunny104

Copy link
Copy Markdown

BlockLeaves reads and writes the two decay-related flags on the wrong bits, so leaves that should be persistent decay, and player-placed leaves are not persistent.

The bundled palette (runtime_block_states.dat) maps the block states like this:

Block meta persistent_bit update_bit
oak_leaves (18) 4 0 1
oak_leaves (18) 8 1 0
azalea / cherry / mangrove leaves 1 0 1
azalea / cherry / mangrove leaves 2 1 0

So for the base leaves persistent is 0x08 and the update/check-decay flag is 0x04. BlockLeaves had them the other way round:

  • isPersistent() checked 0x04, isCheckDecay() checked 0x08, and both setters wrote the opposite bit. A leaf loaded as persistent_bit=1 (meta 8) therefore reports persistent=false, checkDecay=true and is removed by the next random tick when no log is nearby.
  • place() calls setPersistent(true), which set 0x04, i.e. the update bit, not the persistent bit.
  • In BlockAzaleaLeaves, BlockCherryLeaves and BlockLeavesMangrove, setPersistent() cleared bit 1 (~1, the update bit) instead of bit 2 (~2). It wiped the update flag and could not clear persistence.

Changes

  • BlockLeaves: isPersistent/setPersistent use 0x08; isCheckDecay/setCheckDecay use 0x04.
  • Azalea, cherry and mangrove leaves: setPersistent clears ~2 so only the persistent bit changes. Flowering azalea inherits the fix.
  • Species bits and the decay logic itself are unchanged.

Testing

  • Read the palette entries for oak, azalea, cherry and mangrove leaves in runtime_block_states.dat and checked the getters/setters against them by reading the code. The other leaf types were not individually checked.
  • Checked manually on a local server built from this branch: a leaf block placed with no log nearby stays in place.

🤖 Generated with Claude Code

BlockLeaves read and wrote persistent on 0x04 and check-decay on 0x08,
the opposite of the block palette (persistent_bit = 0x08, update_bit =
0x04 for oak/spruce/birch/jungle/acacia/dark oak). Azalea, cherry and
mangrove leaves cleared the update bit instead of the persistent bit in
setPersistent().

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings October 14, 2026 18:05

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@PetteriM1

Copy link
Copy Markdown
Member

The problem is what happens to already placed leaves after this change

@zisunny104

Copy link
Copy Markdown
Author

我是因為發現地圖內由玩家放置的樹葉方塊建築開始消失,才發現一些方塊的狀態可能錯誤設置。

經過這樣的修正,手動放置的樹葉方塊就不會自然消失(錯誤狀態)了。


I discovered that some block states might have been set incorrectly after noticing that leaf block structures placed by players in the world were starting to disappear.

With this fix, manually placed leaf blocks will no longer decay naturally due to incorrect block states.

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.

3 participants