Checking the item the player is holding.

Started by DimaFsn on

Topic category: Help with Minecraft modding (Java Edition)

Joined Jun 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Checking the item the player is holding.

Please tell me the procedure that checks the object of the holding player with the right click.

Joined Nov 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
https://imgur.com/a/DgY2E3g…
Sun, 07/11/2021 - 22:27

https://imgur.com/a/DgY2E3g 

this will make it so if the player holds, lets say a diamond axe it will send a message to him. now if you want it to not do anything if he has, again lets say an axe it will say " yo! that's not an axe" if the player right clicks without an axe, use the "not" block before the red block that checks for the item in the players hand

Joined Jun 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
New Procedure Global Trigger…
Sun, 07/11/2021 - 22:31

New Procedure

Global Trigger should be Player uses Item

If Provided Item Stack = [item your checking for]

  • Do a thing

 

Joined Jun 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Thanks.
Tue, 08/03/2021 - 15:49

Thanks.

Joined Aug 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I use this scheme  New…
Wed, 06/05/2024 - 15:06

I use this scheme 

New Procedure

Global Trigger should be Player uses Item

If Provided Item Stack = [item your checking for]

  • Do a thing

and it don't work, please help me somebody

Joined Aug 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Cracked it!  Do all the…
Sun, 08/11/2024 - 13:21

Cracked it! 

Do all the standard stuff of Global trigger being Player right clicks with item (or left clicks with item, if you're nasty)

Then set up an If-do statment. Then you're going to want three blocks. The first is "Item in main-hand of event/target entity" which can be found in the data tab of Entity procedures. The second is the first red block in the Minecraft components section. The third is the red blank = blank block from the Logic section, and is the one you'll want to stick the first two in. 

You want to tell the red block what item you'd like it to look for in your guys main hand, then voila! The second half of your if statement will only work if the player is holding what you've said they should be holding.

BONUS:

Though I'll admit to not being fully sure how this next bit works, I had some success using the "source entity" tag instead of the "event/target entity" tag in conjunction with the "When right clicked on entity" trigger. This meant I was able to have a modded creature drop an item when I tried to shear it, because if I used the "event/target entity" tag, the mob would've needed to be holding the shears instead of the player for a drop to spawn.