(SOLVED) How do I make an item that gives glowing and weakness to all invisible mobs in 8 block radius on right click?

Started by BeePlay on

Topic category: Help with Minecraft modding (Java Edition)

Joined Aug 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
(SOLVED) How do I make an item that gives glowing and weakness to all invisible mobs in 8 block radius on right click?
Wed, 07/09/2025 - 14:58 (edited)

I want to do a weapon that reveals all invisible mobs in 8 block radius and gives them weakness for 4 seconds on right click. I don't know how to do that, so can someone help? I will be very happy if someone does.

Edited by BeePlay on Wed, 07/09/2025 - 14:58
Joined Apr 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
If not is provided world…
Wed, 07/09/2025 - 12:24

If not is provided world client-side

do: for each entity as entity iterator in square radius around X: X Y: Y Z: Z of size 8 blocks

      do: if entity iterator has active potion effect invisibility

            do: apply potion effect glowing to entity iterator duration: 80 ticks, amplifier: 0

                  apply potion effect weakness to entity iterator duration: 80 ticks, amplifier: 0

 

That should work, although I may have misspelled some procedure blocks. The if not provided world client-side ensures that if it targets a player, that player won't end up with 'ghost' potion effects that don't go away. The for each entity as entity iterator targets all entities in the area. The if entity iterator has active potion effect invisibility checks if the entity iterator is currently invisible, then the apply potion effect procedure blocks will give the entity iterator glowing and weakness. Important: by default, most of the procedure blocks target event/target entity, you must switch it out for entity iterator or else it will target you instead of mobs around you. Note: with this setup, the player using the item will also be included in the selection if they themselves are invisible, if you don't want this, add another if check around the apply potion effect procedure blocks with the condition 'not entity iterator = event/target entity' which will prevent it from self-targeting.

Joined Aug 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Thank you so much for…
Wed, 07/09/2025 - 12:56

Thank you so much for helping!

Joined Apr 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I'm glad I was able to help.
Wed, 07/09/2025 - 12:57

I'm glad I was able to help.