bump dependencies

Includes all adaptions for kutil 1.27
This commit is contained in:
Moritz Zwerger 2025-05-22 18:04:36 +02:00
parent 7599296aff
commit 8e7410d44e
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
34 changed files with 70 additions and 254 deletions

View File

@ -47,7 +47,7 @@ import java.util.stream.Collectors
plugins {
kotlin("jvm") version "2.1.10"
kotlin("jvm") version "2.1.21"
`jvm-test-suite`
application
id("org.ajoberstar.grgit.service") version "5.3.0"
@ -86,7 +86,7 @@ repositories {
buildscript {
dependencies {
classpath("de.bixilon", "kutil", "1.27")
classpath("de.bixilon", "kutil", "1.27.2")
}
}
@ -176,7 +176,7 @@ testing {
dependencies {
implementation(project())
implementation("de.bixilon:kutil:$kutilVersion")
implementation("org.jetbrains.kotlin:kotlin-test:2.1.10")
implementation("org.jetbrains.kotlin:kotlin-test:2.1.21")
}
targets {
@ -355,13 +355,13 @@ fun DependencyHandler.lwjgl(name: String? = null) {
dependencies {
implementation("org.slf4j", "slf4j-api", "2.0.17")
implementation("com.google.guava", "guava", "33.4.0-jre")
implementation("com.google.guava", "guava", "33.4.8-jre")
implementation("dnsjava", "dnsjava", "3.6.3")
implementation("net.sourceforge.argparse4j", "argparse4j", "0.9.0")
implementation("org.jline", "jline", "3.29.0")
implementation("org.jline", "jline", "3.30.0")
implementation("org.l33tlabs.twl", "pngdecoder", "1.0")
implementation("com.github.oshi", "oshi-core", "6.7.1")
implementation("com.github.luben", "zstd-jni", "1.5.7-2", classifier = zstdNatives)
implementation("com.github.oshi", "oshi-core", "6.8.1")
implementation("com.github.luben", "zstd-jni", "1.5.7-3", classifier = zstdNatives)
implementation("org.apache.commons", "commons-lang3", "3.17.0")
implementation("org.kamranzafar", "jtar", "2.3")
implementation("org.reflections", "reflections", "0.10.2")
@ -401,7 +401,7 @@ dependencies {
lwjgl("stb")
// kotlin
implementation(kotlin("reflect", "2.1.10"))
implementation(kotlin("reflect", "2.1.21"))
// platform specific

View File

@ -14,8 +14,8 @@ kotlin.daemon.jvmargs=-Xmx3G
kotlin.code.style=official
javafx.version=19.0.2.1
lwjgl.version=3.3.6
ikonli.version=12.3.1
ikonli.version=12.4.0
netty.version=4.1.119.Final
jackson.version=2.18.3
kutil.version=1.27
jackson.version=2.19.0
kutil.version=1.27.2
glm.version=0.9.9.1-12

View File

@ -14,7 +14,6 @@
package de.bixilon.minosoft.data.entities.entities.player.local
import de.bixilon.kotlinglm.vec3.Vec3d
import de.bixilon.kutil.primitive.BooleanUtil.decide
import de.bixilon.minosoft.data.Tickable
import de.bixilon.minosoft.data.entities.EntityRotation
import de.bixilon.minosoft.data.entities.entities.Entity
@ -51,7 +50,7 @@ class MovementPacketSender(
if (this.sprinting == sprinting) {
return
}
session.connection.send(EntityActionC2SP(player.id, sprinting.decide(EntityActionC2SP.EntityActions.START_SPRINTING, EntityActionC2SP.EntityActions.STOP_SPRINTING)))
session.connection.send(EntityActionC2SP(player.id, if(sprinting) EntityActionC2SP.EntityActions.START_SPRINTING else EntityActionC2SP.EntityActions.STOP_SPRINTING))
this.sprinting = sprinting
}
@ -59,7 +58,7 @@ class MovementPacketSender(
if (this.sneaking == sneaking) {
return
}
session.connection.send(EntityActionC2SP(player.id, sneaking.decide(EntityActionC2SP.EntityActions.START_SNEAKING, EntityActionC2SP.EntityActions.STOP_SNEAKING)))
session.connection.send(EntityActionC2SP(player.id, if(sneaking) EntityActionC2SP.EntityActions.START_SNEAKING else EntityActionC2SP.EntityActions.STOP_SNEAKING))
this.sneaking = sneaking
}

View File

@ -17,6 +17,7 @@ import de.bixilon.kutil.cast.CastUtil.nullCast
import de.bixilon.kutil.concurrent.lock.RWLock
import de.bixilon.kutil.concurrent.schedule.TaskScheduler.runLater
import de.bixilon.kutil.latch.AbstractLatch
import de.bixilon.kutil.time.Interval
import de.bixilon.kutil.time.TimeUtil.millis
import de.bixilon.minosoft.data.accounts.Account
import de.bixilon.minosoft.data.chat.message.internal.InternalChatMessage
@ -30,7 +31,10 @@ import de.bixilon.minosoft.protocol.packets.c2s.play.SessionDataC2SP
import de.bixilon.minosoft.protocol.protocol.ProtocolStates
import de.bixilon.minosoft.protocol.protocol.ProtocolVersions
import de.bixilon.minosoft.util.account.minecraft.MinecraftPrivateKey
import java.time.Duration
import java.time.Instant
import kotlin.time.Duration.Companion.milliseconds
import kotlin.time.Duration.Companion.seconds
class SignatureKeyManagement(
val session: PlaySession,
@ -46,8 +50,8 @@ class SignatureKeyManagement(
fetchKey(latch)
}
private fun registerRefresh(millis: Int) {
runLater(millis) {
private fun registerRefresh(interval: Interval) {
runLater(interval) {
val connection = session.connection.nullCast<NetworkConnection>() ?: return@runLater
if (session.error != null || (session.established && !connection.active) || (connection.active && !connection.client!!.encrypted)) {
// session is dead
@ -57,7 +61,7 @@ class SignatureKeyManagement(
fetchKey(null)
} catch (error: Throwable) {
session.events.fire(ChatMessageEvent(session, InternalChatMessage(TextComponent("Failed to refresh private key. Trying again in 60s: $error"))))
registerRefresh(60 * 1000)
registerRefresh(60.seconds)
}
}
}
@ -70,7 +74,7 @@ class SignatureKeyManagement(
private = key.pair.private,
public = key.pair.public,
)
registerRefresh(maxOf((key.refreshedAfter.toEpochMilli() - millis()).toInt(), 100))
registerRefresh(maxOf((key.refreshedAfter.toEpochMilli() - millis()).milliseconds, 100.milliseconds))
sendSession()
}

View File

@ -14,7 +14,6 @@
package de.bixilon.minosoft.data.registries.item.items.pixlyzer
import de.bixilon.kutil.json.JsonUtil.asJsonObject
import de.bixilon.kutil.primitive.BooleanUtil.decide
import de.bixilon.kutil.primitive.BooleanUtil.toBoolean
import de.bixilon.kutil.primitive.IntUtil.toInt
import de.bixilon.minosoft.data.registries.factory.clazz.MultiClassFactory
@ -26,7 +25,7 @@ import de.bixilon.minosoft.data.registries.registries.Registries
class PixLyzerFoodItem(
resourceLocation: ResourceLocation,
registries: Registries,
data: Map<String, Any>,
data: Map<String, Any>
) : PixLyzerItem(resourceLocation, registries, data), FoodItem {
override val nutrition: Int
override val alwaysEdible: Boolean
@ -36,7 +35,7 @@ class PixLyzerFoodItem(
val foodProperties = data["food_properties"].asJsonObject()
nutrition = foodProperties["nutrition"]?.toInt() ?: 0
alwaysEdible = foodProperties["can_always_eat"]?.toBoolean() ?: false
eatTime = foodProperties["time_to_eat"]?.toInt() ?: foodProperties["fast_food"]?.toBoolean()?.decide(16, 32) ?: 100
eatTime = foodProperties["time_to_eat"]?.toInt() ?: foodProperties["fast_food"]?.toBoolean()?.let { if(it) 16 else 32 } ?: 100
}
companion object : PixLyzerItemFactory<PixLyzerFoodItem>, MultiClassFactory<PixLyzerFoodItem> {

View File

@ -18,6 +18,8 @@ import de.bixilon.kutil.array.ArrayUtil.cast
import de.bixilon.kutil.cast.CastUtil.unsafeCast
import de.bixilon.kutil.math.simple.DoubleMath.ceil
import de.bixilon.kutil.math.simple.DoubleMath.floor
import de.bixilon.kutil.memory.allocator.LongAllocator
import de.bixilon.kutil.memory.allocator.TemporaryAllocator
import de.bixilon.minosoft.data.Axes
import de.bixilon.minosoft.data.registries.blocks.shapes.collision.CollisionPredicate
import de.bixilon.minosoft.data.registries.blocks.shapes.collision.context.CollisionContext
@ -35,8 +37,6 @@ import de.bixilon.minosoft.data.world.positions.BlockPosition
import de.bixilon.minosoft.data.world.positions.BlockPosition.Companion.clampX
import de.bixilon.minosoft.data.world.positions.BlockPosition.Companion.clampY
import de.bixilon.minosoft.data.world.positions.BlockPosition.Companion.clampZ
import de.bixilon.minosoft.gui.rendering.util.allocator.LongAllocator
import de.bixilon.minosoft.gui.rendering.util.allocator.TemporaryAllocator
class CollisionShape(
val world: World,

View File

@ -13,6 +13,7 @@
package de.bixilon.minosoft.data.world.container.block
import de.bixilon.kutil.memory.allocator.ShortAllocator
import de.bixilon.minosoft.data.direction.DirectionVector
import de.bixilon.minosoft.data.direction.Directions
import de.bixilon.minosoft.data.registries.blocks.cube.CubeDirections
@ -21,7 +22,6 @@ import de.bixilon.minosoft.data.registries.blocks.state.BlockStateFlags
import de.bixilon.minosoft.data.registries.blocks.types.properties.shape.special.FullOpaqueBlock
import de.bixilon.minosoft.data.registries.blocks.types.properties.shape.special.PotentialFullOpaqueBlock
import de.bixilon.minosoft.data.world.positions.InSectionPosition
import de.bixilon.minosoft.gui.rendering.util.allocator.ShortAllocator
import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition
import it.unimi.dsi.fastutil.ints.IntOpenHashSet
import java.util.*

View File

@ -13,8 +13,8 @@
package de.bixilon.minosoft.data.world.container.palette.data.array
import de.bixilon.kutil.memory.allocator.LongAllocator
import de.bixilon.minosoft.data.world.container.palette.data.PaletteData
import de.bixilon.minosoft.gui.rendering.util.allocator.LongAllocator
import de.bixilon.minosoft.protocol.protocol.ProtocolVersions.V_1_16
import de.bixilon.minosoft.protocol.protocol.buffers.play.PlayInByteBuffer
@ -91,6 +91,5 @@ class ArrayPaletteData(
companion object {
private val ALLOCATOR = LongAllocator()
const val LONG_BIT_SPLITTING_VERSION = V_1_16 // ToDo: When did this changed? is just a guess
}
}

View File

@ -15,7 +15,6 @@ package de.bixilon.minosoft.gui.eros.dialog
import de.bixilon.kutil.concurrent.pool.DefaultThreadPool
import de.bixilon.kutil.observer.DataObserver.Companion.observe
import de.bixilon.kutil.primitive.BooleanUtil.decide
import de.bixilon.minosoft.config.profile.profiles.eros.ErosProfileManager
import de.bixilon.minosoft.config.profile.profiles.eros.server.entries.ErosServer
import de.bixilon.minosoft.data.registries.identified.ResourceLocation
@ -72,7 +71,7 @@ class ServerModifyDialog(
public override fun show() {
JavaFXUtil.runLater {
JavaFXUtil.openModal((server == null).decide(ADD_TITLE, EDIT_TITLE), LAYOUT, this)
JavaFXUtil.openModal(if(server == null) ADD_TITLE else EDIT_TITLE, LAYOUT, this)
super.show()
}
}
@ -176,8 +175,8 @@ class ServerModifyDialog(
if (modifyServerButtonFX.isDisable) {
return
}
val forcedVersion = (forcedVersionFX.selectionModel.selectedItem == Versions.AUTOMATIC).decide(null) { forcedVersionFX.selectionModel.selectedItem }
DefaultThreadPool += { onUpdate(serverNameFX.text.isBlank().decide({ serverAddressFX.text.toString() }, { serverNameFX.text.trim() }), serverAddressFX.text, forcedVersion, profiles, optionQueryVersionFX.isSelected) }
val forcedVersion = forcedVersionFX.selectionModel.selectedItem.takeIf { forcedVersionFX.selectionModel.selectedItem != Versions.AUTOMATIC }
DefaultThreadPool += { onUpdate(if(serverNameFX.text.isBlank()) serverAddressFX.text.toString() else serverNameFX.text.trim(), serverAddressFX.text, forcedVersion, profiles, optionQueryVersionFX.isSelected) }
stage.close()
}

View File

@ -19,7 +19,6 @@ import de.bixilon.kutil.concurrent.pool.DefaultThreadPool
import de.bixilon.kutil.concurrent.pool.runnable.ForcePooledRunnable
import de.bixilon.kutil.latch.CallbackLatch
import de.bixilon.kutil.observer.map.MapChange.Companion.values
import de.bixilon.kutil.primitive.BooleanUtil.decide
import de.bixilon.minosoft.config.profile.profiles.eros.ErosProfileManager
import de.bixilon.minosoft.data.accounts.Account
import de.bixilon.minosoft.data.accounts.AccountStates
@ -105,7 +104,7 @@ class AccountController : EmbeddedJavaFXController<Pane>() {
}
}
accountListViewFX.items.contains(selected).decide(selected, null).let {
(if (selected in accountListViewFX.items) selected else null).let {
accountListViewFX.selectionModel.select(it)
accountListViewFX.scrollTo(it)
setAccountInfo(it)

View File

@ -17,7 +17,6 @@ import de.bixilon.kutil.cast.CastUtil.unsafeCast
import de.bixilon.kutil.collections.CollectionUtil.toSynchronizedSet
import de.bixilon.kutil.concurrent.pool.DefaultThreadPool.async
import de.bixilon.kutil.latch.CallbackLatch
import de.bixilon.kutil.primitive.BooleanUtil.decide
import de.bixilon.kutil.primitive.IntUtil.thousands
import de.bixilon.kutil.unit.UnitFormatter.formatNanos
import de.bixilon.minosoft.config.profile.ProfileType
@ -236,7 +235,7 @@ class ServerListController : EmbeddedJavaFXController<Pane>(), Refreshable {
updateServer(server)
}
serverListViewFX.items.contains(selected).decide(selected, null).let {
selected.takeIf {selected in serverListViewFX.items}.let {
serverListViewFX.selectionModel.select(it)
serverListViewFX.scrollTo(it)

View File

@ -14,7 +14,6 @@
package de.bixilon.minosoft.gui.eros.main.profiles
import de.bixilon.kutil.observer.map.MapChange.Companion.values
import de.bixilon.kutil.primitive.BooleanUtil.decide
import de.bixilon.minosoft.config.profile.profiles.Profile
import de.bixilon.minosoft.config.profile.storage.StorageProfileManager
import de.bixilon.minosoft.data.registries.identified.ResourceLocation
@ -92,7 +91,7 @@ class ProfilesListController : EmbeddedJavaFXController<Pane>() {
updateProfile(profile)
}
profilesListViewFX.items.contains(selected).decide(selected, null).let {
selected.takeIf { selected in profilesListViewFX.items }.let {
profilesListViewFX.selectionModel.select(it)
profilesListViewFX.scrollTo(it)
@ -104,7 +103,7 @@ class ProfilesListController : EmbeddedJavaFXController<Pane>() {
// Platform.runLater {serverListViewFX.items.remove(card)}
if (!profilesListViewFX.items.contains(profile)) {
if (profile !in profilesListViewFX.items) {
profilesListViewFX.items.add(profile)
}

View File

@ -18,7 +18,6 @@ import de.bixilon.kutil.latch.AbstractLatch
import de.bixilon.kutil.latch.ParentLatch
import de.bixilon.kutil.latch.SimpleLatch
import de.bixilon.kutil.observer.DataObserver.Companion.observe
import de.bixilon.kutil.primitive.BooleanUtil.decide
import de.bixilon.kutil.reflection.ReflectionUtil.forceSet
import de.bixilon.kutil.unit.UnitFormatter.formatNanos
import de.bixilon.minosoft.gui.rendering.RenderUtil.pause
@ -124,9 +123,9 @@ object RenderLoader {
Log.log(LogMessageType.RENDERING, LogLevels.VERBOSE) { "Finishing up (after ${stopwatch.labTime()})..." }
window::focused.observeRendering(this) { state = it.decide(RenderingStates.RUNNING, RenderingStates.SLOW) }
window::focused.observeRendering(this) { state = if(it) RenderingStates.RUNNING else RenderingStates.SLOW }
window::iconified.observeRendering(this) { state = it.decide(RenderingStates.PAUSED, RenderingStates.RUNNING) }
window::iconified.observeRendering(this) { state = if(it) RenderingStates.PAUSED else RenderingStates.RUNNING }
input.init()

View File

@ -16,7 +16,6 @@ package de.bixilon.minosoft.gui.rendering.gui.hud.elements.hotbar.health
import de.bixilon.kotlinglm.vec2.Vec2
import de.bixilon.kotlinglm.vec2.Vec2i
import de.bixilon.kutil.math.simple.FloatMath.rounded10
import de.bixilon.kutil.primitive.BooleanUtil.decide
import de.bixilon.minosoft.data.registries.effects.attributes.MinecraftAttributes
import de.bixilon.minosoft.data.registries.effects.damage.DamageEffect
import de.bixilon.minosoft.data.text.BaseComponent
@ -79,7 +78,7 @@ class HotbarHealthElement(guiRenderer: GUIRenderer) : AbstractHotbarHealthElemen
AtlasImageElement(guiRenderer, image).render(offset + Vec2i(column, (rows - 1) - row) * HEART_SIZE, consumer, options)
heart++
healthLeft -= halfHeart.decide(1.0f, 2.0f)
healthLeft -= if(halfHeart) 1.0f else 2.0f
}
}

View File

@ -15,7 +15,6 @@ package de.bixilon.minosoft.gui.rendering.gui.hud.elements.hotbar.health
import de.bixilon.kotlinglm.vec2.Vec2
import de.bixilon.kutil.math.simple.FloatMath.rounded10
import de.bixilon.kutil.primitive.BooleanUtil.decide
import de.bixilon.minosoft.data.entities.entities.LivingEntity
import de.bixilon.minosoft.data.registries.effects.attributes.MinecraftAttributes
import de.bixilon.minosoft.data.text.ChatComponent
@ -61,7 +60,7 @@ class HotbarVehicleHealthElement(guiRenderer: GUIRenderer) : AbstractHotbarHealt
image?.render(offset + Vec2(column, (rows - 1) - row) * HEART_SIZE, consumer, options)
heart++
healthLeft -= halfHeart.decide(1.0f, 2.0f)
healthLeft -= if(halfHeart) 1.0f else 2.0f
}
}

View File

@ -15,6 +15,7 @@ package de.bixilon.minosoft.gui.rendering.gui.hud.elements.other.debug
import de.bixilon.kutil.concurrent.schedule.RepeatedTask
import de.bixilon.kutil.concurrent.schedule.TaskScheduler
import kotlin.time.Duration.Companion.milliseconds
object AllocationRate {
const val RUNS_PER_SECOND = 3
@ -24,7 +25,7 @@ object AllocationRate {
private var previous = 0L
init {
TaskScheduler += RepeatedTask(1000 / RUNS_PER_SECOND) { tick() }
TaskScheduler += RepeatedTask(1000.milliseconds / RUNS_PER_SECOND) { tick() }
}
private fun tick() {

View File

@ -18,7 +18,6 @@ import de.bixilon.kotlinglm.vec2.Vec2i
import de.bixilon.kutil.collections.CollectionUtil.synchronizedMapOf
import de.bixilon.kutil.collections.CollectionUtil.toSynchronizedMap
import de.bixilon.kutil.observer.DataObserver.Companion.observe
import de.bixilon.kutil.primitive.BooleanUtil.decide
import de.bixilon.minosoft.config.key.KeyActions
import de.bixilon.minosoft.config.key.KeyBinding
import de.bixilon.minosoft.config.key.KeyCodes
@ -92,7 +91,7 @@ class TabListElement(guiRenderer: GUIRenderer) : Element(guiRenderer), LayoutedE
}
}
offset.x = offsetBefore.x
offset.y = offsetBefore.y + (columns > 1).decide(ENTRIES_PER_COLUMN, toRender.size) * (TabListEntryElement.HEIGHT + ENTRY_VERTICAL_SPACING)
offset.y = offsetBefore.y + (if(columns > 1) ENTRIES_PER_COLUMN else toRender.size) * (TabListEntryElement.HEIGHT + ENTRY_VERTICAL_SPACING)
footer.size.let {
@ -150,7 +149,7 @@ class TabListElement(guiRenderer: GUIRenderer) : Element(guiRenderer), LayoutedE
widths[column] = currentMaxPrefWidth
totalEntriesWidth += currentMaxPrefWidth
}
size.y += (columns > 1).decide(ENTRIES_PER_COLUMN, toRender.size) * (TabListEntryElement.HEIGHT + ENTRY_VERTICAL_SPACING)
size.y += (if(columns > 1) ENTRIES_PER_COLUMN else toRender.size) * (TabListEntryElement.HEIGHT + ENTRY_VERTICAL_SPACING)
size.y -= ENTRY_VERTICAL_SPACING // Remove already added space again

View File

@ -14,7 +14,6 @@
package de.bixilon.minosoft.gui.rendering.input.key
import de.bixilon.kutil.cast.CastUtil.nullCast
import de.bixilon.kutil.primitive.BooleanUtil.decide
import de.bixilon.minosoft.config.StaticConfiguration
import de.bixilon.minosoft.config.key.KeyActions
import de.bixilon.minosoft.config.key.KeyBinding
@ -71,7 +70,7 @@ object DebugKeyBindings {
KeyActions.MODIFIER to setOf(KeyCodes.KEY_F4),
KeyActions.STICKY to setOf(KeyCodes.KEY_P),
)) {
val nextMode = it.decide(PolygonModes.LINE, PolygonModes.FILL)
val nextMode = if(it) PolygonModes.LINE else PolygonModes.FILL
context.framebuffer.world.polygonMode = nextMode
session.util.sendDebugMessage("Polygon mode: ${nextMode.format()}")
}

View File

@ -1,22 +0,0 @@
/*
* Minosoft
* Copyright (C) 2020-2025 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.gui.rendering.util.allocator
@Deprecated("kutil 1.27.1")
class ByteAllocator : TemporaryAllocator<ByteArray>() {
override fun getSize(value: ByteArray) = value.size
override fun create(size: Int) = ByteArray(size)
}

View File

@ -1,22 +0,0 @@
/*
* Minosoft
* Copyright (C) 2020-2025 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.gui.rendering.util.allocator
@Deprecated("kutil 1.27.1")
class LongAllocator : TemporaryAllocator<LongArray>() {
override fun getSize(value: LongArray) = value.size
override fun create(size: Int) = LongArray(size)
}

View File

@ -1,22 +0,0 @@
/*
* Minosoft
* Copyright (C) 2020-2025 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.gui.rendering.util.allocator
@Deprecated("kutil 1.27.1")
class ShortAllocator : TemporaryAllocator<ShortArray>() {
override fun getSize(value: ShortArray) = value.size
override fun create(size: Int) = ShortArray(size)
}

View File

@ -1,81 +0,0 @@
/*
* Minosoft
* Copyright (C) 2020-2025 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.gui.rendering.util.allocator
import de.bixilon.kutil.concurrent.lock.locks.reentrant.ReentrantLock
import java.lang.ref.WeakReference
@Deprecated("kutil 1.27.1")
abstract class TemporaryAllocator<T> {
private val lock = ReentrantLock()
private val list: ArrayList<WeakReference<T>> = ArrayList()
private fun cleanup() {
if (list.size < 10) return
lock.lock()
val iterator = list.iterator()
while (iterator.hasNext()) {
val reference = iterator.next()
if (reference.get() == null) {
iterator.remove()
}
}
lock.unlock()
}
fun free(array: T) {
lock.lock()
cleanup()
list.add(0, WeakReference(array))
lock.unlock()
}
private fun find(size: Int): T? {
if (this.list.isEmpty()) return null
lock.lock()
var array: T? = null
val iterator = list.iterator()
while (iterator.hasNext()) {
val reference = iterator.next()
val entry = reference.get()
if (entry == null) {
iterator.remove()
continue
}
if (getSize(entry) >= size) {
array = entry
iterator.remove()
break
}
}
lock.unlock()
return array
}
fun allocate(size: Int): T {
val array = find(size)
if (array != null) return array
// println("Allocating array of size $size")
return create(size)
}
protected abstract fun getSize(value: T): Int
protected abstract fun create(size: Int): T
}

View File

@ -18,6 +18,7 @@ import de.bixilon.kutil.concurrent.schedule.RepeatedTask
import de.bixilon.kutil.concurrent.schedule.TaskScheduler
import de.bixilon.kutil.exception.Broken
import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition
import kotlin.time.Duration.Companion.milliseconds
abstract class KeyHandler {
private var task: RepeatedTask? = null
@ -25,7 +26,7 @@ abstract class KeyHandler {
private set
private fun queueTick() {
val task = RepeatedTask(ProtocolDefinition.TICK_TIME, maxDelay = ProtocolDefinition.TICK_TIME, priority = ThreadPool.HIGH) { onTick() }
val task = RepeatedTask(ProtocolDefinition.TICK_TIME.milliseconds, priority = ThreadPool.HIGH) { onTick() }
this.task = task
TaskScheduler += task
}

View File

@ -68,7 +68,7 @@ object OutOfBlockPusher {
val dimensions = Vec2d(entity.dimensions)
val dimensionsX = dimensions.x * 0.35
val dimensionsY = dimensions.y * 0.35 // TODO: Really dimensions y???
val dimensionsY = dimensions.y * 0.35
pushOutOfBlocks(position.x - dimensionsX, position.z + dimensionsY)
pushOutOfBlocks(position.x - dimensionsX, position.z - dimensionsY)

View File

@ -13,6 +13,7 @@
package de.bixilon.minosoft.protocol.network.network.client.netty
import de.bixilon.minosoft.gui.rendering.util.allocator.ByteAllocator
import de.bixilon.kutil.memory.allocator.ByteAllocator
val NetworkAllocator = ByteAllocator()

View File

@ -13,16 +13,14 @@
package de.bixilon.minosoft.protocol.network.network.client.netty.pipeline.compression
import de.bixilon.kutil.buffer.ByteBufferUtil.createBuffer
import de.bixilon.kutil.compression.zlib.ZlibUtil.decompress
import de.bixilon.minosoft.protocol.network.network.client.netty.NetworkAllocator
import de.bixilon.minosoft.protocol.network.network.client.netty.ReadArray
import de.bixilon.minosoft.protocol.network.network.client.netty.exceptions.ciritical.PacketTooLongException
import de.bixilon.minosoft.protocol.network.network.client.netty.pipeline.compression.exception.SizeMismatchInflaterException
import de.bixilon.minosoft.protocol.protocol.buffers.InByteBuffer
import de.bixilon.minosoft.util.KUtil.readByteArray
import io.netty.channel.ChannelHandlerContext
import io.netty.handler.codec.MessageToMessageDecoder
import java.util.zip.Inflater
class PacketInflater(
@ -55,22 +53,6 @@ class PacketInflater(
out += ReadArray(decompressed, uncompressedLength)
}
@Deprecated("kutil 1.27.1")
private fun ByteArray.decompress(output: ByteArray): Int {
val inflater = Inflater()
inflater.setInput(this, 0, this.size)
val buffer = createBuffer()
var pointer = 0
while (!inflater.finished()) {
val length = inflater.inflate(buffer)
System.arraycopy(buffer, 0, output, pointer, length)
pointer += length
}
return pointer
}
companion object {
const val NAME = "packet_inflater"
}

View File

@ -26,7 +26,6 @@ import de.bixilon.minosoft.protocol.packets.s2c.S2CPacket
import de.bixilon.minosoft.protocol.protocol.DefaultPacketMapping
import de.bixilon.minosoft.protocol.protocol.buffers.InByteBuffer
import de.bixilon.minosoft.protocol.versions.Version
import de.bixilon.minosoft.util.KUtil.readByteArray
import io.netty.channel.ChannelHandlerContext
import io.netty.handler.codec.MessageToMessageDecoder
import java.lang.reflect.InvocationTargetException

View File

@ -24,6 +24,7 @@ import de.bixilon.minosoft.data.world.time.WorldTime
import de.bixilon.minosoft.protocol.network.session.play.PlaySession
import de.bixilon.minosoft.protocol.network.session.play.PlaySessionStates
import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition
import kotlin.time.Duration.Companion.milliseconds
class SessionTicker(private val session: PlaySession) {
private val tasks: MutableSet<RepeatedTask> = mutableSetOf()
@ -39,27 +40,27 @@ class SessionTicker(private val session: PlaySession) {
} else {
// Ticks are postponed 10 ticks
// When joining/respawning the lock on chunks, etc is the performance bottleneck and makes the game laggy.
runLater(10 * ProtocolDefinition.TICK_TIME) { register() }
runLater(10.milliseconds * ProtocolDefinition.TICK_TIME) { register() }
}
}
}
private fun addDefault() {
tasks += RepeatedTask(INTERVAL, maxDelay = MAX_DELAY) {
tasks += RepeatedTask(INTERVAL) {
session.world.entities.tick()
}
tasks += RepeatedTask(INTERVAL, maxDelay = MAX_DELAY) {
tasks += RepeatedTask(INTERVAL) {
session.world.tick()
}
tasks += RepeatedTask(INTERVAL, maxDelay = MAX_DELAY) {
tasks += RepeatedTask(INTERVAL) {
session.world.randomDisplayTick()
}
if (DebugOptions.LIGHT_DEBUG_MODE || DebugOptions.INFINITE_TORCHES) {
tasks += RepeatedTask(INTERVAL, maxDelay = MAX_DELAY) { session.player.items.inventory[44] = ItemStack(session.registries.item["minecraft:torch"]!!, Int.MAX_VALUE) }
tasks += RepeatedTask(INTERVAL) { session.player.items.inventory[44] = ItemStack(session.registries.item["minecraft:torch"]!!, Int.MAX_VALUE) }
}
if (DebugOptions.SIMULATE_TIME) {
tasks += RepeatedTask(INTERVAL, maxDelay = MAX_DELAY) {
tasks += RepeatedTask(INTERVAL) {
val time = session.world.time.time
val offset = if (time in 11800..13300 || (time < 300 || time > 22800)) {
20
@ -105,7 +106,7 @@ class SessionTicker(private val session: PlaySession) {
fun register(runnable: Runnable) {
lock.lock()
val task = RepeatedTask(INTERVAL, maxDelay = MAX_DELAY, runnable = runnable)
val task = RepeatedTask(INTERVAL, runnable = runnable)
this.tasks += task
if (registered) {
TaskScheduler += task
@ -116,7 +117,6 @@ class SessionTicker(private val session: PlaySession) {
operator fun plusAssign(runnable: Runnable) = register(runnable)
private companion object {
const val INTERVAL = ProtocolDefinition.TICK_TIME
const val MAX_DELAY = INTERVAL / 2
val INTERVAL = ProtocolDefinition.TICK_TIME.milliseconds
}
}

View File

@ -20,6 +20,7 @@ import de.bixilon.kutil.observer.DataObserver.Companion.observe
import de.bixilon.kutil.unit.UnitFormatter.formatMillis
import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition
import java.util.concurrent.TimeoutException
import kotlin.time.Duration.Companion.milliseconds
class TimeoutHandler(val session: StatusSession) {
private var task: QueuedTask? = null
@ -48,7 +49,7 @@ class TimeoutHandler(val session: StatusSession) {
cancel()
cancelled = false
task = runLater(ProtocolDefinition.SOCKET_TIMEOUT) {
task = runLater(ProtocolDefinition.SOCKET_TIMEOUT.milliseconds) {
if (cancelled) return@runLater
if (session.state == StatusSessionStates.ERROR) return@runLater
if (session.state == StatusSessionStates.PING_DONE) return@runLater

View File

@ -18,6 +18,7 @@ import de.bixilon.kutil.exception.Broken
import de.bixilon.kutil.json.JsonObject
import de.bixilon.kutil.json.JsonUtil.asJsonObject
import de.bixilon.kutil.json.JsonUtil.toJsonObject
import de.bixilon.kutil.memory.allocator.ByteAllocator
import de.bixilon.kutil.primitive.IntUtil.toInt
import de.bixilon.minosoft.config.StaticConfiguration
import de.bixilon.minosoft.data.registries.biomes.Biome
@ -28,7 +29,6 @@ import de.bixilon.minosoft.data.world.positions.BlockPosition
import de.bixilon.minosoft.data.world.positions.ChunkPosition
import de.bixilon.minosoft.data.world.positions.InChunkPosition
import de.bixilon.minosoft.datafixer.rls.BlockEntityFixer.fixBlockEntity
import de.bixilon.minosoft.gui.rendering.util.allocator.ByteAllocator
import de.bixilon.minosoft.protocol.network.session.play.PlaySession
import de.bixilon.minosoft.protocol.packets.s2c.PlayS2CPacket
import de.bixilon.minosoft.protocol.packets.s2c.play.block.chunk.light.ChunkLightS2CP
@ -46,7 +46,6 @@ import de.bixilon.minosoft.protocol.protocol.ProtocolVersions.V_20W45A
import de.bixilon.minosoft.protocol.protocol.ProtocolVersions.V_21W03A
import de.bixilon.minosoft.protocol.protocol.ProtocolVersions.V_21W37A
import de.bixilon.minosoft.protocol.protocol.buffers.play.PlayInByteBuffer
import de.bixilon.minosoft.util.KUtil.readByteArray
import de.bixilon.minosoft.util.KUtil.toResourceLocation
import de.bixilon.minosoft.util.logging.Log
import de.bixilon.minosoft.util.logging.LogLevels

View File

@ -15,7 +15,6 @@ package de.bixilon.minosoft.protocol.packets.s2c.play.world
import de.bixilon.kotlinglm.vec3.Vec3d
import de.bixilon.kutil.enums.ValuesEnum
import de.bixilon.kutil.enums.ValuesEnum.Companion.names
import de.bixilon.kutil.primitive.BooleanUtil.decide
import de.bixilon.minosoft.data.world.World
import de.bixilon.minosoft.data.world.chunk.chunk.Chunk
import de.bixilon.minosoft.data.world.chunk.update.block.ChunkLocalBlockUpdate
@ -35,7 +34,7 @@ import de.bixilon.minosoft.util.logging.LogMessageType
class ExplosionS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
val position = if (buffer.versionId >= ProtocolVersions.V_22W42A) buffer.readVec3d() else Vec3d(buffer.readVec3f())
val power = buffer.readFloat()
val explodedBlocks: Array<BlockPosition> = buffer.readArray((buffer.versionId < V_1_17).decide({ buffer.readInt() }, { buffer.readVarInt() })) { BlockPosition(buffer.readByte().toInt(), buffer.readByte().toInt(), buffer.readByte().toInt()) } // ToDo: Find out version
val explodedBlocks: Array<BlockPosition> = buffer.readArray(if(buffer.versionId < V_1_17)buffer.readInt() else buffer.readVarInt()) { BlockPosition(buffer.readByte().toInt(), buffer.readByte().toInt(), buffer.readByte().toInt()) } // ToDo: Find out version
val velocity = buffer.readVec3f()
val destruct = if (buffer.versionId >= V_23W45A) buffer.readEnum(DestructionTypes) else DestructionTypes.DESTROY
val particle = if (buffer.versionId >= V_23W45A) buffer.readParticleData() else null

View File

@ -31,10 +31,9 @@ import de.bixilon.kutil.collections.CollectionUtil.toSynchronizedSet
import de.bixilon.kutil.concurrent.pool.DefaultThreadPool
import de.bixilon.kutil.concurrent.pool.runnable.ForcePooledRunnable
import de.bixilon.kutil.concurrent.schedule.TaskScheduler
import de.bixilon.kutil.primitive.BooleanUtil.decide
import de.bixilon.kutil.primitive.DoubleUtil
import de.bixilon.kutil.primitive.DoubleUtil.matches
import de.bixilon.kutil.primitive.IntUtil.checkInt
import de.bixilon.kutil.primitive.IntUtil.isIntSafe
import de.bixilon.kutil.reflection.ReflectionUtil.field
import de.bixilon.kutil.reflection.ReflectionUtil.forceInit
import de.bixilon.kutil.reflection.ReflectionUtil.getFieldOrNull
@ -169,7 +168,7 @@ object KUtil {
is CharSequence -> this.toString()
null -> TextComponent("null").color(ChatColors.DARK_RED)
is TextFormattable -> this.toText()
is Boolean -> TextComponent(this.toString()).color(this.decide(ChatColors.GREEN, ChatColors.RED))
is Boolean -> TextComponent(this.toString()).color(if(this) ChatColors.GREEN else ChatColors.RED)
is Enum<*> -> {
val name = this.name
TextComponent(
@ -230,7 +229,7 @@ object KUtil {
if (string == "true") return true
if (string == "false") return false
string.checkInt()?.let { return it }
string.isIntSafe()?.let { return it }
return string
}
@ -353,15 +352,4 @@ object KUtil {
}
fun ObjectNode.toMap(): HashMap<String, JsonNode> = OBJECT_NODE_CHILDREN[this]
@Deprecated("kutil 1.27.1")
private val IN_BYTE_BUFFER_BYTES = InByteBuffer::class.java.getFieldOrNull("bytes")!!
@Deprecated("kutil 1.27.1")
fun InByteBuffer.readByteArray(array: ByteArray, offset: Int = 0, length: Int) {
require(length, 1)
if (offset + array.size < length) throw IllegalArgumentException("Provided array has not enough capacity! (required: ${offset + array.size}, length=$length)")
System.arraycopy(IN_BYTE_BUFFER_BYTES[this], pointer, array, offset, length)
pointer += length
}
}

View File

@ -36,6 +36,7 @@ import de.bixilon.minosoft.util.logging.Log
import de.bixilon.minosoft.util.logging.LogLevels
import de.bixilon.minosoft.util.logging.LogMessageType
import java.util.concurrent.TimeoutException
import kotlin.time.Duration.Companion.seconds
object MicrosoftOAuthUtils {
const val CLIENT_ID = "feb3836f-0333-4185-8eb9-4cbf0498f947" // Minosoft 2 (microsoft-bixilon2)
@ -68,7 +69,7 @@ object MicrosoftOAuthUtils {
}
if (response == null) {
// no response yet
runLater(deviceCode.interval * 1000) { checkToken() }
runLater(deviceCode.interval.seconds) { checkToken() }
return
}
Log.log(LogMessageType.AUTHENTICATION, LogLevels.INFO) { "Code (${deviceCode.userCode}) is valid, logging in..." }

View File

@ -15,7 +15,6 @@ package de.bixilon.minosoft.util.http
import de.bixilon.kutil.collections.CollectionUtil.extend
import de.bixilon.kutil.http.QueryUtil.toQuery
import de.bixilon.kutil.primitive.BooleanUtil.decide
import de.bixilon.minosoft.util.json.Jackson
import java.net.URI
import java.net.http.HttpClient
@ -52,7 +51,7 @@ object HTTP2 {
url = url,
data = this,
bodyPublisher = { Jackson.MAPPER.writeValueAsString(it) },
bodyBuilder = { it.isBlank().decide(null) { Jackson.MAPPER.readValue(it, Jackson.JSON_MAP_TYPE) as Map<String, Any> } },
bodyBuilder = { if (it.isBlank()) null else Jackson.MAPPER.readValue(it, Jackson.JSON_MAP_TYPE) as Map<String, Any>? },
headers = headers.extend(
"Content-Type" to "application/json",
"Accept" to "application/json",
@ -65,7 +64,7 @@ object HTTP2 {
url = url,
data = this,
bodyPublisher = { this.toQuery() },
bodyBuilder = { it.isBlank().decide(null) { Jackson.MAPPER.readValue(it, Jackson.JSON_MAP_TYPE) as Map<String, Any> } },
bodyBuilder = { if(it.isBlank()) null else Jackson.MAPPER.readValue(it, Jackson.JSON_MAP_TYPE) as Map<String, Any>? },
headers = headers.extend(
"Content-Type" to "application/x-www-form-urlencoded",
)
@ -87,7 +86,7 @@ object HTTP2 {
fun String.getJson(headers: Map<String, Any> = emptyMap()): HTTPResponse<Map<String, Any>?> {
return this.get(
bodyBuilder = { it.isBlank().decide(null) { Jackson.MAPPER.readValue(it, Jackson.JSON_MAP_TYPE) as Map<String, Any> } },
bodyBuilder = { if(it.isBlank()) null else Jackson.MAPPER.readValue(it, Jackson.JSON_MAP_TYPE) as Map<String, Any>? },
headers = headers.extend(
"Content-Type" to "application/json",
"Accept" to "application/json",