diff --git a/crates/horizon-client/src/game/creatures.rs b/crates/horizon-client/src/game/creatures.rs index 0919da120..7ee731e71 100644 --- a/crates/horizon-client/src/game/creatures.rs +++ b/crates/horizon-client/src/game/creatures.rs @@ -4250,6 +4250,9 @@ impl Game<'_> { f64::from(y + 1), f64::from(pos[2]) + 0.5, ]; - let _ = self.spawn_mob("minecraft:zombified_piglin", at, false); + // setPortalCooldown: the new piglin does not travel at once. + if let Some(id) = self.spawn_mob("minecraft:zombified_piglin", at, false) { + self.set_portal_cooldown(id); + } } } diff --git a/crates/horizon-client/src/game/nether_portal.rs b/crates/horizon-client/src/game/nether_portal.rs index c8142284a..95c38d9d1 100644 --- a/crates/horizon-client/src/game/nether_portal.rs +++ b/crates/horizon-client/src/game/nether_portal.rs @@ -662,6 +662,17 @@ impl Game<'_> { ); } } + /// `Entity.setPortalCooldown` on an entity that has just spawned in a + /// portal: it stands in the portal for 300 ticks without going through. + pub(super) fn set_portal_cooldown(&mut self, id: u32) { + self.portals.entities.insert( + id, + PortalState { + cooldown: ENTITY_DELAY, + process: None, + }, + ); + } /// `canUsePortal(false)` of a mob: alive, riding nothing, not asleep, /// not carrying the player, and not a boss that never travels. fn mob_can_use_portal(&self, m: &horizon_client::mobs::Mob) -> bool {