mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-18 20:05:02 -04:00
bump and adopt kutil 1.19
This commit is contained in:
parent
114f369d2e
commit
e90931209b
@ -59,7 +59,7 @@ repositories {
|
||||
|
||||
buildscript {
|
||||
dependencies {
|
||||
classpath("de.bixilon", "kutil", "1.18.3")
|
||||
classpath("de.bixilon", "kutil", "1.19.1")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,4 +17,4 @@ lwjgl.version=3.3.2-SNAPSHOT
|
||||
ikonli.version=12.3.1
|
||||
netty.version=4.1.86.Final
|
||||
jackson.version=2.14.1
|
||||
kutil.version=1.18.3
|
||||
kutil.version=1.19.1
|
||||
|
@ -1,34 +0,0 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||
*/
|
||||
|
||||
package de.bixilon.minosoft.config.profile.delegate
|
||||
|
||||
import de.bixilon.kutil.observer.DataObserver
|
||||
import kotlin.properties.ReadWriteProperty
|
||||
import kotlin.reflect.KProperty
|
||||
|
||||
@Deprecated("Kutil")
|
||||
class BackingDelegate<V>(
|
||||
private val get: () -> V,
|
||||
private val set: (V) -> Unit,
|
||||
) : DataObserver<V>(get()), ReadWriteProperty<Any, V> {
|
||||
|
||||
override fun getValue(thisRef: Any, property: KProperty<*>): V {
|
||||
return get()
|
||||
}
|
||||
|
||||
override fun setValue(thisRef: Any, property: KProperty<*>, value: V) {
|
||||
set(value)
|
||||
super.setValue(thisRef, property, value)
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||
* Copyright (C) 2020-2023 Moritz Zwerger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
@ -17,10 +17,10 @@ import com.fasterxml.jackson.annotation.JsonIgnore
|
||||
import com.fasterxml.jackson.annotation.JsonInclude
|
||||
import com.fasterxml.jackson.annotation.JsonProperty
|
||||
import de.bixilon.kutil.cast.CastUtil.unsafeCast
|
||||
import de.bixilon.kutil.delegates.BackingDelegate
|
||||
import de.bixilon.kutil.observer.DataObserver.Companion.observe
|
||||
import de.bixilon.kutil.random.RandomStringUtil.randomString
|
||||
import de.bixilon.minosoft.config.profile.ProfileManager
|
||||
import de.bixilon.minosoft.config.profile.delegate.BackingDelegate
|
||||
import de.bixilon.minosoft.config.profile.delegate.primitive.BooleanDelegate
|
||||
import de.bixilon.minosoft.config.profile.delegate.types.NullableStringDelegate
|
||||
import de.bixilon.minosoft.config.profile.delegate.types.StringDelegate
|
||||
|
@ -18,9 +18,9 @@ import com.fasterxml.jackson.annotation.JsonIgnore
|
||||
import com.fasterxml.jackson.annotation.JsonInclude
|
||||
import com.fasterxml.jackson.annotation.JsonProperty
|
||||
import de.bixilon.kutil.cast.CastUtil.unsafeCast
|
||||
import de.bixilon.kutil.delegates.BackingDelegate
|
||||
import de.bixilon.kutil.observer.DataObserver.Companion.observe
|
||||
import de.bixilon.minosoft.assets.util.FileAssetsUtil
|
||||
import de.bixilon.minosoft.config.profile.delegate.BackingDelegate
|
||||
import de.bixilon.minosoft.config.profile.delegate.SimpleDelegate
|
||||
import de.bixilon.minosoft.config.profile.delegate.primitive.BooleanDelegate
|
||||
import de.bixilon.minosoft.config.profile.delegate.types.NullableStringDelegate
|
||||
|
@ -1,37 +0,0 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2023 Moritz Zwerger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||
*/
|
||||
|
||||
package de.bixilon.minosoft.data.registries
|
||||
|
||||
import de.bixilon.kutil.cast.CastUtil.unsafeCast
|
||||
import de.bixilon.kutil.unsafe.UnsafeUtil
|
||||
import java.lang.reflect.ParameterizedType
|
||||
import java.lang.reflect.Type
|
||||
|
||||
@Deprecated("Kutil")
|
||||
object GenericUtil {
|
||||
private val parameterizedClass = Class.forName("sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl")
|
||||
private val rawTypeField = parameterizedClass.getDeclaredField("rawType")
|
||||
private val offset = UnsafeUtil.UNSAFE.objectFieldOffset(rawTypeField)
|
||||
|
||||
fun getClassOfFactory(type: Type): Class<*> {
|
||||
val actualType = type.unsafeCast<ParameterizedType>().actualTypeArguments.first()
|
||||
return if (actualType is Class<*>) {
|
||||
actualType
|
||||
} else if (actualType::class.java == parameterizedClass) {
|
||||
UnsafeUtil.UNSAFE.getObject(actualType, offset).unsafeCast<Class<*>>()
|
||||
} else {
|
||||
TODO()
|
||||
}
|
||||
}
|
||||
}
|
@ -13,7 +13,7 @@
|
||||
|
||||
package de.bixilon.minosoft.data.registries.factory.clazz
|
||||
|
||||
import de.bixilon.minosoft.data.registries.GenericUtil
|
||||
import de.bixilon.kutil.reflection.generic.GenericUtil
|
||||
import java.lang.reflect.ParameterizedType
|
||||
import kotlin.reflect.jvm.javaType
|
||||
|
||||
@ -25,7 +25,7 @@ open class DefaultClassFactory<T : ClassFactory<*>>(vararg factories: T) {
|
||||
|
||||
|
||||
for (factory in factories) {
|
||||
val className = GenericUtil.getClassOfFactory(factory::class.supertypes[0].javaType as ParameterizedType).simpleName
|
||||
val className = GenericUtil.getGeneric(factory::class.supertypes[0].javaType as ParameterizedType).simpleName
|
||||
ret[className] = factory
|
||||
if (factory is MultiClassFactory<*>) {
|
||||
for (name in factory.ALIASES) {
|
||||
|
@ -14,10 +14,10 @@
|
||||
package de.bixilon.minosoft.data.registries.registries.registry
|
||||
|
||||
import de.bixilon.kutil.cast.CastUtil.unsafeCast
|
||||
import de.bixilon.kutil.collections.primitive.Clearable
|
||||
import de.bixilon.kutil.json.JsonObject
|
||||
import de.bixilon.minosoft.data.registries.identified.ResourceLocation
|
||||
import de.bixilon.minosoft.data.registries.registries.Registries
|
||||
import de.bixilon.minosoft.util.collections.Clearable
|
||||
import de.bixilon.minosoft.util.json.ResourceLocationJsonMap.toResourceLocationMap
|
||||
|
||||
interface AbstractRegistry<T> : Iterable<T>, Clearable, Parentable<AbstractRegistry<T>> {
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||
* Copyright (C) 2020-2023 Moritz Zwerger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
@ -14,10 +14,10 @@
|
||||
package de.bixilon.minosoft.data.registries.registries.registry
|
||||
|
||||
import de.bixilon.kutil.cast.CastUtil.unsafeCast
|
||||
import de.bixilon.kutil.collections.primitive.Clearable
|
||||
import de.bixilon.kutil.enums.ValuesEnum
|
||||
import de.bixilon.kutil.primitive.IntUtil.toInt
|
||||
import de.bixilon.minosoft.datafixer.enumeration.EnumFixer
|
||||
import de.bixilon.minosoft.util.collections.Clearable
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||
* Copyright (C) 2020-2023 Moritz Zwerger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
@ -13,11 +13,11 @@
|
||||
|
||||
package de.bixilon.minosoft.data.registries.registries.registry
|
||||
|
||||
import de.bixilon.kutil.collections.primitive.Clearable
|
||||
import de.bixilon.kutil.json.JsonObject
|
||||
import de.bixilon.kutil.primitive.IntUtil.toInt
|
||||
import de.bixilon.minosoft.data.registries.registries.Registries
|
||||
import de.bixilon.minosoft.data.registries.registries.registry.codec.IdCodec
|
||||
import de.bixilon.minosoft.util.collections.Clearable
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap
|
||||
|
||||
|
@ -16,7 +16,6 @@ package de.bixilon.minosoft.gui.eros.main.play.server
|
||||
import de.bixilon.kutil.collections.CollectionUtil.toSynchronizedSet
|
||||
import de.bixilon.kutil.concurrent.pool.DefaultThreadPool.async
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.observer.ObservedReference
|
||||
import de.bixilon.kutil.primitive.BooleanUtil.decide
|
||||
import de.bixilon.kutil.primitive.IntUtil.thousands
|
||||
import de.bixilon.kutil.unit.UnitFormatter.formatNanos
|
||||
@ -63,7 +62,7 @@ import javafx.scene.input.KeyCode
|
||||
import javafx.scene.layout.Pane
|
||||
|
||||
|
||||
class ServerListController : EmbeddedJavaFXController<Pane>(), Refreshable, ObservedReference<Any> {
|
||||
class ServerListController : EmbeddedJavaFXController<Pane>(), Refreshable {
|
||||
@FXML private lateinit var hideOfflineFX: CheckBox
|
||||
@FXML private lateinit var hideFullFX: CheckBox
|
||||
@FXML private lateinit var hideEmptyFX: CheckBox
|
||||
@ -163,7 +162,7 @@ class ServerListController : EmbeddedJavaFXController<Pane>(), Refreshable, Obse
|
||||
JavaFXUtil.runLater { updateServer(server, true) }
|
||||
}
|
||||
|
||||
connection.register(JavaFXEventListener.of<KickEvent> { event ->
|
||||
connection.events.register(JavaFXEventListener.of<KickEvent> { event ->
|
||||
KickDialog(
|
||||
title = "minosoft:connection.kick.title".toResourceLocation(),
|
||||
header = "minosoft:connection.kick.header".toResourceLocation(),
|
||||
@ -171,7 +170,7 @@ class ServerListController : EmbeddedJavaFXController<Pane>(), Refreshable, Obse
|
||||
reason = event.reason,
|
||||
).show()
|
||||
})
|
||||
connection.register(JavaFXEventListener.of<LoginKickEvent> { event ->
|
||||
connection.events.register(JavaFXEventListener.of<LoginKickEvent> { event ->
|
||||
KickDialog(
|
||||
title = "minosoft:connection.login_kick.title".toResourceLocation(),
|
||||
header = "minosoft:connection.login_kick.header".toResourceLocation(),
|
||||
@ -410,13 +409,6 @@ class ServerListController : EmbeddedJavaFXController<Pane>(), Refreshable, Obse
|
||||
serverType!!.refresh(serverListViewFX.items)
|
||||
}
|
||||
|
||||
override fun isValid(value: Any): Boolean {
|
||||
if (value is ServerCard) {
|
||||
return value === serverListViewFX.selectionModel.selectedItem
|
||||
}
|
||||
return value === this
|
||||
}
|
||||
|
||||
|
||||
companion object {
|
||||
val LAYOUT = "minosoft:eros/main/play/server/server_list.fxml".toResourceLocation()
|
||||
|
@ -14,7 +14,6 @@
|
||||
package de.bixilon.minosoft.gui.eros.main.play.server.card
|
||||
|
||||
import de.bixilon.kutil.concurrent.pool.DefaultThreadPool
|
||||
import de.bixilon.kutil.observer.ObservedReference
|
||||
import de.bixilon.kutil.primitive.IntUtil.thousands
|
||||
import de.bixilon.kutil.unit.UnitFormatter.formatNanos
|
||||
import de.bixilon.minosoft.Minosoft
|
||||
@ -28,7 +27,6 @@ import de.bixilon.minosoft.gui.eros.main.play.server.card.FaviconManager.saveFav
|
||||
import de.bixilon.minosoft.gui.eros.util.JavaFXUtil
|
||||
import de.bixilon.minosoft.gui.eros.util.JavaFXUtil.ctext
|
||||
import de.bixilon.minosoft.gui.eros.util.JavaFXUtil.text
|
||||
import de.bixilon.minosoft.protocol.network.connection.status.StatusConnection
|
||||
import de.bixilon.minosoft.util.KUtil.text
|
||||
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||
import de.bixilon.minosoft.util.PixelImageView
|
||||
@ -39,7 +37,7 @@ import javafx.scene.image.Image
|
||||
import javafx.scene.text.TextFlow
|
||||
import java.io.ByteArrayInputStream
|
||||
|
||||
class ServerCardController : AbstractCardController<ServerCard>(), ObservedReference<StatusConnection> {
|
||||
class ServerCardController : AbstractCardController<ServerCard>() {
|
||||
@FXML private lateinit var faviconFX: PixelImageView
|
||||
@FXML private lateinit var serverNameFX: TextFlow
|
||||
@FXML private lateinit var motdFX: TextFlow
|
||||
@ -136,10 +134,6 @@ class ServerCardController : AbstractCardController<ServerCard>(), ObservedRefer
|
||||
}
|
||||
}
|
||||
|
||||
override fun isValid(value: StatusConnection): Boolean {
|
||||
return item.ping === value
|
||||
}
|
||||
|
||||
companion object : CardFactory<ServerCardController> {
|
||||
override val LAYOUT: ResourceLocation = "minosoft:eros/main/play/server/server_card.fxml".toResourceLocation()
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||
* Copyright (C) 2020-2023 Moritz Zwerger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
@ -14,6 +14,7 @@
|
||||
package de.bixilon.minosoft.gui.rendering
|
||||
|
||||
import de.bixilon.kotlinglm.vec2.Vec2i
|
||||
import de.bixilon.kutil.exception.ExceptionUtil.ignoreAll
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.observer.DataObserver.Companion.observe
|
||||
import de.bixilon.kutil.primitive.BooleanUtil.decide
|
||||
@ -25,7 +26,6 @@ import de.bixilon.minosoft.gui.rendering.font.FontLoader
|
||||
import de.bixilon.minosoft.gui.rendering.input.key.DefaultKeyCombinations
|
||||
import de.bixilon.minosoft.gui.rendering.renderer.renderer.DefaultRenderer
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnectionStates
|
||||
import de.bixilon.minosoft.util.KUtil
|
||||
import de.bixilon.minosoft.util.Stopwatch
|
||||
import de.bixilon.minosoft.util.delegate.RenderingDelegate.observeRendering
|
||||
import de.bixilon.minosoft.util.logging.Log
|
||||
@ -55,7 +55,7 @@ object RenderLoader {
|
||||
registerRenderer()
|
||||
|
||||
window.init(connection.profiles.rendering)
|
||||
KUtil.ignoreAll { window.setDefaultIcon(connection.assetsManager) }
|
||||
ignoreAll { window.setDefaultIcon(connection.assetsManager) }
|
||||
|
||||
camera.init()
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||
* Copyright (C) 2020-2023 Moritz Zwerger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
@ -13,6 +13,7 @@
|
||||
|
||||
package de.bixilon.minosoft.gui.rendering.font
|
||||
|
||||
import de.bixilon.kutil.array.ArrayUtil.trim
|
||||
import de.bixilon.kutil.concurrent.worker.unconditional.UnconditionalWorker
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.minosoft.assets.util.FileUtil.readJsonObject
|
||||
@ -20,7 +21,6 @@ import de.bixilon.minosoft.data.registries.factory.DefaultFactory
|
||||
import de.bixilon.minosoft.gui.rendering.RenderContext
|
||||
import de.bixilon.minosoft.gui.rendering.font.provider.*
|
||||
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||
import de.bixilon.minosoft.util.KUtil.trim
|
||||
import de.bixilon.minosoft.util.logging.Log
|
||||
import de.bixilon.minosoft.util.logging.LogLevels
|
||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||
* Copyright (C) 2020-2023 Moritz Zwerger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
@ -38,7 +38,7 @@ import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexOptions
|
||||
import de.bixilon.minosoft.gui.rendering.system.window.CursorShapes
|
||||
import de.bixilon.minosoft.gui.rendering.util.vec.vec2.Vec2iUtil.EMPTY
|
||||
import de.bixilon.minosoft.gui.rendering.util.vec.vec4.Vec4iUtil.offset
|
||||
import de.bixilon.minosoft.util.KUtil.length
|
||||
import de.bixilon.minosoft.util.KUtil.charCount
|
||||
|
||||
open class TextElement(
|
||||
guiRenderer: GUIRenderer,
|
||||
@ -50,7 +50,7 @@ open class TextElement(
|
||||
parent: Element? = null,
|
||||
scale: Float = 1.0f,
|
||||
shadow: Boolean = true,
|
||||
) : Element(guiRenderer, text.length * 6 * GUIMesh.GUIMeshStruct.FLOATS_PER_VERTEX), Labeled {
|
||||
) : Element(guiRenderer, text.charCount * 6 * GUIMesh.GUIMeshStruct.FLOATS_PER_VERTEX), Labeled {
|
||||
private var activeElement: TextComponent? = null
|
||||
lateinit var renderInfo: TextRenderInfo
|
||||
private set
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||
* Copyright (C) 2020-2023 Moritz Zwerger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
@ -16,6 +16,7 @@ package de.bixilon.minosoft.gui.rendering.gui.mesh
|
||||
import de.bixilon.kotlinglm.mat4x4.Mat4
|
||||
import de.bixilon.kotlinglm.vec2.Vec2
|
||||
import de.bixilon.kotlinglm.vec2.Vec2t
|
||||
import de.bixilon.kutil.collections.primitive.floats.AbstractFloatList
|
||||
import de.bixilon.minosoft.data.text.formatting.color.RGBColor
|
||||
import de.bixilon.minosoft.gui.rendering.RenderContext
|
||||
import de.bixilon.minosoft.gui.rendering.system.base.MeshUtil.buffer
|
||||
@ -23,7 +24,6 @@ import de.bixilon.minosoft.gui.rendering.system.base.texture.ShaderIdentifiable
|
||||
import de.bixilon.minosoft.gui.rendering.util.mesh.Mesh
|
||||
import de.bixilon.minosoft.gui.rendering.util.mesh.MeshStruct
|
||||
import de.bixilon.minosoft.gui.rendering.util.vec.vec2.Vec2iUtil.orthoTimes
|
||||
import de.bixilon.minosoft.util.collections.floats.AbstractFloatList
|
||||
|
||||
class GUIMesh(
|
||||
context: RenderContext,
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||
* Copyright (C) 2020-2023 Moritz Zwerger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
@ -17,11 +17,11 @@ import de.bixilon.kotlinglm.mat4x4.Mat4
|
||||
import de.bixilon.kotlinglm.vec2.Vec2
|
||||
import de.bixilon.kotlinglm.vec2.Vec2i
|
||||
import de.bixilon.kotlinglm.vec2.Vec2t
|
||||
import de.bixilon.kutil.collections.primitive.floats.AbstractFloatList
|
||||
import de.bixilon.kutil.collections.primitive.floats.HeapArrayFloatList
|
||||
import de.bixilon.minosoft.data.text.formatting.color.RGBColor
|
||||
import de.bixilon.minosoft.gui.rendering.system.base.texture.ShaderIdentifiable
|
||||
import de.bixilon.minosoft.gui.rendering.util.vec.vec2.Vec2iUtil.EMPTY
|
||||
import de.bixilon.minosoft.util.collections.floats.AbstractFloatList
|
||||
import de.bixilon.minosoft.util.collections.floats.HeapArrayFloatList
|
||||
|
||||
class GUIMeshCache(
|
||||
var matrix: Mat4,
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||
* Copyright (C) 2020-2023 Moritz Zwerger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
@ -16,6 +16,7 @@ package de.bixilon.minosoft.gui.rendering.particle
|
||||
import de.bixilon.kotlinglm.vec2.Vec2
|
||||
import de.bixilon.kotlinglm.vec3.Vec3
|
||||
import de.bixilon.kotlinglm.vec3.Vec3d
|
||||
import de.bixilon.kutil.collections.primitive.floats.AbstractFloatList
|
||||
import de.bixilon.minosoft.data.text.formatting.color.RGBColor
|
||||
import de.bixilon.minosoft.gui.rendering.RenderContext
|
||||
import de.bixilon.minosoft.gui.rendering.system.base.MeshUtil.buffer
|
||||
@ -23,7 +24,6 @@ import de.bixilon.minosoft.gui.rendering.system.base.buffer.vertex.PrimitiveType
|
||||
import de.bixilon.minosoft.gui.rendering.system.base.texture.texture.AbstractTexture
|
||||
import de.bixilon.minosoft.gui.rendering.util.mesh.Mesh
|
||||
import de.bixilon.minosoft.gui.rendering.util.mesh.MeshStruct
|
||||
import de.bixilon.minosoft.util.collections.floats.AbstractFloatList
|
||||
|
||||
class ParticleMesh(context: RenderContext, data: AbstractFloatList) : Mesh(context, ParticleMeshStruct, PrimitiveTypes.POINT, -1, clearOnLoad = false, data = data) {
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
package de.bixilon.minosoft.gui.rendering.system.base
|
||||
|
||||
import de.bixilon.kotlinglm.vec2.Vec2i
|
||||
import de.bixilon.kutil.collections.primitive.floats.AbstractFloatList
|
||||
import de.bixilon.minosoft.data.registries.identified.ResourceLocation
|
||||
import de.bixilon.minosoft.data.text.formatting.color.Colors
|
||||
import de.bixilon.minosoft.data.text.formatting.color.RGBColor
|
||||
@ -27,7 +28,6 @@ import de.bixilon.minosoft.gui.rendering.system.base.shader.NativeShader
|
||||
import de.bixilon.minosoft.gui.rendering.system.base.texture.TextureManager
|
||||
import de.bixilon.minosoft.gui.rendering.util.mesh.MeshStruct
|
||||
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||
import de.bixilon.minosoft.util.collections.floats.AbstractFloatList
|
||||
import de.bixilon.minosoft.util.collections.floats.DirectArrayFloatList
|
||||
import java.nio.ByteBuffer
|
||||
import java.nio.FloatBuffer
|
||||
|
@ -13,13 +13,13 @@
|
||||
|
||||
package de.bixilon.minosoft.gui.rendering.tint
|
||||
|
||||
import de.bixilon.kutil.exception.ExceptionUtil.ignoreAll
|
||||
import de.bixilon.minosoft.assets.AssetsManager
|
||||
import de.bixilon.minosoft.assets.util.FileUtil.readRGBArray
|
||||
import de.bixilon.minosoft.data.container.stack.ItemStack
|
||||
import de.bixilon.minosoft.data.registries.biomes.Biome
|
||||
import de.bixilon.minosoft.data.registries.blocks.BlockState
|
||||
import de.bixilon.minosoft.gui.rendering.textures.TextureUtil.texture
|
||||
import de.bixilon.minosoft.util.KUtil.ignoreAll
|
||||
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||
|
||||
private const val FALLBACK_COLOR = 0x48B518
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
package de.bixilon.minosoft.gui.rendering.tint
|
||||
|
||||
import de.bixilon.kutil.exception.ExceptionUtil.ignoreAll
|
||||
import de.bixilon.minosoft.assets.AssetsManager
|
||||
import de.bixilon.minosoft.assets.util.FileUtil.readRGBArray
|
||||
import de.bixilon.minosoft.data.registries.biomes.Biome
|
||||
@ -21,7 +22,6 @@ import de.bixilon.minosoft.data.registries.blocks.BlockState
|
||||
import de.bixilon.minosoft.data.registries.blocks.MinecraftBlocks
|
||||
import de.bixilon.minosoft.data.text.formatting.color.Colors
|
||||
import de.bixilon.minosoft.gui.rendering.textures.TextureUtil.texture
|
||||
import de.bixilon.minosoft.util.KUtil.ignoreAll
|
||||
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||
|
||||
class GrassTintCalculator : TintProvider {
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||
* Copyright (C) 2020-2023 Moritz Zwerger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
@ -16,10 +16,10 @@ package de.bixilon.minosoft.gui.rendering.util.mesh
|
||||
import de.bixilon.kotlinglm.vec2.Vec2
|
||||
import de.bixilon.kotlinglm.vec3.Vec3
|
||||
import de.bixilon.kutil.cast.CastUtil.unsafeCast
|
||||
import de.bixilon.kutil.collections.primitive.floats.AbstractFloatList
|
||||
import de.bixilon.minosoft.gui.rendering.RenderContext
|
||||
import de.bixilon.minosoft.gui.rendering.system.base.buffer.vertex.FloatVertexBuffer
|
||||
import de.bixilon.minosoft.gui.rendering.system.base.buffer.vertex.PrimitiveTypes
|
||||
import de.bixilon.minosoft.util.collections.floats.AbstractFloatList
|
||||
import de.bixilon.minosoft.util.collections.floats.DirectArrayFloatList
|
||||
import de.bixilon.minosoft.util.collections.floats.FloatListUtil
|
||||
|
||||
|
@ -1,28 +0,0 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||
*/
|
||||
|
||||
package de.bixilon.minosoft.protocol.network.network.client.netty
|
||||
|
||||
import java.util.concurrent.ThreadFactory
|
||||
import java.util.concurrent.atomic.AtomicInteger
|
||||
|
||||
@Deprecated("Kutil")
|
||||
class NamedThreadFactory(
|
||||
val format: String,
|
||||
) : ThreadFactory {
|
||||
var count = AtomicInteger(0)
|
||||
|
||||
override fun newThread(runnable: Runnable): Thread {
|
||||
return Thread(runnable, format.format(count.incrementAndGet()))
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||
* Copyright (C) 2020-2023 Moritz Zwerger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
@ -13,7 +13,7 @@
|
||||
|
||||
package de.bixilon.minosoft.protocol.network.network.client.netty.natives
|
||||
|
||||
import de.bixilon.minosoft.protocol.network.network.client.netty.NamedThreadFactory
|
||||
import de.bixilon.kutil.concurrent.thread.NamedThreadFactory
|
||||
import io.netty.channel.Channel
|
||||
import io.netty.channel.epoll.Epoll
|
||||
import io.netty.channel.epoll.EpollEventLoopGroup
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||
* Copyright (C) 2020-2023 Moritz Zwerger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
@ -13,7 +13,7 @@
|
||||
|
||||
package de.bixilon.minosoft.protocol.network.network.client.netty.natives
|
||||
|
||||
import de.bixilon.minosoft.protocol.network.network.client.netty.NamedThreadFactory
|
||||
import de.bixilon.kutil.concurrent.thread.NamedThreadFactory
|
||||
import io.netty.channel.Channel
|
||||
import io.netty.channel.nio.NioEventLoopGroup
|
||||
import io.netty.channel.socket.nio.NioSocketChannel
|
||||
|
@ -1,24 +0,0 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||
*/
|
||||
|
||||
package de.bixilon.minosoft.protocol.protocol
|
||||
|
||||
import java.nio.BufferUnderflowException
|
||||
|
||||
@Deprecated("Kutil")
|
||||
class ByteBufferUnderflowException(
|
||||
val pointer: Int,
|
||||
val size: Int,
|
||||
) : BufferUnderflowException() {
|
||||
override val message: String = "$pointer >= $size"
|
||||
}
|
@ -18,6 +18,7 @@ import de.bixilon.kotlinglm.vec2.Vec2i
|
||||
import de.bixilon.kotlinglm.vec3.Vec3
|
||||
import de.bixilon.kotlinglm.vec3.Vec3d
|
||||
import de.bixilon.kotlinglm.vec3.Vec3i
|
||||
import de.bixilon.kutil.buffer.bytes.`in`.ByteBufferUnderflowException
|
||||
import de.bixilon.kutil.compression.zlib.GzipUtil.decompress
|
||||
import de.bixilon.kutil.uuid.UUIDUtil.toUUID
|
||||
import de.bixilon.minosoft.data.direction.Directions
|
||||
|
@ -15,11 +15,11 @@ package de.bixilon.minosoft.protocol.protocol
|
||||
import de.bixilon.kotlinglm.vec3.Vec3
|
||||
import de.bixilon.kotlinglm.vec3.Vec3d
|
||||
import de.bixilon.kotlinglm.vec3.Vec3i
|
||||
import de.bixilon.kutil.collections.primitive.bytes.HeapArrayByteList
|
||||
import de.bixilon.minosoft.data.registries.identified.Namespaces
|
||||
import de.bixilon.minosoft.data.registries.identified.ResourceLocation
|
||||
import de.bixilon.minosoft.data.text.ChatComponent
|
||||
import de.bixilon.minosoft.protocol.ProtocolUtil.encodeNetwork
|
||||
import de.bixilon.minosoft.util.collections.bytes.HeapArrayByteList
|
||||
import de.bixilon.minosoft.util.json.Jackson
|
||||
import de.bixilon.minosoft.util.nbt.tag.NBTTagTypes
|
||||
import de.bixilon.minosoft.util.nbt.tag.NBTUtil.nbtType
|
||||
|
@ -26,6 +26,7 @@ import de.bixilon.kutil.collections.CollectionUtil.toSynchronizedSet
|
||||
import de.bixilon.kutil.concurrent.pool.DefaultThreadPool
|
||||
import de.bixilon.kutil.concurrent.time.TimeWorker
|
||||
import de.bixilon.kutil.primitive.BooleanUtil.decide
|
||||
import de.bixilon.kutil.primitive.IntUtil.checkInt
|
||||
import de.bixilon.kutil.reflection.ReflectionUtil.forceInit
|
||||
import de.bixilon.kutil.reflection.ReflectionUtil.realName
|
||||
import de.bixilon.kutil.shutdown.ShutdownManager
|
||||
@ -54,9 +55,6 @@ import org.kamranzafar.jtar.TarHeader
|
||||
import java.security.SecureRandom
|
||||
import java.util.*
|
||||
import javax.net.ssl.SSLContext
|
||||
import kotlin.contracts.ExperimentalContracts
|
||||
import kotlin.contracts.InvocationKind
|
||||
import kotlin.contracts.contract
|
||||
|
||||
|
||||
object KUtil {
|
||||
@ -220,18 +218,6 @@ object KUtil {
|
||||
return null
|
||||
}
|
||||
|
||||
@Deprecated("Kutil")
|
||||
private inline fun String.checkInt(): Int? {
|
||||
var first = true
|
||||
for (point in codePoints()) {
|
||||
if (point < '0'.code || point > '9'.code || (first && point == '-'.code)) {
|
||||
return null
|
||||
}
|
||||
first = false
|
||||
}
|
||||
return this.toInt()
|
||||
}
|
||||
|
||||
fun Any?.autoType(): Any? {
|
||||
if (this == null) {
|
||||
return null
|
||||
@ -311,7 +297,7 @@ object KUtil {
|
||||
}
|
||||
}
|
||||
|
||||
val Any.length: Int
|
||||
val Any.charCount: Int
|
||||
get() {
|
||||
if (this is ChatComponent) return this.length
|
||||
if (this is CharSequence) return this.length
|
||||
@ -322,29 +308,4 @@ object KUtil {
|
||||
val random = SecureRandom()
|
||||
return UUID(random.nextLong(), random.nextLong())
|
||||
}
|
||||
|
||||
@Deprecated("Kutil")
|
||||
@OptIn(ExperimentalContracts::class)
|
||||
inline fun <T> ignoreAll(executor: () -> T): T? {
|
||||
contract {
|
||||
callsInPlace(executor, InvocationKind.EXACTLY_ONCE)
|
||||
}
|
||||
try {
|
||||
return executor()
|
||||
} catch (error: Throwable) {
|
||||
error.printStackTrace()
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
inline fun <reified T> Array<T?>.trim(): Array<T> {
|
||||
val list: MutableList<T> = mutableListOf()
|
||||
for (entry in this) {
|
||||
if (entry == null) {
|
||||
continue
|
||||
}
|
||||
list += entry
|
||||
}
|
||||
return list.toTypedArray()
|
||||
}
|
||||
}
|
||||
|
@ -14,13 +14,13 @@
|
||||
package de.bixilon.minosoft.util
|
||||
|
||||
import de.bixilon.kutil.cast.CastUtil.unsafeCast
|
||||
import de.bixilon.kutil.collections.primitive.Clearable
|
||||
import de.bixilon.kutil.concurrent.pool.DefaultThreadPool
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.minosoft.data.registries.GenericUtil
|
||||
import de.bixilon.kutil.reflection.generic.GenericUtil
|
||||
import de.bixilon.minosoft.data.registries.registries.Registries
|
||||
import de.bixilon.minosoft.data.registries.registries.registry.Parentable
|
||||
import de.bixilon.minosoft.data.registries.registries.registry.Registry
|
||||
import de.bixilon.minosoft.util.collections.Clearable
|
||||
import java.lang.reflect.Field
|
||||
|
||||
object RegistriesUtil {
|
||||
@ -57,7 +57,7 @@ object RegistriesUtil {
|
||||
}
|
||||
}
|
||||
|
||||
types[GenericUtil.getClassOfFactory(clazz)] = field
|
||||
types[GenericUtil.getGeneric(clazz)] = field
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,35 +0,0 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||
*/
|
||||
|
||||
package de.bixilon.minosoft.util.collections
|
||||
|
||||
@Deprecated("Kutil")
|
||||
abstract class AbstractPrimitiveList<T> : Clearable {
|
||||
var finished: Boolean = false
|
||||
protected set
|
||||
abstract val limit: Int
|
||||
abstract val size: Int
|
||||
abstract val isEmpty: Boolean
|
||||
|
||||
abstract fun ensureSize(needed: Int)
|
||||
abstract fun add(value: T)
|
||||
|
||||
abstract fun finish()
|
||||
|
||||
|
||||
protected fun checkFinished() {
|
||||
if (finished) {
|
||||
throw IllegalStateException("List is already finished!")
|
||||
}
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||
*/
|
||||
|
||||
package de.bixilon.minosoft.util.collections
|
||||
|
||||
@Deprecated("Kutil")
|
||||
interface Clearable {
|
||||
|
||||
fun clear()
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||
*/
|
||||
|
||||
package de.bixilon.minosoft.util.collections.bytes
|
||||
|
||||
import de.bixilon.minosoft.util.collections.AbstractPrimitiveList
|
||||
|
||||
@Deprecated("Kutil")
|
||||
abstract class AbstractByteList : AbstractPrimitiveList<Byte>() {
|
||||
|
||||
abstract fun addAll(bytes: ByteArray)
|
||||
abstract fun addAll(byteList: AbstractByteList)
|
||||
|
||||
abstract fun toArray(): ByteArray
|
||||
}
|
@ -1,126 +0,0 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||
*/
|
||||
package de.bixilon.minosoft.util.collections.bytes
|
||||
|
||||
@Deprecated("Kutil")
|
||||
class HeapArrayByteList(
|
||||
initialSize: Int = DEFAULT_INITIAL_SIZE,
|
||||
) : AbstractByteList() {
|
||||
private var data: ByteArray = ByteArray(initialSize)
|
||||
override val limit: Int
|
||||
get() = data.size
|
||||
override var size = 0
|
||||
override val isEmpty: Boolean
|
||||
get() = size == 0
|
||||
|
||||
private val nextGrowStep = when {
|
||||
initialSize <= 0 -> DEFAULT_INITIAL_SIZE
|
||||
initialSize <= 50 -> 50
|
||||
else -> initialSize
|
||||
}
|
||||
|
||||
private var output: ByteArray = ByteArray(0)
|
||||
private var outputUpToDate = false
|
||||
|
||||
private fun checkFinalized() {
|
||||
if (finished) {
|
||||
throw IllegalStateException("ByteArrayList is already finalized!")
|
||||
}
|
||||
}
|
||||
|
||||
override fun clear() {
|
||||
checkFinalized()
|
||||
size = 0
|
||||
outputUpToDate = false
|
||||
output = ByteArray(0)
|
||||
}
|
||||
|
||||
override fun ensureSize(needed: Int) {
|
||||
checkFinalized()
|
||||
if (limit - size >= needed) {
|
||||
return
|
||||
}
|
||||
var newSize = data.size
|
||||
while (newSize - size < needed) {
|
||||
newSize += nextGrowStep
|
||||
}
|
||||
grow(newSize)
|
||||
}
|
||||
|
||||
private fun grow(size: Int) {
|
||||
val oldData = data
|
||||
data = ByteArray(size)
|
||||
System.arraycopy(oldData, 0, data, 0, oldData.size)
|
||||
}
|
||||
|
||||
override fun add(value: Byte) {
|
||||
ensureSize(1)
|
||||
data[size++] = value
|
||||
if (outputUpToDate) {
|
||||
outputUpToDate = false
|
||||
}
|
||||
}
|
||||
|
||||
override fun addAll(bytes: ByteArray) {
|
||||
ensureSize(bytes.size)
|
||||
System.arraycopy(bytes, 0, data, size, bytes.size)
|
||||
size += bytes.size
|
||||
if (outputUpToDate) {
|
||||
outputUpToDate = false
|
||||
}
|
||||
}
|
||||
|
||||
override fun addAll(byteList: AbstractByteList) {
|
||||
ensureSize(byteList.size)
|
||||
val source: ByteArray = if (byteList is HeapArrayByteList) {
|
||||
if (byteList.finished) {
|
||||
byteList.output
|
||||
} else {
|
||||
byteList.data
|
||||
}
|
||||
} else {
|
||||
byteList.toArray()
|
||||
}
|
||||
System.arraycopy(source, 0, data, size, byteList.size)
|
||||
size += byteList.size
|
||||
|
||||
if (outputUpToDate) {
|
||||
outputUpToDate = false
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkOutputArray() {
|
||||
if (outputUpToDate) {
|
||||
return
|
||||
}
|
||||
output = ByteArray(size)
|
||||
System.arraycopy(data, 0, output, 0, size)
|
||||
outputUpToDate = true
|
||||
}
|
||||
|
||||
override fun toArray(): ByteArray {
|
||||
checkOutputArray()
|
||||
return output
|
||||
}
|
||||
|
||||
override fun finish() {
|
||||
finished = true
|
||||
checkOutputArray()
|
||||
data = ByteArray(0)
|
||||
}
|
||||
|
||||
|
||||
private companion object {
|
||||
private const val DEFAULT_INITIAL_SIZE = 1000
|
||||
}
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||
*/
|
||||
|
||||
package de.bixilon.minosoft.util.collections.floats
|
||||
|
||||
import de.bixilon.minosoft.util.collections.AbstractPrimitiveList
|
||||
import java.nio.FloatBuffer
|
||||
|
||||
@Deprecated("Kutil")
|
||||
abstract class AbstractFloatList : AbstractPrimitiveList<Float>() {
|
||||
|
||||
abstract fun add(array: FloatArray)
|
||||
operator fun plusAssign(array: FloatArray) = add(array)
|
||||
abstract fun add(floatList: AbstractFloatList)
|
||||
operator fun plusAssign(floatList: AbstractFloatList) = add(floatList)
|
||||
abstract fun add(buffer: FloatBuffer)
|
||||
operator fun plusAssign(buffer: FloatBuffer) = add(buffer)
|
||||
|
||||
abstract fun toArray(): FloatArray
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||
* Copyright (C) 2020-2023 Moritz Zwerger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
@ -13,6 +13,7 @@
|
||||
|
||||
package de.bixilon.minosoft.util.collections.floats
|
||||
|
||||
import de.bixilon.kutil.collections.primitive.floats.AbstractFloatList
|
||||
import de.bixilon.minosoft.util.collections.floats.FloatListUtil.copy
|
||||
import de.bixilon.minosoft.util.collections.floats.FloatListUtil.finish
|
||||
import org.lwjgl.system.MemoryUtil.memAllocFloat
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||
* Copyright (C) 2020-2023 Moritz Zwerger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
@ -13,6 +13,7 @@
|
||||
|
||||
package de.bixilon.minosoft.util.collections.floats
|
||||
|
||||
import de.bixilon.kutil.collections.primitive.floats.AbstractFloatList
|
||||
import de.bixilon.kutil.exception.ExceptionUtil
|
||||
import org.lwjgl.system.MemoryUtil.memAllocFloat
|
||||
import org.lwjgl.system.MemoryUtil.memFree
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||
* Copyright (C) 2020-2023 Moritz Zwerger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
@ -13,6 +13,7 @@
|
||||
|
||||
package de.bixilon.minosoft.util.collections.floats
|
||||
|
||||
import de.bixilon.kutil.collections.primitive.floats.AbstractFloatList
|
||||
import de.bixilon.kutil.exception.Broken
|
||||
import de.bixilon.minosoft.util.collections.floats.FloatListUtil.copy
|
||||
import org.lwjgl.system.MemoryUtil.memAllocFloat
|
||||
|
@ -1,132 +0,0 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||
*/
|
||||
package de.bixilon.minosoft.util.collections.floats
|
||||
|
||||
import java.nio.FloatBuffer
|
||||
|
||||
@Deprecated("Kutil")
|
||||
class HeapArrayFloatList(
|
||||
initialSize: Int = FloatListUtil.DEFAULT_INITIAL_SIZE,
|
||||
) : AbstractFloatList() {
|
||||
private var data: FloatArray = FloatArray(initialSize)
|
||||
override val limit: Int
|
||||
get() = data.size
|
||||
override var size = 0
|
||||
override val isEmpty: Boolean
|
||||
get() = size == 0
|
||||
|
||||
private val nextGrowStep = when {
|
||||
initialSize <= 0 -> FloatListUtil.DEFAULT_INITIAL_SIZE
|
||||
initialSize <= 50 -> 50
|
||||
else -> initialSize
|
||||
}
|
||||
|
||||
private var output: FloatArray = FloatArray(0)
|
||||
private var outputUpToDate = false
|
||||
|
||||
private fun checkFinalized() {
|
||||
if (finished) {
|
||||
throw IllegalStateException("ArrayFloatList is already finalized!")
|
||||
}
|
||||
}
|
||||
|
||||
override fun clear() {
|
||||
checkFinalized()
|
||||
size = 0
|
||||
invalidateOutput()
|
||||
output = FloatArray(0)
|
||||
}
|
||||
|
||||
override fun ensureSize(needed: Int) {
|
||||
checkFinalized()
|
||||
if (limit - size >= needed) {
|
||||
return
|
||||
}
|
||||
var newSize = data.size
|
||||
while (newSize - size < needed) {
|
||||
newSize += nextGrowStep
|
||||
}
|
||||
grow(newSize)
|
||||
}
|
||||
|
||||
private fun grow(size: Int) {
|
||||
val oldData = data
|
||||
data = FloatArray(size)
|
||||
System.arraycopy(oldData, 0, data, 0, oldData.size)
|
||||
}
|
||||
|
||||
override fun add(value: Float) {
|
||||
ensureSize(1)
|
||||
data[size++] = value
|
||||
invalidateOutput()
|
||||
}
|
||||
|
||||
override fun add(array: FloatArray) {
|
||||
ensureSize(array.size)
|
||||
System.arraycopy(array, 0, data, size, array.size)
|
||||
size += array.size
|
||||
invalidateOutput()
|
||||
}
|
||||
|
||||
override fun add(buffer: FloatBuffer) {
|
||||
val position = buffer.position()
|
||||
ensureSize(position)
|
||||
for (i in 0 until position) {
|
||||
data[size + i] = buffer.get(i)
|
||||
}
|
||||
size += position
|
||||
invalidateOutput()
|
||||
}
|
||||
|
||||
override fun add(floatList: AbstractFloatList) {
|
||||
ensureSize(floatList.size)
|
||||
val source: FloatArray = if (floatList is HeapArrayFloatList) {
|
||||
if (floatList.finished) {
|
||||
floatList.output
|
||||
} else {
|
||||
floatList.data
|
||||
}
|
||||
} else {
|
||||
floatList.toArray()
|
||||
}
|
||||
System.arraycopy(source, 0, data, size, floatList.size)
|
||||
size += floatList.size
|
||||
invalidateOutput()
|
||||
}
|
||||
|
||||
private fun checkOutputArray() {
|
||||
if (outputUpToDate) {
|
||||
return
|
||||
}
|
||||
output = FloatArray(size)
|
||||
System.arraycopy(data, 0, output, 0, size)
|
||||
outputUpToDate = true
|
||||
}
|
||||
|
||||
override fun toArray(): FloatArray {
|
||||
checkOutputArray()
|
||||
return output
|
||||
}
|
||||
|
||||
override fun finish() {
|
||||
finished = true
|
||||
checkOutputArray()
|
||||
data = FloatArray(0)
|
||||
}
|
||||
|
||||
private fun invalidateOutput() {
|
||||
if (outputUpToDate) {
|
||||
outputUpToDate = false
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||
* Copyright (C) 2020-2023 Moritz Zwerger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
@ -13,6 +13,8 @@
|
||||
|
||||
package de.bixilon.minosoft.util.collections.floats
|
||||
|
||||
import de.bixilon.kutil.collections.primitive.floats.AbstractFloatList
|
||||
import de.bixilon.kutil.collections.primitive.floats.HeapArrayFloatList
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.junit.jupiter.api.Test
|
||||
import java.nio.FloatBuffer
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||
* Copyright (C) 2020-2023 Moritz Zwerger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
@ -13,6 +13,8 @@
|
||||
|
||||
package de.bixilon.minosoft.util.collections.floats
|
||||
|
||||
import de.bixilon.kutil.collections.primitive.floats.AbstractFloatList
|
||||
|
||||
class BufferedFloatListTest : DirectFloatListTest() {
|
||||
|
||||
override fun create(initialSize: Int): AbstractFloatList {
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||
* Copyright (C) 2020-2023 Moritz Zwerger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
@ -13,6 +13,7 @@
|
||||
|
||||
package de.bixilon.minosoft.util.collections.floats
|
||||
|
||||
import de.bixilon.kutil.collections.primitive.floats.AbstractFloatList
|
||||
import org.junit.jupiter.api.Test
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||
* Copyright (C) 2020-2023 Moritz Zwerger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
@ -13,6 +13,9 @@
|
||||
|
||||
package de.bixilon.minosoft.util.collections.floats
|
||||
|
||||
import de.bixilon.kutil.collections.primitive.floats.AbstractFloatList
|
||||
import de.bixilon.kutil.collections.primitive.floats.HeapArrayFloatList
|
||||
|
||||
class HeapFloatListTest : AbstractFloatListTest() {
|
||||
|
||||
override fun create(initialSize: Int): AbstractFloatList {
|
||||
|
Loading…
x
Reference in New Issue
Block a user