Hbm's Nuclear Tech Mod

Hbm's Nuclear Tech Mod

1M Downloads

[uncomfirmed] XP bug/exploit

Shibva opened this issue · 3 comments

commented

Describe the bug

IN the current version, when you use an empty xp bag with adequet XP to remove one bag woth and you just enchanted something it will take the amount of Xp but also revert to what it was before you enchanted (meaning that if you put the xp you just put into the item back into you you would have the same amount of XP that you had before enchatning)

to reproduce:
1: give yourself 37 experience levels and aquire one empty eperience bag
2: use a large sum of the Xp you have to enchant any valid item as normal
3: after doing so, use the XP bag to store some of your remaining XP (it will revert the XP back to what it was before you enchanted minus the amount you just had withdrawn)
4: use the item again to put what you had taken into it back into yourself
5: you have now the same amount of XP before you even enchanted anything

if this issue is not-reprocucable please let me know so I can investigate this further on my end.

commented

Should be fixed in the upcoming release.

A quick explanation on what was going on (because it's funny):

Minecraft keeps track of experience using three values,

  • experienceLevel, an integer counting the completed levels the player has
  • experience, a float keeping track of the experience points of the current incomplete level, with the maximum being variable depending on the player's completed levels
  • experienceTotal, an integer intended to count all experience points the player has

The way the empty XP bag works is that it takes the value from experienceTotal, reduces it by 100 points, then resets all XP related values to 0 and then adding the new value to the player with a special function (since points per level are variable, they have to be counted individually). The actual issue stems from the fact that experienceTotal isn't actually being updated when enchanting, nor is the value even used anywhere (outside some inconsequential range checking when the total value approaches the integer limit). Why does it exist? Why does Forge's docs state that the values does a thing it actually doesn't? Who knows.

Instead, now it uses a different function to calculate the accurate amount of total points the player has by repeatedly adding up the point capacity of all completed levels the player has plus the incomplete level. with some rounding applied.

commented

I forgot to re-post on this;

in the pack that I was using it appears that when I use another experience storage method that the issue is nonexistent

I knew it was a bug… I thought it was just my Game glitching

I knew something was up and I use a different experience method to store it

Thanks man; feel free to close this once it's implemented into the next release

commented

Fixed in X4501.