diff --git a/CHANGELOG.md b/CHANGELOG.md index ac8551044c..31e5cf4cd9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -358,6 +358,7 @@ - Fixed fished up Pokémon not being added as "seen" to the Pokedex - Fixed surprised Gimmighoul encounters not being added as "seen" to the Pokedex - Fixed a crash involving berry trees that have been world edited. +- Fixed visual desync in multiplayer for players mounting Pokémon outside other players' loaded chunks ### Developer - Added `PokeSnackSpawnerFactory` which allows influence registration on PokeSnack encounters diff --git a/common/src/main/kotlin/com/cobblemon/mod/common/net/messages/client/spawn/SpawnPokemonPacket.kt b/common/src/main/kotlin/com/cobblemon/mod/common/net/messages/client/spawn/SpawnPokemonPacket.kt index 1470487e4b..e69a5d7c76 100644 --- a/common/src/main/kotlin/com/cobblemon/mod/common/net/messages/client/spawn/SpawnPokemonPacket.kt +++ b/common/src/main/kotlin/com/cobblemon/mod/common/net/messages/client/spawn/SpawnPokemonPacket.kt @@ -64,6 +64,7 @@ class SpawnPokemonPacket( var rideStamina: Float, var isAlpha: Boolean, var silent: Boolean, + var riders: List, vanillaSpawnPacket: ClientboundAddEntityPacket, ) : SpawnExtraDataEntityPacket(vanillaSpawnPacket) { @@ -98,6 +99,7 @@ class SpawnPokemonPacket( entity.entityData.get(PokemonEntity.RIDE_STAMINA), entity.entityData.get(PokemonEntity.IS_ALPHA), entity.isSilent, + entity.occupiedSeats.map { entry -> entry.value.id }.toList(), vanillaSpawnPacket ) @@ -134,6 +136,7 @@ class SpawnPokemonPacket( buffer.writeFloat(rideStamina) buffer.writeBoolean(isAlpha) buffer.writeBoolean(silent) + buffer.writeCollection(this.riders) { pb, value -> pb.writeInt(value) } } override fun applyData(entity: PokemonEntity, level: ClientLevel) { @@ -184,6 +187,10 @@ class SpawnPokemonPacket( entity.tickSpawned = this.tickSpawned entity.delegate.updateAge(this.tickSpawned) + + if (this.riders.isNotEmpty()) { + this.riders.forEach { level.getEntity(it)?.startRiding(entity) } + } } override fun checkType(entity: Entity): Boolean = entity is PokemonEntity @@ -222,6 +229,7 @@ class SpawnPokemonPacket( val rideStamina = buffer.readFloat() val isAlpha = buffer.readBoolean() val silent = buffer.readBoolean() + val riders = buffer.readList { it.readInt() }.toList() val vanillaPacket = decodeVanillaPacket(buffer) return SpawnPokemonPacket( @@ -253,6 +261,7 @@ class SpawnPokemonPacket( rideStamina, isAlpha, silent, + riders, vanillaPacket ) }