mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-19 12:25:12 -04:00
remove and deprecate some stuff (KUtil 1.13)
This commit is contained in:
parent
a6dae42b00
commit
37e120de0e
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020 Moritz Zwerger
|
||||
* 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.
|
||||
*
|
||||
@ -12,6 +12,7 @@
|
||||
*/
|
||||
package de.bixilon.minosoft
|
||||
|
||||
@Deprecated("Kutil 1.13")
|
||||
enum class ShutdownReasons(val exitCode: Int) {
|
||||
UNKNOWN(1),
|
||||
REQUESTED_BY_USER(0),
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
package de.bixilon.minosoft.data.registries.blocks.entites
|
||||
|
||||
import de.bixilon.kutil.cast.CollectionCast.asAnyCollection
|
||||
import de.bixilon.minosoft.data.entities.block.BlockEntity
|
||||
import de.bixilon.minosoft.data.entities.block.BlockEntityFactory
|
||||
import de.bixilon.minosoft.data.entities.block.DefaultBlockDataFactory
|
||||
@ -22,7 +23,6 @@ import de.bixilon.minosoft.data.registries.registries.Registries
|
||||
import de.bixilon.minosoft.data.registries.registries.registry.RegistryItem
|
||||
import de.bixilon.minosoft.data.registries.registries.registry.codec.ResourceLocationCodec
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||
import de.bixilon.minosoft.util.CastUtil.asAnyCollection
|
||||
|
||||
data class BlockEntityType<T : BlockEntity>(
|
||||
override val resourceLocation: ResourceLocation,
|
||||
|
@ -16,6 +16,7 @@ import de.bixilon.kotlinglm.vec3.Vec3i
|
||||
import de.bixilon.kutil.cast.CastUtil.nullCast
|
||||
import de.bixilon.kutil.cast.CastUtil.unsafeCast
|
||||
import de.bixilon.kutil.cast.CastUtil.unsafeNull
|
||||
import de.bixilon.kutil.cast.CollectionCast.asAnyMap
|
||||
import de.bixilon.kutil.json.JsonUtil.asJsonObject
|
||||
import de.bixilon.kutil.primitive.DoubleUtil.toDouble
|
||||
import de.bixilon.kutil.primitive.FloatUtil.toFloat
|
||||
@ -39,7 +40,6 @@ import de.bixilon.minosoft.gui.rendering.camera.target.targets.BlockTarget
|
||||
import de.bixilon.minosoft.gui.rendering.input.interaction.InteractionResults
|
||||
import de.bixilon.minosoft.gui.rendering.tint.TintProvider
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||
import de.bixilon.minosoft.util.CastUtil.asAnyMap
|
||||
import kotlin.random.Random
|
||||
|
||||
open class Block(
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
package de.bixilon.minosoft.data.registries.items.tools
|
||||
|
||||
import de.bixilon.kutil.cast.CollectionCast.toAnyMap
|
||||
import de.bixilon.kutil.primitive.IntUtil.toInt
|
||||
import de.bixilon.minosoft.data.container.stack.ItemStack
|
||||
import de.bixilon.minosoft.data.entities.entities.player.Hands
|
||||
@ -22,7 +23,6 @@ import de.bixilon.minosoft.data.registries.registries.Registries
|
||||
import de.bixilon.minosoft.gui.rendering.camera.target.targets.BlockTarget
|
||||
import de.bixilon.minosoft.gui.rendering.input.interaction.InteractionResults
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||
import de.bixilon.minosoft.util.CastUtil.toAnyMap
|
||||
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||
|
||||
open class AxeItem(
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
package de.bixilon.minosoft.data.registries.items.tools
|
||||
|
||||
import de.bixilon.kutil.cast.CollectionCast.toAnyMap
|
||||
import de.bixilon.kutil.primitive.IntUtil.toInt
|
||||
import de.bixilon.minosoft.data.container.stack.ItemStack
|
||||
import de.bixilon.minosoft.data.direction.Directions
|
||||
@ -25,7 +26,6 @@ import de.bixilon.minosoft.gui.rendering.camera.target.targets.BlockTarget
|
||||
import de.bixilon.minosoft.gui.rendering.input.interaction.InteractionResults
|
||||
import de.bixilon.minosoft.gui.rendering.util.VecUtil.plus
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||
import de.bixilon.minosoft.util.CastUtil.toAnyMap
|
||||
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||
|
||||
open class HoeItem(
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
package de.bixilon.minosoft.data.registries.items.tools
|
||||
|
||||
import de.bixilon.kutil.cast.CollectionCast.toAnyMap
|
||||
import de.bixilon.kutil.primitive.IntUtil.toInt
|
||||
import de.bixilon.minosoft.data.container.stack.ItemStack
|
||||
import de.bixilon.minosoft.data.direction.Directions
|
||||
@ -25,7 +26,6 @@ import de.bixilon.minosoft.gui.rendering.camera.target.targets.BlockTarget
|
||||
import de.bixilon.minosoft.gui.rendering.input.interaction.InteractionResults
|
||||
import de.bixilon.minosoft.gui.rendering.util.VecUtil.plus
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||
import de.bixilon.minosoft.util.CastUtil.toAnyMap
|
||||
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||
|
||||
open class ShovelItem(
|
||||
|
@ -14,6 +14,7 @@
|
||||
package de.bixilon.minosoft.gui.rendering.input.interaction
|
||||
|
||||
import de.bixilon.kutil.rate.RateLimiter
|
||||
import de.bixilon.kutil.time.Cooldown
|
||||
import de.bixilon.minosoft.config.key.KeyActions
|
||||
import de.bixilon.minosoft.config.key.KeyBinding
|
||||
import de.bixilon.minosoft.config.key.KeyCodes
|
||||
@ -29,7 +30,7 @@ import de.bixilon.minosoft.gui.rendering.particle.types.norender.emitter.EntityE
|
||||
import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.damage.CritParticle
|
||||
import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.damage.EnchantedHitParticle
|
||||
import de.bixilon.minosoft.protocol.packets.c2s.play.entity.interact.EntityAttackC2SP
|
||||
import de.bixilon.minosoft.util.Cooldown
|
||||
import de.bixilon.minosoft.util.KUtil.setTicks
|
||||
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||
|
||||
class AttackInteractionHandler(
|
||||
|
@ -1,45 +0,0 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2021 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.cast.CastUtil.nullCast
|
||||
import de.bixilon.kutil.cast.CastUtil.unsafeCast
|
||||
|
||||
@Deprecated("Will be part of KUtil in next version")
|
||||
object CastUtil {
|
||||
|
||||
fun Any?.asAnyCollection(): Collection<Any> {
|
||||
return this.unsafeCast()
|
||||
}
|
||||
|
||||
fun Any?.toAnyCollection(): Collection<Any>? {
|
||||
return this?.nullCast()
|
||||
}
|
||||
|
||||
fun Any?.asAnyList(): List<Any> {
|
||||
return this.unsafeCast()
|
||||
}
|
||||
|
||||
fun Any?.toAnyList(): List<Any>? {
|
||||
return this?.nullCast()
|
||||
}
|
||||
|
||||
fun Any?.asAnyMap(): Map<Any, Any> {
|
||||
return this.unsafeCast()
|
||||
}
|
||||
|
||||
fun Any?.toAnyMap(): Map<Any, Any>? {
|
||||
return this?.nullCast()
|
||||
}
|
||||
}
|
@ -1,64 +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
|
||||
|
||||
import de.bixilon.kutil.time.TimeUtil
|
||||
import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition
|
||||
|
||||
class Cooldown {
|
||||
private var start = -1L
|
||||
private var end = -1L
|
||||
val ended: Boolean
|
||||
get() = timeLeft == 0L
|
||||
val time: Long
|
||||
get() {
|
||||
if (start < 0L) {
|
||||
return 0
|
||||
}
|
||||
return end - start
|
||||
}
|
||||
val timeLeft: Long
|
||||
get() {
|
||||
if (start < 0L) {
|
||||
return 0L
|
||||
}
|
||||
val time = TimeUtil.millis
|
||||
return time - end
|
||||
}
|
||||
val progress: Float
|
||||
get() {
|
||||
val timeLeft = timeLeft
|
||||
if (timeLeft == 0L) {
|
||||
return 1.0f
|
||||
}
|
||||
val time = time
|
||||
if (time == 0L) {
|
||||
return 1.0f
|
||||
}
|
||||
return timeLeft.toFloat() / time
|
||||
}
|
||||
|
||||
|
||||
fun set(millis: Long) {
|
||||
val time = TimeUtil.millis
|
||||
start = time
|
||||
end = start + millis
|
||||
}
|
||||
|
||||
fun set(millis: Int) = set(millis.toLong())
|
||||
|
||||
fun setTicks(ticks: Int) {
|
||||
set(ticks * ProtocolDefinition.TICK_TIME)
|
||||
}
|
||||
}
|
@ -27,6 +27,7 @@ import de.bixilon.kutil.concurrent.time.TimeWorker
|
||||
import de.bixilon.kutil.primitive.BooleanUtil.decide
|
||||
import de.bixilon.kutil.reflection.ReflectionUtil.forceInit
|
||||
import de.bixilon.kutil.reflection.ReflectionUtil.realName
|
||||
import de.bixilon.kutil.time.Cooldown
|
||||
import de.bixilon.minosoft.data.container.stack.ItemStack
|
||||
import de.bixilon.minosoft.data.entities.entities.Entity
|
||||
import de.bixilon.minosoft.data.registries.ResourceLocation
|
||||
@ -287,4 +288,8 @@ object KUtil {
|
||||
fun <T> Array<T?>.cast(): Array<T> {
|
||||
return this.unsafeCast()
|
||||
}
|
||||
|
||||
fun Cooldown.setTicks(ticks: Int) {
|
||||
set(ticks * ProtocolDefinition.TICK_TIME)
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ import de.bixilon.minosoft.util.logging.LogMessageType
|
||||
import javafx.application.Platform
|
||||
import kotlin.system.exitProcess
|
||||
|
||||
@Deprecated("Kutil 1.13")
|
||||
object ShutdownManager {
|
||||
private var initialized = false
|
||||
var shuttingDown = false
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2021 Moritz Zwerger
|
||||
* 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.
|
||||
*
|
||||
@ -18,6 +18,7 @@ import java.net.URLConnection
|
||||
import java.net.URLStreamHandler
|
||||
import java.net.URLStreamHandlerFactory
|
||||
|
||||
@Deprecated("KUtil 1.13")
|
||||
object URLProtocolStreamHandlers : URLStreamHandlerFactory {
|
||||
val PROTOCOLS: MutableMap<String, URLStreamHandler> = mutableMapOf(
|
||||
"resource" to ResourceURLHandler,
|
||||
@ -31,7 +32,6 @@ object URLProtocolStreamHandlers : URLStreamHandlerFactory {
|
||||
return PROTOCOLS[protocol]
|
||||
}
|
||||
|
||||
|
||||
val NULL_URL_CONNECTION: URLConnection = object : URLConnection(null) {
|
||||
override fun connect() = Unit
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user