Started by
BeePlay
on
Topic category: Help with Minecraft modding (Java Edition)
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
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.
Thank you so much for helping!
I'm glad I was able to help.