Trigger an action when player harvests from a planterSolved

Hiya,

I'm trying to trigger an action when the player harvests seeds from a planter but am not sure how best to do this - I keep getting NREs trying to use OnEntityDeath and I don't see any farming specific hooks in the docs.

My current code:

		void OnEntityDeath(BaseCombatEntity entity, HitInfo info) {

			string prefab = entity.ShortPrefabName;

			if (prefab != null) {

				if (prefab.Contains("_berry.entity")) {

					if ((info.Initiator) && (info.Initiator.ToPlayer() != null)) {​
The code above just tries to determine what is being destroyed (berry entities currently) but fails with a NRE - I suspect relating to the info.Initiator.ToPlayer()

Anyone able to put me on the right path?

Thanks in advance.

Found a Farming specific hook I could use - worked perfectly.

Locked automatically