You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In ThresholdSwitchBlockEntity.java, the method updateCurrentLevel inaccurately calculates the fill level when storage views have different capacities. It treats all storage views as if they have the same weight, leading to incorrect results.
Here's a simple example to illustrate the problem:
Suppose there are two storage views, one with a capacity of 100 and one with a capacity of 200.
Suppose the first storage is completely full (100/100) and the second storage is half full (100/200).
Using the current code, occupied would be calculated as (100/100) + (100/200) = 1 + 0.5 = 1.5, and totalSpace would be 2.
Therefore, currentLevel would be occupied / totalSpace = 1.5 / 2 = 0.75.
However, the actual fill level of the storage system would be 200 out of a total capacity of 300, or approximately 66.67%.
Proposed Fix:
Calculate Total Space by Summing Actual Capacities: Add the actual space of each storage view to totalSpace instead of incrementing by 1.
Calculate Occupied Space by Summing Actual Counts: Add the actual count of each storage view to occupied instead of calculating count * (1f / space).
As I'm not sure about potential edge cases, I preferred to post about it here instead of submitting a PR (I'm new to the Minecraft mod scene)
Thank you!
Reproduction Steps
Use a Threshold Switch on a storage system with at least two views with different capacity
Fill one and leave the other one empty
Look at the level reported by the Threshold Switch
Expected Result
Accurately calculate the fill level
Screenshots and Videos
No response
Crash Report or Log
No response
Operating System
Windows 11
Mod Version
0.5.1d
Minecraft Version
1.20.1
Other Mods
I've discovered this issue while using the Extended Drawers mod for Fabric but confirmed with the author that it was an issue with the Create block.
Additional Context
No response
The text was updated successfully, but these errors were encountered:
Describe the Bug
Hello!
In ThresholdSwitchBlockEntity.java, the method updateCurrentLevel inaccurately calculates the fill level when storage views have different capacities. It treats all storage views as if they have the same weight, leading to incorrect results.
Here's a simple example to illustrate the problem:
Suppose there are two storage views, one with a capacity of 100 and one with a capacity of 200.
Suppose the first storage is completely full (100/100) and the second storage is half full (100/200).
Using the current code, occupied would be calculated as (100/100) + (100/200) = 1 + 0.5 = 1.5, and totalSpace would be 2.
Therefore, currentLevel would be occupied / totalSpace = 1.5 / 2 = 0.75.
However, the actual fill level of the storage system would be 200 out of a total capacity of 300, or approximately 66.67%.
Proposed Fix:
Calculate Total Space by Summing Actual Capacities: Add the actual space of each storage view to totalSpace instead of incrementing by 1.
Calculate Occupied Space by Summing Actual Counts: Add the actual count of each storage view to occupied instead of calculating count * (1f / space).
As I'm not sure about potential edge cases, I preferred to post about it here instead of submitting a PR (I'm new to the Minecraft mod scene)
Thank you!
Reproduction Steps
Expected Result
Accurately calculate the fill level
Screenshots and Videos
No response
Crash Report or Log
No response
Operating System
Windows 11
Mod Version
0.5.1d
Minecraft Version
1.20.1
Other Mods
I've discovered this issue while using the Extended Drawers mod for Fabric but confirmed with the author that it was an issue with the Create block.
Additional Context
No response
The text was updated successfully, but these errors were encountered: