[SOLVED] Prevent Player from Gaining XP

Started by LemmingsAndSuch on

Topic category: Help with Minecraft modding (Java Edition)

Joined Jan 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
[SOLVED] Prevent Player from Gaining XP
Thu, 02/13/2025 - 19:25 (edited)

I'm making a set of armor with built-in mending, but I can't figure out a way to prevent the player from gaining XP when their armor mends. At the moment it functions pretty much identically to the mending enchantment, but as the armor mends, the player's XP bar continues to go up. I'm considering a method where I keep track of the difference between their XP the previous tick and the current tick, and then subtract that difference from their total XP, effectively locking the XP bar in place, but every time time I've tested it so far, it's been very buggy. Can anyone help?

Edited by LemmingsAndSuch on Thu, 02/13/2025 - 19:25
Joined Mar 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Hi there. You could make a…
Wed, 02/12/2025 - 06:20

Hi there.

You could make a global variable that uses the players current experience level, then whenever the player's experience changes, compare the two values, if the new experience is greater than zero, it should subtract the added experience through another global variable (something like "compared experience").

I hope this helps, just ask me if you need me to elaborate on any parts.

Joined Jan 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Yes, that was what I was…
Wed, 02/12/2025 - 14:05

Yes, that was what I was trying to do, and it was buggy, but I think that might be the only solution. I'll try it again and see if I made any obvious mistakes the first time. Thank you for trying to help!

Joined Jan 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Okay I might be a little…
Thu, 02/13/2025 - 19:24

Okay I might be a little stupid. I was using the "entity picks up experience" procedure, but there's one that I didn't notice called "player XP amount changes" which uses the amount dependency. I can just use that... and it works perfectly with like 2 procedure blocks....