mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-08 23:13:10 -04:00
fix compatibility with Java < 16
This commit is contained in:
parent
a79eff606c
commit
c265b87e48
@ -28,7 +28,7 @@ Minosoft is an open source minecraft client, written from scratch in kotlin (and
|
||||
- RAM: Minimum 300 MiB, 1 GiB recommended
|
||||
- Disk space: Minosoft itself is pretty small (2-3 MiB), the libraries are a bit bigger (~80 MiB). You also need to have the "normal" minecraft assets (~ 300 MiB per minecraft version).
|
||||
- GPU: OpenGL 3.0+. Every modern GPU works and is recommended.
|
||||
- Java 11+, newest version recommended (This is really important, we use features that are only available in this version. Java 8 is currently **not** supported).
|
||||
- Java 11+, 16+ recommended (This is really important, we use features that are only available in this version. Java 8 is currently **not** supported).
|
||||
|
||||
## Rendering
|
||||
|
||||
@ -73,7 +73,7 @@ I always try to add support for the newest version of minecraft. Mostly it is pr
|
||||
|
||||
### Supported versions
|
||||
|
||||
Almost all versions (and snapshots!) between 1.7 and the latest one (1.17 as of writing this). I plan to maintain Minosoft to at least version 1.20, so stay tuned. Support for older protocols will not be dropped as newer protocols are added. And can still only recommend using the latest stable version, should be the most stable one.
|
||||
Almost all versions (and snapshots!) between 1.7 and the latest one (1.17 as of writing this). I plan to maintain Minosoft to at least version 1.20, so stay tuned. Support for older protocols will not be dropped as newer protocols are added. It is still recommended using the latest stable version.
|
||||
|
||||
### Unsupported versions
|
||||
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
package de.bixilon.minosoft.util.collections
|
||||
|
||||
import de.bixilon.minosoft.util.KUtil
|
||||
import de.bixilon.minosoft.util.KUtil.clean
|
||||
import org.lwjgl.system.MemoryUtil.memAllocFloat
|
||||
import java.nio.FloatBuffer
|
||||
@ -64,8 +65,14 @@ class ArrayFloatList(
|
||||
}
|
||||
val oldBuffer = buffer
|
||||
buffer = memAllocFloat(newSize)
|
||||
buffer.put(0, oldBuffer, 0, oldBuffer.position())
|
||||
buffer.position(oldBuffer.position())
|
||||
if (FLOAT_PUT_METHOD == null) { // Java < 16
|
||||
for (i in 0 until oldBuffer.position()) {
|
||||
buffer.put(oldBuffer.get(i))
|
||||
}
|
||||
} else {
|
||||
FLOAT_PUT_METHOD.invoke(buffer, 0, oldBuffer, 0, oldBuffer.position())
|
||||
buffer.position(oldBuffer.position())
|
||||
}
|
||||
oldBuffer.clean()
|
||||
}
|
||||
|
||||
@ -83,16 +90,25 @@ class ArrayFloatList(
|
||||
|
||||
fun addAll(floatList: ArrayFloatList) {
|
||||
ensureSize(floatList.size)
|
||||
buffer.put(buffer.position(), floatList.buffer, 0, floatList.buffer.position())
|
||||
buffer.position(buffer.position() + floatList.buffer.position())
|
||||
if (FLOAT_PUT_METHOD == null) { // Java < 16
|
||||
for (i in 0 until floatList.buffer.position()) {
|
||||
buffer.put(floatList.buffer.get(i))
|
||||
}
|
||||
} else {
|
||||
FLOAT_PUT_METHOD.invoke(buffer, buffer.position(), floatList.buffer, 0, floatList.buffer.position())
|
||||
buffer.position(buffer.position() + floatList.buffer.position())
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkOutputArray() {
|
||||
if (outputUpToDate) {
|
||||
return
|
||||
}
|
||||
output = FloatArray(size)
|
||||
buffer.get(output, 0, buffer.position())
|
||||
val position = buffer.position()
|
||||
output = FloatArray(position)
|
||||
buffer.position(0)
|
||||
buffer.get(output, 0, position)
|
||||
buffer.position(position)
|
||||
outputUpToDate = true
|
||||
}
|
||||
|
||||
@ -105,13 +121,20 @@ class ArrayFloatList(
|
||||
finalized = true
|
||||
val oldBuffer = buffer
|
||||
buffer = memAllocFloat(oldBuffer.position())
|
||||
buffer.put(0, oldBuffer, 0, oldBuffer.position())
|
||||
buffer.position(buffer.limit())
|
||||
if (FLOAT_PUT_METHOD == null) { // Java < 16
|
||||
for (i in 0 until oldBuffer.position()) {
|
||||
buffer.put(oldBuffer.get(i))
|
||||
}
|
||||
} else {
|
||||
FLOAT_PUT_METHOD.invoke(buffer, 0, oldBuffer, 0, oldBuffer.position())
|
||||
buffer.position(buffer.limit())
|
||||
}
|
||||
oldBuffer.clean()
|
||||
}
|
||||
|
||||
|
||||
private companion object {
|
||||
private val FLOAT_PUT_METHOD = KUtil.tryCatch { FloatBuffer::class.java.getMethod("put", Int::class.java, FloatBuffer::class.java, Int::class.java, Int::class.java) }
|
||||
private const val DEFAULT_INITIAL_SIZE = 1000
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user