Does a player get credit for a kill if an environmental block actually does the final kill? [duplicate]

Working on a guardian farm, and I'm not certain about the mechanics here. Will I get credit for the kill if I am able to hit the guardians once, but let the campfire under the guardians, or the lava they're swimming in take the final kill?


Yes, but only if you've hit the Guardians about 5 seconds before they die, no matter how they do it (e.g. death from fire, lava, suffocation, other mobs, etc.). Be careful, though, as cactus, fire and lava might destroy their drops too.