Skip to content

Fluid Reader aspects "Total Capacity" and "Total Amount" overflow their limit. #1547

@ton185

Description

@ton185

Issue type:

  • 🐛 Bug

Short description:

Each block has the ability to expose multiple fluid tanks (up to the integer limit). Every tank can have capacity and amount up Integer.MAX_VALUE. The maximum total fluid capacity/amount a single block can have is Integer.MAX_VALUE * Integer.MAX_VALUE, which is to say that when a block has a total capacity exceeding Integer.MAX_VALUE, the reader's total capacity/amount values will have an integer overflow issue.

Steps to reproduce the problem:

  1. Place any block that has a total capacity over the integer limit.
  2. Observe as the reader shows an incorrect value such as -1 or similar for "Total Capacity" or "Total Amount" aspects.

Expected behaviour:

The reader should show the correct total capacity/amount.


Versions:

  • This mod: 1.27.9
  • Minecraft: 1.21.1
  • Mod loader version: NeoForge 21.1.208

Suggested Fix:

I suggest changing the Total Capacity and Total Amount aspects to use Long instead, which will be more than enough to handle the maximum possible value of Integer.MAX_VALUE * Integer.MAX_VALUE total capacity/amount
Relevant code:
Total Capacity
Total Amount

Workarounds

There is a list of "Tank Fluids" and a list of "Tank Capacity", so you can map them over a cast to long and then reduce the list over add

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions