mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-14 09:56:37 -04:00
reset abilities when changing gamemode
This commit is contained in:
parent
b094d140f4
commit
fa2a73e29d
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Minosoft
|
* 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.
|
* 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.EnumUtil
|
||||||
import de.bixilon.kutil.enums.ValuesEnum
|
import de.bixilon.kutil.enums.ValuesEnum
|
||||||
|
import de.bixilon.minosoft.data.entities.entities.player.local.Abilities
|
||||||
|
|
||||||
enum class Gamemodes(
|
enum class Gamemodes(
|
||||||
val canBuild: Boolean,
|
val canBuild: Boolean,
|
||||||
@ -21,6 +22,7 @@ enum class Gamemodes(
|
|||||||
val useTools: Boolean,
|
val useTools: Boolean,
|
||||||
val canInteract: InteractionAbilities,
|
val canInteract: InteractionAbilities,
|
||||||
val survival: Boolean,
|
val survival: Boolean,
|
||||||
|
val abilities: Abilities,
|
||||||
) {
|
) {
|
||||||
SURVIVAL(
|
SURVIVAL(
|
||||||
canBuild = true,
|
canBuild = true,
|
||||||
@ -28,6 +30,7 @@ enum class Gamemodes(
|
|||||||
useTools = true,
|
useTools = true,
|
||||||
canInteract = InteractionAbilities.EVERYTHING,
|
canInteract = InteractionAbilities.EVERYTHING,
|
||||||
survival = true,
|
survival = true,
|
||||||
|
Abilities(),
|
||||||
),
|
),
|
||||||
CREATIVE(
|
CREATIVE(
|
||||||
canBuild = true,
|
canBuild = true,
|
||||||
@ -35,6 +38,7 @@ enum class Gamemodes(
|
|||||||
useTools = true,
|
useTools = true,
|
||||||
canInteract = InteractionAbilities.EVERYTHING,
|
canInteract = InteractionAbilities.EVERYTHING,
|
||||||
survival = false,
|
survival = false,
|
||||||
|
Abilities(true, true, true),
|
||||||
),
|
),
|
||||||
ADVENTURE(
|
ADVENTURE(
|
||||||
canBuild = false,
|
canBuild = false,
|
||||||
@ -42,6 +46,7 @@ enum class Gamemodes(
|
|||||||
useTools = false,
|
useTools = false,
|
||||||
canInteract = InteractionAbilities.ONLY_ENTITIES,
|
canInteract = InteractionAbilities.ONLY_ENTITIES,
|
||||||
survival = true,
|
survival = true,
|
||||||
|
Abilities(),
|
||||||
),
|
),
|
||||||
SPECTATOR(
|
SPECTATOR(
|
||||||
canBuild = false,
|
canBuild = false,
|
||||||
@ -49,6 +54,7 @@ enum class Gamemodes(
|
|||||||
useTools = false,
|
useTools = false,
|
||||||
canInteract = InteractionAbilities.ONLY_ENTITIES,
|
canInteract = InteractionAbilities.ONLY_ENTITIES,
|
||||||
survival = false,
|
survival = false,
|
||||||
|
Abilities(true, true, true),
|
||||||
),
|
),
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -29,5 +29,6 @@ object GamemodeChangeHandler : GameEventHandler {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
connection.player.additional.gamemode = next
|
connection.player.additional.gamemode = next
|
||||||
|
connection.player.abilities = next.abilities
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -169,6 +169,7 @@ class InitializeS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
|||||||
|
|
||||||
if (previousGamemode != gamemode) {
|
if (previousGamemode != gamemode) {
|
||||||
playerEntity.additional.gamemode = gamemode
|
playerEntity.additional.gamemode = gamemode
|
||||||
|
playerEntity.abilities = gamemode.abilities
|
||||||
}
|
}
|
||||||
|
|
||||||
connection.world.hardcore = isHardcore
|
connection.world.hardcore = isHardcore
|
||||||
|
@ -107,6 +107,7 @@ class RespawnS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
|||||||
override fun handle(connection: PlayConnection) {
|
override fun handle(connection: PlayConnection) {
|
||||||
connection.util.prepareSpawn()
|
connection.util.prepareSpawn()
|
||||||
connection.player.additional.gamemode = gamemode
|
connection.player.additional.gamemode = gamemode
|
||||||
|
connection.player.abilities = gamemode.abilities
|
||||||
val dimensionChange = this.dimension != connection.world.dimension || this.world != connection.world.name
|
val dimensionChange = this.dimension != connection.world.dimension || this.world != connection.world.name
|
||||||
if (dimensionChange) {
|
if (dimensionChange) {
|
||||||
connection.util.resetWorld()
|
connection.util.resetWorld()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user