mirror of
https://gitlab.com/cable-mc/cobblemon.git
synced 2026-11-18 14:18:54 -05:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bf50570ade |
No files matched your search
@@ -10,6 +10,7 @@ package com.cobblemon.mod.common.api.pokemon.feature
|
|||||||
|
|
||||||
import com.cobblemon.mod.common.CobblemonNetwork.sendPacket
|
import com.cobblemon.mod.common.CobblemonNetwork.sendPacket
|
||||||
import com.cobblemon.mod.common.api.data.JsonDataRegistry
|
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.pokemon.aspect.AspectProvider
|
||||||
import com.cobblemon.mod.common.api.properties.CustomPokemonProperty
|
import com.cobblemon.mod.common.api.properties.CustomPokemonProperty
|
||||||
import com.cobblemon.mod.common.api.properties.CustomPokemonPropertyType
|
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 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<*>> {
|
fun getFeaturesFor(species: Species): List<SpeciesFeatureProvider<*>> {
|
||||||
val mentionedFeatures = species.features.mapNotNull(this::getFeature)
|
val mentionedFeatures = species.features.mapNotNull(this::getFeature)
|
||||||
val globalFeatures = GlobalSpeciesFeatures.getFeatures()
|
val globalFeatures = GlobalSpeciesFeatures.getFeatures()
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ object CobblemonClient {
|
|||||||
teamData = ClientPlayerTeamData()
|
teamData = ClientPlayerTeamData()
|
||||||
clientPokedexData = ClientPokedexManager(mutableMapOf())
|
clientPokedexData = ClientPokedexManager(mutableMapOf())
|
||||||
storage.onLogin()
|
storage.onLogin()
|
||||||
CobblemonDataProvider.canReload = false
|
// CobblemonDataProvider.canReload = false
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onLogout() {
|
fun onLogout() {
|
||||||
|
|||||||
@@ -106,10 +106,10 @@ object CobblemonDataProvider : DataProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun <T : DataRegistry> register(registry: T): T {
|
override fun <T : DataRegistry> register(registry: T): T {
|
||||||
// Only send message once
|
// // Only send message once
|
||||||
if (this.registries.isEmpty()) {
|
// 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.")
|
// 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)
|
this.registries.add(registry)
|
||||||
LOGGER.info("Registered the {} registry", registry.id.toString())
|
LOGGER.info("Registered the {} registry", registry.id.toString())
|
||||||
LOGGER.debug("Registered the {} registry of class {}", registry.id.toString(), registry::class.qualifiedName)
|
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 }
|
registries.filter { it.type == this.type }
|
||||||
.forEach { it.reload(manager) }
|
.forEach { it.reload(manager) }
|
||||||
if (isInGame && this.type == PackType.SERVER_DATA) {
|
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.max
|
||||||
import kotlin.math.min
|
import kotlin.math.min
|
||||||
import kotlin.math.roundToInt
|
import kotlin.math.roundToInt
|
||||||
|
import kotlin.properties.Delegates
|
||||||
import kotlin.random.Random
|
import kotlin.random.Random
|
||||||
|
import kotlin.reflect.KProperty
|
||||||
import net.minecraft.core.BlockPos
|
import net.minecraft.core.BlockPos
|
||||||
import net.minecraft.core.RegistryAccess
|
import net.minecraft.core.RegistryAccess
|
||||||
import net.minecraft.nbt.*
|
import net.minecraft.nbt.*
|
||||||
@@ -132,15 +134,17 @@ enum class OriginalTrainerType : StringRepresentable {
|
|||||||
|
|
||||||
open class Pokemon : ShowdownIdentifiable {
|
open class Pokemon : ShowdownIdentifiable {
|
||||||
var uuid = UUID.randomUUID()
|
var uuid = UUID.randomUUID()
|
||||||
var species = PokemonSpecies.random()
|
|
||||||
|
var speciesIdentifier = PokemonSpecies.random().resourceIdentifier
|
||||||
set(value) {
|
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")
|
throw IllegalArgumentException("Cannot set a species that isn't registered")
|
||||||
}
|
}
|
||||||
val quotient = clamp(currentHealth / maxHealth.toFloat(), 0F, 1F)
|
val quotient = clamp(currentHealth / maxHealth.toFloat(), 0F, 1F)
|
||||||
field = value
|
field = value
|
||||||
if (!isClient) {
|
if (!isClient) {
|
||||||
val newFeatures = SpeciesFeatures.getFeaturesFor(species).mapNotNull { it.invoke(this) }
|
val newFeatures = SpeciesFeatures.getFeaturesFor(value).mapNotNull { it.invoke(this) }
|
||||||
features.clear()
|
features.clear()
|
||||||
features.addAll(newFeatures)
|
features.addAll(newFeatures)
|
||||||
}
|
}
|
||||||
@@ -150,12 +154,12 @@ open class Pokemon : ShowdownIdentifiable {
|
|||||||
checkGender()
|
checkGender()
|
||||||
updateHP(quotient)
|
updateHP(quotient)
|
||||||
this.attemptAbilityUpdate()
|
this.attemptAbilityUpdate()
|
||||||
_species.emit(value)
|
_species.emit(species)
|
||||||
}
|
}
|
||||||
|
var formName = "Default"
|
||||||
var form = species.standardForm
|
|
||||||
set(value) {
|
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
|
// 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
|
// 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)
|
val quotient = clamp(currentHealth / maxHealth.toFloat(), 0F, 1F)
|
||||||
@@ -167,9 +171,17 @@ open class Pokemon : ShowdownIdentifiable {
|
|||||||
checkGender()
|
checkGender()
|
||||||
updateHP(quotient)
|
updateHP(quotient)
|
||||||
this.attemptAbilityUpdate()
|
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
|
// Floating Platform for surface water battles
|
||||||
var battleSurface: Boat? = null
|
var battleSurface: Boat? = null
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user