mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-08 14:59:16 -04:00
fix gamemode handling
This commit is contained in:
parent
f1c932a68a
commit
4db63f37f5
@ -231,7 +231,7 @@ class WorldRenderer(
|
||||
}
|
||||
|
||||
private fun updateSectionSync(chunkPosition: Vec2i, sectionHeight: Int, chunk: Chunk, meshes: SynchronizedMap<Int, ChunkSectionMeshes>) {
|
||||
if (!chunk.isFullyLoaded || incomplete.contains(chunkPosition)) {
|
||||
if (!chunk.isFullyLoaded || chunkPosition in incomplete) {
|
||||
// chunk not loaded and/or neighbours also not fully loaded
|
||||
return
|
||||
}
|
||||
@ -339,7 +339,7 @@ class WorldRenderer(
|
||||
|
||||
for ((chunkPosition, sectionHeights) in this.queue.toSynchronizedMap()) {
|
||||
val chunk = world[chunkPosition]
|
||||
if (chunk == null) {
|
||||
if (chunk == null || !chunk.isFullyLoaded || chunkPosition in incomplete) {
|
||||
this.queue.remove(chunkPosition)
|
||||
continue
|
||||
}
|
||||
|
@ -17,10 +17,9 @@ import de.bixilon.minosoft.Minosoft
|
||||
import de.bixilon.minosoft.config.key.KeyAction
|
||||
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.direction.Directions
|
||||
import de.bixilon.minosoft.data.registries.ResourceLocation
|
||||
import de.bixilon.minosoft.data.registries.other.game.event.handlers.gamemode.GamemodeChangeGameEventHandler
|
||||
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.ChatColors
|
||||
import de.bixilon.minosoft.data.text.TextComponent
|
||||
@ -41,7 +40,6 @@ 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.modding.event.events.DifficultyChangeEvent
|
||||
import de.bixilon.minosoft.modding.event.events.GameEventChangeEvent
|
||||
import de.bixilon.minosoft.modding.event.events.TimeChangeEvent
|
||||
import de.bixilon.minosoft.modding.event.invoker.CallbackEventInvoker
|
||||
import de.bixilon.minosoft.modding.loading.ModLoader
|
||||
@ -152,12 +150,8 @@ class DebugHUDElement(hudRenderer: HUDRenderer) : LayoutedHUDElement<GridLayout>
|
||||
layout += LineSpacerElement(hudRenderer)
|
||||
|
||||
layout += TextElement(hudRenderer, BaseComponent("Gamemode ", connection.player.gamemode)).apply {
|
||||
connection.registerEvent(CallbackEventInvoker.of<GameEventChangeEvent> {
|
||||
if (it.event.resourceLocation != GamemodeChangeGameEventHandler.RESOURCE_LOCATION) {
|
||||
return@of
|
||||
}
|
||||
// ToDo: Improve game mode change event
|
||||
text = BaseComponent("Gamemode ", Gamemodes[it.data.toInt()])
|
||||
connection.registerEvent(CallbackEventInvoker.of<GamemodeChangeEvent> {
|
||||
text = BaseComponent("Gamemode ", it.gamemode)
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -147,6 +147,7 @@ class JoinGameS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
||||
}
|
||||
|
||||
override fun handle(connection: PlayConnection) {
|
||||
val gamemode = Gamemodes.SPECTATOR
|
||||
val playerEntity = connection.player
|
||||
val previousGamemode = playerEntity.tabListItem.gamemode
|
||||
|
||||
|
@ -169,13 +169,13 @@ class TabListDataS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
||||
entity.tabListItem.specialMerge(data)
|
||||
} else {
|
||||
tabListItem.merge(data)
|
||||
}
|
||||
|
||||
if (entity == null || entity !is PlayerEntity) {
|
||||
continue
|
||||
if (entity == null || entity !is PlayerEntity) {
|
||||
continue
|
||||
}
|
||||
|
||||
entity.tabListItem = tabListItem
|
||||
}
|
||||
|
||||
entity.tabListItem = tabListItem
|
||||
}
|
||||
connection.fireEvent(TabListEntryChangeEvent(connection, this))
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user