#Accessing player who grew a sapling

3 messages · Page 1 of 1 (latest)

real trellis
#

I'm trying to port a Spigot plugin of mine that implements a robust claims system into Fabric. This mod is server-side only. I'm most of the way through, but one event that's escaping me is StructureGrowEvent.

In Spigot, I have access to the player that caused the StructureGrowEvent if there was one, (person who bonemealed a mushroom or a sapling,) but in Fabric as best as I can tell, the last time a player comes into the equation is BoneMealItem#useOnFertilizable. I'd like to somehow find the player that bonemealed, (or even planted the sapling,) when the tree is generated.

My current mixin is at the head of TreeFeature#canReplace, and that seems to be the method I want after messing with it some. Any ideas I could explore?

digital narwhal
#

the game itself doesnt track if a sapling was naturally generated or a player (or enderman) placed it.

you can use mixin to WrapOperation the useOnFertilizable, though if you are doing a claim system, an easier mechanism might be to just handle item and block usages in a listener

#

UseItemCallback, UseBlockCallback, AttackBlockCallback, AttackEntityCallback, PlayerBlockBreakEvents, etc