Skip to content

Conversation

@MCTian-mi
Copy link
Contributor

@MCTian-mi MCTian-mi commented Nov 21, 2025

What

Fixes an oversight in #2726, where Bytes in ProspectingTexture#map aren't treated as unsigned as intended, resulting MCTian-mi/SussyPatches#32, where the same feature was implemented for 2.8.10.

Also replaced original HashMap<Byte, String>s with Byte2ObjectOpenHashMaps from fastutil.

Implementation Details

Replaced the Byte#intValue method call with Byte#toUnsignedInt, whose implementation is:

    /**
     * Converts the argument to an {@code int} by an unsigned
     * conversion.  In an unsigned conversion to an {@code int}, the
     * high-order 24 bits of the {@code int} are zero and the
     * low-order 8 bits are equal to the bits of the {@code byte} argument.
     *
     * Consequently, zero and positive {@code byte} values are mapped
     * to a numerically equal {@code int} value and negative {@code
     * byte} values are mapped to an {@code int} value equal to the
     * input plus 2<sup>8</sup>.
     *
     * @param  x the value to convert to an unsigned {@code int}
     * @return the argument converted to {@code int} by an unsigned
     *         conversion
     * @since 1.8
     */
    public static int toUnsignedInt(byte x) {
        return ((int) x) & 0xff;
    }

@MCTian-mi MCTian-mi requested a review from a team as a code owner November 21, 2025 12:01
MCTian-mi added a commit to MCTian-mi/SussyPatches that referenced this pull request Nov 21, 2025
@MCTian-mi MCTian-mi changed the title Treat Bytes in ProspectingTexture#map as UByte Treat Bytes in ProspectingTexture#map as UByte & switch to fastutil maps Nov 21, 2025
@MCTian-mi MCTian-mi force-pushed the prospector-height-ubyte branch from 5ba1794 to 44a5a20 Compare November 21, 2025 15:49
MCTian-mi added a commit to MCTian-mi/SussyPatches that referenced this pull request Nov 21, 2025
@M-W-K M-W-K added the type: refactor Suggestion to refactor a section of code label Nov 21, 2025
IntegerLimit added a commit to Nomi-CEu/Nomi-Labs that referenced this pull request Nov 24, 2025
@ALongStringOfNumbers ALongStringOfNumbers merged commit 8182590 into GregTechCEu:master Dec 1, 2025
3 checks passed
@MCTian-mi MCTian-mi deleted the prospector-height-ubyte branch December 2, 2025 13:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: refactor Suggestion to refactor a section of code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants