diff --git a/crates/horizon-client/src/block_entity_item.rs b/crates/horizon-client/src/block_entity_item.rs index 2361dcbfb..6eb99ae84 100644 --- a/crates/horizon-client/src/block_entity_item.rs +++ b/crates/horizon-client/src/block_entity_item.rs @@ -35,6 +35,25 @@ pub fn op_warning(stack: &crate::items::ItemStack) -> bool { data(stack).is_some_and(|(id, _)| OP_ONLY.contains(&id.as_str())) } +/// `SpawnEggItem.shouldPrintOpWarning` for a player with game master +/// permission: a spawn egg carries data of an op-only entity type +/// (`EntityTypes.OP_ONLY_CUSTOM_DATA`). +pub fn spawn_egg_op_warning(stack: &crate::items::ItemStack) -> bool { + stack.item.ends_with("_spawn_egg") + && matches!( + stack + .data() + .and_then(|d| d.other("minecraft:entity_data")) + .and_then(|data| data.get("id")), + Some(Tag::String(id)) if matches!( + id.to_string_lossy().as_str(), + "minecraft:falling_block" + | "minecraft:command_block_minecart" + | "minecraft:spawner_minecart" + ) + ) +} + /// `Spawner.getSpawnEntityDisplayName` (`SpawnData.entity.id` of the item's /// data, which `ItemStack.addDetailsToTooltip` reads for spawners and trial /// spawners alike): the entity type a spawner item spawns. diff --git a/crates/horizon-client/src/game.rs b/crates/horizon-client/src/game.rs index cb709c399..fbbf7f947 100644 --- a/crates/horizon-client/src/game.rs +++ b/crates/horizon-client/src/game.rs @@ -670,15 +670,22 @@ impl EntityObstructionWorld for BuildingObstruction { } } impl GameLevel<'_> { - /// The mobs that trigger plates and tripwires: living entities that don't - /// ignore block triggers (`Entity.isIgnoringBlockTriggers`: bats; armor - /// stands are not in `mobs`). + /// The living entities that trigger plates and tripwires and don't ignore + /// block triggers (`Entity.isIgnoringBlockTriggers`: bats and marker armor + /// stands). Armor stands live apart from `mobs`. fn mob_trigger_boxes(&self) -> impl Iterator + '_ { self.blockers .mobs .iter() .filter(|m| !m.removed && m.species() != horizon_client::mobs::Species::Bat) .map(Mob::bounds) + .chain( + self.blockers + .armor_stands + .iter() + .filter(|s| !s.marker) + .map(|s| s.bounds()), + ) } /// The non-living entities that trigger plates and tripwires (boats, /// crystals, primed TNT, falling blocks, item entities, experience orbs and diff --git a/crates/horizon-client/src/game/stations.rs b/crates/horizon-client/src/game/stations.rs index 1734cb3ee..38064caad 100644 --- a/crates/horizon-client/src/game/stations.rs +++ b/crates/horizon-client/src/game/stations.rs @@ -2059,9 +2059,16 @@ impl Game<'_> { ); } } - // ItemStack.OP_NBT_WARNING, for a player with game master permission. - if !nested && self.ui.registries.permission >= 2 && block_entity_item::op_warning(stack) { - for (key, fallback) in [ + // ItemStack.OP_NBT_WARNING: `BlockItem` and `SpawnEggItem` + // `.shouldPrintOpWarning` for a player with game master permission; + // a nested projectile has no player. The first line is bold. + if !nested + && self.ui.registries.permission >= 2 + && (item_info.is_some_and(|i| i.block.is_some()) + && block_entity_item::op_warning(stack) + || block_entity_item::spawn_egg_op_warning(stack)) + { + for (i, (key, fallback)) in [ ("item.op_warning.line1", "Warning:"), ( "item.op_warning.line2", @@ -2071,12 +2078,15 @@ impl Game<'_> { "item.op_warning.line3", "Do not use unless you know the exact contents!", ), - ] { - push( - &mut lines, - self.translate(key, fallback), + ] + .into_iter() + .enumerate() + { + let text = horizon_client::text::Text::legacy(&self.translate(key, fallback)); + lines.push(( + if i == 0 { text.bold() } else { text }, rgba(255, 85, 85, 255), - ); + )); } } lines