mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-09 07:20:04 -04:00
remove a ton of events (and replace them with observables)
This commit is contained in:
parent
abebe9aad0
commit
6d1424f508
@ -4,7 +4,8 @@
|
||||
|
||||
- [Mojang](https://mojang.com) For the original game. Many people (including me) blame mojang for making "bad decisions". imho that is kind of true. I know the protocol is a mess at some point, but also genius on the other side. The thing is, minecraft is more than a protocol. While reversing the game, I saw so much stuff. The original game has around 20 Mib of code. That is immense. Every different particle behaves different and has so much thinking in it. It is incredible, that somebody thought, that the campfire particle has a velocity of 0.81 in y direction, etc
|
||||
(just an example, not quite true). I never thought of it. I learned so much while writing minosoft and want to thank mojang for it. The game is just fascinating, in players view and even more in developer view.
|
||||
- [PixLyzer](https://gitlab.bixilon.de/bixilon/pixlyzer)
|
||||
- [Burger](https://github.com/Pokechu22/Burger)
|
||||
- [wiki.vg](https://wiki.vg)
|
||||
- [PixLyzer](https://gitlab.bixilon.de/bixilon/pixlyzer) (For providing data)
|
||||
- [Burger](https://github.com/Pokechu22/Burger) (For generating protocol diffs in old versions)
|
||||
- [wiki.vg](https://wiki.vg) (For providing a lot of documentation about old versions)
|
||||
- [yarn](https://github.com/fabricmc/yarn) For providing better mappings than mojang thus letting me easier reverse the protocol
|
||||
- `#mcdevs` for being available when I needed help
|
||||
|
@ -287,9 +287,9 @@ fun DependencyHandler.netty(name: String) {
|
||||
implementation("io.netty", "netty-$name", nettyVersion)
|
||||
}
|
||||
|
||||
fun DependencyHandler.lwjgl(name: String) {
|
||||
fun DependencyHandler.lwjgl(name: String? = null) {
|
||||
var artifactId = "lwjgl"
|
||||
if (name.isNotEmpty()) {
|
||||
if (name != null) {
|
||||
artifactId += "-$name"
|
||||
}
|
||||
implementation("org.lwjgl", artifactId, lwjglVersion)
|
||||
@ -309,7 +309,7 @@ dependencies {
|
||||
implementation("org.kamranzafar", "jtar", "2.3")
|
||||
implementation("org.reflections", "reflections", "0.10.2")
|
||||
implementation("it.unimi.dsi", "fastutil-core", "8.5.9")
|
||||
implementation("org.xeustechnologies", "jcl-core", version = "2.8")
|
||||
implementation("org.xeustechnologies", "jcl-core", "2.8")
|
||||
|
||||
|
||||
// ikonli
|
||||
@ -335,7 +335,7 @@ dependencies {
|
||||
|
||||
// lwjgl
|
||||
implementation(platform("org.lwjgl:lwjgl-bom:$lwjglVersion"))
|
||||
lwjgl("")
|
||||
lwjgl()
|
||||
lwjgl("glfw")
|
||||
lwjgl("openal")
|
||||
lwjgl("opengl")
|
||||
|
@ -36,7 +36,7 @@ Those assets are not modifiable and checked everytime they get loaded (to disabl
|
||||
|
||||
## Resource packs
|
||||
|
||||
They are pretty bugged, expect that things break. They are still supported. To add a resource pack, add this to `resource_packs` in the `resources.json:
|
||||
They are pretty bugged, expect that things break. They are still supported. To add a resource pack, add this to `resource_packs` in the `resources.json`:
|
||||
|
||||
```json
|
||||
{
|
||||
|
@ -24,4 +24,5 @@
|
||||
- Multiple `mods` folders
|
||||
- pre boot (before loading anything)
|
||||
- boot (while loading everything else)
|
||||
- post boot (start loading in while, but don't wait for them. Only wait before loading connection)
|
||||
- post boot (start loading after booting, but don't wait for them. Only wait before loading connection)
|
||||
- No classic event system, events are stateless. Everything that is stateful should use observables
|
||||
|
@ -120,7 +120,7 @@ object Minosoft {
|
||||
BOOT_LATCH.await()
|
||||
val end = nanos()
|
||||
Log.log(LogMessageType.OTHER, LogLevels.INFO) { "Minosoft boot sequence finished in ${(end - start).formatNanos()}!" }
|
||||
GlobalEventMaster.fireEvent(FinishInitializingEvent())
|
||||
GlobalEventMaster.fire(FinishInitializingEvent())
|
||||
DefaultThreadPool += { ModLoader.load(LoadingPhases.POST_BOOT, CountUpAndDownLatch(0)) }
|
||||
|
||||
|
||||
|
@ -42,7 +42,7 @@ object AccountProfileManager : ProfileManager<AccountProfile> {
|
||||
set(value) {
|
||||
field = value
|
||||
GlobalProfileManager.selectProfile(this, value)
|
||||
GlobalEventMaster.fireEvent(AccountProfileSelectEvent(value))
|
||||
GlobalEventMaster.fire(AccountProfileSelectEvent(value))
|
||||
}
|
||||
|
||||
override fun createProfile(name: String, description: String?): AccountProfile {
|
||||
|
@ -43,7 +43,7 @@ object AudioProfileManager : ProfileManager<AudioProfile> {
|
||||
set(value) {
|
||||
field = value
|
||||
GlobalProfileManager.selectProfile(this, value)
|
||||
GlobalEventMaster.fireEvent(AudioProfileSelectEvent(value))
|
||||
GlobalEventMaster.fire(AudioProfileSelectEvent(value))
|
||||
}
|
||||
|
||||
override fun createProfile(name: String, description: String?): AudioProfile {
|
||||
|
@ -42,7 +42,7 @@ object BlockProfileManager : ProfileManager<BlockProfile> {
|
||||
set(value) {
|
||||
field = value
|
||||
GlobalProfileManager.selectProfile(this, value)
|
||||
GlobalEventMaster.fireEvent(BlockProfileSelectEvent(value))
|
||||
GlobalEventMaster.fire(BlockProfileSelectEvent(value))
|
||||
}
|
||||
|
||||
override fun createProfile(name: String, description: String?): BlockProfile {
|
||||
|
@ -42,7 +42,7 @@ object ConnectionProfileManager : ProfileManager<ConnectionProfile> {
|
||||
set(value) {
|
||||
field = value
|
||||
GlobalProfileManager.selectProfile(this, value)
|
||||
GlobalEventMaster.fireEvent(ConnectionProfileSelectEvent(value))
|
||||
GlobalEventMaster.fire(ConnectionProfileSelectEvent(value))
|
||||
}
|
||||
|
||||
override fun createProfile(name: String, description: String?): ConnectionProfile {
|
||||
|
@ -42,7 +42,7 @@ object ControlsProfileManager : ProfileManager<ControlsProfile> {
|
||||
set(value) {
|
||||
field = value
|
||||
GlobalProfileManager.selectProfile(this, value)
|
||||
GlobalEventMaster.fireEvent(ControlsProfileSelectEvent(value))
|
||||
GlobalEventMaster.fire(ControlsProfileSelectEvent(value))
|
||||
}
|
||||
|
||||
override fun createProfile(name: String, description: String?): ControlsProfile {
|
||||
|
@ -42,7 +42,7 @@ object EntityProfileManager : ProfileManager<EntityProfile> {
|
||||
set(value) {
|
||||
field = value
|
||||
GlobalProfileManager.selectProfile(this, value)
|
||||
GlobalEventMaster.fireEvent(EntityProfileSelectEvent(value))
|
||||
GlobalEventMaster.fire(EntityProfileSelectEvent(value))
|
||||
}
|
||||
|
||||
override fun createProfile(name: String, description: String?): EntityProfile {
|
||||
|
@ -53,7 +53,7 @@ object ErosProfileManager : ProfileManager<ErosProfile> {
|
||||
set(value) {
|
||||
field = value
|
||||
GlobalProfileManager.selectProfile(this, value)
|
||||
GlobalEventMaster.fireEvent(ErosProfileSelectEvent(value))
|
||||
GlobalEventMaster.fire(ErosProfileSelectEvent(value))
|
||||
}
|
||||
|
||||
override fun createProfile(name: String, description: String?): ErosProfile {
|
||||
|
@ -42,7 +42,7 @@ object GUIProfileManager : ProfileManager<GUIProfile> {
|
||||
set(value) {
|
||||
field = value
|
||||
GlobalProfileManager.selectProfile(this, value)
|
||||
GlobalEventMaster.fireEvent(GUIProfileSelectEvent(value))
|
||||
GlobalEventMaster.fire(GUIProfileSelectEvent(value))
|
||||
}
|
||||
|
||||
override fun createProfile(name: String, description: String?): GUIProfile {
|
||||
|
@ -42,7 +42,7 @@ object OtherProfileManager : ProfileManager<OtherProfile> {
|
||||
set(value) {
|
||||
field = value
|
||||
GlobalProfileManager.selectProfile(this, value)
|
||||
GlobalEventMaster.fireEvent(OtherProfileSelectEvent(value))
|
||||
GlobalEventMaster.fire(OtherProfileSelectEvent(value))
|
||||
}
|
||||
|
||||
override fun createProfile(name: String, description: String?): OtherProfile {
|
||||
|
@ -42,7 +42,7 @@ object ParticleProfileManager : ProfileManager<ParticleProfile> {
|
||||
set(value) {
|
||||
field = value
|
||||
GlobalProfileManager.selectProfile(this, value)
|
||||
GlobalEventMaster.fireEvent(ParticleProfileSelectEvent(value))
|
||||
GlobalEventMaster.fire(ParticleProfileSelectEvent(value))
|
||||
}
|
||||
|
||||
override fun createProfile(name: String, description: String?): ParticleProfile {
|
||||
|
@ -42,7 +42,7 @@ object RenderingProfileManager : ProfileManager<RenderingProfile> {
|
||||
set(value) {
|
||||
field = value
|
||||
GlobalProfileManager.selectProfile(this, value)
|
||||
GlobalEventMaster.fireEvent(RenderingProfileSelectEvent(value))
|
||||
GlobalEventMaster.fire(RenderingProfileSelectEvent(value))
|
||||
}
|
||||
|
||||
override fun createProfile(name: String, description: String?): RenderingProfile {
|
||||
|
@ -42,7 +42,7 @@ object ResourcesProfileManager : ProfileManager<ResourcesProfile> {
|
||||
set(value) {
|
||||
field = value
|
||||
GlobalProfileManager.selectProfile(this, value)
|
||||
GlobalEventMaster.fireEvent(ResourcesProfileSelectEvent(value))
|
||||
GlobalEventMaster.fire(ResourcesProfileSelectEvent(value))
|
||||
}
|
||||
|
||||
override fun createProfile(name: String, description: String?): ResourcesProfile {
|
||||
|
@ -22,5 +22,5 @@ class PlayerEntityMessageSender(
|
||||
name: String,
|
||||
val player: PlayerEntity,
|
||||
) : PlayerMessageSender(uuid, name) {
|
||||
override val publicKey: PlayerPublicKey? get() = player.tabListItem.publicKey
|
||||
override val publicKey: PlayerPublicKey? get() = player.additional.publicKey
|
||||
}
|
||||
|
@ -13,13 +13,13 @@
|
||||
|
||||
package de.bixilon.minosoft.data.chat.sender
|
||||
|
||||
import de.bixilon.minosoft.data.entities.entities.player.tab.TabListItem
|
||||
import de.bixilon.minosoft.data.entities.entities.player.additional.PlayerAdditional
|
||||
import de.bixilon.minosoft.protocol.PlayerPublicKey
|
||||
import java.util.*
|
||||
|
||||
class UnspawnedMessageSender(
|
||||
uuid: UUID,
|
||||
val tab: TabListItem,
|
||||
val tab: PlayerAdditional,
|
||||
) : PlayerMessageSender(uuid, tab.name) {
|
||||
override val publicKey: PlayerPublicKey? get() = tab.publicKey
|
||||
}
|
||||
|
@ -28,8 +28,8 @@ import de.bixilon.minosoft.data.entities.data.EntityData
|
||||
import de.bixilon.minosoft.data.entities.data.EntityDataField
|
||||
import de.bixilon.minosoft.data.entities.entities.LivingEntity
|
||||
import de.bixilon.minosoft.data.entities.entities.SynchronizedEntityData
|
||||
import de.bixilon.minosoft.data.entities.entities.player.additional.PlayerAdditional
|
||||
import de.bixilon.minosoft.data.entities.entities.player.properties.PlayerProperties
|
||||
import de.bixilon.minosoft.data.entities.entities.player.tab.TabListItem
|
||||
import de.bixilon.minosoft.data.registries.entities.EntityType
|
||||
import de.bixilon.minosoft.data.registries.item.items.armor.DyeableArmorItem
|
||||
import de.bixilon.minosoft.data.text.formatting.color.ChatColors
|
||||
@ -49,9 +49,9 @@ abstract class PlayerEntity(
|
||||
data: EntityData,
|
||||
position: Vec3d = Vec3d.EMPTY,
|
||||
rotation: EntityRotation = EntityRotation(0.0, 0.0),
|
||||
name: String = "TBA",
|
||||
name: String = "",
|
||||
properties: PlayerProperties? = null,
|
||||
var tabListItem: TabListItem = TabListItem(name = name, gamemode = Gamemodes.SURVIVAL, properties = properties),
|
||||
val additional: PlayerAdditional = PlayerAdditional(name = name, properties = properties),
|
||||
) : LivingEntity(connection, entityType, data, position, rotation) {
|
||||
protected var _model: PlayerModel?
|
||||
get() = super.model.nullCast()
|
||||
@ -64,11 +64,11 @@ abstract class PlayerEntity(
|
||||
|
||||
@get:SynchronizedEntityData
|
||||
val gamemode: Gamemodes
|
||||
get() = tabListItem.gamemode
|
||||
get() = additional.gamemode
|
||||
|
||||
@get:SynchronizedEntityData
|
||||
val name: String
|
||||
get() = tabListItem.name
|
||||
get() = additional.name
|
||||
|
||||
@get:SynchronizedEntityData
|
||||
val playerAbsorptionHearts: Float
|
||||
@ -139,7 +139,7 @@ abstract class PlayerEntity(
|
||||
if (chestPlate != null && chestPlate.item.item is DyeableArmorItem) {
|
||||
chestPlate._display?.dyeColor?.let { return it }
|
||||
}
|
||||
val formattingCode = tabListItem.team?.formattingCode
|
||||
val formattingCode = additional.team?.formattingCode
|
||||
if (formattingCode is RGBColor) {
|
||||
return formattingCode
|
||||
}
|
||||
|
@ -17,8 +17,8 @@ import de.bixilon.kotlinglm.vec3.Vec3d
|
||||
import de.bixilon.minosoft.data.abilities.Gamemodes
|
||||
import de.bixilon.minosoft.data.entities.EntityRotation
|
||||
import de.bixilon.minosoft.data.entities.data.EntityData
|
||||
import de.bixilon.minosoft.data.entities.entities.player.additional.PlayerAdditional
|
||||
import de.bixilon.minosoft.data.entities.entities.player.properties.PlayerProperties
|
||||
import de.bixilon.minosoft.data.entities.entities.player.tab.TabListItem
|
||||
import de.bixilon.minosoft.data.registries.ResourceLocation
|
||||
import de.bixilon.minosoft.data.registries.entities.EntityFactory
|
||||
import de.bixilon.minosoft.data.registries.entities.EntityType
|
||||
@ -33,7 +33,7 @@ class RemotePlayerEntity(
|
||||
rotation: EntityRotation = EntityRotation(0.0, 0.0),
|
||||
name: String = "TBA",
|
||||
properties: PlayerProperties? = null,
|
||||
tabListItem: TabListItem = TabListItem(name = name, gamemode = Gamemodes.SURVIVAL, properties = properties),
|
||||
tabListItem: PlayerAdditional = PlayerAdditional(name = name, gamemode = Gamemodes.SURVIVAL, properties = properties),
|
||||
) : PlayerEntity(connection, entityType, data, position, rotation, name, properties, tabListItem) {
|
||||
|
||||
companion object : EntityFactory<PlayerEntity> {
|
||||
|
@ -11,7 +11,7 @@
|
||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||
*/
|
||||
|
||||
package de.bixilon.minosoft.data.entities.entities.player.tab
|
||||
package de.bixilon.minosoft.data.entities.entities.player.additional
|
||||
|
||||
import de.bixilon.minosoft.data.abilities.Gamemodes
|
||||
import de.bixilon.minosoft.data.entities.entities.player.properties.PlayerProperties
|
||||
@ -19,7 +19,7 @@ import de.bixilon.minosoft.data.scoreboard.Team
|
||||
import de.bixilon.minosoft.data.text.ChatComponent
|
||||
import de.bixilon.minosoft.protocol.PlayerPublicKey
|
||||
|
||||
data class TabListItemData(
|
||||
data class AdditionalDataUpdate(
|
||||
val name: String? = null,
|
||||
var ping: Int? = null,
|
||||
var gamemode: Gamemodes? = null,
|
@ -11,8 +11,9 @@
|
||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||
*/
|
||||
|
||||
package de.bixilon.minosoft.data.entities.entities.player.tab
|
||||
package de.bixilon.minosoft.data.entities.entities.player.additional
|
||||
|
||||
import de.bixilon.kutil.watcher.DataWatcher.Companion.watched
|
||||
import de.bixilon.minosoft.data.abilities.Gamemodes
|
||||
import de.bixilon.minosoft.data.entities.entities.player.properties.PlayerProperties
|
||||
import de.bixilon.minosoft.data.scoreboard.Team
|
||||
@ -20,25 +21,33 @@ import de.bixilon.minosoft.data.text.ChatComponent
|
||||
import de.bixilon.minosoft.protocol.PlayerPublicKey
|
||||
import de.bixilon.minosoft.util.KUtil.nullCompare
|
||||
|
||||
data class TabListItem(
|
||||
var name: String,
|
||||
var ping: Int = -1,
|
||||
var gamemode: Gamemodes = Gamemodes.SURVIVAL,
|
||||
var displayName: ChatComponent = ChatComponent.of(name),
|
||||
var properties: PlayerProperties? = null,
|
||||
var team: Team? = null,
|
||||
var publicKey: PlayerPublicKey? = null,
|
||||
) : Comparable<TabListItem> {
|
||||
val tabDisplayName: ChatComponent
|
||||
get() = team?.decorateName(displayName) ?: displayName
|
||||
class PlayerAdditional(
|
||||
name: String,
|
||||
ping: Int = -1,
|
||||
gamemode: Gamemodes = Gamemodes.SURVIVAL,
|
||||
displayName: ChatComponent? = null,
|
||||
properties: PlayerProperties? = null,
|
||||
team: Team? = null,
|
||||
publicKey: PlayerPublicKey? = null,
|
||||
) : Comparable<PlayerAdditional> {
|
||||
var name by watched(name)
|
||||
var ping by watched(ping)
|
||||
var gamemode by watched(gamemode)
|
||||
var displayName by watched(displayName)
|
||||
var properties by watched(properties)
|
||||
var team by watched(team)
|
||||
var publicKey by watched(publicKey)
|
||||
|
||||
fun merge(data: TabListItemData) {
|
||||
val tabDisplayName: ChatComponent
|
||||
get() = displayName?.let { team?.decorateName(it) ?: it } ?: ChatComponent.of(name)
|
||||
|
||||
fun merge(data: AdditionalDataUpdate) {
|
||||
genericMerge(data)
|
||||
data.gamemode?.let { gamemode = it }
|
||||
data.publicKey?.let { publicKey = it }
|
||||
}
|
||||
|
||||
fun genericMerge(data: TabListItemData) {
|
||||
fun genericMerge(data: AdditionalDataUpdate) {
|
||||
data.name?.let { name = it }
|
||||
data.ping?.let { ping = it }
|
||||
|
||||
@ -57,7 +66,7 @@ data class TabListItem(
|
||||
data.team?.let { team = it }
|
||||
}
|
||||
|
||||
override fun compareTo(other: TabListItem): Int {
|
||||
override fun compareTo(other: PlayerAdditional): Int {
|
||||
if (this.gamemode != other.gamemode) {
|
||||
if (this.gamemode == Gamemodes.SPECTATOR) {
|
||||
return -1
|
@ -13,8 +13,11 @@
|
||||
|
||||
package de.bixilon.minosoft.data.entities.entities.player.local
|
||||
|
||||
import de.bixilon.kutil.watcher.DataWatcher.Companion.watched
|
||||
|
||||
@Deprecated("make values final")
|
||||
class ExperienceCondition {
|
||||
var level = 0
|
||||
var totalExperience = 0
|
||||
var experienceBarProgress = 0.0f
|
||||
var level by watched(0)
|
||||
var total by watched(0)
|
||||
var bar by watched(0.0f)
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ package de.bixilon.minosoft.data.entities.entities.player.local
|
||||
|
||||
import de.bixilon.kutil.watcher.DataWatcher.Companion.watched
|
||||
|
||||
@Deprecated("Make values final")
|
||||
class HealthCondition {
|
||||
var hp by watched(20.0f)
|
||||
var hunger by watched(20)
|
||||
|
@ -30,6 +30,8 @@ import de.bixilon.kutil.collections.map.bi.SynchronizedBiMap
|
||||
import de.bixilon.kutil.math.interpolation.DoubleInterpolation.interpolateLinear
|
||||
import de.bixilon.kutil.primitive.BooleanUtil.decide
|
||||
import de.bixilon.kutil.time.TimeUtil.millis
|
||||
import de.bixilon.kutil.watcher.DataWatcher.Companion.observe
|
||||
import de.bixilon.kutil.watcher.DataWatcher.Companion.watched
|
||||
import de.bixilon.minosoft.data.Axes
|
||||
import de.bixilon.minosoft.data.abilities.Gamemodes
|
||||
import de.bixilon.minosoft.data.abilities.ItemCooldown
|
||||
@ -94,15 +96,16 @@ class LocalPlayerEntity(
|
||||
val containers: SynchronizedBiMap<Int, Container> = synchronizedBiMapOf(
|
||||
ProtocolDefinition.PLAYER_CONTAINER_ID to inventory,
|
||||
)
|
||||
var selectedHotbarSlot: Int = 0
|
||||
set(value) {
|
||||
if (field == value) {
|
||||
return
|
||||
}
|
||||
field = value
|
||||
|
||||
var selectedHotbarSlot: Int by watched(0)
|
||||
|
||||
init {
|
||||
this::selectedHotbarSlot.observe(this) {
|
||||
equipment.remove(InventorySlots.EquipmentSlots.MAIN_HAND)
|
||||
equipment[InventorySlots.EquipmentSlots.MAIN_HAND] = inventory.getHotbarSlot(value) ?: return
|
||||
equipment[InventorySlots.EquipmentSlots.MAIN_HAND] = inventory.getHotbarSlot(it) ?: return@observe
|
||||
}
|
||||
}
|
||||
|
||||
var openedContainer: Container? = null
|
||||
|
||||
val itemCooldown: MutableMap<Item, ItemCooldown> = synchronizedMapOf()
|
||||
|
@ -13,12 +13,13 @@
|
||||
|
||||
package de.bixilon.minosoft.data.entities.entities.player.tab
|
||||
|
||||
import de.bixilon.minosoft.data.entities.entities.player.additional.PlayerAdditional
|
||||
import de.bixilon.minosoft.data.text.ChatComponent
|
||||
import java.util.*
|
||||
|
||||
class TabList {
|
||||
val tabListItemsByUUID: MutableMap<UUID, TabListItem> = mutableMapOf()
|
||||
val tabListItemsByName: MutableMap<String, TabListItem> = mutableMapOf()
|
||||
val tabListItemsByUUID: MutableMap<UUID, PlayerAdditional> = mutableMapOf()
|
||||
val tabListItemsByName: MutableMap<String, PlayerAdditional> = mutableMapOf()
|
||||
var header = ChatComponent.of("")
|
||||
var footer = ChatComponent.of("")
|
||||
}
|
||||
|
@ -1,26 +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.data.registries.other.game.event.handlers.gamemode
|
||||
|
||||
import de.bixilon.minosoft.data.abilities.Gamemodes
|
||||
import de.bixilon.minosoft.modding.event.EventInitiators
|
||||
import de.bixilon.minosoft.modding.event.events.connection.play.PlayConnectionEvent
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||
|
||||
class GamemodeChangeEvent(
|
||||
connection: PlayConnection,
|
||||
initiator: EventInitiators,
|
||||
val previousGameMode: Gamemodes,
|
||||
val gamemode: Gamemodes,
|
||||
) : PlayConnectionEvent(connection, initiator)
|
@ -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.
|
||||
*
|
||||
@ -16,7 +16,6 @@ package de.bixilon.minosoft.data.registries.other.game.event.handlers.gamemode
|
||||
import de.bixilon.minosoft.data.abilities.Gamemodes
|
||||
import de.bixilon.minosoft.data.registries.ResourceLocation
|
||||
import de.bixilon.minosoft.data.registries.other.game.event.handlers.GameEventHandler
|
||||
import de.bixilon.minosoft.modding.event.EventInitiators
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||
|
||||
@ -24,12 +23,11 @@ object GamemodeChangeGameEventHandler : GameEventHandler {
|
||||
override val RESOURCE_LOCATION: ResourceLocation = "minecraft:gamemode_change".toResourceLocation()
|
||||
|
||||
override fun handle(data: Float, connection: PlayConnection) {
|
||||
val previous = connection.player.tabListItem.gamemode
|
||||
val previous = connection.player.additional.gamemode
|
||||
val next = Gamemodes[data.toInt()]
|
||||
if (previous == next) {
|
||||
return
|
||||
}
|
||||
connection.player.tabListItem.gamemode = next
|
||||
connection.fireEvent(GamemodeChangeEvent(connection, EventInitiators.SERVER, previous, next))
|
||||
connection.player.additional.gamemode = next
|
||||
}
|
||||
}
|
||||
|
@ -13,12 +13,10 @@
|
||||
|
||||
package de.bixilon.minosoft.data.registries.other.game.event.handlers.win
|
||||
|
||||
import de.bixilon.minosoft.modding.event.EventInitiators
|
||||
import de.bixilon.minosoft.modding.event.events.connection.play.PlayConnectionEvent
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||
|
||||
class WinGameEvent(
|
||||
connection: PlayConnection,
|
||||
initiator: EventInitiators,
|
||||
val showCredits: Boolean,
|
||||
) : PlayConnectionEvent(connection, initiator)
|
||||
) : PlayConnectionEvent(connection)
|
||||
|
@ -15,7 +15,6 @@ package de.bixilon.minosoft.data.registries.other.game.event.handlers.win
|
||||
|
||||
import de.bixilon.minosoft.data.registries.ResourceLocation
|
||||
import de.bixilon.minosoft.data.registries.other.game.event.handlers.GameEventHandler
|
||||
import de.bixilon.minosoft.modding.event.EventInitiators
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||
import de.bixilon.minosoft.protocol.packets.c2s.play.ClientActionC2SP
|
||||
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||
@ -25,7 +24,7 @@ object WinGameEventHandler : GameEventHandler {
|
||||
|
||||
override fun handle(data: Float, connection: PlayConnection) {
|
||||
val credits = data.toInt() == 0x01
|
||||
connection.fireEvent(WinGameEvent(connection, EventInitiators.SERVER, credits))
|
||||
connection.fire(WinGameEvent(connection, credits))
|
||||
if (!credits) {
|
||||
connection.sendPacket(ClientActionC2SP(ClientActionC2SP.ClientActions.PERFORM_RESPAWN))
|
||||
}
|
||||
|
@ -16,14 +16,14 @@ package de.bixilon.minosoft.data.registries.versions
|
||||
import de.bixilon.minosoft.data.entities.block.FlowerPotBlockEntity
|
||||
import de.bixilon.minosoft.data.registries.blocks.entites.BlockEntityType
|
||||
import de.bixilon.minosoft.modding.event.events.loading.RegistriesLoadEvent
|
||||
import de.bixilon.minosoft.modding.event.invoker.CallbackEventInvoker
|
||||
import de.bixilon.minosoft.modding.event.listener.CallbackEventListener
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||
|
||||
object MinecraftRegistryFixer {
|
||||
|
||||
|
||||
fun register(connection: PlayConnection) {
|
||||
connection.registerEvent(CallbackEventInvoker.of<RegistriesLoadEvent> {
|
||||
connection.register(CallbackEventListener.of<RegistriesLoadEvent> {
|
||||
if (it.state != RegistriesLoadEvent.States.POST) {
|
||||
return@of
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ class ScoreboardManager(private val connection: PlayConnection) {
|
||||
if (!fireEvent) {
|
||||
continue
|
||||
}
|
||||
connection.fireEvent(ScoreTeamChangeEvent(connection, objective, score, team, remove))
|
||||
connection.fire(ScoreTeamChangeEvent(connection, objective, score, team, remove))
|
||||
}
|
||||
}
|
||||
objective.scores.lock.release()
|
||||
|
@ -20,7 +20,6 @@ import de.bixilon.kutil.concurrent.pool.ThreadPool
|
||||
import de.bixilon.kutil.concurrent.worker.unconditional.UnconditionalTask
|
||||
import de.bixilon.kutil.concurrent.worker.unconditional.UnconditionalWorker
|
||||
import de.bixilon.kutil.watcher.DataWatcher.Companion.watched
|
||||
import de.bixilon.minosoft.data.Difficulties
|
||||
import de.bixilon.minosoft.data.entities.block.BlockEntity
|
||||
import de.bixilon.minosoft.data.registries.biomes.Biome
|
||||
import de.bixilon.minosoft.data.registries.blocks.BlockState
|
||||
@ -35,6 +34,7 @@ import de.bixilon.minosoft.data.world.border.WorldBorder
|
||||
import de.bixilon.minosoft.data.world.chunk.Chunk
|
||||
import de.bixilon.minosoft.data.world.chunk.light.SectionLight
|
||||
import de.bixilon.minosoft.data.world.chunk.neighbours.ChunkNeighbours
|
||||
import de.bixilon.minosoft.data.world.difficulty.WorldDifficulty
|
||||
import de.bixilon.minosoft.data.world.particle.AbstractParticleRenderer
|
||||
import de.bixilon.minosoft.data.world.particle.WorldParticleRenderer
|
||||
import de.bixilon.minosoft.data.world.positions.BlockPosition
|
||||
@ -48,7 +48,6 @@ import de.bixilon.minosoft.gui.rendering.util.vec.vec3.Vec3dUtil.blockPosition
|
||||
import de.bixilon.minosoft.gui.rendering.util.vec.vec3.Vec3iUtil.EMPTY
|
||||
import de.bixilon.minosoft.gui.rendering.util.vec.vec3.Vec3iUtil.chunkPosition
|
||||
import de.bixilon.minosoft.gui.rendering.util.vec.vec3.Vec3iUtil.inChunkPosition
|
||||
import de.bixilon.minosoft.modding.event.EventInitiators
|
||||
import de.bixilon.minosoft.modding.event.events.blocks.BlockSetEvent
|
||||
import de.bixilon.minosoft.modding.event.events.blocks.chunk.ChunkDataChangeEvent
|
||||
import de.bixilon.minosoft.modding.event.events.blocks.chunk.ChunkUnloadEvent
|
||||
@ -70,8 +69,7 @@ class World(
|
||||
val entities = WorldEntities()
|
||||
var hardcore by watched(false)
|
||||
var dimension: DimensionProperties? by watched(null)
|
||||
var difficulty: Difficulties? by watched(null)
|
||||
var difficultyLocked by watched(false)
|
||||
var difficulty: WorldDifficulty? by watched(null)
|
||||
var hashedSeed = 0L
|
||||
val time = WorldTime(this)
|
||||
val weather = WorldWeather()
|
||||
@ -181,7 +179,7 @@ class World(
|
||||
blockState?.block?.onPlace(connection, blockPosition, blockState)
|
||||
chunk[inChunkPosition] = blockState
|
||||
chunk.getOrPutBlockEntity(inChunkPosition)
|
||||
connection.fireEvent(
|
||||
connection.fire(
|
||||
BlockSetEvent(
|
||||
connection = connection,
|
||||
blockPosition = blockPosition,
|
||||
@ -232,10 +230,10 @@ class World(
|
||||
val offset = ChunkNeighbours.OFFSETS[index]
|
||||
val neighbourPosition = chunkPosition + offset
|
||||
neighbour.neighbours.remove(-offset)
|
||||
connection.fireEvent(ChunkDataChangeEvent(connection, EventInitiators.UNKNOWN, neighbourPosition, neighbour))
|
||||
connection.fire(ChunkDataChangeEvent(connection, neighbourPosition, neighbour))
|
||||
}
|
||||
// connection.world.view.updateServerViewDistance(chunkPosition, false)
|
||||
connection.fireEvent(ChunkUnloadEvent(connection, EventInitiators.UNKNOWN, chunkPosition, chunk))
|
||||
connection.fire(ChunkUnloadEvent(connection, chunkPosition, chunk))
|
||||
if (chunkPosition.x <= chunkMin.x || chunkPosition.y <= chunkMin.y || chunkPosition.x >= chunkMax.x || chunkPosition.y >= chunkMax.y) {
|
||||
recalculateChunkExtreme()
|
||||
}
|
||||
@ -379,7 +377,7 @@ class World(
|
||||
|
||||
chunk.light.recalculate(false)
|
||||
chunk.light.propagateFromNeighbours()
|
||||
connection.fireEvent(ChunkDataChangeEvent(connection, EventInitiators.UNKNOWN, chunk.chunkPosition, chunk))
|
||||
connection.fire(ChunkDataChangeEvent(connection, chunk.chunkPosition, chunk))
|
||||
}
|
||||
|
||||
fun onChunkUpdate(chunkPosition: ChunkPosition, chunk: Chunk, checkNeighbours: Boolean = true) {
|
||||
@ -410,7 +408,7 @@ class World(
|
||||
}
|
||||
|
||||
if (chunk.neighbours.complete) {
|
||||
connection.fireEvent(ChunkDataChangeEvent(connection, EventInitiators.UNKNOWN, chunkPosition, chunk))
|
||||
connection.fire(ChunkDataChangeEvent(connection, chunkPosition, chunk))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,6 @@ import de.bixilon.minosoft.gui.rendering.util.VecUtil.inSectionHeight
|
||||
import de.bixilon.minosoft.gui.rendering.util.VecUtil.sectionHeight
|
||||
import de.bixilon.minosoft.gui.rendering.util.vec.vec3.Vec3iUtil.chunkPosition
|
||||
import de.bixilon.minosoft.gui.rendering.util.vec.vec3.Vec3iUtil.inChunkPosition
|
||||
import de.bixilon.minosoft.modding.event.EventInitiators
|
||||
import de.bixilon.minosoft.modding.event.events.blocks.chunk.ChunkDataChangeEvent
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||
import de.bixilon.minosoft.util.chunk.ChunkUtil
|
||||
@ -178,7 +177,7 @@ class Chunk(
|
||||
}
|
||||
lock.unlock()
|
||||
world.onChunkUpdate(chunkPosition, this)
|
||||
connection.fireEvent(ChunkDataChangeEvent(connection, EventInitiators.UNKNOWN, chunkPosition, this))
|
||||
connection.fire(ChunkDataChangeEvent(connection, chunkPosition, this))
|
||||
}
|
||||
|
||||
fun getOrPut(sectionHeight: Int, calculateLight: Boolean = true): ChunkSection? {
|
||||
|
@ -23,7 +23,6 @@ import de.bixilon.minosoft.data.world.chunk.ChunkSection
|
||||
import de.bixilon.minosoft.data.world.chunk.neighbours.ChunkNeighbours
|
||||
import de.bixilon.minosoft.gui.rendering.util.VecUtil.inSectionHeight
|
||||
import de.bixilon.minosoft.gui.rendering.util.VecUtil.sectionHeight
|
||||
import de.bixilon.minosoft.modding.event.EventInitiators
|
||||
import de.bixilon.minosoft.modding.event.events.blocks.chunk.LightChangeEvent
|
||||
import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition
|
||||
|
||||
@ -55,17 +54,17 @@ class ChunkLight(private val chunk: Chunk) {
|
||||
|
||||
val chunkPosition = chunk.chunkPosition
|
||||
if (fireSameChunkEvent) {
|
||||
connection.fireEvent(LightChangeEvent(connection, EventInitiators.CLIENT, chunkPosition, chunk, sectionHeight, true))
|
||||
connection.fire(LightChangeEvent(connection, chunkPosition, chunk, sectionHeight, true))
|
||||
|
||||
val down = section.neighbours?.get(Directions.O_DOWN)?.light
|
||||
if (down != null && down.update) {
|
||||
down.update = false
|
||||
connection.fireEvent(LightChangeEvent(connection, EventInitiators.CLIENT, chunkPosition, chunk, sectionHeight - 1, false))
|
||||
connection.fire(LightChangeEvent(connection, chunkPosition, chunk, sectionHeight - 1, false))
|
||||
}
|
||||
val up = section.neighbours?.get(Directions.O_UP)?.light
|
||||
if (up?.update == true) {
|
||||
up.update = false
|
||||
connection.fireEvent(LightChangeEvent(connection, EventInitiators.CLIENT, chunkPosition, chunk, sectionHeight + 1, false))
|
||||
connection.fire(LightChangeEvent(connection, chunkPosition, chunk, sectionHeight + 1, false))
|
||||
}
|
||||
}
|
||||
|
||||
@ -84,7 +83,7 @@ class ChunkLight(private val chunk: Chunk) {
|
||||
continue
|
||||
}
|
||||
neighbourSection.light.update = false
|
||||
connection.fireEvent(LightChangeEvent(connection, EventInitiators.CLIENT, nextPosition, chunk, sectionHeight + chunkY, false))
|
||||
connection.fire(LightChangeEvent(connection, nextPosition, chunk, sectionHeight + chunkY, false))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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.
|
||||
*
|
||||
@ -10,7 +10,7 @@
|
||||
*
|
||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||
*/
|
||||
package de.bixilon.minosoft.data
|
||||
package de.bixilon.minosoft.data.world.difficulty
|
||||
|
||||
import de.bixilon.kutil.enums.EnumUtil
|
||||
import de.bixilon.kutil.enums.ValuesEnum
|
@ -10,13 +10,10 @@
|
||||
*
|
||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||
*/
|
||||
package de.bixilon.minosoft.modding.event.events.annotations
|
||||
|
||||
import de.bixilon.minosoft.modding.EventPriorities
|
||||
package de.bixilon.minosoft.data.world.difficulty
|
||||
|
||||
@Target(AnnotationTarget.FUNCTION)
|
||||
@Retention(AnnotationRetention.RUNTIME)
|
||||
annotation class EventHandler(
|
||||
val ignoreCancelled: Boolean = false,
|
||||
val priority: EventPriorities = EventPriorities.NORMAL,
|
||||
class WorldDifficulty(
|
||||
val difficulty: Difficulties,
|
||||
val locked: Boolean,
|
||||
)
|
@ -15,17 +15,19 @@ package de.bixilon.minosoft.data.world.time
|
||||
|
||||
import de.bixilon.kotlinglm.func.common.clamp
|
||||
import de.bixilon.kutil.math.simple.DoubleMath.fractional
|
||||
import de.bixilon.kutil.watcher.DataWatcher.Companion.watched
|
||||
import de.bixilon.minosoft.data.world.World
|
||||
import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition
|
||||
import kotlin.math.PI
|
||||
import kotlin.math.abs
|
||||
import kotlin.math.cos
|
||||
|
||||
@Deprecated("make values final")
|
||||
class WorldTime(
|
||||
private val world: World,
|
||||
) {
|
||||
var time = 0L
|
||||
var age = 0L
|
||||
var time by watched(0L)
|
||||
var age by watched(0L)
|
||||
|
||||
|
||||
val skyAngle: Float
|
||||
|
@ -34,7 +34,7 @@ class WorldView(
|
||||
return
|
||||
}
|
||||
field = realValue
|
||||
connection.fireEvent(ViewDistanceChangeEvent(connection, realValue))
|
||||
connection.fire(ViewDistanceChangeEvent(connection, realValue))
|
||||
}
|
||||
|
||||
var serverSimulationDistance = Int.MAX_VALUE
|
||||
@ -49,7 +49,7 @@ class WorldView(
|
||||
return
|
||||
}
|
||||
field = realValue
|
||||
connection.fireEvent(SimulationDistanceChangeEvent(connection, realValue))
|
||||
connection.fire(SimulationDistanceChangeEvent(connection, realValue))
|
||||
particleViewDistance = minOf(realValue, connection.profiles.particle.viewDistance)
|
||||
}
|
||||
|
||||
@ -60,7 +60,7 @@ class WorldView(
|
||||
return
|
||||
}
|
||||
field = realValue
|
||||
connection.fireEvent(ParticleViewDistanceChangeEvent(connection, realValue))
|
||||
connection.fire(ParticleViewDistanceChangeEvent(connection, realValue))
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
|
@ -18,7 +18,7 @@ import de.bixilon.minosoft.config.profile.profiles.eros.ErosProfileSelectEvent
|
||||
import de.bixilon.minosoft.gui.eros.main.MainErosController
|
||||
import de.bixilon.minosoft.gui.eros.util.JavaFXUtil
|
||||
import de.bixilon.minosoft.modding.event.events.FinishInitializingEvent
|
||||
import de.bixilon.minosoft.modding.event.invoker.CallbackEventInvoker
|
||||
import de.bixilon.minosoft.modding.event.listener.CallbackEventListener
|
||||
import de.bixilon.minosoft.modding.event.master.GlobalEventMaster
|
||||
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||
import javafx.stage.Window
|
||||
@ -58,14 +58,14 @@ object Eros {
|
||||
|
||||
|
||||
init {
|
||||
GlobalEventMaster.registerEvent(CallbackEventInvoker.of<FinishInitializingEvent> {
|
||||
GlobalEventMaster.register(CallbackEventListener.of<FinishInitializingEvent> {
|
||||
if (skipErosStartup) {
|
||||
return@of
|
||||
}
|
||||
start()
|
||||
})
|
||||
|
||||
GlobalEventMaster.registerEvent(CallbackEventInvoker.of<ErosProfileSelectEvent> {
|
||||
GlobalEventMaster.register(CallbackEventListener.of<ErosProfileSelectEvent> {
|
||||
if (skipErosStartup || !this::mainErosController.isInitialized) {
|
||||
return@of
|
||||
}
|
||||
|
@ -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.
|
||||
*
|
||||
@ -41,6 +41,6 @@ abstract class JavaFXController : Initializable {
|
||||
open fun postInit() = Unit
|
||||
|
||||
open fun terminate() {
|
||||
GlobalEventMaster.fireEvent(ErosControllerTerminateEvent(this))
|
||||
GlobalEventMaster.fire(ErosControllerTerminateEvent(this))
|
||||
}
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ import de.bixilon.minosoft.gui.eros.main.play.server.card.FaviconManager.saveFav
|
||||
import de.bixilon.minosoft.gui.eros.main.play.server.card.ServerCard
|
||||
import de.bixilon.minosoft.gui.eros.main.play.server.card.ServerCardController
|
||||
import de.bixilon.minosoft.gui.eros.main.play.server.type.types.ServerType
|
||||
import de.bixilon.minosoft.gui.eros.modding.invoker.JavaFXEventInvoker
|
||||
import de.bixilon.minosoft.gui.eros.modding.invoker.JavaFXEventListener
|
||||
import de.bixilon.minosoft.gui.eros.util.JavaFXUtil
|
||||
import de.bixilon.minosoft.gui.eros.util.JavaFXUtil.ctext
|
||||
import de.bixilon.minosoft.modding.event.events.KickEvent
|
||||
@ -163,7 +163,7 @@ class ServerListController : EmbeddedJavaFXController<Pane>(), Refreshable {
|
||||
JavaFXUtil.runLater { updateServer(server, true) }
|
||||
}
|
||||
|
||||
connection.registerEvent(JavaFXEventInvoker.of<KickEvent> { event ->
|
||||
connection.register(JavaFXEventListener.of<KickEvent> { event ->
|
||||
KickDialog(
|
||||
title = "minosoft:connection.kick.title".toResourceLocation(),
|
||||
header = "minosoft:connection.kick.header".toResourceLocation(),
|
||||
@ -171,7 +171,7 @@ class ServerListController : EmbeddedJavaFXController<Pane>(), Refreshable {
|
||||
reason = event.reason,
|
||||
).show()
|
||||
})
|
||||
connection.registerEvent(JavaFXEventInvoker.of<LoginKickEvent> { event ->
|
||||
connection.register(JavaFXEventListener.of<LoginKickEvent> { event ->
|
||||
KickDialog(
|
||||
title = "minosoft:connection.login_kick.title".toResourceLocation(),
|
||||
header = "minosoft:connection.login_kick.header".toResourceLocation(),
|
||||
|
@ -18,7 +18,7 @@ import de.bixilon.kutil.collections.CollectionUtil.synchronizedSetOf
|
||||
import de.bixilon.kutil.collections.map.SynchronizedMap
|
||||
import de.bixilon.minosoft.config.profile.profiles.eros.server.entries.Server
|
||||
import de.bixilon.minosoft.data.accounts.Account
|
||||
import de.bixilon.minosoft.modding.event.invoker.EventInvoker
|
||||
import de.bixilon.minosoft.modding.event.listener.EventListener
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||
import de.bixilon.minosoft.protocol.network.connection.status.StatusConnection
|
||||
|
||||
@ -29,20 +29,20 @@ class ServerCard(
|
||||
val connections: MutableSet<PlayConnection> = synchronizedSetOf()
|
||||
private var pinged = false
|
||||
|
||||
var statusReceiveInvoker: EventInvoker? = null
|
||||
var statusReceiveInvoker: EventListener? = null
|
||||
set(value) {
|
||||
field = value
|
||||
ping.registerEvent(value ?: return)
|
||||
ping.register(value ?: return)
|
||||
}
|
||||
var statusErrorInvoker: EventInvoker? = null
|
||||
var statusErrorInvoker: EventListener? = null
|
||||
set(value) {
|
||||
field = value
|
||||
ping.registerEvent(value ?: return)
|
||||
ping.register(value ?: return)
|
||||
}
|
||||
var pongInvoker: EventInvoker? = null
|
||||
var pongInvoker: EventListener? = null
|
||||
set(value) {
|
||||
field = value
|
||||
ping.registerEvent(value ?: return)
|
||||
ping.register(value ?: return)
|
||||
}
|
||||
|
||||
init {
|
||||
@ -51,9 +51,9 @@ class ServerCard(
|
||||
|
||||
|
||||
fun unregister() {
|
||||
statusReceiveInvoker?.let { statusReceiveInvoker = null; ping.unregisterEvent(it) }
|
||||
statusErrorInvoker?.let { statusErrorInvoker = null; ping.unregisterEvent(it) }
|
||||
pongInvoker?.let { pongInvoker = null; ping.unregisterEvent(it) }
|
||||
statusReceiveInvoker?.let { statusReceiveInvoker = null; ping.unregister(it) }
|
||||
statusErrorInvoker?.let { statusErrorInvoker = null; ping.unregister(it) }
|
||||
pongInvoker?.let { pongInvoker = null; ping.unregister(it) }
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
|
@ -25,7 +25,7 @@ import de.bixilon.minosoft.gui.eros.card.CardFactory
|
||||
import de.bixilon.minosoft.gui.eros.main.play.server.ServerListController
|
||||
import de.bixilon.minosoft.gui.eros.main.play.server.card.FaviconManager.favicon
|
||||
import de.bixilon.minosoft.gui.eros.main.play.server.card.FaviconManager.saveFavicon
|
||||
import de.bixilon.minosoft.gui.eros.modding.invoker.JavaFXEventInvoker
|
||||
import de.bixilon.minosoft.gui.eros.modding.invoker.JavaFXEventListener
|
||||
import de.bixilon.minosoft.gui.eros.util.JavaFXUtil
|
||||
import de.bixilon.minosoft.gui.eros.util.JavaFXUtil.ctext
|
||||
import de.bixilon.minosoft.gui.eros.util.JavaFXUtil.text
|
||||
@ -84,7 +84,7 @@ class ServerCardController : AbstractCardController<ServerCard>(), WatcherRefere
|
||||
|
||||
item.server.favicon?.let { faviconFX.image = it }
|
||||
|
||||
item.statusReceiveInvoker = JavaFXEventInvoker.of<ServerStatusReceiveEvent> {
|
||||
item.statusReceiveInvoker = JavaFXEventListener.of<ServerStatusReceiveEvent> {
|
||||
if (this.item != item || it.connection.error != null) {
|
||||
// error already occurred, not setting any data
|
||||
return@of
|
||||
@ -117,7 +117,7 @@ class ServerCardController : AbstractCardController<ServerCard>(), WatcherRefere
|
||||
serverList?.onPingUpdate(item)
|
||||
}
|
||||
|
||||
item.statusErrorInvoker = JavaFXEventInvoker.of<ConnectionErrorEvent> {
|
||||
item.statusErrorInvoker = JavaFXEventListener.of<ConnectionErrorEvent> {
|
||||
if (this.item != item) {
|
||||
return@of
|
||||
}
|
||||
@ -127,7 +127,7 @@ class ServerCardController : AbstractCardController<ServerCard>(), WatcherRefere
|
||||
serverList?.onPingUpdate(item)
|
||||
}
|
||||
|
||||
item.pongInvoker = JavaFXEventInvoker.of<StatusPongReceiveEvent> {
|
||||
item.pongInvoker = JavaFXEventListener.of<StatusPongReceiveEvent> {
|
||||
if (this.item != item || it.connection.error != null) {
|
||||
// error already occurred, not setting any data
|
||||
return@of
|
||||
|
@ -20,7 +20,7 @@ import de.bixilon.minosoft.config.profile.profiles.eros.server.entries.Server
|
||||
import de.bixilon.minosoft.data.registries.ResourceLocation
|
||||
import de.bixilon.minosoft.gui.eros.main.play.server.card.ServerCard
|
||||
import de.bixilon.minosoft.modding.EventPriorities
|
||||
import de.bixilon.minosoft.modding.event.invoker.CallbackEventInvoker
|
||||
import de.bixilon.minosoft.modding.event.listener.CallbackEventListener
|
||||
import de.bixilon.minosoft.modding.event.master.GlobalEventMaster
|
||||
import de.bixilon.minosoft.protocol.network.connection.status.StatusConnectionStates
|
||||
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||
@ -36,7 +36,7 @@ object CustomServerType : ServerType {
|
||||
override val translationKey: ResourceLocation = "minosoft:server_type.custom".toResourceLocation()
|
||||
|
||||
init {
|
||||
GlobalEventMaster.registerEvent(CallbackEventInvoker.of<ErosProfileSelectEvent>(priority = EventPriorities.LOW) {
|
||||
GlobalEventMaster.register(CallbackEventListener.of<ErosProfileSelectEvent>(priority = EventPriorities.LOW) {
|
||||
servers = ErosProfileManager.selected.server.entries
|
||||
})
|
||||
}
|
||||
|
@ -13,41 +13,48 @@
|
||||
|
||||
package de.bixilon.minosoft.gui.eros.modding.invoker
|
||||
|
||||
import de.bixilon.kutil.cast.CastUtil.unsafeCast
|
||||
import de.bixilon.minosoft.gui.eros.util.JavaFXUtil
|
||||
import de.bixilon.minosoft.modding.EventPriorities
|
||||
import de.bixilon.minosoft.modding.event.events.CancelableEvent
|
||||
import de.bixilon.minosoft.modding.event.events.Event
|
||||
import de.bixilon.minosoft.modding.event.invoker.EventInstantFireable
|
||||
import de.bixilon.minosoft.modding.event.invoker.EventInvoker
|
||||
import de.bixilon.minosoft.modding.event.invoker.OneShotInvoker
|
||||
import de.bixilon.minosoft.modding.event.listener.EventInstantFireable
|
||||
import de.bixilon.minosoft.modding.event.listener.EventListener
|
||||
import de.bixilon.minosoft.modding.event.listener.OneShotListener
|
||||
import de.bixilon.minosoft.modding.event.master.AbstractEventMaster
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
/**
|
||||
* Basically a CallbackEventInvoker, bt the callback runs on the java fx ui thread
|
||||
*/
|
||||
class JavaFXEventInvoker<E : Event> private constructor(
|
||||
class JavaFXEventListener<E : Event> constructor(
|
||||
ignoreCancelled: Boolean,
|
||||
private val callback: (E) -> Unit,
|
||||
override val oneShot: Boolean,
|
||||
override val kEventType: KClass<out Event>,
|
||||
override val eventType: Class<out Event>,
|
||||
override val instantFire: Boolean,
|
||||
) : EventInvoker(ignoreCancelled, EventPriorities.NORMAL), EventInstantFireable, OneShotInvoker {
|
||||
) : EventListener(ignoreCancelled, EventPriorities.NORMAL), EventInstantFireable, OneShotListener {
|
||||
|
||||
override operator fun invoke(event: Event) {
|
||||
if (!this.isIgnoreCancelled && event is CancelableEvent && event.cancelled) {
|
||||
if (!this.ignoreCancelled && event is CancelableEvent && event.cancelled) {
|
||||
return
|
||||
}
|
||||
JavaFXUtil.runLater {
|
||||
callback(event as E)
|
||||
callback(event.unsafeCast())
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmOverloads
|
||||
@Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE")
|
||||
inline fun <reified E : Event> of(ignoreCancelled: Boolean = false, instantFire: Boolean = true, oneShot: Boolean = false, noinline callback: (E) -> Unit): JavaFXEventInvoker<E> {
|
||||
return JavaFXEventInvoker(
|
||||
|
||||
inline fun <reified E : Event> AbstractEventMaster.javaFX(ignoreCancelled: Boolean = false, instantFire: Boolean = true, oneShot: Boolean = false, noinline callback: (E) -> Unit): JavaFXEventListener<E> {
|
||||
val listener = of(ignoreCancelled, instantFire, oneShot, callback)
|
||||
register(listener)
|
||||
return listener
|
||||
}
|
||||
|
||||
inline fun <reified E : Event> of(ignoreCancelled: Boolean = false, instantFire: Boolean = true, oneShot: Boolean = false, noinline callback: (E) -> Unit): JavaFXEventListener<E> {
|
||||
return JavaFXEventListener(
|
||||
ignoreCancelled = ignoreCancelled,
|
||||
callback = callback,
|
||||
oneShot = oneShot,
|
@ -20,6 +20,7 @@ import de.bixilon.kutil.math.simple.DoubleMath.rounded10
|
||||
import de.bixilon.kutil.primitive.BooleanUtil.decide
|
||||
import de.bixilon.kutil.time.TimeUtil.millis
|
||||
import de.bixilon.kutil.watcher.DataWatcher.Companion.observe
|
||||
import de.bixilon.kutil.watcher.DataWatcher.Companion.watched
|
||||
import de.bixilon.minosoft.config.profile.delegate.watcher.SimpleProfileDelegateWatcher.Companion.profileWatch
|
||||
import de.bixilon.minosoft.gui.rendering.camera.Camera
|
||||
import de.bixilon.minosoft.gui.rendering.font.Font
|
||||
@ -28,7 +29,8 @@ import de.bixilon.minosoft.gui.rendering.framebuffer.FramebufferManager
|
||||
import de.bixilon.minosoft.gui.rendering.gui.GUIRenderer
|
||||
import de.bixilon.minosoft.gui.rendering.input.key.DefaultKeyCombinations
|
||||
import de.bixilon.minosoft.gui.rendering.input.key.RenderWindowInputHandler
|
||||
import de.bixilon.minosoft.gui.rendering.modding.events.*
|
||||
import de.bixilon.minosoft.gui.rendering.modding.events.ResizeWindowEvent
|
||||
import de.bixilon.minosoft.gui.rendering.modding.events.WindowCloseEvent
|
||||
import de.bixilon.minosoft.gui.rendering.models.ModelLoader
|
||||
import de.bixilon.minosoft.gui.rendering.renderer.renderer.RendererManager
|
||||
import de.bixilon.minosoft.gui.rendering.renderer.renderer.RendererManager.Companion.registerDefault
|
||||
@ -42,12 +44,13 @@ import de.bixilon.minosoft.gui.rendering.system.window.BaseWindow
|
||||
import de.bixilon.minosoft.gui.rendering.tint.TintManager
|
||||
import de.bixilon.minosoft.gui.rendering.util.ScreenshotTaker
|
||||
import de.bixilon.minosoft.gui.rendering.world.LightMap
|
||||
import de.bixilon.minosoft.modding.event.invoker.CallbackEventInvoker
|
||||
import de.bixilon.minosoft.modding.event.listener.CallbackEventListener.Companion.listen
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnectionStates
|
||||
import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition
|
||||
import de.bixilon.minosoft.terminal.RunConfiguration
|
||||
import de.bixilon.minosoft.util.Stopwatch
|
||||
import de.bixilon.minosoft.util.delegate.RenderingDelegate.observeRendering
|
||||
import de.bixilon.minosoft.util.logging.Log
|
||||
import de.bixilon.minosoft.util.logging.LogLevels
|
||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||
@ -99,18 +102,7 @@ class RenderWindow(
|
||||
lateinit var thread: Thread
|
||||
private set
|
||||
|
||||
var renderingState = RenderingStates.RUNNING
|
||||
private set(value) {
|
||||
if (field == value) {
|
||||
return
|
||||
}
|
||||
if (field == RenderingStates.PAUSED) {
|
||||
queue.clear()
|
||||
}
|
||||
val previousState = field
|
||||
field = value
|
||||
connection.fireEvent(RenderingStateChangeEvent(connection, previousState, value))
|
||||
}
|
||||
var state by watched(RenderingStates.RUNNING)
|
||||
|
||||
init {
|
||||
connection::state.observe(this) {
|
||||
@ -127,6 +119,16 @@ class RenderWindow(
|
||||
}
|
||||
profile.performance::slowRendering.profileWatch(this, profile = profile) { this.slowRendering = it }
|
||||
renderer.registerDefault(connection.profiles)
|
||||
|
||||
var paused = false
|
||||
this::state.observe(this) {
|
||||
paused = if (paused) {
|
||||
queue.clear()
|
||||
false
|
||||
} else {
|
||||
it == RenderingStates.PAUSED
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun init(latch: CountUpAndDownLatch) {
|
||||
@ -194,26 +196,22 @@ class RenderWindow(
|
||||
|
||||
Log.log(LogMessageType.RENDERING_LOADING, LogLevels.VERBOSE) { "Registering callbacks (after ${stopwatch.labTime()})..." }
|
||||
|
||||
connection.registerEvent(CallbackEventInvoker.of<WindowFocusChangeEvent> {
|
||||
renderingState = it.focused.decide(RenderingStates.RUNNING, RenderingStates.SLOW)
|
||||
})
|
||||
window::focused.observeRendering(this) { state = it.decide(RenderingStates.RUNNING, RenderingStates.SLOW) }
|
||||
|
||||
connection.registerEvent(CallbackEventInvoker.of<WindowIconifyChangeEvent> {
|
||||
renderingState = it.iconified.decide(RenderingStates.PAUSED, RenderingStates.RUNNING)
|
||||
})
|
||||
window::iconified.observeRendering(this) { state = it.decide(RenderingStates.PAUSED, RenderingStates.RUNNING) }
|
||||
profile.animations::sprites.profileWatch(this, true, profile = profile) { textureManager.staticTextures.animator.enabled = it }
|
||||
|
||||
|
||||
inputHandler.init()
|
||||
DefaultKeyCombinations.registerAll(this)
|
||||
connection.registerEvent(CallbackEventInvoker.of<RenderingStateChangeEvent> {
|
||||
if (it.state != RenderingStates.RUNNING) {
|
||||
this::state.observe(this) {
|
||||
if (it != RenderingStates.RUNNING) {
|
||||
pause(true)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
connection.fireEvent(ResizeWindowEvent(this, previousSize = Vec2i(0, 0), size = window.size))
|
||||
connection.events.fire(ResizeWindowEvent(this, previousSize = Vec2i(0, 0), size = window.size))
|
||||
|
||||
textureManager.dynamicTextures.activate()
|
||||
textureManager.staticTextures.activate()
|
||||
@ -229,18 +227,18 @@ class RenderWindow(
|
||||
|
||||
fun startLoop() {
|
||||
Log.log(LogMessageType.RENDERING_LOADING) { "Starting loop" }
|
||||
connection.registerEvent(CallbackEventInvoker.of<WindowCloseEvent> { renderingState = RenderingStates.QUITTING })
|
||||
connection.events.listen<WindowCloseEvent> { state = RenderingStates.QUITTING }
|
||||
while (true) {
|
||||
if (renderingState == RenderingStates.PAUSED) {
|
||||
if (state == RenderingStates.PAUSED) {
|
||||
window.title = "Minosoft | Paused"
|
||||
}
|
||||
|
||||
while (renderingState == RenderingStates.PAUSED) {
|
||||
while (state == RenderingStates.PAUSED) {
|
||||
Thread.sleep(20L)
|
||||
window.pollEvents()
|
||||
}
|
||||
|
||||
if (connection.wasConnected || !renderingState.active) {
|
||||
if (connection.wasConnected || !state.active) {
|
||||
break
|
||||
}
|
||||
|
||||
@ -282,11 +280,11 @@ class RenderWindow(
|
||||
// handle opengl context tasks, but limit it per frame
|
||||
queue.timeWork(RenderConstants.MAXIMUM_QUEUE_TIME_PER_FRAME)
|
||||
|
||||
if (renderingState == RenderingStates.STOPPED) {
|
||||
if (state == RenderingStates.STOPPED) {
|
||||
window.close()
|
||||
break
|
||||
}
|
||||
if (renderingState == RenderingStates.SLOW && slowRendering) {
|
||||
if (state == RenderingStates.SLOW && slowRendering) {
|
||||
Thread.sleep(100L)
|
||||
}
|
||||
|
||||
@ -301,7 +299,7 @@ class RenderWindow(
|
||||
}
|
||||
|
||||
Log.log(LogMessageType.RENDERING_LOADING) { "Destroying render window..." }
|
||||
renderingState = RenderingStates.STOPPED
|
||||
state = RenderingStates.STOPPED
|
||||
renderSystem.destroy()
|
||||
window.destroy()
|
||||
Log.log(LogMessageType.RENDERING_LOADING) { "Render window destroyed!" }
|
||||
|
@ -72,7 +72,7 @@ class Rendering(private val connection: PlayConnection) {
|
||||
exception.printStackTrace()
|
||||
try {
|
||||
renderWindow.window.destroy()
|
||||
connection.fireEvent(WindowCloseEvent(renderWindow, window = renderWindow.window))
|
||||
connection.fire(WindowCloseEvent(renderWindow, window = renderWindow.window))
|
||||
} catch (ignored: Throwable) {
|
||||
}
|
||||
connection.network.disconnect()
|
||||
|
@ -30,7 +30,7 @@ import de.bixilon.minosoft.gui.rendering.util.vec.vec3.Vec3Util.EMPTY
|
||||
import de.bixilon.minosoft.gui.rendering.util.vec.vec3.Vec3Util.blockPosition
|
||||
import de.bixilon.minosoft.gui.rendering.util.vec.vec3.Vec3iUtil.chunkPosition
|
||||
import de.bixilon.minosoft.gui.rendering.util.vec.vec3.Vec3iUtil.sectionHeight
|
||||
import de.bixilon.minosoft.modding.event.invoker.CallbackEventInvoker
|
||||
import de.bixilon.minosoft.modding.event.listener.CallbackEventListener
|
||||
|
||||
class MatrixHandler(
|
||||
private val renderWindow: RenderWindow,
|
||||
@ -103,7 +103,7 @@ class MatrixHandler(
|
||||
}
|
||||
|
||||
fun init() {
|
||||
connection.registerEvent(CallbackEventInvoker.of<ResizeWindowEvent> {
|
||||
connection.register(CallbackEventListener.of<ResizeWindowEvent> {
|
||||
calculateProjectionMatrix(Vec2(it.size))
|
||||
upToDate = false
|
||||
})
|
||||
@ -140,14 +140,16 @@ class MatrixHandler(
|
||||
camera.visibilityGraph.updateCamera(cameraBlockPosition.chunkPosition, cameraBlockPosition.sectionHeight)
|
||||
}
|
||||
|
||||
connection.fireEvent(CameraPositionChangeEvent(renderWindow, eyePosition))
|
||||
connection.fire(CameraPositionChangeEvent(renderWindow, eyePosition))
|
||||
|
||||
connection.fireEvent(CameraMatrixChangeEvent(
|
||||
renderWindow = renderWindow,
|
||||
viewMatrix = viewMatrix,
|
||||
projectionMatrix = projectionMatrix,
|
||||
viewProjectionMatrix = viewProjectionMatrix,
|
||||
))
|
||||
connection.fire(
|
||||
CameraMatrixChangeEvent(
|
||||
renderWindow = renderWindow,
|
||||
viewMatrix = viewMatrix,
|
||||
projectionMatrix = projectionMatrix,
|
||||
viewProjectionMatrix = viewProjectionMatrix,
|
||||
)
|
||||
)
|
||||
|
||||
updateShaders(if (debugView) debugPosition else eyePosition)
|
||||
upToDate = true
|
||||
|
@ -35,7 +35,8 @@ import de.bixilon.minosoft.gui.rendering.system.base.RenderSystem
|
||||
import de.bixilon.minosoft.gui.rendering.system.base.phases.OpaqueDrawable
|
||||
import de.bixilon.minosoft.modding.event.events.EntityDestroyEvent
|
||||
import de.bixilon.minosoft.modding.event.events.EntitySpawnEvent
|
||||
import de.bixilon.minosoft.modding.event.invoker.CallbackEventInvoker
|
||||
import de.bixilon.minosoft.modding.event.listener.CallbackEventListener
|
||||
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.format
|
||||
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||
@ -59,15 +60,15 @@ class EntityRenderer(
|
||||
private set
|
||||
|
||||
override fun init(latch: CountUpAndDownLatch) {
|
||||
connection.registerEvent(CallbackEventInvoker.of<EntitySpawnEvent> { event ->
|
||||
connection.register(CallbackEventListener.of<EntitySpawnEvent> { event ->
|
||||
DefaultThreadPool += { event.entity.createModel(this)?.let { models[event.entity] = it } }
|
||||
})
|
||||
connection.registerEvent(CallbackEventInvoker.of<EntityDestroyEvent> {
|
||||
connection.register(CallbackEventListener.of<EntityDestroyEvent> {
|
||||
DefaultThreadPool += add@{ toUnload += models.remove(it.entity) ?: return@add }
|
||||
})
|
||||
connection.registerEvent(CallbackEventInvoker.of<VisibilityGraphChangeEvent> {
|
||||
connection.events.listen<VisibilityGraphChangeEvent> {
|
||||
runAsync { it.updateVisibility(visibilityGraph) }
|
||||
})
|
||||
}
|
||||
|
||||
profile.hitbox::enabled.profileWatch(this, profile = profile) { this.hitboxes = it }
|
||||
|
||||
|
@ -32,7 +32,7 @@ import de.bixilon.minosoft.gui.rendering.system.base.texture.dynamic.DynamicText
|
||||
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||
|
||||
open class PlayerModel(renderer: EntityRenderer, player: PlayerEntity) : SkeletalEntityModel<PlayerEntity>(renderer, player), DynamicStateChangeCallback {
|
||||
private var properties = player.tabListItem.properties
|
||||
private var properties = player.additional.properties
|
||||
private var skin: DynamicTexture? = null
|
||||
protected var refreshModel = false
|
||||
|
||||
@ -87,7 +87,7 @@ open class PlayerModel(renderer: EntityRenderer, player: PlayerEntity) : Skeleta
|
||||
}
|
||||
|
||||
override fun prepareAsync() {
|
||||
val properties = entity.tabListItem.properties // ToDo: Check for skin layers
|
||||
val properties = entity.additional.properties // ToDo: Check for skin layers
|
||||
if (refreshModel || this.properties != properties) {
|
||||
_instance = instance
|
||||
instance = createModel(properties)
|
||||
|
@ -19,7 +19,7 @@ import de.bixilon.minosoft.gui.rendering.framebuffer.world.WorldFramebuffer
|
||||
import de.bixilon.minosoft.gui.rendering.modding.events.ResizeWindowEvent
|
||||
import de.bixilon.minosoft.gui.rendering.renderer.drawable.Drawable
|
||||
import de.bixilon.minosoft.gui.rendering.system.base.PolygonModes
|
||||
import de.bixilon.minosoft.modding.event.invoker.CallbackEventInvoker
|
||||
import de.bixilon.minosoft.modding.event.listener.CallbackEventListener
|
||||
|
||||
class FramebufferManager(
|
||||
private val renderWindow: RenderWindow,
|
||||
@ -32,7 +32,7 @@ class FramebufferManager(
|
||||
world.init()
|
||||
gui.init()
|
||||
|
||||
renderWindow.connection.registerEvent(CallbackEventInvoker.of<ResizeWindowEvent> {
|
||||
renderWindow.connection.register(CallbackEventListener.of<ResizeWindowEvent> {
|
||||
world.framebuffer.resize(it.size)
|
||||
gui.framebuffer.resize(it.size)
|
||||
})
|
||||
|
@ -38,7 +38,7 @@ import de.bixilon.minosoft.gui.rendering.system.base.buffer.frame.Framebuffer
|
||||
import de.bixilon.minosoft.gui.rendering.system.base.phases.OtherDrawable
|
||||
import de.bixilon.minosoft.gui.rendering.system.window.KeyChangeTypes
|
||||
import de.bixilon.minosoft.gui.rendering.util.vec.vec2.Vec2iUtil.EMPTY
|
||||
import de.bixilon.minosoft.modding.event.invoker.CallbackEventInvoker
|
||||
import de.bixilon.minosoft.modding.event.listener.CallbackEventListener
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||
|
||||
@ -81,7 +81,7 @@ class GUIRenderer(
|
||||
renderWindow.textureManager.staticTextures.animator.use(shader)
|
||||
renderWindow.textureManager.dynamicTextures.use(shader)
|
||||
|
||||
connection.registerEvent(CallbackEventInvoker.of<ResizeWindowEvent> { recalculateMatrices(it.size) })
|
||||
connection.register(CallbackEventListener.of<ResizeWindowEvent> { recalculateMatrices(it.size) })
|
||||
profile::scale.profileWatchRendering(this, profile = profile) { recalculateMatrices(scale = it) }
|
||||
|
||||
gui.postInit()
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
package de.bixilon.minosoft.gui.rendering.gui.elements
|
||||
|
||||
@Deprecated("events")
|
||||
interface Pollable {
|
||||
|
||||
/**
|
||||
|
@ -21,7 +21,7 @@ import de.bixilon.minosoft.gui.rendering.gui.elements.HorizontalAlignments.Compa
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.text.TextElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexConsumer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexOptions
|
||||
import de.bixilon.minosoft.modding.event.invoker.CallbackEventInvoker
|
||||
import de.bixilon.minosoft.modding.event.listener.CallbackEventListener
|
||||
import de.bixilon.minosoft.protocol.packets.c2s.play.ClientActionC2SP
|
||||
|
||||
@Deprecated("ToDo")
|
||||
@ -52,7 +52,7 @@ class CreditsScreen(
|
||||
companion object {
|
||||
|
||||
fun register(guiRenderer: GUIRenderer) {
|
||||
guiRenderer.connection.registerEvent(CallbackEventInvoker.of<WinGameEvent> {
|
||||
guiRenderer.connection.register(CallbackEventListener.of<WinGameEvent> {
|
||||
if (!it.showCredits) {
|
||||
return@of
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ import de.bixilon.minosoft.gui.rendering.system.base.texture.texture.AbstractTex
|
||||
import de.bixilon.minosoft.gui.rendering.system.window.KeyChangeTypes
|
||||
import de.bixilon.minosoft.gui.rendering.world.entities.renderer.sign.SignBlockEntityRenderer
|
||||
import de.bixilon.minosoft.modding.event.events.OpenSignEditorEvent
|
||||
import de.bixilon.minosoft.modding.event.invoker.CallbackEventInvoker
|
||||
import de.bixilon.minosoft.modding.event.listener.CallbackEventListener
|
||||
import de.bixilon.minosoft.protocol.packets.c2s.play.block.SignTextC2SP
|
||||
|
||||
class SignEditorScreen(
|
||||
@ -220,7 +220,7 @@ class SignEditorScreen(
|
||||
private val BACKGROUND_SIZE = Vec2i(24, 12) * BACKGROUND_SCALE
|
||||
|
||||
fun register(guiRenderer: GUIRenderer) {
|
||||
guiRenderer.connection.registerEvent(CallbackEventInvoker.of<OpenSignEditorEvent> { guiRenderer.gui.push(SignEditorScreen(guiRenderer, it.blockPosition)) })
|
||||
guiRenderer.connection.register(CallbackEventListener.of<OpenSignEditorEvent> { guiRenderer.gui.push(SignEditorScreen(guiRenderer, it.blockPosition)) })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ import de.bixilon.minosoft.gui.rendering.gui.gui.LayoutedGUIElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.gui.screen.container.inventory.LocalInventoryScreen
|
||||
import de.bixilon.minosoft.modding.event.events.container.ContainerCloseEvent
|
||||
import de.bixilon.minosoft.modding.event.events.container.ContainerOpenEvent
|
||||
import de.bixilon.minosoft.modding.event.invoker.CallbackEventInvoker
|
||||
import de.bixilon.minosoft.modding.event.listener.CallbackEventListener
|
||||
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||
|
||||
object ContainerGUIManager {
|
||||
@ -65,7 +65,7 @@ object ContainerGUIManager {
|
||||
fun register(guiRenderer: GUIRenderer) {
|
||||
registerLocalContainerEvent(guiRenderer)
|
||||
|
||||
guiRenderer.connection.registerEvent(CallbackEventInvoker.of<ContainerOpenEvent> { open(guiRenderer, it.container) })
|
||||
guiRenderer.connection.registerEvent(CallbackEventInvoker.of<ContainerCloseEvent> { close(guiRenderer, it.container) })
|
||||
guiRenderer.connection.register(CallbackEventListener.of<ContainerOpenEvent> { open(guiRenderer, it.container) })
|
||||
guiRenderer.connection.register(CallbackEventListener.of<ContainerCloseEvent> { close(guiRenderer, it.container) })
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,6 @@ package de.bixilon.minosoft.gui.rendering.gui.gui.screen.menu.debug
|
||||
|
||||
import de.bixilon.kotlinglm.vec2.Vec2i
|
||||
import de.bixilon.kotlinglm.vec3.Vec3d
|
||||
import de.bixilon.minosoft.data.registries.other.game.event.handlers.gamemode.GamemodeChangeEvent
|
||||
import de.bixilon.minosoft.gui.rendering.gui.GUIRenderer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.HorizontalAlignments
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.input.button.ButtonElement
|
||||
@ -24,7 +23,6 @@ import de.bixilon.minosoft.gui.rendering.gui.elements.text.TextElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.gui.GUIBuilder
|
||||
import de.bixilon.minosoft.gui.rendering.gui.gui.LayoutedGUIElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.gui.screen.menu.Menu
|
||||
import de.bixilon.minosoft.modding.event.EventInitiators
|
||||
|
||||
class DebugMenu(guiRenderer: GUIRenderer) : Menu(guiRenderer) {
|
||||
private val connection = guiRenderer.connection
|
||||
@ -34,10 +32,9 @@ class DebugMenu(guiRenderer: GUIRenderer) : Menu(guiRenderer) {
|
||||
add(SpacerElement(guiRenderer, Vec2i(0, 10)))
|
||||
add(ButtonElement(guiRenderer, "Switch to next gamemode") { connection.util.typeChat("/gamemode ${connection.player.gamemode.next().name.lowercase()}") })
|
||||
add(ButtonElement(guiRenderer, "Hack to next gamemode") {
|
||||
val previous = connection.player.tabListItem.gamemode
|
||||
val previous = connection.player.additional.gamemode
|
||||
val next = previous.next()
|
||||
connection.player.tabListItem.gamemode = next
|
||||
connection.fireEvent(GamemodeChangeEvent(connection, EventInitiators.SERVER, previous, next))
|
||||
connection.player.additional.gamemode = next
|
||||
})
|
||||
add(ButtonElement(guiRenderer, "Toggle collisions") {
|
||||
connection.player.hasCollisions = !connection.player.hasCollisions
|
||||
|
@ -26,7 +26,7 @@ import de.bixilon.minosoft.gui.rendering.gui.gui.GUIBuilder
|
||||
import de.bixilon.minosoft.gui.rendering.gui.gui.LayoutedGUIElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.gui.screen.menu.Menu
|
||||
import de.bixilon.minosoft.modding.event.events.RespawnEvent
|
||||
import de.bixilon.minosoft.modding.event.invoker.CallbackEventInvoker
|
||||
import de.bixilon.minosoft.modding.event.listener.CallbackEventListener
|
||||
import de.bixilon.minosoft.protocol.packets.c2s.play.ClientActionC2SP
|
||||
|
||||
class RespawnMenu(guiRenderer: GUIRenderer) : Menu(guiRenderer) {
|
||||
@ -72,7 +72,7 @@ class RespawnMenu(guiRenderer: GUIRenderer) : Menu(guiRenderer) {
|
||||
guiRenderer.gui.pop(element)
|
||||
}
|
||||
}
|
||||
guiRenderer.connection.registerEvent(CallbackEventInvoker.of<RespawnEvent> {
|
||||
guiRenderer.connection.register(CallbackEventListener.of<RespawnEvent> {
|
||||
val element = guiRenderer.gui[this]
|
||||
if (element.state == ElementStates.CLOSED) {
|
||||
return@of
|
||||
|
@ -25,7 +25,7 @@ import de.bixilon.minosoft.gui.rendering.gui.gui.LayoutedGUIElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.Initializable
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.elements.HUDBuilder
|
||||
import de.bixilon.minosoft.modding.event.events.bossbar.*
|
||||
import de.bixilon.minosoft.modding.event.invoker.CallbackEventInvoker
|
||||
import de.bixilon.minosoft.modding.event.listener.CallbackEventListener
|
||||
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||
|
||||
class BossbarLayout(guiRenderer: GUIRenderer) : RowLayout(guiRenderer, HorizontalAlignments.CENTER, 2), LayoutedElement, Initializable {
|
||||
@ -92,25 +92,25 @@ class BossbarLayout(guiRenderer: GUIRenderer) : RowLayout(guiRenderer, Horizonta
|
||||
)
|
||||
|
||||
override fun postInit() {
|
||||
connection.registerEvent(CallbackEventInvoker.of<BossbarAddEvent> {
|
||||
connection.register(CallbackEventListener.of<BossbarAddEvent> {
|
||||
val element = BossbarElement(guiRenderer, it.bossbar, atlas)
|
||||
this += element
|
||||
val previous = bossbars.put(it.bossbar, element) ?: return@of
|
||||
this -= previous
|
||||
})
|
||||
|
||||
connection.registerEvent(CallbackEventInvoker.of<BossbarRemoveEvent> {
|
||||
connection.register(CallbackEventListener.of<BossbarRemoveEvent> {
|
||||
val element = bossbars.remove(it.bossbar) ?: return@of
|
||||
this -= element
|
||||
})
|
||||
|
||||
connection.registerEvent(CallbackEventInvoker.of<BossbarValueSetEvent> {
|
||||
connection.register(CallbackEventListener.of<BossbarValueSetEvent> {
|
||||
bossbars[it.bossbar]?.apply()
|
||||
})
|
||||
connection.registerEvent(CallbackEventInvoker.of<BossbarTitleSetEvent> {
|
||||
connection.register(CallbackEventListener.of<BossbarTitleSetEvent> {
|
||||
bossbars[it.bossbar]?.apply()
|
||||
})
|
||||
connection.registerEvent(CallbackEventInvoker.of<BossbarStyleSetEvent> {
|
||||
connection.register(CallbackEventListener.of<BossbarStyleSetEvent> {
|
||||
bossbars[it.bossbar]?.apply()
|
||||
})
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexOptions
|
||||
import de.bixilon.minosoft.gui.rendering.system.window.KeyChangeTypes
|
||||
import de.bixilon.minosoft.modding.event.events.InternalMessageReceiveEvent
|
||||
import de.bixilon.minosoft.modding.event.events.chat.ChatMessageReceiveEvent
|
||||
import de.bixilon.minosoft.modding.event.invoker.CallbackEventInvoker
|
||||
import de.bixilon.minosoft.modding.event.listener.CallbackEventListener
|
||||
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||
|
||||
class ChatElement(guiRenderer: GUIRenderer) : AbstractChatElement(guiRenderer), LayoutedElement {
|
||||
@ -81,13 +81,13 @@ class ChatElement(guiRenderer: GUIRenderer) : AbstractChatElement(guiRenderer),
|
||||
|
||||
|
||||
override fun init() {
|
||||
connection.registerEvent(CallbackEventInvoker.of<ChatMessageReceiveEvent> {
|
||||
connection.register(CallbackEventListener.of<ChatMessageReceiveEvent> {
|
||||
if (it.message.type.position == ChatTextPositions.HOTBAR) {
|
||||
return@of
|
||||
}
|
||||
DefaultThreadPool += { messages += it.message.text }
|
||||
})
|
||||
connection.registerEvent(CallbackEventInvoker.of<InternalMessageReceiveEvent> {
|
||||
connection.register(CallbackEventListener.of<InternalMessageReceiveEvent> {
|
||||
if (!profile.chat.internal.hidden) {
|
||||
return@of
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ import de.bixilon.minosoft.config.profile.delegate.watcher.SimpleProfileDelegate
|
||||
import de.bixilon.minosoft.gui.rendering.gui.GUIRenderer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.Element
|
||||
import de.bixilon.minosoft.modding.event.events.InternalMessageReceiveEvent
|
||||
import de.bixilon.minosoft.modding.event.invoker.CallbackEventInvoker
|
||||
import de.bixilon.minosoft.modding.event.listener.CallbackEventListener
|
||||
|
||||
class InternalChatElement(guiRenderer: GUIRenderer) : AbstractChatElement(guiRenderer) {
|
||||
private val chatProfile = profile.chat.internal
|
||||
@ -47,7 +47,7 @@ class InternalChatElement(guiRenderer: GUIRenderer) : AbstractChatElement(guiRen
|
||||
|
||||
|
||||
override fun init() {
|
||||
connection.registerEvent(CallbackEventInvoker.of<InternalMessageReceiveEvent> {
|
||||
connection.register(CallbackEventListener.of<InternalMessageReceiveEvent> {
|
||||
if (profile.chat.internal.hidden) {
|
||||
return@of
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ class HotbarCoreElement(guiRenderer: GUIRenderer) : Element(guiRenderer) {
|
||||
private val topRight = RowLayout(guiRenderer, HorizontalAlignments.RIGHT, 1) // contains hunger, air
|
||||
|
||||
|
||||
private var gamemode = guiRenderer.renderWindow.connection.player.tabListItem.gamemode
|
||||
private var gamemode = guiRenderer.renderWindow.connection.player.additional.gamemode
|
||||
|
||||
private var renderElements = setOf(
|
||||
base,
|
||||
@ -99,7 +99,7 @@ class HotbarCoreElement(guiRenderer: GUIRenderer) : Element(guiRenderer) {
|
||||
|
||||
val size = Vec2i.EMPTY
|
||||
|
||||
gamemode = guiRenderer.renderWindow.connection.player.tabListItem.gamemode
|
||||
gamemode = guiRenderer.renderWindow.connection.player.additional.gamemode
|
||||
if (gamemode != Gamemodes.SPECTATOR) {
|
||||
size += base.size
|
||||
}
|
||||
|
@ -20,7 +20,6 @@ import de.bixilon.minosoft.data.container.InventorySlots
|
||||
import de.bixilon.minosoft.data.container.stack.ItemStack
|
||||
import de.bixilon.minosoft.data.entities.entities.player.Arms
|
||||
import de.bixilon.minosoft.data.registries.ResourceLocation
|
||||
import de.bixilon.minosoft.data.registries.other.game.event.handlers.gamemode.GamemodeChangeEvent
|
||||
import de.bixilon.minosoft.gui.rendering.gui.GUIRenderer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.Element
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.HorizontalAlignments
|
||||
@ -35,11 +34,10 @@ import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexOptions
|
||||
import de.bixilon.minosoft.gui.rendering.util.vec.vec2.Vec2iUtil.EMPTY
|
||||
import de.bixilon.minosoft.gui.rendering.util.vec.vec4.Vec4iUtil.left
|
||||
import de.bixilon.minosoft.gui.rendering.util.vec.vec4.Vec4iUtil.right
|
||||
import de.bixilon.minosoft.modding.event.events.ExperienceChangeEvent
|
||||
import de.bixilon.minosoft.modding.event.events.SelectHotbarSlotEvent
|
||||
import de.bixilon.minosoft.modding.event.events.chat.ChatMessageReceiveEvent
|
||||
import de.bixilon.minosoft.modding.event.invoker.CallbackEventInvoker
|
||||
import de.bixilon.minosoft.modding.event.listener.CallbackEventListener
|
||||
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||
import de.bixilon.minosoft.util.delegate.RenderingDelegate.observeRendering
|
||||
import java.lang.Integer.max
|
||||
|
||||
class HotbarElement(guiRenderer: GUIRenderer) : Element(guiRenderer), LayoutedElement, Initializable {
|
||||
@ -172,13 +170,18 @@ class HotbarElement(guiRenderer: GUIRenderer) : Element(guiRenderer), LayoutedEl
|
||||
prefMaxSize = Vec2i(-1, -1)
|
||||
|
||||
val connection = renderWindow.connection
|
||||
connection.registerEvent(CallbackEventInvoker.of<ExperienceChangeEvent> { core.experience.apply() })
|
||||
val player = connection.player
|
||||
|
||||
connection.registerEvent(CallbackEventInvoker.of<GamemodeChangeEvent> { forceApply() })
|
||||
// ToDo: Don't listen 3 times
|
||||
player.experienceCondition::level.observeRendering(this) { core.experience.apply() }
|
||||
player.experienceCondition::total.observeRendering(this) { core.experience.apply() }
|
||||
player.experienceCondition::bar.observeRendering(this) { core.experience.apply() }
|
||||
|
||||
connection.registerEvent(CallbackEventInvoker.of<SelectHotbarSlotEvent> { core.base.apply() })
|
||||
player.additional::gamemode.observeRendering(this) { forceApply() }
|
||||
|
||||
connection.registerEvent(CallbackEventInvoker.of<ChatMessageReceiveEvent> {
|
||||
player::selectedHotbarSlot.observeRendering(this) { core.base.apply() }
|
||||
|
||||
connection.register(CallbackEventListener.of<ChatMessageReceiveEvent> {
|
||||
if (it.message.type.position != ChatTextPositions.HOTBAR) {
|
||||
return@of
|
||||
}
|
||||
|
@ -76,8 +76,8 @@ class HotbarExperienceBarElement(guiRenderer: GUIRenderer) : Element(guiRenderer
|
||||
|
||||
if (!jumping) {
|
||||
val experienceCondition = guiRenderer.renderWindow.connection.player.experienceCondition
|
||||
if (this.jumping != jumping || progress != experienceCondition.experienceBarProgress || this.level != experienceCondition.level) {
|
||||
this.progress = experienceCondition.experienceBarProgress
|
||||
if (this.jumping != jumping || progress != experienceCondition.bar || this.level != experienceCondition.level) {
|
||||
this.progress = experienceCondition.bar
|
||||
this.jumping = jumping
|
||||
this.level = experienceCondition.level
|
||||
return true
|
||||
|
@ -24,7 +24,6 @@ import de.bixilon.minosoft.config.key.KeyBinding
|
||||
import de.bixilon.minosoft.config.key.KeyCodes
|
||||
import de.bixilon.minosoft.data.direction.Directions
|
||||
import de.bixilon.minosoft.data.registries.ResourceLocation
|
||||
import de.bixilon.minosoft.data.registries.other.game.event.handlers.gamemode.GamemodeChangeEvent
|
||||
import de.bixilon.minosoft.data.text.BaseComponent
|
||||
import de.bixilon.minosoft.data.text.TextComponent
|
||||
import de.bixilon.minosoft.data.text.formatting.color.ChatColors
|
||||
@ -50,9 +49,7 @@ import de.bixilon.minosoft.gui.rendering.modding.events.ResizeWindowEvent
|
||||
import de.bixilon.minosoft.gui.rendering.particle.ParticleRenderer
|
||||
import de.bixilon.minosoft.gui.rendering.util.vec.vec2.Vec2iUtil.EMPTY
|
||||
import de.bixilon.minosoft.gui.rendering.world.WorldRenderer
|
||||
import de.bixilon.minosoft.modding.event.events.DifficultyChangeEvent
|
||||
import de.bixilon.minosoft.modding.event.events.TimeChangeEvent
|
||||
import de.bixilon.minosoft.modding.event.invoker.CallbackEventInvoker
|
||||
import de.bixilon.minosoft.modding.event.listener.CallbackEventListener.Companion.listen
|
||||
import de.bixilon.minosoft.properties.MinosoftProperties
|
||||
import de.bixilon.minosoft.properties.MinosoftPropertiesLoader
|
||||
import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition
|
||||
@ -169,21 +166,19 @@ class DebugHUDElement(guiRenderer: GUIRenderer) : Element(guiRenderer), Layouted
|
||||
layout += LineSpacerElement(guiRenderer)
|
||||
|
||||
layout += TextElement(guiRenderer, BaseComponent("Gamemode ", connection.player.gamemode)).apply {
|
||||
connection.registerEvent(CallbackEventInvoker.of<GamemodeChangeEvent> {
|
||||
text = BaseComponent("Gamemode ", it.gamemode)
|
||||
})
|
||||
connection.player.additional::gamemode.observe(this) { text = BaseComponent("Gamemode ", it) }
|
||||
}
|
||||
|
||||
layout += TextElement(guiRenderer, BaseComponent("Difficulty ", connection.world.difficulty, ", locked=", connection.world.difficultyLocked)).apply {
|
||||
connection.registerEvent(CallbackEventInvoker.of<DifficultyChangeEvent> {
|
||||
text = BaseComponent("Difficulty ", it.difficulty, ", locked=", it.locked)
|
||||
})
|
||||
layout += TextElement(guiRenderer, BaseComponent("Difficulty ", connection.world.difficulty?.difficulty, ", locked=", connection.world.difficulty?.locked)).apply {
|
||||
connection.world::difficulty.observe(this) { text = BaseComponent("Difficulty ", it?.difficulty, ", locked=", it?.locked) }
|
||||
}
|
||||
|
||||
layout += TextElement(guiRenderer, "Time TBA").apply {
|
||||
connection.registerEvent(CallbackEventInvoker.of<TimeChangeEvent> {
|
||||
text = BaseComponent("Time ", abs(it.time % ProtocolDefinition.TICKS_PER_DAY), ", moving=", it.time >= 0, ", day=", abs(it.age) / ProtocolDefinition.TICKS_PER_DAY)
|
||||
})
|
||||
fun update(time: Long, age: Long) {
|
||||
text = BaseComponent("Time ", abs(time % ProtocolDefinition.TICKS_PER_DAY), ", moving=", time >= 0, ", day=", abs(age) / ProtocolDefinition.TICKS_PER_DAY)
|
||||
}
|
||||
connection.world.time::time.observe(this) { update(it, connection.world.time.age) }
|
||||
connection.world.time::age.observe(this) { update(connection.world.time.time, it) }
|
||||
}
|
||||
|
||||
layout += AutoTextElement(guiRenderer, 1) { "Fun effect: " + renderWindow.framebufferManager.world.`fun`.effect?.resourceLocation.format() }
|
||||
@ -221,9 +216,9 @@ class DebugHUDElement(guiRenderer: GUIRenderer) : Element(guiRenderer), Layouted
|
||||
layout += LineSpacerElement(guiRenderer)
|
||||
|
||||
layout += TextElement(guiRenderer, "Display <?>", HorizontalAlignments.RIGHT).apply {
|
||||
guiRenderer.renderWindow.connection.registerEvent(CallbackEventInvoker.of<ResizeWindowEvent> {
|
||||
guiRenderer.renderWindow.connection.events.listen<ResizeWindowEvent> {
|
||||
text = "Display ${it.size.x.format()}x${it.size.y.format()}"
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
renderWindow.renderSystem.apply {
|
||||
@ -241,7 +236,7 @@ class DebugHUDElement(guiRenderer: GUIRenderer) : Element(guiRenderer), Layouted
|
||||
|
||||
layout += LineSpacerElement(guiRenderer)
|
||||
|
||||
layout += TextElement(guiRenderer, "${connection.size.format()}x listeners", HorizontalAlignments.RIGHT)
|
||||
layout += TextElement(guiRenderer, "${connection.events.size.format()}x listeners", HorizontalAlignments.RIGHT)
|
||||
|
||||
layout += LineSpacerElement(guiRenderer)
|
||||
|
||||
@ -294,7 +289,7 @@ class DebugHUDElement(guiRenderer: GUIRenderer) : Element(guiRenderer), Layouted
|
||||
val builder = StringBuilder()
|
||||
if (chunk.blocksInitialized) builder.append('s') // for block states
|
||||
if (chunk.biomesInitialized) builder.append('b') // biomes
|
||||
if (chunk.neighbours != null) builder.append('n') // neighbours
|
||||
if (chunk.neighbours.complete) builder.append('n') // neighbours
|
||||
|
||||
value = builder.toString()
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ import de.bixilon.minosoft.gui.rendering.renderer.drawable.AsyncDrawable
|
||||
import de.bixilon.minosoft.gui.rendering.util.vec.vec2.Vec2iUtil.EMPTY
|
||||
import de.bixilon.minosoft.modding.event.events.scoreboard.*
|
||||
import de.bixilon.minosoft.modding.event.events.scoreboard.team.TeamUpdateEvent
|
||||
import de.bixilon.minosoft.modding.event.invoker.CallbackEventInvoker
|
||||
import de.bixilon.minosoft.modding.event.listener.CallbackEventListener
|
||||
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||
|
||||
class ScoreboardSideElement(guiRenderer: GUIRenderer) : Element(guiRenderer), LayoutedElement, Initializable, AsyncDrawable {
|
||||
@ -163,38 +163,38 @@ class ScoreboardSideElement(guiRenderer: GUIRenderer) : Element(guiRenderer), La
|
||||
|
||||
override fun init() {
|
||||
val connection = renderWindow.connection
|
||||
connection.registerEvent(CallbackEventInvoker.of<ObjectivePositionSetEvent> {
|
||||
connection.register(CallbackEventListener.of<ObjectivePositionSetEvent> {
|
||||
if (it.position != ScoreboardPositions.SIDEBAR) {
|
||||
return@of
|
||||
}
|
||||
|
||||
this.objective = it.objective
|
||||
})
|
||||
connection.registerEvent(CallbackEventInvoker.of<ScoreboardObjectiveUpdateEvent> {
|
||||
connection.register(CallbackEventListener.of<ScoreboardObjectiveUpdateEvent> {
|
||||
if (it.objective != this.objective) {
|
||||
return@of
|
||||
}
|
||||
this.updateName()
|
||||
})
|
||||
connection.registerEvent(CallbackEventInvoker.of<ScoreboardScoreRemoveEvent> {
|
||||
connection.register(CallbackEventListener.of<ScoreboardScoreRemoveEvent> {
|
||||
if (it.score.objective != this.objective) {
|
||||
return@of
|
||||
}
|
||||
this.removeScore(it.score)
|
||||
})
|
||||
connection.registerEvent(CallbackEventInvoker.of<ScoreboardScorePutEvent> {
|
||||
connection.register(CallbackEventListener.of<ScoreboardScorePutEvent> {
|
||||
if (it.score.objective != this.objective) {
|
||||
return@of
|
||||
}
|
||||
this.updateScore(it.score)
|
||||
})
|
||||
connection.registerEvent(CallbackEventInvoker.of<ScoreTeamChangeEvent> {
|
||||
connection.register(CallbackEventListener.of<ScoreTeamChangeEvent> {
|
||||
if (it.score.objective != this.objective) {
|
||||
return@of
|
||||
}
|
||||
this.updateScore(it.score)
|
||||
})
|
||||
connection.registerEvent(CallbackEventInvoker.of<TeamUpdateEvent> {
|
||||
connection.register(CallbackEventListener.of<TeamUpdateEvent> {
|
||||
val objective = this.objective ?: return@of
|
||||
for ((_, score) in objective.scores) {
|
||||
if (it.team != score.team) {
|
||||
|
@ -39,7 +39,7 @@ import de.bixilon.minosoft.gui.rendering.renderer.drawable.AsyncDrawable
|
||||
import de.bixilon.minosoft.gui.rendering.util.vec.vec2.Vec2iUtil.EMPTY
|
||||
import de.bixilon.minosoft.modding.event.events.TabListEntryChangeEvent
|
||||
import de.bixilon.minosoft.modding.event.events.TabListInfoChangeEvent
|
||||
import de.bixilon.minosoft.modding.event.invoker.CallbackEventInvoker
|
||||
import de.bixilon.minosoft.modding.event.listener.CallbackEventListener
|
||||
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||
import java.util.*
|
||||
import java.util.concurrent.locks.ReentrantLock
|
||||
@ -221,11 +221,11 @@ class TabListElement(guiRenderer: GUIRenderer) : Element(guiRenderer), LayoutedE
|
||||
|
||||
override fun init() {
|
||||
val connection = renderWindow.connection
|
||||
connection.registerEvent(CallbackEventInvoker.of<TabListInfoChangeEvent> {
|
||||
connection.register(CallbackEventListener.of<TabListInfoChangeEvent> {
|
||||
header.text = it.header
|
||||
footer.text = it.footer
|
||||
})
|
||||
connection.registerEvent(CallbackEventInvoker.of<TabListEntryChangeEvent> {
|
||||
connection.register(CallbackEventListener.of<TabListEntryChangeEvent> {
|
||||
for ((uuid, entry) in it.items) {
|
||||
if (entry == null) {
|
||||
remove(uuid)
|
||||
|
@ -17,7 +17,7 @@ import de.bixilon.kotlinglm.vec2.Vec2
|
||||
import de.bixilon.kotlinglm.vec2.Vec2i
|
||||
import de.bixilon.kutil.concurrent.pool.DefaultThreadPool
|
||||
import de.bixilon.minosoft.data.abilities.Gamemodes
|
||||
import de.bixilon.minosoft.data.entities.entities.player.tab.TabListItem
|
||||
import de.bixilon.minosoft.data.entities.entities.player.additional.PlayerAdditional
|
||||
import de.bixilon.minosoft.data.text.ChatComponent
|
||||
import de.bixilon.minosoft.data.text.formatting.color.RGBColor
|
||||
import de.bixilon.minosoft.gui.rendering.gui.GUIRenderer
|
||||
@ -40,7 +40,7 @@ class TabListEntryElement(
|
||||
guiRenderer: GUIRenderer,
|
||||
val tabList: TabListElement,
|
||||
uuid: UUID,
|
||||
val item: TabListItem,
|
||||
val item: PlayerAdditional,
|
||||
width: Int,
|
||||
) : Element(guiRenderer), Pollable, Comparable<TabListEntryElement> {
|
||||
|
||||
@ -56,7 +56,7 @@ class TabListEntryElement(
|
||||
private val nameElement = TextElement(guiRenderer, "", background = false, parent = this)
|
||||
private lateinit var pingElement: AtlasImageElement
|
||||
|
||||
private var displayName: ChatComponent = item.displayName
|
||||
private var displayName: ChatComponent = item.tabDisplayName
|
||||
private var ping = item.ping
|
||||
private var gamemode: Gamemodes = item.gamemode
|
||||
private var name: String = item.name
|
||||
|
@ -29,7 +29,7 @@ import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexConsumer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexOptions
|
||||
import de.bixilon.minosoft.gui.rendering.util.vec.vec2.Vec2iUtil.EMPTY
|
||||
import de.bixilon.minosoft.modding.event.events.title.*
|
||||
import de.bixilon.minosoft.modding.event.invoker.CallbackEventInvoker
|
||||
import de.bixilon.minosoft.modding.event.listener.CallbackEventListener
|
||||
import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition
|
||||
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||
import java.lang.Integer.max
|
||||
@ -128,21 +128,21 @@ class TitleElement(guiRenderer: GUIRenderer) : Element(guiRenderer), LayoutedEle
|
||||
override fun init() {
|
||||
val connection = renderWindow.connection
|
||||
|
||||
connection.registerEvent(CallbackEventInvoker.of<TitleResetEvent> {
|
||||
connection.register(CallbackEventListener.of<TitleResetEvent> {
|
||||
this.reset()
|
||||
})
|
||||
connection.registerEvent(CallbackEventInvoker.of<TitleHideEvent> {
|
||||
connection.register(CallbackEventListener.of<TitleHideEvent> {
|
||||
this.hide()
|
||||
})
|
||||
connection.registerEvent(CallbackEventInvoker.of<TitleSetEvent> {
|
||||
connection.register(CallbackEventListener.of<TitleSetEvent> {
|
||||
this.title.text = it.title
|
||||
this.show()
|
||||
})
|
||||
connection.registerEvent(CallbackEventInvoker.of<TitleSubtitleSetEvent> {
|
||||
connection.register(CallbackEventListener.of<TitleSubtitleSetEvent> {
|
||||
this.subtitle.text = it.subtitle
|
||||
// layout.show() // non vanilla behavior
|
||||
})
|
||||
connection.registerEvent(CallbackEventInvoker.of<TitleTimesSetEvent> {
|
||||
connection.register(CallbackEventListener.of<TitleTimesSetEvent> {
|
||||
this.fadeInTime = it.fadeInTime * ProtocolDefinition.TICK_TIME.toLong()
|
||||
this.stayTime = it.stayTime * ProtocolDefinition.TICK_TIME.toLong()
|
||||
this.fadeOutTime = it.fadeOutTime * ProtocolDefinition.TICK_TIME.toLong()
|
||||
|
@ -32,7 +32,7 @@ import de.bixilon.minosoft.data.registries.other.world.event.handlers.BlockDestr
|
||||
import de.bixilon.minosoft.gui.rendering.RenderWindow
|
||||
import de.bixilon.minosoft.gui.rendering.camera.target.targets.BlockTarget
|
||||
import de.bixilon.minosoft.modding.event.events.LegacyBlockBreakAckEvent
|
||||
import de.bixilon.minosoft.modding.event.invoker.CallbackEventInvoker
|
||||
import de.bixilon.minosoft.modding.event.listener.CallbackEventListener
|
||||
import de.bixilon.minosoft.protocol.packets.c2s.play.PlayerActionC2SP
|
||||
import de.bixilon.minosoft.protocol.packets.c2s.play.move.SwingArmC2SP
|
||||
import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition
|
||||
@ -253,7 +253,7 @@ class BreakInteractionHandler(
|
||||
KeyActions.CHANGE to setOf(KeyCodes.MOUSE_BUTTON_LEFT),
|
||||
))
|
||||
|
||||
connection.registerEvent(CallbackEventInvoker.of<LegacyBlockBreakAckEvent> {
|
||||
connection.register(CallbackEventListener.of<LegacyBlockBreakAckEvent> {
|
||||
when (it.actions) {
|
||||
PlayerActionC2SP.Actions.START_DIGGING -> {
|
||||
if (it.successful) {
|
||||
|
@ -23,9 +23,7 @@ import de.bixilon.minosoft.data.container.InventorySlots
|
||||
import de.bixilon.minosoft.data.container.types.PlayerInventory
|
||||
import de.bixilon.minosoft.gui.rendering.RenderWindow
|
||||
import de.bixilon.minosoft.gui.rendering.modding.events.input.MouseScrollEvent
|
||||
import de.bixilon.minosoft.modding.event.EventInitiators
|
||||
import de.bixilon.minosoft.modding.event.events.SelectHotbarSlotEvent
|
||||
import de.bixilon.minosoft.modding.event.invoker.CallbackEventInvoker
|
||||
import de.bixilon.minosoft.modding.event.listener.CallbackEventListener
|
||||
import de.bixilon.minosoft.protocol.packets.c2s.play.HotbarSlotC2SP
|
||||
import de.bixilon.minosoft.protocol.packets.c2s.play.PlayerActionC2SP
|
||||
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||
@ -48,10 +46,9 @@ class HotbarInteractionHandler(
|
||||
if (connection.player.selectedHotbarSlot == slot) {
|
||||
return
|
||||
}
|
||||
connection.player.selectedHotbarSlot = slot
|
||||
interactionManager.use.stopUsingItem()
|
||||
connection.player.selectedHotbarSlot = slot
|
||||
slotLimiter += { connection.sendPacket(HotbarSlotC2SP(slot)) }
|
||||
connection.fireEvent(SelectHotbarSlotEvent(connection, EventInitiators.CLIENT, slot))
|
||||
}
|
||||
|
||||
fun swapItems() {
|
||||
@ -83,7 +80,7 @@ class HotbarInteractionHandler(
|
||||
)) { selectSlot(i - 1) }
|
||||
}
|
||||
|
||||
connection.registerEvent(CallbackEventInvoker.of<MouseScrollEvent> {
|
||||
connection.register(CallbackEventListener.of<MouseScrollEvent> {
|
||||
currentScrollOffset += it.offset.y
|
||||
|
||||
val limit = connection.profiles.controls.mouse.scrollSensitivity
|
||||
|
@ -14,15 +14,15 @@
|
||||
package de.bixilon.minosoft.gui.rendering.input.interaction
|
||||
|
||||
import de.bixilon.kutil.rate.RateLimiter
|
||||
import de.bixilon.kutil.watcher.DataWatcher.Companion.observe
|
||||
import de.bixilon.minosoft.config.key.KeyActions
|
||||
import de.bixilon.minosoft.config.key.KeyBinding
|
||||
import de.bixilon.minosoft.config.key.KeyCodes
|
||||
import de.bixilon.minosoft.data.abilities.Gamemodes
|
||||
import de.bixilon.minosoft.data.entities.entities.Entity
|
||||
import de.bixilon.minosoft.data.registries.other.game.event.handlers.gamemode.GamemodeChangeEvent
|
||||
import de.bixilon.minosoft.gui.rendering.RenderWindow
|
||||
import de.bixilon.minosoft.modding.event.events.CameraSetEvent
|
||||
import de.bixilon.minosoft.modding.event.invoker.CallbackEventInvoker
|
||||
import de.bixilon.minosoft.modding.event.listener.CallbackEventListener
|
||||
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||
|
||||
class SpectateInteractionManager(
|
||||
@ -32,12 +32,14 @@ class SpectateInteractionManager(
|
||||
private val rateLimiter = RateLimiter()
|
||||
|
||||
fun init() {
|
||||
renderWindow.inputHandler.registerKeyCallback(STOP_SPECTATING, KeyBinding(
|
||||
renderWindow.inputHandler.registerKeyCallback(
|
||||
STOP_SPECTATING, KeyBinding(
|
||||
KeyActions.PRESS to setOf(KeyCodes.KEY_LEFT_SHIFT),
|
||||
)) { spectate(null) }
|
||||
)
|
||||
) { spectate(null) }
|
||||
|
||||
renderWindow.connection.registerEvent(CallbackEventInvoker.of<GamemodeChangeEvent> { spectate(null) })
|
||||
renderWindow.connection.registerEvent(CallbackEventInvoker.of<CameraSetEvent> { spectate(it.entity) })
|
||||
connection.player.additional::gamemode.observe(this) { spectate(null) }
|
||||
connection.register(CallbackEventListener.of<CameraSetEvent> { spectate(it.entity) })
|
||||
}
|
||||
|
||||
|
||||
|
@ -36,7 +36,7 @@ import de.bixilon.minosoft.gui.rendering.system.window.CursorModes
|
||||
import de.bixilon.minosoft.gui.rendering.system.window.KeyChangeTypes
|
||||
import de.bixilon.minosoft.gui.rendering.util.vec.vec2.Vec2dUtil.EMPTY
|
||||
import de.bixilon.minosoft.modding.EventPriorities
|
||||
import de.bixilon.minosoft.modding.event.invoker.CallbackEventInvoker
|
||||
import de.bixilon.minosoft.modding.event.listener.CallbackEventListener
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||
import de.bixilon.minosoft.util.KUtil.format
|
||||
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||
@ -94,11 +94,11 @@ class RenderWindowInputHandler(
|
||||
fun init() {
|
||||
interactionManager.init()
|
||||
|
||||
connection.registerEvent(CallbackEventInvoker.of<RawCharInputEvent> { charInput(it.char) })
|
||||
connection.registerEvent(CallbackEventInvoker.of<RawKeyInputEvent> { keyInput(it.keyCode, it.keyChangeType) })
|
||||
connection.registerEvent(CallbackEventInvoker.of<MouseScrollEvent>(priority = EventPriorities.LOW) { scroll(it.offset, it) })
|
||||
connection.register(CallbackEventListener.of<RawCharInputEvent> { charInput(it.char) })
|
||||
connection.register(CallbackEventListener.of<RawKeyInputEvent> { keyInput(it.keyCode, it.keyChangeType) })
|
||||
connection.register(CallbackEventListener.of<MouseScrollEvent>(priority = EventPriorities.LOW) { scroll(it.offset, it) })
|
||||
|
||||
connection.registerEvent(CallbackEventInvoker.of<MouseMoveEvent> {
|
||||
connection.register(CallbackEventListener.of<MouseMoveEvent> {
|
||||
val inputHandler = inputHandler
|
||||
currentMousePosition = it.position
|
||||
if (inputHandler != null) {
|
||||
|
@ -1,25 +0,0 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||
*/
|
||||
|
||||
package de.bixilon.minosoft.gui.rendering.modding.events
|
||||
|
||||
import de.bixilon.minosoft.gui.rendering.RenderingStates
|
||||
import de.bixilon.minosoft.modding.event.events.connection.play.PlayConnectionEvent
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||
|
||||
@Deprecated("Delegates")
|
||||
class RenderingStateChangeEvent(
|
||||
override val connection: PlayConnection,
|
||||
val previousState: RenderingStates,
|
||||
val state: RenderingStates,
|
||||
) : PlayConnectionEvent(connection)
|
@ -1,23 +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.gui.rendering.modding.events
|
||||
|
||||
import de.bixilon.minosoft.gui.rendering.RenderWindow
|
||||
import de.bixilon.minosoft.gui.rendering.system.window.BaseWindow
|
||||
|
||||
class WindowFocusChangeEvent(
|
||||
renderWindow: RenderWindow,
|
||||
val window: BaseWindow,
|
||||
val focused: Boolean,
|
||||
) : RenderEvent(renderWindow)
|
@ -1,23 +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.gui.rendering.modding.events
|
||||
|
||||
import de.bixilon.minosoft.gui.rendering.RenderWindow
|
||||
import de.bixilon.minosoft.gui.rendering.system.window.BaseWindow
|
||||
|
||||
class WindowIconifyChangeEvent(
|
||||
renderWindow: RenderWindow,
|
||||
val window: BaseWindow,
|
||||
val iconified: Boolean,
|
||||
) : RenderEvent(renderWindow)
|
@ -18,10 +18,9 @@ import de.bixilon.kutil.concurrent.pool.DefaultThreadPool
|
||||
import de.bixilon.minosoft.gui.rendering.particle.types.norender.ExplosionEmitterParticle
|
||||
import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.explosion.ExplosionParticle
|
||||
import de.bixilon.minosoft.gui.rendering.util.VecUtil.times
|
||||
import de.bixilon.minosoft.modding.event.EventInitiators
|
||||
import de.bixilon.minosoft.modding.event.events.ExplosionEvent
|
||||
import de.bixilon.minosoft.modding.event.events.ParticleSpawnEvent
|
||||
import de.bixilon.minosoft.modding.event.invoker.CallbackEventInvoker
|
||||
import de.bixilon.minosoft.modding.event.listener.CallbackEventListener
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||
import de.bixilon.minosoft.util.logging.Log
|
||||
import de.bixilon.minosoft.util.logging.LogLevels
|
||||
@ -35,7 +34,7 @@ object DefaultParticleBehavior {
|
||||
val explosionEmitterParticleType = connection.registries.particleTypeRegistry[ExplosionEmitterParticle]!!
|
||||
val typesConfig = connection.profiles.particle.types
|
||||
val invokers = listOf(
|
||||
CallbackEventInvoker.of<ExplosionEvent> {
|
||||
CallbackEventListener.of<ExplosionEvent> {
|
||||
if (typesConfig.explosions) {
|
||||
return@of
|
||||
}
|
||||
@ -45,11 +44,8 @@ object DefaultParticleBehavior {
|
||||
particleRenderer += ExplosionParticle(connection, Vec3d(it.position), explosionParticleType.default())
|
||||
}
|
||||
},
|
||||
CallbackEventInvoker.of<ParticleSpawnEvent> {
|
||||
CallbackEventListener.of<ParticleSpawnEvent> {
|
||||
DefaultThreadPool += add@{
|
||||
if (it.initiator == EventInitiators.SERVER && !typesConfig.packet) {
|
||||
return@add
|
||||
}
|
||||
fun spawn(position: Vec3d, velocity: Vec3d) {
|
||||
val factory = it.data.type.factory
|
||||
if (factory == null) {
|
||||
@ -75,6 +71,6 @@ object DefaultParticleBehavior {
|
||||
},
|
||||
)
|
||||
|
||||
connection.registerEvents(*invokers.toTypedArray())
|
||||
connection.register(*invokers.toTypedArray())
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ import de.bixilon.minosoft.gui.rendering.system.base.phases.TransparentDrawable
|
||||
import de.bixilon.minosoft.gui.rendering.system.base.shader.Shader
|
||||
import de.bixilon.minosoft.gui.rendering.system.base.shader.Shader.Companion.loadAnimated
|
||||
import de.bixilon.minosoft.gui.rendering.system.base.shader.ShaderUniforms
|
||||
import de.bixilon.minosoft.modding.event.invoker.CallbackEventInvoker
|
||||
import de.bixilon.minosoft.modding.event.listener.CallbackEventListener
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnectionStates
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnectionStates.Companion.disconnected
|
||||
@ -109,7 +109,7 @@ class ParticleRenderer(
|
||||
profile::maxAmount.profileWatch(this, true, profile) { maxAmount = minOf(it, RenderConstants.MAXIMUM_PARTICLE_AMOUNT) }
|
||||
profile::enabled.profileWatch(this, true, profile) { enabled = it }
|
||||
|
||||
connection.registerEvent(CallbackEventInvoker.of<CameraMatrixChangeEvent> {
|
||||
connection.register(CallbackEventListener.of<CameraMatrixChangeEvent> {
|
||||
renderWindow.queue += {
|
||||
fun applyToShader(shader: Shader) {
|
||||
shader.apply {
|
||||
@ -144,7 +144,7 @@ class ParticleRenderer(
|
||||
connection.world.particleRenderer = this
|
||||
|
||||
particleTask = TimeWorkerTask(ProtocolDefinition.TICK_TIME, maxDelayTime = ProtocolDefinition.TICK_TIME / 2) {
|
||||
if (!renderWindow.renderingState.running || !enabled || connection.state != PlayConnectionStates.PLAYING) {
|
||||
if (!renderWindow.state.running || !enabled || connection.state != PlayConnectionStates.PLAYING) {
|
||||
return@TimeWorkerTask
|
||||
}
|
||||
val cameraPosition = connection.player.positionInfo.chunkPosition
|
||||
@ -190,7 +190,7 @@ class ParticleRenderer(
|
||||
}
|
||||
|
||||
override fun addParticle(particle: Particle) {
|
||||
if (!renderWindow.renderingState.running || !enabled) {
|
||||
if (!renderWindow.state.running || !enabled) {
|
||||
return
|
||||
}
|
||||
val particleCount = particles.size + particleQueue.size
|
||||
|
@ -18,6 +18,7 @@ import de.bixilon.kotlinglm.mat4x4.Mat4
|
||||
import de.bixilon.kotlinglm.vec2.Vec2
|
||||
import de.bixilon.kotlinglm.vec3.Vec3
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.watcher.DataWatcher.Companion.observe
|
||||
import de.bixilon.minosoft.data.registries.ResourceLocation
|
||||
import de.bixilon.minosoft.data.text.formatting.color.ChatColors
|
||||
import de.bixilon.minosoft.data.text.formatting.color.RGBColor
|
||||
@ -32,8 +33,7 @@ import de.bixilon.minosoft.gui.rendering.system.base.phases.PreDrawable
|
||||
import de.bixilon.minosoft.gui.rendering.system.base.texture.texture.AbstractTexture
|
||||
import de.bixilon.minosoft.gui.rendering.textures.TextureUtil.texture
|
||||
import de.bixilon.minosoft.gui.rendering.util.mesh.SimpleTextureMesh
|
||||
import de.bixilon.minosoft.modding.event.events.TimeChangeEvent
|
||||
import de.bixilon.minosoft.modding.event.invoker.CallbackEventInvoker
|
||||
import de.bixilon.minosoft.modding.event.listener.CallbackEventListener
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||
import de.bixilon.minosoft.util.KUtil.minosoft
|
||||
|
||||
@ -62,18 +62,14 @@ class SkyRenderer(
|
||||
skySunMesh.load()
|
||||
|
||||
|
||||
connection.registerEvent(CallbackEventInvoker.of<CameraMatrixChangeEvent> {
|
||||
connection.register(CallbackEventListener.of<CameraMatrixChangeEvent> {
|
||||
val viewProjectionMatrix = it.projectionMatrix * it.viewMatrix.toMat3().toMat4()
|
||||
renderWindow.queue += {
|
||||
skyboxShader.use().setMat4(SKY_MATRIX, Mat4(viewProjectionMatrix))
|
||||
setSunMatrix(viewProjectionMatrix)
|
||||
}
|
||||
})
|
||||
connection.registerEvent(CallbackEventInvoker.of<TimeChangeEvent> {
|
||||
if (connection.world.time.time != it.time) {
|
||||
updateSun = true
|
||||
}
|
||||
})
|
||||
connection.world.time::time.observe(this) { updateSun = true }
|
||||
sunTexture = renderWindow.textureManager.staticTextures.createTexture(SUN_TEXTURE_RESOURCE_LOCATION)
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ import de.bixilon.minosoft.gui.rendering.camera.MatrixHandler
|
||||
import de.bixilon.minosoft.gui.rendering.modding.events.CameraPositionChangeEvent
|
||||
import de.bixilon.minosoft.gui.rendering.sound.sounds.Sound
|
||||
import de.bixilon.minosoft.gui.rendering.util.vec.vec3.Vec3Util.EMPTY
|
||||
import de.bixilon.minosoft.modding.event.invoker.CallbackEventInvoker
|
||||
import de.bixilon.minosoft.modding.event.listener.CallbackEventListener
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||
import de.bixilon.minosoft.util.logging.Log
|
||||
import de.bixilon.minosoft.util.logging.LogLevels
|
||||
@ -93,7 +93,7 @@ class AudioPlayer(
|
||||
listener.masterVolume = volumeConfig.masterVolume
|
||||
volumeConfig::masterVolume.profileWatch(this) { queue += { listener.masterVolume = it } }
|
||||
|
||||
connection.registerEvent(CallbackEventInvoker.of<CameraPositionChangeEvent> {
|
||||
connection.register(CallbackEventListener.of<CameraPositionChangeEvent> {
|
||||
queue += {
|
||||
listener.position = Vec3(it.newPosition)
|
||||
listener.setOrientation(it.renderWindow.camera.matrixHandler.cameraFront, MatrixHandler.CAMERA_UP_VEC3)
|
||||
|
@ -15,7 +15,7 @@ package de.bixilon.minosoft.gui.rendering.sound
|
||||
|
||||
import de.bixilon.minosoft.modding.event.events.ExplosionEvent
|
||||
import de.bixilon.minosoft.modding.event.events.PlaySoundEvent
|
||||
import de.bixilon.minosoft.modding.event.invoker.CallbackEventInvoker
|
||||
import de.bixilon.minosoft.modding.event.listener.CallbackEventListener
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||
import kotlin.random.Random
|
||||
@ -26,10 +26,10 @@ object DefaultAudioBehavior {
|
||||
fun register(connection: PlayConnection) {
|
||||
val world = connection.world
|
||||
val invokers = listOf(
|
||||
CallbackEventInvoker.of<PlaySoundEvent> { world.playSound(it.soundEvent, it.position, it.volume, it.pitch) },
|
||||
CallbackEventInvoker.of<ExplosionEvent> { world.playSound(ENTITY_GENERIC_EXPLODE, it.position, 4.0f, (1.0f + (Random.nextFloat() - Random.nextFloat()) * 0.2f) * 0.7f) },
|
||||
CallbackEventListener.of<PlaySoundEvent> { world.playSound(it.soundEvent, it.position, it.volume, it.pitch) },
|
||||
CallbackEventListener.of<ExplosionEvent> { world.playSound(ENTITY_GENERIC_EXPLODE, it.position, 4.0f, (1.0f + (Random.nextFloat() - Random.nextFloat()) * 0.2f) * 0.7f) },
|
||||
)
|
||||
|
||||
connection.registerEvents(*invokers.toTypedArray())
|
||||
connection.register(*invokers.toTypedArray())
|
||||
}
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ abstract class TextureManager {
|
||||
return getFallbackTexture(uuid)
|
||||
}
|
||||
|
||||
fun getSkin(player: PlayerEntity, properties: PlayerProperties? = player.tabListItem.properties): DynamicTexture {
|
||||
fun getSkin(player: PlayerEntity, properties: PlayerProperties? = player.additional.properties): DynamicTexture {
|
||||
if (player is LocalPlayerEntity) {
|
||||
return skin
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ import de.bixilon.minosoft.gui.rendering.system.opengl.texture.OpenGLTextureMana
|
||||
import de.bixilon.minosoft.gui.rendering.system.opengl.vendor.*
|
||||
import de.bixilon.minosoft.gui.rendering.util.mesh.Mesh
|
||||
import de.bixilon.minosoft.gui.rendering.util.mesh.MeshStruct
|
||||
import de.bixilon.minosoft.modding.event.invoker.CallbackEventInvoker
|
||||
import de.bixilon.minosoft.modding.event.listener.CallbackEventListener
|
||||
import de.bixilon.minosoft.util.logging.Log
|
||||
import de.bixilon.minosoft.util.logging.LogLevels
|
||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||
@ -131,7 +131,7 @@ class OpenGLRenderSystem(
|
||||
this.version = glGetString(GL_VERSION) ?: "UNKNOWN"
|
||||
this.gpuType = glGetString(GL_RENDERER) ?: "UNKNOWN"
|
||||
|
||||
renderWindow.connection.registerEvent(CallbackEventInvoker.of<ResizeWindowEvent> {
|
||||
renderWindow.connection.register(CallbackEventListener.of<ResizeWindowEvent> {
|
||||
renderWindow.queue += {
|
||||
glViewport(0, 0, it.size.x, it.size.y)
|
||||
}
|
||||
|
@ -48,6 +48,9 @@ interface BaseWindow {
|
||||
|
||||
val time: Double
|
||||
|
||||
val iconified: Boolean
|
||||
val focused: Boolean
|
||||
|
||||
fun init(profile: RenderingProfile) {
|
||||
resizable = true
|
||||
profile.advanced::swapInterval.profileWatchRendering(this, true, profile) { swapInterval = it }
|
||||
|
@ -19,11 +19,14 @@ import de.bixilon.kutil.concurrent.pool.DefaultThreadPool
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.os.OSTypes
|
||||
import de.bixilon.kutil.os.PlatformInfo
|
||||
import de.bixilon.kutil.watcher.DataWatcher.Companion.watched
|
||||
import de.bixilon.minosoft.config.key.KeyCodes
|
||||
import de.bixilon.minosoft.config.profile.profiles.rendering.RenderingProfile
|
||||
import de.bixilon.minosoft.gui.rendering.RenderWindow
|
||||
import de.bixilon.minosoft.gui.rendering.Rendering
|
||||
import de.bixilon.minosoft.gui.rendering.modding.events.*
|
||||
import de.bixilon.minosoft.gui.rendering.modding.events.RenderEvent
|
||||
import de.bixilon.minosoft.gui.rendering.modding.events.ResizeWindowEvent
|
||||
import de.bixilon.minosoft.gui.rendering.modding.events.WindowCloseEvent
|
||||
import de.bixilon.minosoft.gui.rendering.modding.events.input.MouseMoveEvent
|
||||
import de.bixilon.minosoft.gui.rendering.modding.events.input.MouseScrollEvent
|
||||
import de.bixilon.minosoft.gui.rendering.modding.events.input.RawCharInputEvent
|
||||
@ -263,20 +266,22 @@ class GLFWWindow(
|
||||
glfwWindowHint(GLFW_OPENGL_PROFILE, if (coreProfile) GLFW_OPENGL_CORE_PROFILE else GLFW_OPENGL_ANY_PROFILE)
|
||||
}
|
||||
|
||||
override var focused by watched(false)
|
||||
|
||||
private fun onFocusChange(window: Long, focused: Boolean) {
|
||||
if (window != this.window) {
|
||||
return
|
||||
}
|
||||
|
||||
fireGLFWEvent(WindowFocusChangeEvent(renderWindow, window = this, focused = focused))
|
||||
this.focused = focused
|
||||
}
|
||||
|
||||
override var iconified by watched(false)
|
||||
|
||||
private fun onIconify(window: Long, iconified: Boolean) {
|
||||
if (window != this.window) {
|
||||
return
|
||||
}
|
||||
|
||||
fireGLFWEvent(WindowIconifyChangeEvent(renderWindow, window = this, iconified = iconified))
|
||||
this.iconified = iconified
|
||||
}
|
||||
|
||||
private fun onClose(window: Long) {
|
||||
@ -370,10 +375,10 @@ class GLFWWindow(
|
||||
private fun fireGLFWEvent(event: RenderEvent): Boolean {
|
||||
// ToDo: It looks like glfwPollEvents is mixing threads. This should not happen.
|
||||
if (Rendering.currentContext != event.renderWindow) {
|
||||
event.renderWindow.queue += { eventMaster.fireEvent(event) }
|
||||
event.renderWindow.queue += { eventMaster.fire(event) }
|
||||
return false
|
||||
}
|
||||
return eventMaster.fireEvent(event)
|
||||
return eventMaster.fire(event)
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
@ -36,7 +36,6 @@ import de.bixilon.minosoft.data.world.chunk.Chunk
|
||||
import de.bixilon.minosoft.data.world.chunk.ChunkSection
|
||||
import de.bixilon.minosoft.gui.rendering.RenderWindow
|
||||
import de.bixilon.minosoft.gui.rendering.RenderingStates
|
||||
import de.bixilon.minosoft.gui.rendering.modding.events.RenderingStateChangeEvent
|
||||
import de.bixilon.minosoft.gui.rendering.modding.events.VisibilityGraphChangeEvent
|
||||
import de.bixilon.minosoft.gui.rendering.renderer.renderer.Renderer
|
||||
import de.bixilon.minosoft.gui.rendering.renderer.renderer.RendererBuilder
|
||||
@ -72,7 +71,7 @@ import de.bixilon.minosoft.modding.event.events.blocks.BlocksSetEvent
|
||||
import de.bixilon.minosoft.modding.event.events.blocks.chunk.ChunkDataChangeEvent
|
||||
import de.bixilon.minosoft.modding.event.events.blocks.chunk.ChunkUnloadEvent
|
||||
import de.bixilon.minosoft.modding.event.events.blocks.chunk.LightChangeEvent
|
||||
import de.bixilon.minosoft.modding.event.invoker.CallbackEventInvoker
|
||||
import de.bixilon.minosoft.modding.event.listener.CallbackEventListener
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnectionStates
|
||||
import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition
|
||||
@ -165,11 +164,11 @@ class WorldRenderer(
|
||||
loadWorldShader(this.textShader, false)
|
||||
|
||||
|
||||
connection.registerEvent(CallbackEventInvoker.of<VisibilityGraphChangeEvent> { onFrustumChange() })
|
||||
connection.register(CallbackEventListener.of<VisibilityGraphChangeEvent> { onFrustumChange() })
|
||||
|
||||
connection.registerEvent(CallbackEventInvoker.of<RespawnEvent> { unloadWorld() })
|
||||
connection.registerEvent(CallbackEventInvoker.of<ChunkDataChangeEvent> { queueChunk(it.chunkPosition, it.chunk) })
|
||||
connection.registerEvent(CallbackEventInvoker.of<BlockSetEvent> {
|
||||
connection.register(CallbackEventListener.of<RespawnEvent> { unloadWorld() })
|
||||
connection.register(CallbackEventListener.of<ChunkDataChangeEvent> { queueChunk(it.chunkPosition, it.chunk) })
|
||||
connection.register(CallbackEventListener.of<BlockSetEvent> {
|
||||
val chunkPosition = it.blockPosition.chunkPosition
|
||||
val sectionHeight = it.blockPosition.sectionHeight
|
||||
val chunk = world[chunkPosition] ?: return@of
|
||||
@ -194,7 +193,7 @@ class WorldRenderer(
|
||||
}
|
||||
})
|
||||
|
||||
connection.registerEvent(CallbackEventInvoker.of<LightChangeEvent> {
|
||||
connection.register(CallbackEventListener.of<LightChangeEvent> {
|
||||
if (it.blockChange) {
|
||||
// change is already covered
|
||||
return@of
|
||||
@ -202,7 +201,7 @@ class WorldRenderer(
|
||||
queueSection(it.chunkPosition, it.sectionHeight, it.chunk)
|
||||
})
|
||||
|
||||
connection.registerEvent(CallbackEventInvoker.of<BlocksSetEvent> {
|
||||
connection.register(CallbackEventListener.of<BlocksSetEvent> {
|
||||
val chunk = world[it.chunkPosition] ?: return@of // should not happen
|
||||
if (!chunk.isFullyLoaded) {
|
||||
return@of
|
||||
@ -252,16 +251,20 @@ class WorldRenderer(
|
||||
}
|
||||
})
|
||||
|
||||
connection.registerEvent(CallbackEventInvoker.of<ChunkUnloadEvent> { unloadChunk(it.chunkPosition) })
|
||||
connection.register(CallbackEventListener.of<ChunkUnloadEvent> { unloadChunk(it.chunkPosition) })
|
||||
connection::state.observe(this) { if (it == PlayConnectionStates.DISCONNECTED) unloadWorld() }
|
||||
connection.registerEvent(CallbackEventInvoker.of<RenderingStateChangeEvent> {
|
||||
if (it.state == RenderingStates.PAUSED) {
|
||||
|
||||
var paused = false
|
||||
renderWindow::state.observe(this) {
|
||||
if (it == RenderingStates.PAUSED) {
|
||||
unloadWorld()
|
||||
} else if (it.previousState == RenderingStates.PAUSED) {
|
||||
paused = true
|
||||
} else if (paused) {
|
||||
prepareWorld()
|
||||
paused = false
|
||||
}
|
||||
})
|
||||
connection.registerEvent(CallbackEventInvoker.of<BlockDataChangeEvent> { queueSection(it.blockPosition.chunkPosition, it.blockPosition.sectionHeight) })
|
||||
}
|
||||
connection.register(CallbackEventListener.of<BlockDataChangeEvent> { queueSection(it.blockPosition.chunkPosition, it.blockPosition.sectionHeight) })
|
||||
|
||||
renderWindow.inputHandler.registerKeyCallback(
|
||||
"minosoft:clear_chunk_cache".toResourceLocation(),
|
||||
@ -601,7 +604,7 @@ class WorldRenderer(
|
||||
}
|
||||
|
||||
private fun queueSection(chunkPosition: Vec2i, sectionHeight: Int, chunk: Chunk? = world.chunks[chunkPosition], section: ChunkSection? = chunk?.get(sectionHeight), ignoreFrustum: Boolean = false, neighbours: Array<Chunk>? = chunk?.neighbours?.get()) {
|
||||
if (chunk == null || neighbours == null || section == null || renderWindow.renderingState == RenderingStates.PAUSED) {
|
||||
if (chunk == null || neighbours == null || section == null || renderWindow.state == RenderingStates.PAUSED) {
|
||||
return
|
||||
}
|
||||
val queued = internalQueueSection(chunkPosition, sectionHeight, chunk, section, ignoreFrustum, neighbours)
|
||||
@ -614,7 +617,7 @@ class WorldRenderer(
|
||||
|
||||
private fun queueChunk(chunkPosition: Vec2i, chunk: Chunk = world.chunks[chunkPosition]!!) {
|
||||
val neighbours = chunk.neighbours.get()
|
||||
if (neighbours == null || !chunk.isFullyLoaded || renderWindow.renderingState == RenderingStates.PAUSED) {
|
||||
if (neighbours == null || !chunk.isFullyLoaded || renderWindow.state == RenderingStates.PAUSED) {
|
||||
return
|
||||
}
|
||||
this.loadedMeshesLock.acquire()
|
||||
|
@ -309,7 +309,7 @@ class WorldVisibilityGraph(
|
||||
@Synchronized
|
||||
private fun calculateGraph() {
|
||||
if (!RenderConstants.OCCLUSION_CULLING_ENABLED) {
|
||||
connection.fireEvent(VisibilityGraphChangeEvent(renderWindow))
|
||||
connection.fire(VisibilityGraphChangeEvent(renderWindow))
|
||||
return
|
||||
}
|
||||
connection.world.chunks.lock.acquire()
|
||||
@ -351,7 +351,7 @@ class WorldVisibilityGraph(
|
||||
|
||||
connection.world.chunks.lock.release()
|
||||
|
||||
connection.fireEvent(VisibilityGraphChangeEvent(renderWindow))
|
||||
connection.fire(VisibilityGraphChangeEvent(renderWindow))
|
||||
}
|
||||
|
||||
override fun onOcclusionChange() {
|
||||
|
@ -1,30 +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.modding.event
|
||||
|
||||
import de.bixilon.kutil.enums.EnumUtil
|
||||
import de.bixilon.kutil.enums.ValuesEnum
|
||||
|
||||
enum class EventInitiators {
|
||||
CLIENT,
|
||||
SERVER,
|
||||
UNKNOWN,
|
||||
;
|
||||
|
||||
companion object : ValuesEnum<EventInitiators> {
|
||||
override val VALUES: Array<EventInitiators> = values()
|
||||
override val NAME_MAP: Map<String, EventInitiators> = EnumUtil.getEnumValues(VALUES)
|
||||
val DEFAULT = UNKNOWN
|
||||
}
|
||||
}
|
@ -13,18 +13,16 @@
|
||||
package de.bixilon.minosoft.modding.event.events
|
||||
|
||||
import de.bixilon.kotlinglm.vec3.Vec3i
|
||||
import de.bixilon.minosoft.modding.event.EventInitiators
|
||||
import de.bixilon.minosoft.modding.event.events.connection.play.PlayConnectionEvent
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||
import de.bixilon.minosoft.protocol.packets.s2c.play.block.BlockBreakAnimationS2CP
|
||||
|
||||
class BlockBreakAnimationEvent(
|
||||
connection: PlayConnection,
|
||||
initiator: EventInitiators,
|
||||
val entityId: Int,
|
||||
val blockPosition: Vec3i,
|
||||
val stage: Int,
|
||||
) : PlayConnectionEvent(connection, initiator), CancelableEvent {
|
||||
) : PlayConnectionEvent(connection), CancelableEvent {
|
||||
|
||||
constructor(connection: PlayConnection, packet: BlockBreakAnimationS2CP) : this(connection, EventInitiators.SERVER, packet.entityId, packet.blockPosition, packet.stage)
|
||||
constructor(connection: PlayConnection, packet: BlockBreakAnimationS2CP) : this(connection, packet.entityId, packet.blockPosition, packet.stage)
|
||||
}
|
||||
|
@ -14,18 +14,16 @@ package de.bixilon.minosoft.modding.event.events
|
||||
|
||||
import de.bixilon.kutil.cast.CastUtil.unsafeCast
|
||||
import de.bixilon.minosoft.data.entities.entities.Entity
|
||||
import de.bixilon.minosoft.modding.event.EventInitiators
|
||||
import de.bixilon.minosoft.modding.event.events.connection.play.PlayConnectionEvent
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||
import de.bixilon.minosoft.protocol.packets.s2c.play.entity.EntityCollectS2CP
|
||||
|
||||
class CollectItemAnimationEvent(
|
||||
connection: PlayConnection,
|
||||
initiator: EventInitiators,
|
||||
val collectedEntity: Entity,
|
||||
val collector: Entity,
|
||||
val count: Int,
|
||||
) : PlayConnectionEvent(connection, initiator), CancelableEvent {
|
||||
) : PlayConnectionEvent(connection), CancelableEvent {
|
||||
|
||||
constructor(connection: PlayConnection, packet: EntityCollectS2CP) : this(connection, EventInitiators.SERVER, connection.world.entities[packet.itemEntityId].unsafeCast<Entity>(), connection.world.entities[packet.collectorEntityId].unsafeCast<Entity>(), packet.count)
|
||||
constructor(connection: PlayConnection, packet: EntityCollectS2CP) : this(connection, connection.world.entities[packet.itemEntityId].unsafeCast<Entity>(), connection.world.entities[packet.collectorEntityId].unsafeCast<Entity>(), packet.count)
|
||||
}
|
||||
|
@ -13,17 +13,15 @@
|
||||
package de.bixilon.minosoft.modding.event.events
|
||||
|
||||
import de.bixilon.kotlinglm.vec3.Vec3i
|
||||
import de.bixilon.minosoft.modding.event.EventInitiators
|
||||
import de.bixilon.minosoft.modding.event.events.connection.play.PlayConnectionEvent
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||
import de.bixilon.minosoft.protocol.packets.s2c.play.CompassPositionS2CP
|
||||
|
||||
class CompassPositionChangeEvent(
|
||||
connection: PlayConnection,
|
||||
initiator: EventInitiators,
|
||||
val spawnPosition: Vec3i,
|
||||
val angle: Float,
|
||||
) : PlayConnectionEvent(connection, initiator) {
|
||||
) : PlayConnectionEvent(connection) {
|
||||
|
||||
constructor(connection: PlayConnection, packet: CompassPositionS2CP) : this(connection, EventInitiators.SERVER, packet.spawnPosition, packet.angle)
|
||||
constructor(connection: PlayConnection, packet: CompassPositionS2CP) : this(connection, packet.spawnPosition, packet.angle)
|
||||
}
|
||||
|
@ -1,29 +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.modding.event.events
|
||||
|
||||
import de.bixilon.minosoft.data.Difficulties
|
||||
import de.bixilon.minosoft.modding.event.EventInitiators
|
||||
import de.bixilon.minosoft.modding.event.events.connection.play.PlayConnectionEvent
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||
import de.bixilon.minosoft.protocol.packets.s2c.play.DifficultyS2CP
|
||||
|
||||
class DifficultyChangeEvent(
|
||||
connection: PlayConnection,
|
||||
initiator: EventInitiators = EventInitiators.DEFAULT,
|
||||
val difficulty: Difficulties,
|
||||
val locked: Boolean,
|
||||
) : PlayConnectionEvent(connection, initiator) {
|
||||
|
||||
constructor(connection: PlayConnection, packet: DifficultyS2CP) : this(connection, EventInitiators.SERVER, packet.difficulty, packet.locked)
|
||||
}
|
@ -13,16 +13,14 @@
|
||||
package de.bixilon.minosoft.modding.event.events
|
||||
|
||||
import de.bixilon.minosoft.data.entities.entities.Entity
|
||||
import de.bixilon.minosoft.modding.event.EventInitiators
|
||||
import de.bixilon.minosoft.modding.event.events.connection.play.PlayConnectionEvent
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||
import de.bixilon.minosoft.protocol.packets.s2c.play.entity.EntityDataS2CP
|
||||
|
||||
class EntityDataChangeEvent(
|
||||
connection: PlayConnection,
|
||||
initiator: EventInitiators,
|
||||
val entity: Entity,
|
||||
) : PlayConnectionEvent(connection, initiator) {
|
||||
) : PlayConnectionEvent(connection) {
|
||||
|
||||
constructor(connection: PlayConnection, packet: EntityDataS2CP) : this(connection, EventInitiators.SERVER, connection.world.entities[packet.entityId]!!)
|
||||
constructor(connection: PlayConnection, packet: EntityDataS2CP) : this(connection, connection.world.entities[packet.entityId]!!)
|
||||
}
|
||||
|
@ -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.
|
||||
*
|
||||
@ -13,12 +13,10 @@
|
||||
package de.bixilon.minosoft.modding.event.events
|
||||
|
||||
import de.bixilon.minosoft.data.entities.entities.Entity
|
||||
import de.bixilon.minosoft.modding.event.EventInitiators
|
||||
import de.bixilon.minosoft.modding.event.events.connection.play.PlayConnectionEvent
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||
|
||||
class EntityDestroyEvent(
|
||||
connection: PlayConnection,
|
||||
initiator: EventInitiators,
|
||||
val entity: Entity,
|
||||
) : PlayConnectionEvent(connection, initiator)
|
||||
) : PlayConnectionEvent(connection)
|
||||
|
@ -15,17 +15,15 @@ package de.bixilon.minosoft.modding.event.events
|
||||
import de.bixilon.minosoft.data.container.InventorySlots.EquipmentSlots
|
||||
import de.bixilon.minosoft.data.container.stack.ItemStack
|
||||
import de.bixilon.minosoft.data.entities.entities.Entity
|
||||
import de.bixilon.minosoft.modding.event.EventInitiators
|
||||
import de.bixilon.minosoft.modding.event.events.connection.play.PlayConnectionEvent
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||
import de.bixilon.minosoft.protocol.packets.s2c.play.entity.EntityEquipmentS2CP
|
||||
|
||||
class EntityEquipmentChangeEvent(
|
||||
connection: PlayConnection,
|
||||
initiator: EventInitiators,
|
||||
val entity: Entity,
|
||||
val equipment: Map<EquipmentSlots, ItemStack?>,
|
||||
) : PlayConnectionEvent(connection, initiator) {
|
||||
) : PlayConnectionEvent(connection) {
|
||||
|
||||
constructor(connection: PlayConnection, packet: EntityEquipmentS2CP) : this(connection, EventInitiators.SERVER, connection.world.entities[packet.entityId]!!, packet.equipment)
|
||||
constructor(connection: PlayConnection, packet: EntityEquipmentS2CP) : this(connection, connection.world.entities[packet.entityId]!!, packet.equipment)
|
||||
}
|
||||
|
@ -13,7 +13,6 @@
|
||||
package de.bixilon.minosoft.modding.event.events
|
||||
|
||||
import de.bixilon.minosoft.data.entities.entities.Entity
|
||||
import de.bixilon.minosoft.modding.event.EventInitiators
|
||||
import de.bixilon.minosoft.modding.event.events.connection.play.PlayConnectionEvent
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||
import de.bixilon.minosoft.protocol.packets.s2c.play.entity.EntityPlayerS2CP
|
||||
@ -21,19 +20,18 @@ import de.bixilon.minosoft.protocol.packets.s2c.play.entity.spawn.*
|
||||
|
||||
class EntitySpawnEvent(
|
||||
connection: PlayConnection,
|
||||
initiator: EventInitiators,
|
||||
val entity: Entity,
|
||||
) : PlayConnectionEvent(connection, initiator) {
|
||||
) : PlayConnectionEvent(connection) {
|
||||
|
||||
constructor(connection: PlayConnection, packet: EntityMobSpawnS2CP) : this(connection, EventInitiators.SERVER, packet.entity)
|
||||
constructor(connection: PlayConnection, packet: EntityMobSpawnS2CP) : this(connection, packet.entity)
|
||||
|
||||
constructor(connection: PlayConnection, packet: GlobalEntitySpawnS2CP) : this(connection, EventInitiators.SERVER, packet.entity)
|
||||
constructor(connection: PlayConnection, packet: GlobalEntitySpawnS2CP) : this(connection, packet.entity)
|
||||
|
||||
constructor(connection: PlayConnection, packet: EntityPlayerS2CP) : this(connection, EventInitiators.SERVER, packet.entity)
|
||||
constructor(connection: PlayConnection, packet: EntityPlayerS2CP) : this(connection, packet.entity)
|
||||
|
||||
constructor(connection: PlayConnection, packet: EntityExperienceOrbS2CP) : this(connection, EventInitiators.SERVER, packet.entity)
|
||||
constructor(connection: PlayConnection, packet: EntityExperienceOrbS2CP) : this(connection, packet.entity)
|
||||
|
||||
constructor(connection: PlayConnection, packet: EntityObjectSpawnS2CP) : this(connection, EventInitiators.SERVER, packet.entity)
|
||||
constructor(connection: PlayConnection, packet: EntityObjectSpawnS2CP) : this(connection, packet.entity)
|
||||
|
||||
constructor(connection: PlayConnection, packet: EntityPaintingS2CP) : this(connection, EventInitiators.SERVER, packet.entity)
|
||||
constructor(connection: PlayConnection, packet: EntityPaintingS2CP) : this(connection, packet.entity)
|
||||
}
|
||||
|
@ -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.
|
||||
*
|
||||
@ -13,7 +13,6 @@
|
||||
package de.bixilon.minosoft.modding.event.events
|
||||
|
||||
import de.bixilon.minosoft.data.entities.entities.Entity
|
||||
import de.bixilon.minosoft.modding.event.EventInitiators
|
||||
import de.bixilon.minosoft.modding.event.events.connection.play.PlayConnectionEvent
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||
import de.bixilon.minosoft.protocol.packets.s2c.play.CameraS2CP
|
||||
@ -23,9 +22,8 @@ import de.bixilon.minosoft.protocol.packets.s2c.play.CameraS2CP
|
||||
*/
|
||||
class EntitySpectateEvent(
|
||||
connection: PlayConnection,
|
||||
initiator: EventInitiators,
|
||||
val entity: Entity,
|
||||
) : PlayConnectionEvent(connection, initiator) {
|
||||
) : PlayConnectionEvent(connection) {
|
||||
|
||||
constructor(connection: PlayConnection, packet: CameraS2CP) : this(connection, EventInitiators.SERVER, connection.world.entities[packet.entityId]!!)
|
||||
constructor(connection: PlayConnection, packet: CameraS2CP) : this(connection, connection.world.entities[packet.entityId]!!)
|
||||
}
|
||||
|
@ -1,29 +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.modding.event.events
|
||||
|
||||
import de.bixilon.minosoft.modding.event.EventInitiators
|
||||
import de.bixilon.minosoft.modding.event.events.connection.play.PlayConnectionEvent
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||
import de.bixilon.minosoft.protocol.packets.s2c.play.ExperienceS2CP
|
||||
|
||||
class ExperienceChangeEvent(
|
||||
connection: PlayConnection,
|
||||
initiator: EventInitiators,
|
||||
val bar: Float,
|
||||
val level: Int,
|
||||
val total: Int,
|
||||
) : PlayConnectionEvent(connection, initiator) {
|
||||
|
||||
constructor(connection: PlayConnection, packet: ExperienceS2CP) : this(connection, EventInitiators.SERVER, packet.bar, packet.level, packet.total)
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user