PaperMC / PaperMC/Paper

Bonemealing saplings results in tree different than the sapling due to using shared static variable for all events

Open
#13,092 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status: accepted version: 1.21.8
Dominant language
Java
Stars
12.7k
Forks
3.5k
Avg merge
3d 13h
Merged PRs (30d)
11

Description

Expected behavior

Saplings (and the resulting StructureGrowEvent TreeType) should result in the corresponding tree growing.

Observed/Actual behavior

Different plants and structures grow instead.

Steps/models to reproduce

We haven't been able to reproduce this in a small scale (development servers), only on our production server with ~40 online players spread on a large map and multiple worlds. We have a custom tree growing plugin (developed by us) that relies on the StructureGrowEvent and uses the .getSpecies() (TreeType) directly, so that value is already wrong:

This is likely due to this singleton/static value logic used in multiple places (eg. SaplingBlock.java):

org.bukkit.TreeType treeType = SaplingBlock.treeType;
SaplingBlock.treeType = null;

And this value is shared for all grow events. If an another plant grows before the bone mealing is complete, it will get replaced and grown instead.

Similar code is also used in ItemStack.java (in useOn method), I'm not sure which gets used but both rely on the same logic (depending on TreeGrower.java to set the value).

Plugin and Datapack List

Custom plugins: Abydos, AbydosPluginCheck

Apollo-Bukkit, BlueMap, CoreProtect, FastAsyncWorldEdit, GSit, InvSeePlusPlus, LuckPerms, Multiverse-Core, packetevents, ProtocollLib, SimpleWarps, SuperVanish, WorldGuard

Paper version

This server is running Paper version 1.21.8-60-main@29c8822 (2025-09-06T21:49:13Z) (Implementing API version 1.21.8-R0.1-SNAPSHOT)

Other

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading SaplingBlock.java, ItemStack.java, and TreeGrower.java to trace how TreeType is set and consumed during growth. Check how concurrent growth can share that state, then verify that each StructureGrowEvent reports the corresponding sapling after the change, including under simultaneous growth in multiple worlds.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.