mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-15 10:25:06 -04:00
bump kutil
kutil 1.24.1 actually speeds up reflection a lot. Those improvements make joining servers in minosoft a lot faster. It also contains a bunch of other improvements.
This commit is contained in:
parent
fd5c3f5aa9
commit
bfd1ed44f7
@ -17,5 +17,5 @@ lwjgl.version=3.3.3
|
||||
ikonli.version=12.3.1
|
||||
netty.version=4.1.100.Final
|
||||
jackson.version=2.15.3
|
||||
kutil.version=1.24.0
|
||||
kutil.version=1.24.2
|
||||
glm.version=0.9.9.1-12
|
||||
|
@ -40,7 +40,6 @@ import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||
import de.bixilon.minosoft.protocol.versions.Versions
|
||||
import org.objenesis.ObjenesisStd
|
||||
import org.testng.annotations.Test
|
||||
import kotlin.reflect.jvm.javaField
|
||||
|
||||
const val SECTIONS = 16
|
||||
|
||||
@ -50,7 +49,7 @@ object LightTestingUtil {
|
||||
fun createConnection(): PlayConnection {
|
||||
val connection = ObjenesisStd().newInstance(PlayConnection::class.java)
|
||||
|
||||
Connection::events.javaField!!.forceSet(connection, EventMaster())
|
||||
Connection::events.jvmField.forceSet(connection, EventMaster())
|
||||
return connection
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,7 @@ import de.bixilon.kutil.primitive.DoubleUtil.matches
|
||||
import de.bixilon.kutil.primitive.FloatUtil
|
||||
import de.bixilon.kutil.primitive.FloatUtil.matches
|
||||
import de.bixilon.kutil.reflection.ReflectionUtil.forceSet
|
||||
import de.bixilon.kutil.reflection.ReflectionUtil.jvmField
|
||||
import de.bixilon.minosoft.camera.ConnectionCamera
|
||||
import de.bixilon.minosoft.data.entities.StatusEffectInstance
|
||||
import de.bixilon.minosoft.data.entities.entities.Entity
|
||||
@ -36,15 +37,14 @@ import de.bixilon.minosoft.util.KUtil.matches
|
||||
import de.bixilon.minosoft.util.KUtil.startInit
|
||||
import org.testng.Assert
|
||||
import java.util.*
|
||||
import kotlin.reflect.jvm.javaField
|
||||
|
||||
object PhysicsTestUtil {
|
||||
const val MATCH_EXACTLY = true
|
||||
val VALUE_MARGIN = if (MATCH_EXACTLY) 0.0 else DoubleUtil.DEFAULT_MARGIN
|
||||
|
||||
private val PLAYER_ATTRIBUTES = LocalPlayerEntity::attributes.javaField!!
|
||||
private val CONNECTION_PLAYER = PlayConnection::player.javaField!!
|
||||
private val CONNECTION_CAMERA = PlayConnection::camera.javaField!!
|
||||
private val PLAYER_ATTRIBUTES = LocalPlayerEntity::attributes.jvmField
|
||||
private val CONNECTION_PLAYER = PlayConnection::player.jvmField
|
||||
private val CONNECTION_CAMERA = PlayConnection::camera.jvmField
|
||||
|
||||
|
||||
fun createPlayer(connection: PlayConnection = createConnection(light = false)): LocalPlayerEntity {
|
||||
|
@ -17,6 +17,7 @@ import de.bixilon.kotlinglm.vec2.Vec2i
|
||||
import de.bixilon.kutil.concurrent.lock.thread.ThreadLock
|
||||
import de.bixilon.kutil.observer.DataObserver
|
||||
import de.bixilon.kutil.reflection.ReflectionUtil.forceSet
|
||||
import de.bixilon.kutil.reflection.ReflectionUtil.jvmField
|
||||
import de.bixilon.minosoft.data.registries.blocks.state.BlockState
|
||||
import de.bixilon.minosoft.data.registries.dimension.DimensionProperties
|
||||
import de.bixilon.minosoft.data.world.World
|
||||
@ -29,7 +30,6 @@ import de.bixilon.minosoft.modding.event.master.EventMaster
|
||||
import de.bixilon.minosoft.protocol.network.connection.Connection
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||
import org.objenesis.ObjenesisStd
|
||||
import kotlin.reflect.jvm.javaField
|
||||
|
||||
const val SECTIONS = 16
|
||||
|
||||
@ -39,7 +39,7 @@ object LightTestingUtil {
|
||||
fun createConnection(): PlayConnection {
|
||||
val connection = ObjenesisStd().newInstance(PlayConnection::class.java)
|
||||
|
||||
Connection::events.javaField!!.forceSet(connection, EventMaster())
|
||||
Connection::events.jvmField.forceSet(connection, EventMaster())
|
||||
return connection
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,6 @@ import de.bixilon.minosoft.gui.rendering.input.key.manager.binding.actions.keysP
|
||||
import de.bixilon.minosoft.gui.rendering.system.window.KeyChangeTypes
|
||||
import de.bixilon.minosoft.gui.rendering.system.window.dummy.DummyWindow
|
||||
import de.bixilon.minosoft.test.IT
|
||||
import de.bixilon.minosoft.util.KUtil.set
|
||||
import it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap
|
||||
|
||||
object InputTestUtil {
|
||||
|
@ -25,7 +25,6 @@ import de.bixilon.minosoft.gui.rendering.input.key.manager.binding.BindingsManag
|
||||
import de.bixilon.minosoft.gui.rendering.input.key.manager.binding.KeyBindingFilterState
|
||||
import de.bixilon.minosoft.gui.rendering.input.key.manager.binding.KeyBindingState
|
||||
import de.bixilon.minosoft.test.IT.OBJENESIS
|
||||
import de.bixilon.minosoft.util.KUtil.set
|
||||
import it.unimi.dsi.fastutil.objects.Object2LongMap
|
||||
import it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap
|
||||
import org.testng.Assert.assertFalse
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
package de.bixilon.minosoft.gui.rendering.models.baked
|
||||
|
||||
import de.bixilon.kutil.collections.primitive.floats.HeapArrayFloatList
|
||||
import de.bixilon.kutil.reflection.ReflectionUtil.forceSet
|
||||
import de.bixilon.minosoft.gui.rendering.chunk.mesh.ChunkMesh
|
||||
import de.bixilon.minosoft.gui.rendering.chunk.mesh.ChunkMeshes
|
||||
@ -24,7 +25,6 @@ import de.bixilon.minosoft.gui.rendering.system.base.texture.texture.Texture
|
||||
import de.bixilon.minosoft.gui.rendering.util.mesh.MeshOrder
|
||||
import de.bixilon.minosoft.test.IT.OBJENESIS
|
||||
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||
import de.bixilon.minosoft.util.collections.floats.FragmentedArrayFloatList
|
||||
import org.testng.Assert.assertEquals
|
||||
import org.testng.annotations.Test
|
||||
|
||||
@ -42,7 +42,7 @@ class BakedFaceTest {
|
||||
mesh::quadType.forceSet(PrimitiveTypes.QUAD)
|
||||
mesh::order.forceSet(MeshOrder.QUAD)
|
||||
|
||||
mesh.data = FragmentedArrayFloatList(1000) // TODO: kutil 1.24
|
||||
mesh.data = HeapArrayFloatList(1000)
|
||||
|
||||
mesh::initialCacheSize.forceSet(1000)
|
||||
|
||||
|
@ -16,6 +16,7 @@ package de.bixilon.minosoft.protocol.network.connection.play
|
||||
import de.bixilon.kotlinglm.pow
|
||||
import de.bixilon.kutil.observer.DataObserver
|
||||
import de.bixilon.kutil.reflection.ReflectionUtil.forceSet
|
||||
import de.bixilon.kutil.reflection.ReflectionUtil.jvmField
|
||||
import de.bixilon.minosoft.assets.connection.ConnectionAssetsManager
|
||||
import de.bixilon.minosoft.assets.minecraft.MinecraftPackFormat.packFormat
|
||||
import de.bixilon.minosoft.assets.properties.manager.AssetsManagerProperties
|
||||
@ -40,7 +41,6 @@ import de.bixilon.minosoft.test.IT.reference
|
||||
import de.bixilon.minosoft.test.ITUtil
|
||||
import de.bixilon.minosoft.util.KUtil.startInit
|
||||
import java.util.concurrent.atomic.AtomicInteger
|
||||
import kotlin.reflect.jvm.javaField
|
||||
|
||||
|
||||
object ConnectionTestUtil {
|
||||
@ -50,21 +50,21 @@ object ConnectionTestUtil {
|
||||
reference()
|
||||
}
|
||||
|
||||
private val LANGUAGE = PlayConnection::language.javaField!!
|
||||
private val SEQUENCE = PlayConnection::sequence.javaField!!
|
||||
private val ACCOUNT = PlayConnection::account.javaField!!
|
||||
private val VERSION = PlayConnection::version.javaField!!
|
||||
private val REGISTRIES = PlayConnection::registries.javaField!!
|
||||
private val WORLD = PlayConnection::world.javaField!!
|
||||
private val PLAYER = PlayConnection::player.javaField!!
|
||||
private val NETWORK = PlayConnection::network.javaField!!
|
||||
private val EVENTS = PlayConnection::events.javaField!!
|
||||
private val PROFILES = PlayConnection::profiles.javaField!!
|
||||
private val ASSETS_MANAGER = PlayConnection::assetsManager.javaField!!
|
||||
private val STATE = PlayConnection::state.javaField!!
|
||||
private val TAGS = PlayConnection::tags.javaField!!
|
||||
private val LEGACY_TAGS = PlayConnection::legacyTags.javaField!!
|
||||
private val CAMERA = PlayConnection::camera.javaField!!
|
||||
private val LANGUAGE = PlayConnection::language.jvmField
|
||||
private val SEQUENCE = PlayConnection::sequence.jvmField
|
||||
private val ACCOUNT = PlayConnection::account.jvmField
|
||||
private val VERSION = PlayConnection::version.jvmField
|
||||
private val REGISTRIES = PlayConnection::registries.jvmField
|
||||
private val WORLD = PlayConnection::world.jvmField
|
||||
private val PLAYER = PlayConnection::player.jvmField
|
||||
private val NETWORK = PlayConnection::network.jvmField
|
||||
private val EVENTS = PlayConnection::events.jvmField
|
||||
private val PROFILES = PlayConnection::profiles.jvmField
|
||||
private val ASSETS_MANAGER = PlayConnection::assetsManager.jvmField
|
||||
private val STATE = PlayConnection::state.jvmField
|
||||
private val TAGS = PlayConnection::tags.jvmField
|
||||
private val LEGACY_TAGS = PlayConnection::legacyTags.jvmField
|
||||
private val CAMERA = PlayConnection::camera.jvmField
|
||||
|
||||
private val language = LanguageList(mutableListOf())
|
||||
private val signature = OBJENESIS.newInstance(SignatureKeyManagement::class.java)
|
||||
|
@ -17,11 +17,11 @@ import de.bixilon.kutil.cast.CastUtil.unsafeCast
|
||||
import de.bixilon.kutil.cast.CastUtil.unsafeNull
|
||||
import de.bixilon.kutil.observer.DataObserver
|
||||
import de.bixilon.kutil.observer.DataObserver.Companion.observed
|
||||
import de.bixilon.kutil.reflection.ReflectionUtil.jvmField
|
||||
import de.bixilon.minosoft.camera.target.TargetHandler
|
||||
import de.bixilon.minosoft.data.entities.entities.Entity
|
||||
import de.bixilon.minosoft.input.interaction.InteractionManager
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||
import kotlin.reflect.jvm.javaField
|
||||
|
||||
class ConnectionCamera(
|
||||
val connection: PlayConnection,
|
||||
@ -32,12 +32,12 @@ class ConnectionCamera(
|
||||
|
||||
fun init() {
|
||||
entity = connection.player
|
||||
Companion.interactions[this] = InteractionManager(this)
|
||||
INTERACTIONS[this] = InteractionManager(this)
|
||||
interactions.init()
|
||||
}
|
||||
|
||||
|
||||
companion object {
|
||||
private val interactions = ConnectionCamera::interactions.javaField!!.apply { isAccessible = true }
|
||||
private val INTERACTIONS = ConnectionCamera::interactions.jvmField
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ interface AbstractDelegate<T> : TextFormattable {
|
||||
val description: ResourceLocation
|
||||
|
||||
fun get(): T
|
||||
fun set(value: T)
|
||||
fun set(value: T): T
|
||||
|
||||
fun validate(value: T) = Unit
|
||||
|
||||
|
@ -27,10 +27,9 @@ open class SimpleDelegate<T>(
|
||||
override val name = minosoft(name)
|
||||
override val description = minosoft("$name.description")
|
||||
|
||||
override fun get() = value
|
||||
override fun set(value: T) {
|
||||
override fun set(value: T): T {
|
||||
validate(value)
|
||||
this.value = value
|
||||
return super.set(value)
|
||||
}
|
||||
|
||||
override fun setValue(thisRef: Any, property: KProperty<*>, value: T) {
|
||||
|
@ -32,9 +32,11 @@ class ListDelegate<V>(
|
||||
}
|
||||
|
||||
override fun get() = value
|
||||
override fun set(value: MutableList<V>) {
|
||||
override fun set(value: MutableList<V>): MutableList<V> {
|
||||
validate(value)
|
||||
val previous = this.value.unsafe
|
||||
this.value.unsafe = value
|
||||
return previous
|
||||
}
|
||||
|
||||
override fun setValue(thisRef: Any, property: KProperty<*>, value: MutableList<V>) {
|
||||
|
@ -32,9 +32,11 @@ open class MapDelegate<K, V>(
|
||||
}
|
||||
|
||||
override fun get() = value
|
||||
override fun set(value: MutableMap<K, V>) {
|
||||
override fun set(value: MutableMap<K, V>): MutableMap<K, V> {
|
||||
validate(value)
|
||||
val previous = this.value.unsafe
|
||||
this.value.unsafe = value
|
||||
return previous
|
||||
}
|
||||
|
||||
override fun setValue(thisRef: Any, property: KProperty<*>, value: MutableMap<K, V>) {
|
||||
|
@ -32,9 +32,11 @@ class SetDelegate<V>(
|
||||
}
|
||||
|
||||
override fun get() = value
|
||||
override fun set(value: MutableSet<V>) {
|
||||
override fun set(value: MutableSet<V>): MutableSet<V> {
|
||||
validate(value)
|
||||
val previous = this.value.unsafe
|
||||
this.value.unsafe = value
|
||||
return previous
|
||||
}
|
||||
|
||||
override fun setValue(thisRef: Any, property: KProperty<*>, value: MutableSet<V>) {
|
||||
|
@ -20,12 +20,12 @@ import de.bixilon.kutil.cast.CastUtil.unsafeNull
|
||||
import de.bixilon.kutil.enums.EnumUtil
|
||||
import de.bixilon.kutil.enums.ValuesEnum
|
||||
import de.bixilon.kutil.reflection.ReflectionUtil.forceSet
|
||||
import de.bixilon.kutil.reflection.ReflectionUtil.jvmField
|
||||
import de.bixilon.minosoft.data.Axes
|
||||
import de.bixilon.minosoft.data.registries.blocks.state.BlockState
|
||||
import de.bixilon.minosoft.data.world.chunk.ChunkSection
|
||||
import de.bixilon.minosoft.gui.rendering.util.vec.vec3.Vec3iUtil.get
|
||||
import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition
|
||||
import kotlin.reflect.jvm.javaField
|
||||
|
||||
enum class Directions(
|
||||
val vector: Vec3i,
|
||||
@ -156,8 +156,8 @@ enum class Directions(
|
||||
}
|
||||
|
||||
init {
|
||||
val inverted = Directions::inverted.javaField!!
|
||||
val axis = Directions::axis.javaField!!
|
||||
val inverted = Directions::inverted.jvmField
|
||||
val axis = Directions::axis.jvmField
|
||||
for (direction in VALUES) {
|
||||
inverted.forceSet(direction, direction.invert())
|
||||
axis.forceSet(direction, Axes[direction])
|
||||
|
@ -14,8 +14,6 @@
|
||||
package de.bixilon.minosoft.data.entities.data
|
||||
|
||||
import de.bixilon.kutil.observer.DataObserver
|
||||
import de.bixilon.kutil.observer.ObserveUtil.invalid
|
||||
import de.bixilon.kutil.observer.RemoveObserver
|
||||
import kotlin.reflect.KProperty
|
||||
|
||||
class EntityDataDelegate<V>(
|
||||
@ -28,14 +26,6 @@ class EntityDataDelegate<V>(
|
||||
data.observe<V>(field) { set(it ?: default) }
|
||||
}
|
||||
|
||||
@Deprecated("kutil 1.25")
|
||||
private fun set(value: V) {
|
||||
if (this.value == value) return
|
||||
lock.lock()
|
||||
unsafeSet(value)
|
||||
lock.unlock()
|
||||
}
|
||||
|
||||
override fun setValue(thisRef: Any, property: KProperty<*>, value: V) {
|
||||
this.value = value
|
||||
data[field] = value
|
||||
@ -43,24 +33,4 @@ class EntityDataDelegate<V>(
|
||||
unsafeSet(value)
|
||||
lock.unlock()
|
||||
}
|
||||
|
||||
private fun unsafeSet(value: V) {
|
||||
this.value = value
|
||||
|
||||
val iterator = observers.iterator()
|
||||
for ((reference, _, observer) in iterator) {
|
||||
if (reference.invalid) {
|
||||
iterator.remove()
|
||||
continue
|
||||
}
|
||||
try {
|
||||
observer.invoke(value)
|
||||
} catch (_: RemoveObserver) {
|
||||
iterator.remove()
|
||||
continue
|
||||
} catch (exception: Throwable) {
|
||||
exception.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ import de.bixilon.kutil.bit.BitByte.isBitMask
|
||||
import de.bixilon.kutil.cast.CastUtil.unsafeCast
|
||||
import de.bixilon.kutil.cast.CastUtil.unsafeNull
|
||||
import de.bixilon.kutil.reflection.ReflectionUtil.forceSet
|
||||
import de.bixilon.kutil.reflection.ReflectionUtil.jvmField
|
||||
import de.bixilon.kutil.time.TimeUtil.millis
|
||||
import de.bixilon.minosoft.data.abilities.Gamemodes
|
||||
import de.bixilon.minosoft.data.entities.EntityAnimations
|
||||
@ -42,7 +43,6 @@ import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition
|
||||
import de.bixilon.minosoft.terminal.RunConfiguration
|
||||
import de.bixilon.minosoft.util.Initializable
|
||||
import java.util.*
|
||||
import kotlin.reflect.jvm.javaField
|
||||
|
||||
abstract class Entity(
|
||||
val connection: PlayConnection,
|
||||
@ -260,8 +260,8 @@ abstract class Entity(
|
||||
|
||||
|
||||
companion object {
|
||||
private val RENDER_INFO = Entity::renderInfo.javaField!!.apply { isAccessible = true }
|
||||
private val DEFAULT_AABB = Entity::defaultAABB.javaField!!.apply { isAccessible = true }
|
||||
private val RENDER_INFO = Entity::renderInfo.jvmField
|
||||
private val DEFAULT_AABB = Entity::defaultAABB.jvmField
|
||||
private val PHYSICS = Entity::class.java.getDeclaredField("physics").apply { isAccessible = true }
|
||||
|
||||
val FLAGS_DATA = EntityDataField("ENTITY_FLAGS")
|
||||
|
@ -13,6 +13,7 @@
|
||||
package de.bixilon.minosoft.data.registries.blocks.types
|
||||
|
||||
import de.bixilon.kutil.cast.CastUtil.unsafeNull
|
||||
import de.bixilon.kutil.reflection.ReflectionUtil.jvmField
|
||||
import de.bixilon.minosoft.data.language.LanguageUtil.translation
|
||||
import de.bixilon.minosoft.data.language.translate.Translatable
|
||||
import de.bixilon.minosoft.data.registries.blocks.properties.BlockProperty
|
||||
@ -30,7 +31,6 @@ import de.bixilon.minosoft.data.registries.blocks.types.properties.physics.Pushi
|
||||
import de.bixilon.minosoft.data.registries.identified.ResourceLocation
|
||||
import de.bixilon.minosoft.data.registries.registries.registry.RegistryItem
|
||||
import de.bixilon.minosoft.gui.rendering.models.block.state.render.BlockRender
|
||||
import kotlin.reflect.jvm.javaField
|
||||
|
||||
abstract class Block(
|
||||
override val identifier: ResourceLocation,
|
||||
@ -58,6 +58,6 @@ abstract class Block(
|
||||
}
|
||||
|
||||
private companion object {
|
||||
val STATES = Block::states.javaField!!.apply { isAccessible = true }
|
||||
val STATES = Block::states.jvmField
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ import de.bixilon.kutil.json.JsonUtil.asJsonObject
|
||||
import de.bixilon.kutil.primitive.BooleanUtil.toBoolean
|
||||
import de.bixilon.kutil.primitive.FloatUtil.toFloat
|
||||
import de.bixilon.kutil.primitive.IntUtil.toInt
|
||||
import de.bixilon.kutil.reflection.ReflectionUtil.jvmField
|
||||
import de.bixilon.minosoft.data.registries.blocks.factory.PixLyzerBlockFactories
|
||||
import de.bixilon.minosoft.data.registries.blocks.factory.PixLyzerBlockFactory
|
||||
import de.bixilon.minosoft.data.registries.blocks.settings.BlockSettings
|
||||
@ -55,7 +56,6 @@ import de.bixilon.minosoft.gui.rendering.util.vec.vec3.Vec3Util.EMPTY
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||
import de.bixilon.minosoft.protocol.versions.Version
|
||||
import de.bixilon.minosoft.protocol.versions.Versions
|
||||
import kotlin.reflect.jvm.javaField
|
||||
|
||||
open class PixLyzerBlock(
|
||||
identifier: ResourceLocation,
|
||||
@ -119,7 +119,7 @@ open class PixLyzerBlock(
|
||||
companion object : ResourceLocationCodec<Block>, PixLyzerBlockFactory<Block>, MultiClassFactory<Block> {
|
||||
private val NULL_OFFSET_XYZ = Vec3i(0, 0, 0).getWorldOffset(RandomOffsetTypes.XYZ)
|
||||
private val NULL_OFFSET_XZ = Vec3i(0, 0, 0).getWorldOffset(RandomOffsetTypes.XZ)
|
||||
private val ITEM_FIELD = PixLyzerBlock::item.javaField!!
|
||||
private val ITEM_FIELD = PixLyzerBlock::item.jvmField
|
||||
override val ALIASES: Set<String> = setOf("Block")
|
||||
|
||||
override fun deserialize(registries: Registries?, resourceLocation: ResourceLocation, data: Map<String, Any>): Block {
|
||||
|
@ -14,6 +14,7 @@
|
||||
package de.bixilon.minosoft.data.registries.blocks.types.pixlyzer.entity
|
||||
|
||||
import de.bixilon.kutil.cast.CastUtil.unsafeNull
|
||||
import de.bixilon.kutil.reflection.ReflectionUtil.jvmField
|
||||
import de.bixilon.minosoft.data.entities.block.BlockEntity
|
||||
import de.bixilon.minosoft.data.registries.blocks.entites.BlockEntityType
|
||||
import de.bixilon.minosoft.data.registries.blocks.types.entity.BlockWithEntity
|
||||
@ -22,7 +23,6 @@ import de.bixilon.minosoft.data.registries.identified.ResourceLocation
|
||||
import de.bixilon.minosoft.data.registries.registries.Registries
|
||||
import de.bixilon.minosoft.data.registries.registries.registry.RegistryItem
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||
import kotlin.reflect.jvm.javaField
|
||||
|
||||
abstract class PixLyzerBlockWithEntity<T : BlockEntity>(resourceLocation: ResourceLocation, registries: Registries, data: Map<String, Any>) : PixLyzerBlock(resourceLocation, registries, data), BlockWithEntity<BlockEntity> {
|
||||
private val blockEntity: BlockEntityType<BlockEntity>? = unsafeNull()
|
||||
@ -35,6 +35,6 @@ abstract class PixLyzerBlockWithEntity<T : BlockEntity>(resourceLocation: Resour
|
||||
override fun createBlockEntity(connection: PlayConnection) = blockEntity?.factory?.build(connection)
|
||||
|
||||
private companion object {
|
||||
val FACTORY_FIELD = PixLyzerBlockWithEntity<*>::blockEntity.javaField!!
|
||||
val FACTORY_FIELD = PixLyzerBlockWithEntity<*>::blockEntity.jvmField
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,7 @@
|
||||
package de.bixilon.minosoft.data.registries.item.items.block
|
||||
|
||||
import de.bixilon.kutil.cast.CastUtil.unsafeNull
|
||||
import de.bixilon.kutil.reflection.ReflectionUtil.jvmField
|
||||
import de.bixilon.minosoft.camera.target.targets.BlockTarget
|
||||
import de.bixilon.minosoft.data.container.stack.ItemStack
|
||||
import de.bixilon.minosoft.data.registries.blocks.types.Block
|
||||
@ -24,7 +25,6 @@ import de.bixilon.minosoft.data.registries.item.stack.StackableItem
|
||||
import de.bixilon.minosoft.data.registries.registries.registry.RegistryItem
|
||||
import de.bixilon.minosoft.gui.rendering.models.item.ItemRender
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||
import kotlin.reflect.jvm.javaField
|
||||
|
||||
abstract class BlockItem<T : Block>(identifier: ResourceLocation) : Item(identifier), StackableItem, PlaceableItem {
|
||||
val block: T = unsafeNull()
|
||||
@ -44,6 +44,6 @@ abstract class BlockItem<T : Block>(identifier: ResourceLocation) : Item(identif
|
||||
|
||||
|
||||
private companion object {
|
||||
private val BLOCK_FIELD = BlockItem<*>::block.javaField!!
|
||||
private val BLOCK_FIELD = BlockItem<*>::block.jvmField
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,7 @@
|
||||
package de.bixilon.minosoft.data.registries.item.items.block.legacy
|
||||
|
||||
import de.bixilon.kutil.cast.CastUtil.unsafeNull
|
||||
import de.bixilon.kutil.reflection.ReflectionUtil.jvmField
|
||||
import de.bixilon.minosoft.camera.target.targets.BlockTarget
|
||||
import de.bixilon.minosoft.data.container.stack.ItemStack
|
||||
import de.bixilon.minosoft.data.registries.blocks.state.BlockState
|
||||
@ -27,7 +28,6 @@ import de.bixilon.minosoft.data.registries.registries.Registries
|
||||
import de.bixilon.minosoft.data.registries.registries.registry.RegistryItem
|
||||
import de.bixilon.minosoft.gui.rendering.models.item.ItemRender
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||
import kotlin.reflect.jvm.javaField
|
||||
|
||||
open class PixLyzerBlockItem(
|
||||
resourceLocation: ResourceLocation,
|
||||
@ -52,7 +52,7 @@ open class PixLyzerBlockItem(
|
||||
|
||||
companion object : PixLyzerItemFactory<PixLyzerBlockItem>, MultiClassFactory<PixLyzerBlockItem> {
|
||||
override val ALIASES = setOf("BlockItem", "AliasedBlockItem")
|
||||
private val BLOCK_FIELD = PixLyzerBlockItem::block.javaField!!
|
||||
private val BLOCK_FIELD = PixLyzerBlockItem::block.jvmField
|
||||
|
||||
override fun build(resourceLocation: ResourceLocation, registries: Registries, data: Map<String, Any>): PixLyzerBlockItem {
|
||||
return PixLyzerBlockItem(resourceLocation, registries, data)
|
||||
|
@ -15,19 +15,19 @@ package de.bixilon.minosoft.data.registries.registries.registry
|
||||
|
||||
import de.bixilon.kutil.cast.CastUtil.unsafeNull
|
||||
import de.bixilon.kutil.reflection.ReflectionUtil.forceSet
|
||||
import de.bixilon.kutil.reflection.ReflectionUtil.jvmField
|
||||
import de.bixilon.minosoft.data.registries.identified.Identified
|
||||
import de.bixilon.minosoft.data.registries.identified.ResourceLocation
|
||||
import de.bixilon.minosoft.data.registries.registries.Registries
|
||||
import java.lang.reflect.Field
|
||||
import kotlin.reflect.KProperty
|
||||
import kotlin.reflect.jvm.javaField
|
||||
|
||||
abstract class RegistryItem : Identified {
|
||||
open val injectable: Boolean get() = true
|
||||
private val injects: MutableMap<Field, List<Any>> = if (injectable) hashMapOf() else unsafeNull()
|
||||
|
||||
fun <T : RegistryItem> KProperty<T?>.inject(vararg keys: Any?): T {
|
||||
return this.javaField!!.inject(*keys)
|
||||
return this.jvmField.inject(*keys)
|
||||
}
|
||||
|
||||
fun <T : RegistryItem> Field.inject(vararg keys: Any?): T {
|
||||
@ -79,6 +79,6 @@ abstract class RegistryItem : Identified {
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val INJECTS_FIELD = RegistryItem::injects.javaField!!.apply { isAccessible = true }
|
||||
private val INJECTS_FIELD = RegistryItem::injects.jvmField
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,6 @@ import de.bixilon.minosoft.data.language.translate.Translator
|
||||
import de.bixilon.minosoft.data.text.events.click.ClickEvents
|
||||
import de.bixilon.minosoft.data.text.events.hover.HoverEvents
|
||||
import de.bixilon.minosoft.data.text.formatting.FormattingCodes
|
||||
import de.bixilon.minosoft.data.text.formatting.TextFormatting
|
||||
import de.bixilon.minosoft.data.text.formatting.color.ChatColors.toColor
|
||||
import de.bixilon.minosoft.data.text.formatting.color.RGBColor
|
||||
import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition
|
||||
@ -49,7 +48,7 @@ class BaseComponent : ChatComponent {
|
||||
constructor(translator: Translator? = null, parent: TextComponent? = null, json: Map<String, Any>, restricted: Boolean = false) {
|
||||
val color = json["color"]?.nullCast<String>()?.toColor() ?: parent?.color
|
||||
|
||||
val formatting = parent?.formatting?.copy() ?: TextFormatting()
|
||||
val formatting = parent?.formatting?.copy() ?: FormattingCodes.set()
|
||||
|
||||
json["bold"]?.toBoolean()?.let { formatting[FormattingCodes.BOLD] = it }
|
||||
json["italic"]?.toBoolean()?.let { formatting[FormattingCodes.ITALIC] = it }
|
||||
|
@ -13,12 +13,12 @@
|
||||
|
||||
package de.bixilon.minosoft.data.text
|
||||
|
||||
import de.bixilon.kutil.enums.BitEnumSet
|
||||
import de.bixilon.kutil.url.URLUtil.toURL
|
||||
import de.bixilon.minosoft.data.text.events.click.ClickEvent
|
||||
import de.bixilon.minosoft.data.text.events.click.OpenFileClickEvent
|
||||
import de.bixilon.minosoft.data.text.events.click.OpenURLClickEvent
|
||||
import de.bixilon.minosoft.data.text.formatting.FormattingCodes
|
||||
import de.bixilon.minosoft.data.text.formatting.TextFormatting
|
||||
import de.bixilon.minosoft.data.text.formatting.color.ChatColors
|
||||
import de.bixilon.minosoft.data.text.formatting.color.RGBColor
|
||||
import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition
|
||||
@ -81,7 +81,7 @@ object LegacyComponentReader {
|
||||
fun parse(parent: TextComponent? = null, legacy: String = "", restricted: Boolean = false): ChatComponent {
|
||||
val parts: PartList = mutableListOf()
|
||||
|
||||
val sequence = SequenceBuilder(color = parent?.color, formatting = parent?.formatting?.copy() ?: TextFormatting())
|
||||
val sequence = SequenceBuilder(color = parent?.color, formatting = parent?.formatting?.copy() ?: FormattingCodes.set())
|
||||
|
||||
val iterator = StringCharacterIterator(legacy)
|
||||
|
||||
@ -133,7 +133,7 @@ object LegacyComponentReader {
|
||||
private data class SequenceBuilder(
|
||||
var text: StringBuilder = StringBuilder(),
|
||||
var color: RGBColor? = null,
|
||||
var formatting: TextFormatting = TextFormatting(),
|
||||
var formatting: BitEnumSet<FormattingCodes> = FormattingCodes.set(),
|
||||
) {
|
||||
|
||||
fun reset() {
|
||||
|
@ -12,13 +12,13 @@
|
||||
*/
|
||||
package de.bixilon.minosoft.data.text
|
||||
|
||||
import de.bixilon.kutil.enums.BitEnumSet
|
||||
import de.bixilon.kutil.json.MutableJsonObject
|
||||
import de.bixilon.minosoft.config.profile.profiles.eros.ErosProfileManager
|
||||
import de.bixilon.minosoft.data.registries.identified.ResourceLocation
|
||||
import de.bixilon.minosoft.data.text.events.click.ClickEvent
|
||||
import de.bixilon.minosoft.data.text.events.hover.HoverEvent
|
||||
import de.bixilon.minosoft.data.text.formatting.FormattingCodes
|
||||
import de.bixilon.minosoft.data.text.formatting.TextFormatting
|
||||
import de.bixilon.minosoft.data.text.formatting.TextStyle
|
||||
import de.bixilon.minosoft.data.text.formatting.color.ChatColors
|
||||
import de.bixilon.minosoft.data.text.formatting.color.RGBColor
|
||||
@ -37,7 +37,7 @@ import java.util.concurrent.atomic.AtomicInteger
|
||||
open class TextComponent(
|
||||
message: Any? = "",
|
||||
override var color: RGBColor? = null,
|
||||
override val formatting: TextFormatting = TextFormatting(),
|
||||
override val formatting: BitEnumSet<FormattingCodes> = FormattingCodes.set(),
|
||||
var font: ResourceLocation? = null,
|
||||
var clickEvent: ClickEvent? = null,
|
||||
var hoverEvent: HoverEvent? = null,
|
||||
@ -194,7 +194,7 @@ open class TextComponent(
|
||||
return json
|
||||
}
|
||||
|
||||
fun copy(message: Any? = this.message, color: RGBColor? = this.color, formatting: TextFormatting = this.formatting, clickEvent: ClickEvent? = this.clickEvent, hoverEvent: HoverEvent? = this.hoverEvent): TextComponent {
|
||||
fun copy(message: Any? = this.message, color: RGBColor? = this.color, formatting: BitEnumSet<FormattingCodes> = this.formatting, clickEvent: ClickEvent? = this.clickEvent, hoverEvent: HoverEvent? = this.hoverEvent): TextComponent {
|
||||
return TextComponent(
|
||||
message = message,
|
||||
color = color,
|
||||
|
@ -1,84 +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.text.formatting
|
||||
|
||||
import de.bixilon.minosoft.util.set.IntBitSet
|
||||
|
||||
@Deprecated("BitEnumSet kutil 1.25")
|
||||
class TextFormatting(
|
||||
val bits: IntBitSet = IntBitSet(),
|
||||
) : Iterable<FormattingCodes> {
|
||||
|
||||
operator fun minusAssign(code: FormattingCodes) {
|
||||
this[code] = false
|
||||
}
|
||||
|
||||
operator fun plusAssign(code: FormattingCodes) {
|
||||
this[code] = true
|
||||
}
|
||||
|
||||
operator fun set(code: FormattingCodes, value: Boolean) {
|
||||
bits[code.ordinal] = value
|
||||
}
|
||||
|
||||
fun clear() {
|
||||
bits.clear()
|
||||
}
|
||||
|
||||
operator fun contains(code: FormattingCodes): Boolean {
|
||||
return bits[code.ordinal]
|
||||
}
|
||||
|
||||
fun copy(): TextFormatting {
|
||||
return TextFormatting(bits.clone())
|
||||
}
|
||||
|
||||
fun collect(): Set<FormattingCodes> {
|
||||
val set: MutableSet<FormattingCodes> = mutableSetOf()
|
||||
for (code in FormattingCodes.VALUES) {
|
||||
if (code !in this) continue
|
||||
|
||||
set += code
|
||||
}
|
||||
|
||||
return set
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
return bits.hashCode()
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (other !is TextFormatting) return false
|
||||
return bits == other.bits
|
||||
}
|
||||
|
||||
override fun iterator(): Iterator<FormattingCodes> {
|
||||
return TextFormattingIterator()
|
||||
}
|
||||
|
||||
private inner class TextFormattingIterator : Iterator<FormattingCodes> {
|
||||
private val length = bits.length()
|
||||
private var index = 0
|
||||
|
||||
override fun hasNext(): Boolean {
|
||||
return length > index
|
||||
// TODO: fairly broken!!! use kutil 1.25
|
||||
}
|
||||
|
||||
override fun next(): FormattingCodes {
|
||||
return FormattingCodes.VALUES[index++]
|
||||
}
|
||||
}
|
||||
}
|
@ -13,10 +13,11 @@
|
||||
|
||||
package de.bixilon.minosoft.data.text.formatting
|
||||
|
||||
import de.bixilon.kutil.enums.BitEnumSet
|
||||
import de.bixilon.minosoft.data.text.formatting.color.RGBColor
|
||||
|
||||
interface TextStyle {
|
||||
var color: RGBColor?
|
||||
|
||||
val formatting: TextFormatting
|
||||
val formatting: BitEnumSet<FormattingCodes>
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ import de.bixilon.kotlinglm.vec2.Vec2i
|
||||
import de.bixilon.kotlinglm.vec3.Vec3i
|
||||
import de.bixilon.kutil.array.ArrayUtil.cast
|
||||
import de.bixilon.kutil.cast.CastUtil.unsafeNull
|
||||
import de.bixilon.kutil.reflection.ReflectionUtil.jvmField
|
||||
import de.bixilon.minosoft.data.entities.block.BlockEntity
|
||||
import de.bixilon.minosoft.data.registries.biomes.Biome
|
||||
import de.bixilon.minosoft.data.world.biome.accessor.NoiseBiomeAccessor
|
||||
@ -27,7 +28,6 @@ import de.bixilon.minosoft.gui.rendering.util.VecUtil.of
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||
import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition
|
||||
import java.util.*
|
||||
import kotlin.reflect.jvm.javaField
|
||||
|
||||
/**
|
||||
* Collection of 16x16x16 blocks
|
||||
@ -96,7 +96,7 @@ class ChunkSection(
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val CHUNK = ChunkSection::chunk.javaField!!.apply { isAccessible = true }
|
||||
private val CHUNK = ChunkSection::chunk.jvmField
|
||||
|
||||
inline val Vec3i.index: Int
|
||||
get() = getIndex(x, y, z)
|
||||
|
@ -16,6 +16,7 @@ package de.bixilon.minosoft.data.world.chunk.chunk
|
||||
import de.bixilon.kotlinglm.vec3.Vec3i
|
||||
import de.bixilon.kutil.json.JsonObject
|
||||
import de.bixilon.kutil.reflection.ReflectionUtil.forceSet
|
||||
import de.bixilon.kutil.reflection.ReflectionUtil.jvmField
|
||||
import de.bixilon.minosoft.config.StaticConfiguration
|
||||
import de.bixilon.minosoft.data.registries.blocks.types.entity.BlockWithEntity
|
||||
import de.bixilon.minosoft.data.world.biome.source.BiomeSource
|
||||
@ -25,7 +26,6 @@ import de.bixilon.minosoft.data.world.positions.ChunkPosition
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||
import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition
|
||||
import it.unimi.dsi.fastutil.ints.IntOpenHashSet
|
||||
import kotlin.reflect.jvm.javaField
|
||||
|
||||
class ChunkPrototype(
|
||||
var blocks: Array<BlockSectionDataProvider?>? = null,
|
||||
@ -157,6 +157,6 @@ class ChunkPrototype(
|
||||
}
|
||||
|
||||
private companion object {
|
||||
private val SECTION = BlockSectionDataProvider::section.javaField!!.apply { isAccessible = true }
|
||||
private val SECTION = BlockSectionDataProvider::section.jvmField
|
||||
}
|
||||
}
|
||||
|
@ -15,13 +15,13 @@ package de.bixilon.minosoft.data.world.container.block
|
||||
|
||||
import de.bixilon.kutil.cast.CastUtil.unsafeNull
|
||||
import de.bixilon.kutil.concurrent.lock.Lock
|
||||
import de.bixilon.kutil.reflection.ReflectionUtil.jvmField
|
||||
import de.bixilon.minosoft.data.registries.blocks.state.BlockState
|
||||
import de.bixilon.minosoft.data.registries.blocks.types.fluid.FluidHolder
|
||||
import de.bixilon.minosoft.data.registries.fluid.fluids.WaterFluid.Companion.isWaterlogged
|
||||
import de.bixilon.minosoft.data.world.chunk.ChunkSection
|
||||
import de.bixilon.minosoft.data.world.chunk.ChunkSection.Companion.getIndex
|
||||
import de.bixilon.minosoft.data.world.container.SectionDataProvider
|
||||
import kotlin.reflect.jvm.javaField
|
||||
|
||||
class BlockSectionDataProvider(
|
||||
lock: Lock? = null,
|
||||
@ -91,7 +91,7 @@ class BlockSectionDataProvider(
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val sections = BlockSectionDataProvider::section.javaField!!.apply { isAccessible = true }
|
||||
private val sections = BlockSectionDataProvider::section.jvmField
|
||||
|
||||
@Deprecated("properly integrate in constructor")
|
||||
fun BlockSectionDataProvider.unsafeSetSection(section: ChunkSection) {
|
||||
|
@ -16,6 +16,7 @@ package de.bixilon.minosoft.gui.eros.util
|
||||
import de.bixilon.kutil.cast.CastUtil.unsafeCast
|
||||
import de.bixilon.kutil.concurrent.pool.DefaultThreadPool
|
||||
import de.bixilon.kutil.reflection.ReflectionUtil.forceSet
|
||||
import de.bixilon.kutil.reflection.ReflectionUtil.jvmField
|
||||
import de.bixilon.kutil.url.URLUtil.toURL
|
||||
import de.bixilon.minosoft.Minosoft
|
||||
import de.bixilon.minosoft.config.profile.profiles.eros.ErosProfileManager
|
||||
@ -47,7 +48,6 @@ import javafx.stage.Modality
|
||||
import javafx.stage.Stage
|
||||
import javafx.stage.Window
|
||||
import java.io.File
|
||||
import kotlin.reflect.jvm.javaField
|
||||
|
||||
object JavaFXUtil {
|
||||
private const val DEFAULT_STYLE = "resource:minosoft:eros/style.css"
|
||||
@ -135,7 +135,7 @@ object JavaFXUtil {
|
||||
|
||||
val controller = fxmlLoader.getController<T>()
|
||||
|
||||
controller::root.javaField!!.forceSet(controller, pane)
|
||||
controller::root.jvmField.forceSet(controller, pane)
|
||||
controller.postInit()
|
||||
|
||||
return controller
|
||||
|
@ -14,8 +14,8 @@
|
||||
package de.bixilon.minosoft.gui.rendering.font.renderer.code
|
||||
|
||||
import de.bixilon.kotlinglm.vec2.Vec2
|
||||
import de.bixilon.kutil.enums.BitEnumSet
|
||||
import de.bixilon.minosoft.data.text.formatting.FormattingCodes
|
||||
import de.bixilon.minosoft.data.text.formatting.TextFormatting
|
||||
import de.bixilon.minosoft.data.text.formatting.color.RGBColor
|
||||
import de.bixilon.minosoft.gui.rendering.font.renderer.CodePointAddResult
|
||||
import de.bixilon.minosoft.gui.rendering.font.renderer.element.TextOffset
|
||||
@ -48,7 +48,7 @@ interface CodePointRenderer {
|
||||
}
|
||||
|
||||
|
||||
fun render(offset: TextOffset, color: RGBColor, properties: TextRenderProperties, info: TextRenderInfo, formatting: TextFormatting, codePoint: Int, consumer: GUIVertexConsumer?, options: GUIVertexOptions?): CodePointAddResult {
|
||||
fun render(offset: TextOffset, color: RGBColor, properties: TextRenderProperties, info: TextRenderInfo, formatting: BitEnumSet<FormattingCodes>, codePoint: Int, consumer: GUIVertexConsumer?, options: GUIVertexOptions?): CodePointAddResult {
|
||||
val width = calculateWidth(properties.scale, properties.shadow)
|
||||
var spacing = getVerticalSpacing(offset, properties, info, consumer != null)
|
||||
val height = offset.getNextLineHeight(properties)
|
||||
|
@ -15,6 +15,7 @@ package de.bixilon.minosoft.gui.rendering.input.key.manager
|
||||
|
||||
import de.bixilon.kotlinglm.vec2.Vec2
|
||||
import de.bixilon.kotlinglm.vec2.Vec2d
|
||||
import de.bixilon.kutil.enums.BitEnumSet
|
||||
import de.bixilon.kutil.time.TimeUtil.millis
|
||||
import de.bixilon.minosoft.config.key.KeyCodes
|
||||
import de.bixilon.minosoft.gui.rendering.RenderContext
|
||||
@ -31,10 +32,8 @@ import de.bixilon.minosoft.gui.rendering.util.vec.vec2.Vec2dUtil.EMPTY
|
||||
import de.bixilon.minosoft.modding.EventPriorities
|
||||
import de.bixilon.minosoft.modding.event.listener.CallbackEventListener.Companion.listen
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||
import de.bixilon.minosoft.util.KUtil.set
|
||||
import it.unimi.dsi.fastutil.objects.Object2LongMap
|
||||
import it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap
|
||||
import java.util.*
|
||||
|
||||
class InputManager(
|
||||
val context: RenderContext,
|
||||
@ -46,7 +45,7 @@ class InputManager(
|
||||
val interaction = InteractionManagerKeys(this, connection.camera.interactions)
|
||||
|
||||
|
||||
private val pressed: EnumSet<KeyCodes> = KeyCodes.set()
|
||||
private val pressed: BitEnumSet<KeyCodes> = KeyCodes.set()
|
||||
private val times: Object2LongMap<KeyCodes> = Object2LongOpenHashMap<KeyCodes>().apply { defaultReturnValue(-1L) }
|
||||
|
||||
var mousePosition: Vec2d = Vec2d.EMPTY
|
||||
|
@ -51,7 +51,6 @@ import de.bixilon.minosoft.protocol.protocol.buffers.InByteBuffer
|
||||
import de.bixilon.minosoft.protocol.protocol.encryption.CryptManager
|
||||
import de.bixilon.minosoft.recipes.Ingredient
|
||||
import de.bixilon.minosoft.util.KUtil
|
||||
import de.bixilon.minosoft.util.KUtil.set
|
||||
import de.bixilon.minosoft.util.logging.Log
|
||||
import de.bixilon.minosoft.util.logging.LogLevels
|
||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||
|
@ -1,68 +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.util
|
||||
|
||||
import de.bixilon.kutil.concurrent.lock.Lock
|
||||
import de.bixilon.kutil.concurrent.lock.NobodyIsReadingException
|
||||
import de.bixilon.kutil.concurrent.lock.NobodyIsWritingException
|
||||
|
||||
|
||||
@Deprecated("kutil 1.25")
|
||||
class DebugLock : Lock {
|
||||
private val lock = Object()
|
||||
override var readers = 0
|
||||
private set
|
||||
override var locked = false
|
||||
private set
|
||||
|
||||
override fun acquire() {
|
||||
synchronized(lock) {
|
||||
while (locked) {
|
||||
lock.wait()
|
||||
}
|
||||
readers++
|
||||
// Exception("acquire").printStackTrace()
|
||||
lock.notifyAll()
|
||||
}
|
||||
}
|
||||
|
||||
override fun release() {
|
||||
synchronized(lock) {
|
||||
if (readers <= 0) throw NobodyIsReadingException()
|
||||
readers--
|
||||
// Exception("release").printStackTrace()
|
||||
lock.notifyAll()
|
||||
}
|
||||
}
|
||||
|
||||
override fun lock() {
|
||||
synchronized(lock) {
|
||||
while (locked || readers > 0) {
|
||||
lock.wait()
|
||||
}
|
||||
locked = true
|
||||
Exception("lock").printStackTrace()
|
||||
lock.notifyAll()
|
||||
}
|
||||
}
|
||||
|
||||
override fun unlock() {
|
||||
synchronized(lock) {
|
||||
if (!locked) throw NobodyIsWritingException()
|
||||
locked = false
|
||||
Exception("unlock").printStackTrace()
|
||||
lock.notifyAll()
|
||||
}
|
||||
}
|
||||
}
|
@ -1,25 +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.util
|
||||
|
||||
import java.util.*
|
||||
|
||||
|
||||
@Deprecated("kutil 1.24")
|
||||
object EnumSetUtil {
|
||||
|
||||
fun <T : Enum<T>> create(clazz: Class<T>, universe: Array<T>): EnumSet<T> {
|
||||
return EnumSet.noneOf(clazz) // TODO: optimize and use universe
|
||||
}
|
||||
}
|
@ -28,7 +28,6 @@ import de.bixilon.kutil.collections.CollectionUtil.synchronizedSetOf
|
||||
import de.bixilon.kutil.collections.CollectionUtil.toSynchronizedSet
|
||||
import de.bixilon.kutil.concurrent.pool.DefaultThreadPool
|
||||
import de.bixilon.kutil.concurrent.schedule.TaskScheduler
|
||||
import de.bixilon.kutil.enums.ValuesEnum
|
||||
import de.bixilon.kutil.primitive.BooleanUtil.decide
|
||||
import de.bixilon.kutil.primitive.DoubleUtil
|
||||
import de.bixilon.kutil.primitive.DoubleUtil.matches
|
||||
@ -337,12 +336,6 @@ object KUtil {
|
||||
return table
|
||||
}
|
||||
|
||||
@Deprecated("kutil 1.24")
|
||||
@JvmStatic
|
||||
inline fun <reified T : Enum<T>> ValuesEnum<T>.set(): EnumSet<T> {
|
||||
return EnumSetUtil.create(T::class.java, VALUES)
|
||||
}
|
||||
|
||||
fun PlayInByteBuffer.dump(name: String) {
|
||||
val pointer = pointer
|
||||
this.pointer = 0
|
||||
|
@ -1,26 +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.util.set
|
||||
|
||||
@Deprecated("kutil 1.25")
|
||||
interface AbstractBitSet : Cloneable {
|
||||
|
||||
operator fun get(index: Int): Boolean
|
||||
|
||||
operator fun set(index: Int, value: Boolean)
|
||||
fun clear()
|
||||
|
||||
fun capacity(): Int
|
||||
fun length(): Int
|
||||
}
|
@ -1,69 +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.util.set
|
||||
|
||||
@Deprecated("kutil 1.25")
|
||||
class IntBitSet(private var data: Int = 0) : AbstractBitSet {
|
||||
|
||||
override operator fun get(index: Int): Boolean {
|
||||
checkIndex(index)
|
||||
val mask = 1 shl index
|
||||
return (data and mask) != 0
|
||||
}
|
||||
|
||||
override operator fun set(index: Int, value: Boolean) {
|
||||
checkIndex(index)
|
||||
val mask = 1 shl index
|
||||
data = if (value) {
|
||||
data or mask
|
||||
} else {
|
||||
data and mask.inv()
|
||||
}
|
||||
}
|
||||
|
||||
override fun clear() {
|
||||
this.data = 0
|
||||
}
|
||||
|
||||
override fun capacity() = Int.SIZE_BITS
|
||||
|
||||
override fun length(): Int {
|
||||
var data = data
|
||||
var bit = 0
|
||||
|
||||
while (data != 0) {
|
||||
data = data ushr 1
|
||||
bit++
|
||||
}
|
||||
return bit
|
||||
}
|
||||
|
||||
public override fun clone(): IntBitSet {
|
||||
return IntBitSet(data)
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
return data
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (other !is IntBitSet) return false
|
||||
return data == other.data
|
||||
}
|
||||
|
||||
|
||||
private inline fun checkIndex(index: Int) {
|
||||
if (index < 0 || index >= Int.SIZE_BITS) throw IndexOutOfBoundsException("Index out of bounds $index")
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user