replace Abilities::creative with gamemode

This commit is contained in:
Bixilon 2023-01-17 23:45:32 +01:00
parent fbcd7e75de
commit a383d5972c
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
4 changed files with 9 additions and 11 deletions

View File

@ -1,6 +1,6 @@
/* /*
* Minosoft * Minosoft
* Copyright (C) 2020-2022 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.
* *
@ -17,7 +17,6 @@ data class Abilities(
var isInvulnerable: Boolean = false, var isInvulnerable: Boolean = false,
var isFlying: Boolean = false, var isFlying: Boolean = false,
var canFly: Boolean = false, var canFly: Boolean = false,
var creative: Boolean = false, // ToDo: This is the check if we are in creative mode, but no exactly sure...
var flyingSpeed: Double = 0.05, var flyingSpeed: Double = 0.05,
var walkingSpeed: Double = 0.1, var walkingSpeed: Double = 0.1,

View File

@ -142,9 +142,8 @@ class BreakInteractionHandler(
val canStartBreaking = currentTime - breakSent >= ProtocolDefinition.TICK_TIME val canStartBreaking = currentTime - breakSent >= ProtocolDefinition.TICK_TIME
val canInstantBreak = connection.player.baseAbilities.creative || connection.player.gamemode == Gamemodes.CREATIVE
if (canInstantBreak) { if (connection.player.gamemode == Gamemodes.CREATIVE) {
if (!canStartBreaking) { if (!canStartBreaking) {
return true return true
} }

View File

@ -1,6 +1,6 @@
/* /*
* Minosoft * Minosoft
* Copyright (C) 2020-2022 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.
* *
@ -17,6 +17,7 @@ import de.bixilon.kutil.rate.RateLimiter
import de.bixilon.minosoft.config.key.KeyActions import de.bixilon.minosoft.config.key.KeyActions
import de.bixilon.minosoft.config.key.KeyBinding import de.bixilon.minosoft.config.key.KeyBinding
import de.bixilon.minosoft.config.key.KeyCodes import de.bixilon.minosoft.config.key.KeyCodes
import de.bixilon.minosoft.data.abilities.Gamemodes
import de.bixilon.minosoft.data.container.EquipmentSlots import de.bixilon.minosoft.data.container.EquipmentSlots
import de.bixilon.minosoft.data.container.ItemStackUtil import de.bixilon.minosoft.data.container.ItemStackUtil
import de.bixilon.minosoft.data.container.stack.ItemStack import de.bixilon.minosoft.data.container.stack.ItemStack
@ -44,7 +45,7 @@ class ItemPickInteractionHandler(
} }
fun pickItem(copyNBT: Boolean) { fun pickItem(copyNBT: Boolean) {
if (!connection.player.baseAbilities.creative) { if (connection.player.gamemode != Gamemodes.CREATIVE) {
return return
} }
val target = context.camera.targetHandler.target ?: return val target = context.camera.targetHandler.target ?: return

View File

@ -27,7 +27,7 @@ class PlayerAbilitiesS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
val isInvulnerable: Boolean val isInvulnerable: Boolean
val isFlying: Boolean val isFlying: Boolean
val canFly: Boolean val canFly: Boolean
val canInstantBuild: Boolean val creative: Boolean
val flyingSpeed: Double val flyingSpeed: Double
val walkingSpeed: Double val walkingSpeed: Double
@ -38,9 +38,9 @@ class PlayerAbilitiesS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
canFly = flags.isBit(2) canFly = flags.isBit(2)
if (buffer.versionId < ProtocolVersions.V_14W03B) { // ToDo: Find out correct version if (buffer.versionId < ProtocolVersions.V_14W03B) { // ToDo: Find out correct version
isInvulnerable = flags.isBit(0) isInvulnerable = flags.isBit(0)
canInstantBuild = flags.isBit(3) creative = flags.isBit(3)
} else { } else {
canInstantBuild = flags.isBit(0) creative = flags.isBit(0)
isInvulnerable = flags.isBit(3) isInvulnerable = flags.isBit(3)
} }
flyingSpeed = buffer.readFloat().toDouble() flyingSpeed = buffer.readFloat().toDouble()
@ -48,7 +48,7 @@ class PlayerAbilitiesS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
} }
override fun log(reducedLog: Boolean) { override fun log(reducedLog: Boolean) {
Log.log(LogMessageType.NETWORK_PACKETS_IN, level = LogLevels.VERBOSE) { "Player abilities (isInvulnerable=$isInvulnerable, isFlying=$isFlying, canFly=$canFly, canInstantBuild=$canInstantBuild, flyingSpeed=$flyingSpeed, walkingSpeed=$walkingSpeed)" } Log.log(LogMessageType.NETWORK_PACKETS_IN, level = LogLevels.VERBOSE) { "Player abilities (isInvulnerable=$isInvulnerable, isFlying=$isFlying, canFly=$canFly, canInstantBuild=$creative, flyingSpeed=$flyingSpeed, walkingSpeed=$walkingSpeed)" }
} }
override fun handle(connection: PlayConnection) { override fun handle(connection: PlayConnection) {
@ -57,7 +57,6 @@ class PlayerAbilitiesS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
abilities.isInvulnerable = isInvulnerable abilities.isInvulnerable = isInvulnerable
abilities.isFlying = isFlying abilities.isFlying = isFlying
abilities.canFly = canFly abilities.canFly = canFly
abilities.creative = canInstantBuild
abilities.flyingSpeed = flyingSpeed abilities.flyingSpeed = flyingSpeed
abilities.walkingSpeed = walkingSpeed abilities.walkingSpeed = walkingSpeed