How do you detect what item was used to kill a mob?

Started by Matt The Banana on

Topic category: Help with Minecraft modding (Java Edition)

Joined Sep 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How do you detect what item was used to kill a mob?
Mon, 03/02/2020 - 00:36 (edited)

I am making an advancements mod and I want to add an advancement that is given when the player gets 100 kills with a bow. Unfortunately, I do not know how to detect if the player killed the mobs with a bow and if the player is the same, and not a different player. If I could get some help on this, it would be appreciated greatly!

Edited by Matt The Banana on Mon, 03/02/2020 - 00:36
Joined Sep 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Nevermind I found out how to…
Mon, 03/02/2020 - 00:36

Nevermind I found out how to do it.

Joined Oct 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
This sounds like it could be…
Tue, 03/03/2020 - 21:47

This sounds like it could be useful to me as well, would you mind sharing how you did it?

Joined Sep 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
What I did to solve the…
Tue, 03/03/2020 - 22:13

What I did to solve the issue was I detected what the player was holding when they killed something. Since it was a bow for me, I checked if they had a bow in their main hand, off hand, or both.

Joined Oct 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Yeah thats what I figured ^u…
Tue, 03/03/2020 - 23:12

Yeah thats what I figured ^u^; I have an identical procedure in my mod too XD