BG-Software-LLC / SuperiorSkyblock2

Optimized, feature packed Skyblock core.
https://bg-software.com/superiorskyblock/
GNU General Public License v3.0
159 stars 134 forks source link

Incorrect island worth calculation #1902

Closed anhcraft closed 6 months ago

anhcraft commented 8 months ago

Minecraft's Version

Tuinity 1.16.5

Plugin's Version

The latest dev version built from the source: https://github.com/BG-Software-LLC/SuperiorSkyblock2/commit/863efc15db47a8542d2bedc18d703ab601d75b28

Describe the bug

Using /is admin recalc or using auto recalculation outputs incorrect island worth. This also happens when rechecking using /is admin count and /is top in which the quantity of some blocks is missing a lot. For example, one of my member's island has tons of stacked diamond blocks and the plugin only counts like 1% of them.

This had not happened before so the issue seems to start since the changes of key: 0bf6e5166c74c3f98a907d6195e5887571ea4e60

I tried to debug the plugin and found that the problem is at this line: https://github.com/BG-Software-LLC/SuperiorSkyblock2/blob/863efc15db47a8542d2bedc18d703ab601d75b28/src/main/java/com/bgsoftware/superiorskyblock/island/algorithm/DefaultIslandCalculationAlgorithm.java#L198 So getRaw sometimes returned zero despite that the previous calculation had already added the count to the map.

My workaround is this. It's just a temporary solution since I have no idea how other code works.

        public synchronized void addCounts(Key blockKey, int amount) {
            blockCounts.put(blockKey, blockCounts.getOrDefault(blockKey, BigInteger.ZERO).add(BigInteger.valueOf(amount)));
        }

        public synchronized void addCounts(KeyMap<Counter> other) {
            other.forEach((key, counter) -> addCounts(key, counter.get()));
        }

To Reproduce

Stated above

Additional Information

Level and worth configuration stays the same as default.

OmerBenGera commented 8 months ago

Try replicating the issue yourself on a server with only SSB installed, as well as using official build from our website.

OmerBenGera commented 7 months ago

Any news regarding this?

DarkStark2 commented 7 months ago

Not sure if I should create a new post regarding this or what. But I seem to have the same issue as the person above. I have no clue how it happened so I don't know how to reproduce it with other plugins or without. However it does seem like I may know more info about this.

Currently the issue is happening to 2 islands. Each island has 2 types of valuable blocks, diamond and emerald and both islands got 2 different stacks of each block (4 in total)

Island 1: 1st Stack has 50911 Diamond Blocks and 51989 Emerald Blocks 2nd Stack has 137438 Diamond Blocks and 114183 Emerald Blocks However in /is top values it shows only the 1st stack -1, so 50910 diamond blocks and 51989 Emerald Blocks

Island 2: 1st Stack has 580623 Diamond Blocks and 8474 Emerald Blocks 2nd Stack has 49758 Diamond Blocks and 69327 Emerald Blocks However in /is top values it shows 49757 Diamond Blocks and 69326 Emerald Blocks.

Conclusion: I am using SuperiorSkyblock2 built in stacker, and it seems like it only counts 1 stack of island and doesn't add them all together. Hope this all makes sense

OmerBenGera commented 7 months ago

Check out latest dev build, let me know if it is fixed.

anhcraft commented 7 months ago

I've just tested the dev build and the issue is resolved. btw, found another issue is that recalculation from console will not return the result while in-game can

OmerBenGera commented 7 months ago

I've just tested the dev build and the issue is resolved. btw, found another issue is that recalculation from console will not return the result while in-game can

It calculates the worth correctly but not showing a meesage, or it doesn't calculate the worth at all?

OmerBenGera commented 6 months ago

I am closing this for now @anhcraft Open a new issue regarding the new issue.