forked from mirrors/cobblemon
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bf50570ade |
@@ -10,6 +10,7 @@ package com.cobblemon.mod.common.api.pokemon.feature
|
||||
|
||||
import com.cobblemon.mod.common.CobblemonNetwork.sendPacket
|
||||
import com.cobblemon.mod.common.api.data.JsonDataRegistry
|
||||
import com.cobblemon.mod.common.api.pokemon.PokemonSpecies
|
||||
import com.cobblemon.mod.common.api.pokemon.aspect.AspectProvider
|
||||
import com.cobblemon.mod.common.api.properties.CustomPokemonProperty
|
||||
import com.cobblemon.mod.common.api.properties.CustomPokemonPropertyType
|
||||
@@ -76,6 +77,12 @@ object SpeciesFeatures : JsonDataRegistry<SpeciesFeatureProvider<*>> {
|
||||
}
|
||||
|
||||
fun getFeatures() = (resourceFeatures.keys + codeFeatures.keys).mapNotNull(this::getFeature)
|
||||
|
||||
fun getFeaturesFor(speciesIdentifier: ResourceLocation): List<SpeciesFeatureProvider<*>> {
|
||||
val species = PokemonSpecies.getByIdentifier(speciesIdentifier) ?: return emptyList()
|
||||
return getFeaturesFor(species)
|
||||
}
|
||||
|
||||
fun getFeaturesFor(species: Species): List<SpeciesFeatureProvider<*>> {
|
||||
val mentionedFeatures = species.features.mapNotNull(this::getFeature)
|
||||
val globalFeatures = GlobalSpeciesFeatures.getFeatures()
|
||||
|
||||
@@ -94,7 +94,7 @@ object CobblemonClient {
|
||||
teamData = ClientPlayerTeamData()
|
||||
clientPokedexData = ClientPokedexManager(mutableMapOf())
|
||||
storage.onLogin()
|
||||
CobblemonDataProvider.canReload = false
|
||||
// CobblemonDataProvider.canReload = false
|
||||
}
|
||||
|
||||
fun onLogout() {
|
||||
|
||||
@@ -106,10 +106,10 @@ object CobblemonDataProvider : DataProvider {
|
||||
}
|
||||
|
||||
override fun <T : DataRegistry> register(registry: T): T {
|
||||
// Only send message once
|
||||
if (this.registries.isEmpty()) {
|
||||
LOGGER.info("Note: Cobblemon data registries are only loaded once per server instance as Pokémon species are not safe to reload.")
|
||||
}
|
||||
// // Only send message once
|
||||
// if (this.registries.isEmpty()) {
|
||||
// LOGGER.info("Note: Cobblemon data registries are only loaded once per server instance as Pokémon species are not safe to reload.")
|
||||
// }
|
||||
this.registries.add(registry)
|
||||
LOGGER.info("Registered the {} registry", registry.id.toString())
|
||||
LOGGER.debug("Registered the {} registry of class {}", registry.id.toString(), registry::class.qualifiedName)
|
||||
@@ -148,7 +148,7 @@ object CobblemonDataProvider : DataProvider {
|
||||
registries.filter { it.type == this.type }
|
||||
.forEach { it.reload(manager) }
|
||||
if (isInGame && this.type == PackType.SERVER_DATA) {
|
||||
canReload = false
|
||||
// canReload = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,7 +96,9 @@ import kotlin.math.absoluteValue
|
||||
import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
import kotlin.math.roundToInt
|
||||
import kotlin.properties.Delegates
|
||||
import kotlin.random.Random
|
||||
import kotlin.reflect.KProperty
|
||||
import net.minecraft.core.BlockPos
|
||||
import net.minecraft.core.RegistryAccess
|
||||
import net.minecraft.nbt.*
|
||||
@@ -132,15 +134,17 @@ enum class OriginalTrainerType : StringRepresentable {
|
||||
|
||||
open class Pokemon : ShowdownIdentifiable {
|
||||
var uuid = UUID.randomUUID()
|
||||
var species = PokemonSpecies.random()
|
||||
|
||||
var speciesIdentifier = PokemonSpecies.random().resourceIdentifier
|
||||
set(value) {
|
||||
if (PokemonSpecies.getByIdentifier(value.resourceIdentifier) == null) {
|
||||
val species = PokemonSpecies.getByIdentifier(value) ?: PokemonSpecies.random()
|
||||
if (PokemonSpecies.getByIdentifier(value) == null) {
|
||||
throw IllegalArgumentException("Cannot set a species that isn't registered")
|
||||
}
|
||||
val quotient = clamp(currentHealth / maxHealth.toFloat(), 0F, 1F)
|
||||
field = value
|
||||
if (!isClient) {
|
||||
val newFeatures = SpeciesFeatures.getFeaturesFor(species).mapNotNull { it.invoke(this) }
|
||||
val newFeatures = SpeciesFeatures.getFeaturesFor(value).mapNotNull { it.invoke(this) }
|
||||
features.clear()
|
||||
features.addAll(newFeatures)
|
||||
}
|
||||
@@ -150,12 +154,12 @@ open class Pokemon : ShowdownIdentifiable {
|
||||
checkGender()
|
||||
updateHP(quotient)
|
||||
this.attemptAbilityUpdate()
|
||||
_species.emit(value)
|
||||
_species.emit(species)
|
||||
}
|
||||
|
||||
var form = species.standardForm
|
||||
var formName = "Default"
|
||||
set(value) {
|
||||
val old = field
|
||||
val old = species.forms.find { it.name == formName } ?: species.standardForm
|
||||
val new = species.forms.find { it.name == value } ?: species.standardForm
|
||||
// Species updates already update HP but just a form change may require it
|
||||
// Moved to before the field was set else it won't actually do the hp calc proper <3
|
||||
val quotient = clamp(currentHealth / maxHealth.toFloat(), 0F, 1F)
|
||||
@@ -167,9 +171,17 @@ open class Pokemon : ShowdownIdentifiable {
|
||||
checkGender()
|
||||
updateHP(quotient)
|
||||
this.attemptAbilityUpdate()
|
||||
_form.emit(value)
|
||||
_form.emit(new)
|
||||
}
|
||||
|
||||
var species: Species
|
||||
get() = PokemonSpecies.getByIdentifier(speciesIdentifier) ?: PokemonSpecies.random()
|
||||
set(value) { speciesIdentifier = value.resourceIdentifier }
|
||||
|
||||
var form: FormData
|
||||
get() = species.forms.find { it.name == formName } ?: species.standardForm
|
||||
set(value) { formName = value.name }
|
||||
|
||||
// Floating Platform for surface water battles
|
||||
var battleSurface: Boat? = null
|
||||
|
||||
|
||||
Reference in New Issue
Block a user