Trick JVM into not validating hierarchy tree

This commit is contained in:
DBotThePony 2023-01-29 00:02:41 +07:00
parent fdad25cb17
commit 4c78e4e6c6
Signed by: DBot
GPG Key ID: DCC23B5715498507

View File

@ -1,14 +1,26 @@
package ru.dbotthepony.mc.otm.menu.input package ru.dbotthepony.mc.otm.menu.input
import net.minecraft.world.entity.player.Player
import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.minecraft
import ru.dbotthepony.mc.otm.core.GetterSetter import ru.dbotthepony.mc.otm.core.GetterSetter
import ru.dbotthepony.mc.otm.menu.MatteryMenu import ru.dbotthepony.mc.otm.menu.MatteryMenu
import kotlin.reflect.KMutableProperty0 import kotlin.reflect.KMutableProperty0
abstract class AbstractNetworkedInput<V> { /**
* Getting and setting values should ONLY be done clientside
*/
abstract class AbstractNetworkedInput<V> : GetterSetter<V> {
abstract val input: MatteryMenu.PlayerInput<V> abstract val input: MatteryMenu.PlayerInput<V>
abstract val value: V abstract val value: V
override fun get(): V {
return value
}
override fun accept(t: V) {
input.checkedInput(t, minecraft.player as Player?)
}
var supplier: (() -> V)? = null var supplier: (() -> V)? = null
var consumer: ((V) -> Unit)? = null var consumer: ((V) -> Unit)? = null
@ -44,13 +56,13 @@ abstract class AbstractNetworkedInput<V> {
* shortcut to checked input of [input] * shortcut to checked input of [input]
*/ */
fun input(newValue: V) { fun input(newValue: V) {
input.checkedInput(newValue, minecraft.player) input.checkedInput(newValue, minecraft.player as Player?)
} }
/** /**
* checks if local (client) player can modify this input * checks if local (client) player can modify this input
*/ */
fun check(): Boolean { fun check(): Boolean {
return input.allowSpectators || minecraft.player?.isSpectator == false return input.allowSpectators || (minecraft.player as Player?)?.isSpectator == false
} }
} }