forked from mirrors/cobblemon
fix size categories not working properly on servers with non-default scales
Closes #2022 Signed-off-by: Polymeta <4726322-polymeta@users.noreply.gitlab.com>
This commit is contained in:
+2
@@ -22,6 +22,8 @@ object ServerSettingsPacketHandler : ClientNetworkPacketHandler<ServerSettingsPa
|
||||
ServerSettings.maxPokemonFriendship = packet.maxPokemonFriendship
|
||||
ServerSettings.maxDynamaxLevel = packet.maxDynamaxLevel
|
||||
ServerSettings.unlockAllMoveDexMovesByDefault = packet.unlockAllMoveDexMovesByDefault
|
||||
ServerSettings.pokemonIntrinsicSizeMin = packet.pokemonIntrinsicSizeMin
|
||||
ServerSettings.pokemonIntrinsicSizeMax = packet.pokemonIntrinsicSizeMax
|
||||
}
|
||||
|
||||
}
|
||||
@@ -28,5 +28,7 @@ object ServerSettings {
|
||||
var maxPokemonFriendship = Cobblemon.config.maxPokemonFriendship
|
||||
var maxDynamaxLevel = Cobblemon.config.maxDynamaxLevel
|
||||
var unlockAllMoveDexMovesByDefault = Cobblemon.config.unlockAllMoveDexMovesByDefault
|
||||
var pokemonIntrinsicSizeMin = Cobblemon.config.pokemonIntrinsicSizeMin
|
||||
var pokemonIntrinsicSizeMax = Cobblemon.config.pokemonIntrinsicSizeMax
|
||||
|
||||
}
|
||||
+9
-2
@@ -26,7 +26,9 @@ class ServerSettingsPacket internal constructor(
|
||||
val maxPokemonLevel: Int,
|
||||
val maxPokemonFriendship: Int,
|
||||
val maxDynamaxLevel: Int,
|
||||
val unlockAllMoveDexMovesByDefault: Boolean
|
||||
val unlockAllMoveDexMovesByDefault: Boolean,
|
||||
val pokemonIntrinsicSizeMin: Float,
|
||||
val pokemonIntrinsicSizeMax: Float
|
||||
) : NetworkPacket<ServerSettingsPacket> {
|
||||
override val id = ID
|
||||
override fun encode(buffer: RegistryFriendlyByteBuf) {
|
||||
@@ -37,9 +39,14 @@ class ServerSettingsPacket internal constructor(
|
||||
buffer.writeInt(Cobblemon.config.maxPokemonFriendship)
|
||||
buffer.writeInt(Cobblemon.config.maxDynamaxLevel)
|
||||
buffer.writeBoolean(Cobblemon.config.unlockAllMoveDexMovesByDefault)
|
||||
buffer.writeFloat(Cobblemon.config.pokemonIntrinsicSizeMin)
|
||||
buffer.writeFloat(Cobblemon.config.pokemonIntrinsicSizeMax)
|
||||
}
|
||||
companion object {
|
||||
val ID = cobblemonResource("server_settings")
|
||||
fun decode(buffer: RegistryFriendlyByteBuf) = ServerSettingsPacket(buffer.readBoolean(), buffer.readBoolean(), buffer.readBoolean(), buffer.readInt(), buffer.readInt(), buffer.readInt(), buffer.readBoolean())
|
||||
fun decode(buffer: RegistryFriendlyByteBuf) = ServerSettingsPacket(buffer.readBoolean(),
|
||||
buffer.readBoolean(), buffer.readBoolean(),
|
||||
buffer.readInt(), buffer.readInt(), buffer.readInt(),
|
||||
buffer.readBoolean(), buffer.readFloat(), buffer.readFloat())
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
package com.cobblemon.mod.common.pokemon
|
||||
|
||||
import com.cobblemon.mod.common.Cobblemon
|
||||
import com.cobblemon.mod.common.client.settings.ServerSettings
|
||||
|
||||
enum class PokemonSizeCategory {
|
||||
XS,
|
||||
@@ -21,7 +21,7 @@ enum class PokemonSizeCategory {
|
||||
// Find which size category corresponds to the given scale modifier.
|
||||
// The scale modifier should be between the intrinsic min and max size.
|
||||
fun fromScale(scaleModifier: Float): PokemonSizeCategory {
|
||||
val config = Cobblemon.config
|
||||
val config = ServerSettings //Don't use cobblemon config here as it will be used by server AND client
|
||||
val minScale = config.pokemonIntrinsicSizeMin
|
||||
val maxScale = config.pokemonIntrinsicSizeMax
|
||||
val range = (maxScale - minScale).coerceAtLeast(0.0001F)
|
||||
|
||||
Reference in New Issue
Block a user