diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/ImpreciseFraction.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/ImpreciseFraction.kt index 9ffbdea55..48633d0a9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/ImpreciseFraction.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/ImpreciseFraction.kt @@ -500,9 +500,8 @@ class ImpreciseFraction @JvmOverloads constructor(whole: BigInteger, decimal: Do fun write(buff: FriendlyByteBuf) { val whole = whole.toByteArray() - buff.writeByte(whole.size) - buff.writeBytes(whole) - buff.writeBytes(longToBytesBE(decimal.toBits())) + buff.writeByteArray(whole) + buff.writeDouble(decimal) } override fun toFloat(): Float { @@ -635,14 +634,7 @@ class ImpreciseFraction @JvmOverloads constructor(whole: BigInteger, decimal: Do @JvmStatic fun read(buff: FriendlyByteBuf): ImpreciseFraction { - val len = unsignedInt(buff.readByte()) - val slice = ByteArray(len) - - for (i in 0 until len) - slice[i] = buff.readByte() - - val bits = bytesToLongBE(buff.readByte(), buff.readByte(), buff.readByte(), buff.readByte(), buff.readByte(), buff.readByte(), buff.readByte(), buff.readByte()) - return ImpreciseFraction(BigInteger(slice), Double.fromBits(bits)) + return ImpreciseFraction(BigInteger(buff.readByteArray()), buff.readDouble()) } } }