How to make that if you hold an item in main hand or off hand, you get an effect?

Started by Diwcox_ on

Topic category: Help with Minecraft modding (Java Edition)

Joined Nov 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How to make that if you hold an item in main hand or off hand, you get an effect?

I am trying to make a mod that adds ores and all related items. It has uranium too, but because you get poisoned when you hold a piece of it, I wanted that whenever I hold uranium, I will get that effect unless I wear a mask. I know how to make a mask, but not how to make the uranium when help poisoned. Help please.

Joined Sep 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
trigger: player tick if ( …
Tue, 11/23/2021 - 08:50
trigger: player tick

if (
 (
  (
   (item in main-hand of [event/target entity])
   ==
   [CUSTOM:Uranium]
  )
  or
  (
   (item in off-hand of [event/target entity])
   ==
   [CUSTOM:Uranium]
  )
 )
 and
 (
  (item from armor-slot [x] of [event/target entity])
  !=
  [CUSTOM:Mask]
 )
)
{
 add effect [Poison V] with power [1] and duration [1] ticks to [event/target entity]
}

Try this! If the mask is on the head. Try replacing x with something 0, if it doesn't work, then with 3.

Joined Apr 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I think the item in hand…
Tue, 11/23/2021 - 13:29

I think the item in hand procedure is easier
So you only have to check whether the mask is on

Joined Apr 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
But that only works for the…
Tue, 11/23/2021 - 13:30

But that only works for the main hand i think... I also might be wrong