Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integer Overflow with Blood Magic Orb #16398

Closed
2 of 3 tasks
jurrejelle opened this issue May 28, 2024 · 0 comments · Fixed by GTNewHorizons/BloodMagic#64
Closed
2 of 3 tasks

Integer Overflow with Blood Magic Orb #16398

jurrejelle opened this issue May 28, 2024 · 0 comments · Fixed by GTNewHorizons/BloodMagic#64
Labels
Bug: Minor Mod: Avaritia Status: Ready for Developer Issue ready for a developer to pick up and implement

Comments

@jurrejelle
Copy link

jurrejelle commented May 28, 2024

Your GTNH Discord Username

jurrejelle

Your Pack Version

2.6.1 (2024-05-20)

Your Server

Private server

Java Version

Java 21

Type of Server

Vanilla Forge

Your Expectation

When a blood orb of armok charges, it shouldn't pass over the integer limit.

The Reality

image

Picking it up resets it to 1 billion
image

OnUpdate, it seems to set the current LP to 1,000,000,000 (one billion)
(https://github.com/GTNewHorizons/Avaritia/blob/master/src/main/java/fox/spiteful/avaritia/compat/bloodmagic/ItemOrbArmok.java#L60)

    @Override
    public void onUpdate(ItemStack stack, World world, Entity entity, int itemSlot, boolean isSelected) {
...
SoulNetworkHandler.setCurrentEssence(itemTag.getString("ownerName"), getMaxEssence());
...

    @Override
    public int getMaxEssence() {
        return 1000000000;
    }

It seems the "currentEssence" is indeed an int (https://github.com/GTNewHorizons/BloodMagic/blob/master/src/main/java/WayofTime/alchemicalWizardry/api/soulNetwork/SoulNetworkHandler.java#L214)

    public static int getCurrentEssence(String ownerName) {

and (https://github.com/GTNewHorizons/BloodMagic/blob/master/src/main/java/WayofTime/alchemicalWizardry/api/soulNetwork/LifeEssenceNetwork.java#L10)

public class LifeEssenceNetwork extends net.minecraft.world.WorldSavedData {

    public int currentEssence;
    public int maxOrb;
...

There don't seem to be any protections in place for integer overflow.

Your Proposal

it seems that the idea behind the orb is to always have 1 billion LP (onUpdate sets it to 1 bil). Either disable charging when the max orb is armok's, add a limit for the orb, or store the LP value in a long (or similar bigger datatype).

Final Checklist

  • I have searched this issue tracker and there is nothing similar already. Posting on a closed issue saying the bug still exists will prompt us to investigate and reopen it once we confirm your report.
  • I can reproduce this problem consistently by follow the exact steps I described above, or this does not need reproducing, e.g. recipe loophole.
  • I have asked other people and they confirm they also have this problem by follow the exact steps I described above, or this does not need reproducing, e.g. recipe loophole.
@jurrejelle jurrejelle added Status: Triage Issue awaiting triage. Remove once this issue is processed Bug: Minor labels May 28, 2024
@chochem chochem added Status: Ready for Developer Issue ready for a developer to pick up and implement and removed Status: Triage Issue awaiting triage. Remove once this issue is processed labels Jan 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug: Minor Mod: Avaritia Status: Ready for Developer Issue ready for a developer to pick up and implement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants