mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-14 18:05:51 -04:00
reset abilities when changing gamemode
This commit is contained in:
parent
b094d140f4
commit
fa2a73e29d
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2021 Moritz Zwerger
|
||||
* Copyright (C) 2020-2023 Moritz Zwerger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
@ -14,6 +14,7 @@ package de.bixilon.minosoft.data.abilities
|
||||
|
||||
import de.bixilon.kutil.enums.EnumUtil
|
||||
import de.bixilon.kutil.enums.ValuesEnum
|
||||
import de.bixilon.minosoft.data.entities.entities.player.local.Abilities
|
||||
|
||||
enum class Gamemodes(
|
||||
val canBuild: Boolean,
|
||||
@ -21,6 +22,7 @@ enum class Gamemodes(
|
||||
val useTools: Boolean,
|
||||
val canInteract: InteractionAbilities,
|
||||
val survival: Boolean,
|
||||
val abilities: Abilities,
|
||||
) {
|
||||
SURVIVAL(
|
||||
canBuild = true,
|
||||
@ -28,6 +30,7 @@ enum class Gamemodes(
|
||||
useTools = true,
|
||||
canInteract = InteractionAbilities.EVERYTHING,
|
||||
survival = true,
|
||||
Abilities(),
|
||||
),
|
||||
CREATIVE(
|
||||
canBuild = true,
|
||||
@ -35,6 +38,7 @@ enum class Gamemodes(
|
||||
useTools = true,
|
||||
canInteract = InteractionAbilities.EVERYTHING,
|
||||
survival = false,
|
||||
Abilities(true, true, true),
|
||||
),
|
||||
ADVENTURE(
|
||||
canBuild = false,
|
||||
@ -42,6 +46,7 @@ enum class Gamemodes(
|
||||
useTools = false,
|
||||
canInteract = InteractionAbilities.ONLY_ENTITIES,
|
||||
survival = true,
|
||||
Abilities(),
|
||||
),
|
||||
SPECTATOR(
|
||||
canBuild = false,
|
||||
@ -49,6 +54,7 @@ enum class Gamemodes(
|
||||
useTools = false,
|
||||
canInteract = InteractionAbilities.ONLY_ENTITIES,
|
||||
survival = false,
|
||||
Abilities(true, true, true),
|
||||
),
|
||||
;
|
||||
|
||||
|
@ -29,5 +29,6 @@ object GamemodeChangeHandler : GameEventHandler {
|
||||
return
|
||||
}
|
||||
connection.player.additional.gamemode = next
|
||||
connection.player.abilities = next.abilities
|
||||
}
|
||||
}
|
||||
|
@ -169,6 +169,7 @@ class InitializeS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||
|
||||
if (previousGamemode != gamemode) {
|
||||
playerEntity.additional.gamemode = gamemode
|
||||
playerEntity.abilities = gamemode.abilities
|
||||
}
|
||||
|
||||
connection.world.hardcore = isHardcore
|
||||
|
@ -107,6 +107,7 @@ class RespawnS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||
override fun handle(connection: PlayConnection) {
|
||||
connection.util.prepareSpawn()
|
||||
connection.player.additional.gamemode = gamemode
|
||||
connection.player.abilities = gamemode.abilities
|
||||
val dimensionChange = this.dimension != connection.world.dimension || this.world != connection.world.name
|
||||
if (dimensionChange) {
|
||||
connection.util.resetWorld()
|
||||
|
Loading…
x
Reference in New Issue
Block a user