diff --git a/common/src/main/kotlin/com/cobblemon/mod/common/api/data/ClientDataSynchronizer.kt b/common/src/main/kotlin/com/cobblemon/mod/common/api/data/ClientDataSynchronizer.kt deleted file mode 100644 index 5d5f71f029..0000000000 --- a/common/src/main/kotlin/com/cobblemon/mod/common/api/data/ClientDataSynchronizer.kt +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) 2023 Cobblemon Contributors - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ - -package com.cobblemon.mod.common.api.data - -import com.cobblemon.mod.common.api.net.Decodable -import com.cobblemon.mod.common.api.net.Encodable - -// TODO this is implemented in multiple places but unused. Can we scratch this? -/** - * Represents an object that will possibly be synchronized to the client during datapack synchronization. - * - * @param T The type of the object being synchronized. - * - * @author Licious - * @since October 14th, 2022 - */ -interface ClientDataSynchronizer : Decodable, Encodable { - - /** - * Compares an object of type [T] with this instance to see if synchronization is necessary. - * - * @param other The other instance of type [T]. - * @return If synchronization is necessary. - */ - fun shouldSynchronize(other: T): Boolean - -} \ No newline at end of file diff --git a/common/src/main/kotlin/com/cobblemon/mod/common/api/pokedex/def/AggregatePokedexDef.kt b/common/src/main/kotlin/com/cobblemon/mod/common/api/pokedex/def/AggregatePokedexDef.kt index 5638606188..7fb33dda1c 100644 --- a/common/src/main/kotlin/com/cobblemon/mod/common/api/pokedex/def/AggregatePokedexDef.kt +++ b/common/src/main/kotlin/com/cobblemon/mod/common/api/pokedex/def/AggregatePokedexDef.kt @@ -56,10 +56,8 @@ class AggregatePokedexDef( return speciesToEntry.values.toList() } } - - override fun shouldSynchronize(other: PokedexDef) = true - - override fun decode(buffer: RegistryFriendlyByteBuf) { + + fun decode(buffer: RegistryFriendlyByteBuf) { sortOrder = buffer.readSizedInt(IntSize.U_BYTE) val size = buffer.readInt() for (i in 0 until size) { @@ -67,7 +65,7 @@ class AggregatePokedexDef( } } - override fun encode(buffer: RegistryFriendlyByteBuf) { + fun encode(buffer: RegistryFriendlyByteBuf) { buffer.writeSizedInt(IntSize.U_BYTE, sortOrder) buffer.writeInt(subDexIds.size) subDexIds.forEach { diff --git a/common/src/main/kotlin/com/cobblemon/mod/common/api/pokedex/def/PokedexDef.kt b/common/src/main/kotlin/com/cobblemon/mod/common/api/pokedex/def/PokedexDef.kt index 4b6d749d03..2b9f3de13b 100644 --- a/common/src/main/kotlin/com/cobblemon/mod/common/api/pokedex/def/PokedexDef.kt +++ b/common/src/main/kotlin/com/cobblemon/mod/common/api/pokedex/def/PokedexDef.kt @@ -8,8 +8,6 @@ package com.cobblemon.mod.common.api.pokedex.def -import com.cobblemon.mod.common.api.data.ClientDataSynchronizer -import com.cobblemon.mod.common.api.pokedex.entry.DexEntries import com.cobblemon.mod.common.api.pokedex.entry.PokedexEntry import com.mojang.serialization.Codec import com.mojang.serialization.MapCodec @@ -23,7 +21,7 @@ import net.minecraft.resources.ResourceLocation * @since August 24, 2024 * @author Apion */ -abstract class PokedexDef: ClientDataSynchronizer { +abstract class PokedexDef { //The ID used to find the codecs for this "type" of PokedexDef abstract val typeId: ResourceLocation //The ID of this dex in the Dexes registry diff --git a/common/src/main/kotlin/com/cobblemon/mod/common/api/pokedex/def/SimplePokedexDef.kt b/common/src/main/kotlin/com/cobblemon/mod/common/api/pokedex/def/SimplePokedexDef.kt index 844090f7ba..ffad93f064 100644 --- a/common/src/main/kotlin/com/cobblemon/mod/common/api/pokedex/def/SimplePokedexDef.kt +++ b/common/src/main/kotlin/com/cobblemon/mod/common/api/pokedex/def/SimplePokedexDef.kt @@ -45,9 +45,7 @@ class SimplePokedexDef( override fun getEntries() = entries.mapNotNull { DexEntries.entries[it] } - override fun shouldSynchronize(other: PokedexDef) = true - - override fun decode(buffer: RegistryFriendlyByteBuf) { + fun decode(buffer: RegistryFriendlyByteBuf) { sortOrder = buffer.readSizedInt(IntSize.U_BYTE) val size = buffer.readInt() for (i in 0 until size) { @@ -55,7 +53,7 @@ class SimplePokedexDef( } } - override fun encode(buffer: RegistryFriendlyByteBuf) { + fun encode(buffer: RegistryFriendlyByteBuf) { buffer.writeSizedInt(IntSize.U_BYTE, sortOrder) buffer.writeInt(entries.size) entries.forEach { diff --git a/common/src/main/kotlin/com/cobblemon/mod/common/api/pokemon/moves/Learnset.kt b/common/src/main/kotlin/com/cobblemon/mod/common/api/pokemon/moves/Learnset.kt index 480c926419..97aed32e37 100644 --- a/common/src/main/kotlin/com/cobblemon/mod/common/api/pokemon/moves/Learnset.kt +++ b/common/src/main/kotlin/com/cobblemon/mod/common/api/pokemon/moves/Learnset.kt @@ -8,7 +8,6 @@ package com.cobblemon.mod.common.api.pokemon.moves -import com.cobblemon.mod.common.api.data.ClientDataSynchronizer import com.cobblemon.mod.common.api.moves.MoveTemplate import com.cobblemon.mod.common.api.moves.Moves import com.cobblemon.mod.common.net.IntSize @@ -18,7 +17,7 @@ import com.cobblemon.mod.common.util.writeSizedInt import com.google.gson.JsonElement import net.minecraft.network.RegistryFriendlyByteBuf -open class Learnset : ClientDataSynchronizer { +open class Learnset { class Interpreter(val loadMove: (JsonElement, Learnset) -> Boolean) { companion object { fun parseFromPrefixIntoList(prefix: String, list: (Learnset) -> MutableList): Interpreter { @@ -111,9 +110,9 @@ open class Learnset : ClientDataSynchronizer { } // We only sync level up moves atm - override fun shouldSynchronize(other: Learnset) = other.levelUpMoves != this.levelUpMoves + fun shouldSynchronize(other: Learnset) = other.levelUpMoves != this.levelUpMoves - override fun decode(buffer: RegistryFriendlyByteBuf) { + fun decode(buffer: RegistryFriendlyByteBuf) { this.levelUpMoves.clear() repeat(times = buffer.readSizedInt(IntSize.U_BYTE)) { val level = buffer.readSizedInt(IntSize.U_SHORT) @@ -125,7 +124,7 @@ open class Learnset : ClientDataSynchronizer { } } - override fun encode(buffer: RegistryFriendlyByteBuf) { + fun encode(buffer: RegistryFriendlyByteBuf) { buffer.writeSizedInt(IntSize.U_BYTE, levelUpMoves.size) for ((level, moves) in levelUpMoves) { buffer.writeSizedInt(IntSize.U_SHORT, level) diff --git a/common/src/main/kotlin/com/cobblemon/mod/common/pokemon/Species.kt b/common/src/main/kotlin/com/cobblemon/mod/common/pokemon/Species.kt index 7b6e5e7f17..d5ce643118 100644 --- a/common/src/main/kotlin/com/cobblemon/mod/common/pokemon/Species.kt +++ b/common/src/main/kotlin/com/cobblemon/mod/common/pokemon/Species.kt @@ -16,7 +16,6 @@ import com.cobblemon.mod.common.api.abilities.AbilityPool import com.cobblemon.mod.common.api.abilities.CommonAbility import com.cobblemon.mod.common.api.abilities.PotentialAbility import com.cobblemon.mod.common.api.ai.config.BehaviourConfig -import com.cobblemon.mod.common.api.data.ClientDataSynchronizer import com.cobblemon.mod.common.api.data.ShowdownIdentifiable import com.cobblemon.mod.common.api.drop.DropTable import com.cobblemon.mod.common.api.molang.MoLangFunctions.addSpeciesFunctions @@ -52,7 +51,7 @@ import net.minecraft.network.chat.MutableComponent import net.minecraft.resources.ResourceLocation import net.minecraft.world.entity.EntityDimensions -class Species : ClientDataSynchronizer, ShowdownIdentifiable { +class Species : ShowdownIdentifiable { var name: String = "Bulbasaur" val translationKey: String get() = "${this.resourceIdentifier.namespace}.species.${this.unformattedShowdownId()}.name" @@ -218,7 +217,7 @@ class Species : ClientDataSynchronizer, ShowdownIdentifiable { fun canGmax() = this.forms.find { it.formOnlyShowdownId() == "gmax" } != null - override fun encode(buffer: RegistryFriendlyByteBuf) { + fun encode(buffer: RegistryFriendlyByteBuf) { buffer.writeBoolean(this.implemented) buffer.writeString(this.name) buffer.writeInt(this.nationalPokedexNumber) @@ -259,7 +258,7 @@ class Species : ClientDataSynchronizer, ShowdownIdentifiable { this.riding.encode(buffer) } - override fun decode(buffer: RegistryFriendlyByteBuf) { + fun decode(buffer: RegistryFriendlyByteBuf) { this.implemented = buffer.readBoolean() this.name = buffer.readString() this.nationalPokedexNumber = buffer.readInt() @@ -303,27 +302,6 @@ class Species : ClientDataSynchronizer, ShowdownIdentifiable { this.initialize() } - override fun shouldSynchronize(other: Species): Boolean { - if (other.resourceIdentifier.toString() != other.resourceIdentifier.toString()) - return false - return other.showdownId() != this.showdownId() - || other.nationalPokedexNumber != this.nationalPokedexNumber - || other.baseStats != this.baseStats - || other.hitbox != this.hitbox - || other.primaryType != this.primaryType - || other.secondaryType != this.secondaryType - || other.standingEyeHeight != this.standingEyeHeight - || other.swimmingEyeHeight != this.swimmingEyeHeight - || other.flyingEyeHeight != this.flyingEyeHeight - || other.dynamaxBlocked != this.dynamaxBlocked - || other.pokedex != this.pokedex - || other.forms != this.forms - // We only sync level up moves atm - || this.moves.shouldSynchronize(other.moves) - || other.battleTheme != this.battleTheme - || other.features != this.features - } - /** * The literal Showdown ID of this species. * This will be a lowercase version of the [name] with all the non-alphanumeric characters removed. For example, "Mr. Mime" becomes "mrmime".