Compare commits

...
4 Commits
Author SHA1 Message Date
Paul 8b5231d6f0 Alternative way to fix dupe issue to not crash (huge) 2023-12-01 12:07:00 +10:00
Hiroku e01bc2eeab Merge branch 'nickname_invalid_format' into '1.4.0'
Resolves a bug in the format in which the nickname is saved in JSON.

See merge request cable-mc/cobblemon!797
2023-11-26 23:19:50 +00:00
Pedro Souza f6f3070b8e changelog 2023-11-26 20:18:37 -03:00
Pedro Souza 0f2301e668 Resolved nickname invalid format bug 2023-11-26 12:24:54 -03:00
3 changed files with 18 additions and 13 deletions
+1
View File
@@ -797,6 +797,7 @@
- Fixed Magnitude battle messages.
- Moves that are disabled or out of PP now show transparently in the battle GUI instead of being hidden completely.
- Statuses like sleep and frozen no longer last forever if it was carried over from a previous battle.
- Fixed a formatting error that affected Pokemon nicknames when the storage type is JSON.
### Localization
- Added species, ability, and move translations for `ko_ko`, `jp_jp`, `fr_fr`, `es_es`, `it_it`, and `zh_cn`.
@@ -146,6 +146,8 @@ class PokemonEntity(
var tethering: PokemonPastureBlockEntity.Tethering? = null
var queuedToDespawn = false
/**
* The amount of steps this entity has traveled.
*/
@@ -266,6 +268,9 @@ class PokemonEntity(
super.tick()
// We will be handling idle logic ourselves thank you
this.setDespawnCounter(0)
if (queuedToDespawn) {
return remove(RemovalReason.DISCARDED)
}
entityProperties.forEach { it.checkForUpdate() }
delegate.tick(this)
ticksLived++
@@ -994,18 +999,17 @@ class PokemonEntity(
return
}
if(this.ownerUuid == player.uuid && tethering == null) {
if (player.isDisconnected) {
this.remove(RemovalReason.DISCARDED)
return
}
val chunkPos = ChunkPos(BlockPos(x.toInt(), y.toInt(), z.toInt()))
(world as ServerWorld).chunkManager
.addTicket(ChunkTicketType.POST_TELEPORT, chunkPos, 0, id)
this.goalSelector.tick()
if(distanceTo(player.blockPos) > 100) pokemon.recall()
if (this.ownerUuid == player.uuid && tethering == null) {
queuedToDespawn = true
return
}
//
// val chunkPos = ChunkPos(BlockPos(x.toInt(), y.toInt(), z.toInt()))
// (world as ServerWorld).chunkManager
// .addTicket(ChunkTicketType.POST_TELEPORT, chunkPos, 0, id)
// this.goalSelector.tick()
// if(distanceTo(player.blockPos) > 100) pokemon.recall()
// }
}
override fun canBeLeashedBy(player: PlayerEntity): Boolean {
@@ -753,7 +753,7 @@ open class Pokemon : ShowdownIdentifiable {
json.addProperty(DataKeys.POKEMON_LAST_SAVED_VERSION, Cobblemon.VERSION)
json.addProperty(DataKeys.POKEMON_UUID, uuid.toString())
json.addProperty(DataKeys.POKEMON_SPECIES_IDENTIFIER, species.resourceIdentifier.toString())
nickname?.let { json.addProperty(DataKeys.POKEMON_NICKNAME, Text.Serializer.toJson(it)) }
nickname?.let { json.add(DataKeys.POKEMON_NICKNAME, Text.Serializer.toJsonTree(it)) }
json.addProperty(DataKeys.POKEMON_FORM_ID, form.formOnlyShowdownId())
json.addProperty(DataKeys.POKEMON_EXPERIENCE, experience)
json.addProperty(DataKeys.POKEMON_LEVEL, level)
@@ -803,7 +803,7 @@ open class Pokemon : ShowdownIdentifiable {
} catch (e: InvalidIdentifierException) {
throw IllegalStateException("Failed to deserialize a species identifier")
}
nickname = json.get(DataKeys.POKEMON_NICKNAME)?.asString?.takeIf { it.isNotBlank() }?.let { Text.Serializer.fromJson(it) }
nickname = json.get(DataKeys.POKEMON_NICKNAME)?.let { Text.Serializer.fromJson(it) }
form = species.forms.find { it.formOnlyShowdownId() == json.get(DataKeys.POKEMON_FORM_ID).asString } ?: species.standardForm
level = json.get(DataKeys.POKEMON_LEVEL).asInt
experience = json.get(DataKeys.POKEMON_EXPERIENCE).asInt.takeIf { experienceGroup.getLevel(it) == level } ?: experienceGroup.getExperience(level)