I'm making a mod for my fiancee, and I'm having issues with entity detection.

Started by adamenlight on

Topic category: Help with Minecraft modding (Java Edition)

Joined Jan 2026
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I'm making a mod for my fiancee, and I'm having issues with entity detection.

So, I'm making a mod for my partner and I added Wedding Rings - an item that gives you potion effects based on enchants that you have on it and if nearby entities that also have a Wedding Ring are present. 
So the problem I'm having is that I the effect doesn't disappear when you exit the Wedding Rings range, I tried many different ways to go about it, but nothing really worked. I deleted most of my attempts so I don't have any documentation on what I tried and what I didn't.

Please, I really want to surprise her the next time we have the time to play together.

Joined Oct 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
put that in the if in off…
Sun, 01/04/2026 - 04:01

put that in the if in off hand or in hand if you dont know how to do that tell me

Joined Oct 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
oh i didnt understand what…
Sun, 01/04/2026 - 04:08

oh i didnt understand what you were saying

you should make a new enchant

make it so only the ring can be enchanted with this special enchantment

then go to the procedures in your item

and grab make it say if provided itemstack has enchantment(enchantmentname) then, give certain potion effect

 

I HAVE NO IDEA HOW TO DO THE NEARBY MOB HAS RING THING 

Joined Apr 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Because I don't know how the…
Sun, 01/04/2026 - 13:59

Because I don't know how the wedding ring is implemented (is it an item that you need to have in your inventory, an item that only works from off-hand, an armor piece or a curios item) my advice may need to be changed slightly to fit how you have it implemented. I am going to assume that it is an item that just needs to be in your inventory to provide effects, so I will write this advice with that in mind. I am also going to assume that you already got the enchantment-based potion effects working for yourself by using the item in inventory tick trigger, and this advice is on how to expand that every tick procedure.

First off, if you are having problems with potion effects lasting forever, I would recommend putting the entire procedure in an if block "if not is provided world client-side" which forces the procedure to run server-side only, which handles potion effects better, or at least did in older Minecraft versions (client-side and server-side may handle them equally well now, but I'm not sure).

Because presumably, only players will get wedding rings (and because non-player entities don't run item in inventory tick), I would recommend using 'get each player in provided world as entity iterator' to detect all other players.

Then, an if block "if not event/target entity = entity iterator" this is to make sure that it doesn't count you as another player.

Inside that, a somewhat complex if condition "if (abs(x of target - x of iterator) - abs(y of target - of iterator) - abs(z of target - z of iterator)) < 30" this will get the distance between you and the other player and compare it to 30, which you can change to whatever you want the range of the wedding rings to be. Also, the full names of the procedure blocks are things like "x position of event/target entity" but I shortened them to save space. And the absolute procedure block is accessed through a dropdown menu when clicking on the round procedure block.

Then a simple condition "if entity iterator has wedding ring in main inventory" or something like that, I may be misremembering the exact names of some of the procedure blocks, but the meaning is the same. This is to make sure that the other player has a wedding ring before doing a complex check to get the enchantments on it.

Then use a procedure block to get a copy of all items from entity iterator main inventory as itemstack iterator (I haven't worked with this one a lot, so I'm probably misremembering the name).

Then check if itemstack iterator is a wedding ring, and if so, run a series of if conditions to check for the presence of each enchantment on it. For each enchantment, give a potion effect to event/target entity for a short duration (5 ticks should work for everything but night vision). If the level of the enchantment should determine the potency, just get the level of enchantment from itemstack iterator and use that as the potency (for both, they act in-game as one level higher than they are internally, so they can be converted between each other directly without needing to compensate for that one level difference.)

Hopefully this will help. I don't feel like I'm the best at explaining things, so feel free to comment if you have any questions. Also, make sure to swap out provided itemstack for itemstack iterator when placing the procedure blocks that check the other player's wedding ring, and event/target entity for entity iterator when you want to refer to the other player. Forgetting to swap those out is a really easy mistake that I have made myself countless times, and one that can completely break the whole procedure.

Two final notes, this procedure is probably a little resource heavy, but it should work (in theory, I haven't tested it but I am fairly confident). Lastly, you don't need to do anything to the other player from your own wedding ring's trigger, because their wedding ring will be running the same procedure.

Joined Jan 2026
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Holy, thank you Mr/Mrs…
Sun, 01/04/2026 - 23:24

Holy, thank you Mr/Mrs Catnip, I'm going to test it out tomorrow with my buddies! I'll let you know if something breaks!