Skip to content
This repository was archived by the owner on Jun 26, 2019. It is now read-only.
This repository was archived by the owner on Jun 26, 2019. It is now read-only.

LITTLE_ENDIAN Floats and Doubles are read as BIG_ENDIAN #15

@xcube16

Description

@xcube16

https://github.com/flow/nbt/blob/7a1b6d986e6fbd01862356d47827b8b357349a22/src/main/java/com/flowpowered/nbt/stream/EndianSwitchableInputStream.java#L100-L122

As you can see, readInt() and readLong() take care of the endian ness, but readFloat() and readDouble() also try to take care of flipping the bytes around! This causes LITTLE_ENDIAN Floats and Doubles to be read as BIG_ENDIAN.

    public float readFloat() throws IOException {
        return Float.intBitsToFloat(readInt());
    }

    public double readDouble() throws IOException {
        return Double.longBitsToDouble(readLong());
    }

That should fix it.

If someone could sneak that into there next PR that would be nice! ;) Fixed in PR #16

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions