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

Fix non-deterministic TileNodeLinker instabilityCheck crash with zero… #33

Merged
merged 1 commit into from
Jun 2, 2024

Conversation

topquarkred
Copy link

nextInt(int bound) throws an IllegalArgumentException if bound is <= 0. If instabilityCheck is called with self.instability == 0, and this.worldObj.rand.nextInt(50) rolls a 0, this.worldObj.rand.nextInt(this.instability) would throw an uncaught exception.

Example crash stack trace, right after linking two node linkers:

java.lang.IllegalArgumentException: bound must be positive
        at java.base/java.util.Random.nextInt(Random.java:322)
        at RFB-Launch//tb.common.tile.TileNodeLinker.instabilityCheck(TileNodeLinker.java:171)
        at RFB-Launch//tb.common.tile.TileNodeLinker.func_145845_h(TileNodeLinker.java:133)
        at RFB-Launch//net.minecraft.world.World.func_72939_s(World.java:1939)
        at RFB-Launch//net.minecraft.world.WorldServer.func_72939_s(WorldServer.java:489)
        at RFB-Launch//net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:636)
        at RFB-Launch//net.minecraft.server.dedicated.DedicatedServer.func_71190_q(DedicatedServer.java:334)
        at RFB-Launch//net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:547)
        at RFB-Launch//net.minecraft.server.MinecraftServer.run(MinecraftServer.java:427)
        at RFB-Launch//net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:685)


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Stacktrace:
        at java.base/java.util.Random.nextInt(Random.java:322)
        at RFB-Launch//tb.common.tile.TileNodeLinker.instabilityCheck(TileNodeLinker.java:171)
        at RFB-Launch//tb.common.tile.TileNodeLinker.func_145845_h(TileNodeLinker.java:133)

-- Block entity being ticked --
Details:
        Name: tb.nodeLinker // tb.common.tile.TileNodeLinker
        Block type: ID #2231 (tile.nodeLinker // tb.common.block.BlockNodeLinker)
        Block data value: 0 / 0x0 / 0b0000
        Block location: World: (-493,68,-197), Chunk: (at 3,4,11 in -31,-13; contains blocks -496,0,-208 to -481,255,-193), Region: (-1,-1; contains chunks -32,-32 to -1,-1, blocks -512,0,-512 to -1,255,-1)
        Actual block type: ID #2231 (tile.nodeLinker // tb.common.block.BlockNodeLinker)
        Actual block data value: 0 / 0x0 / 0b0000
Stacktrace:
        at RFB-Launch//net.minecraft.world.World.func_72939_s(World.java:1939)
        at RFB-Launch//net.minecraft.world.WorldServer.func_72939_s(WorldServer.java:489)

@Dream-Master Dream-Master requested a review from a team June 2, 2024 20:31
Copy link

@Alastors Alastors left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not non-deterministic, the rng function of code is insanely deterministic, but sure, looks fine

@Dream-Master Dream-Master merged commit a69ec07 into GTNewHorizons:master Jun 2, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants