diff --git a/crates/horizon-client/src/game.rs b/crates/horizon-client/src/game.rs index 277c7f2fd..de7dee7b2 100644 --- a/crates/horizon-client/src/game.rs +++ b/crates/horizon-client/src/game.rs @@ -123,6 +123,7 @@ mod raids; mod recipe_book; mod remote; mod remote_mob_data; +mod remote_mob_use; mod remote_objects; mod remote_projectiles; mod remote_stations; @@ -505,6 +506,9 @@ enum FallStep { enum GuestUse { OnBlock(Hand), Item(Hand), + /// `handleInteract`: `Player.interactOn` with the hand, nothing else (the + /// client sends UseItem itself when the entity passed). + Entity(Hand), } /// The client world as seen by the vanilla block-behaviour library. @@ -3239,6 +3243,9 @@ impl Game<'_> { // A guest's use packets name one hand and touch no entity: the client // sends one per hand and part of its click, and Interact for entities. let guest = self.guest_use; + if let Some(GuestUse::Entity(hand)) = guest { + return Ok(self.with_hand(hand, Game::interact_entity)?.then_some(hand)); + } let on_block = matches!(guest, Some(GuestUse::OnBlock(_))); if !on_block && self.riding.is_some() @@ -3247,14 +3254,7 @@ impl Game<'_> { { return Ok(Some(Hand::Main)); } - if guest.is_none() - && (self.interact_frame() - || self.interact_armor_stand() - || self.interact_boat() - || self.interact_cart() - || self.interact_mob()? - || self.interact_knot()) - { + if guest.is_none() && self.interact_entity()? { return Ok(Some(Hand::Main)); } // An EntityHitResult may fall through to Item.use, never to useItemOn. @@ -3264,16 +3264,33 @@ impl Game<'_> { self.pick() }; let hands = match guest { - Some(GuestUse::OnBlock(hand) | GuestUse::Item(hand)) => vec![hand], + Some(GuestUse::OnBlock(hand) | GuestUse::Item(hand) | GuestUse::Entity(hand)) => { + vec![hand] + } None => Hand::BOTH.to_vec(), }; + let entity = guest.is_none() && self.entity_targeted(); for hand in hands { + // The off hand's turn starts on the entity too (Minecraft.startUseItem). + if entity && hand == Hand::Off && self.with_hand(hand, Game::interact_entity)? { + return Ok(Some(hand)); + } if self.with_hand(hand, |game| game.use_hand(block_hit.as_ref()))? { return Ok(Some(hand)); } } Ok(None) } + /// `Player.interactOn` for the entity under the crosshair with the + /// acting hand: whether it took the click. + fn interact_entity(&mut self) -> Result { + Ok(self.interact_frame() + || self.interact_armor_stand() + || self.interact_boat() + || self.interact_cart() + || self.interact_mob()? + || self.interact_knot()) + } /// One hand's turn in `startUseItem`: `useItemOn` the block aimed at, /// then `useItem`. Whether the click ends here (it acted or failed). fn use_hand(&mut self, block_hit: Option<&Hit>) -> Result { diff --git a/crates/horizon-client/src/game/armor_stands.rs b/crates/horizon-client/src/game/armor_stands.rs index 6e06f21b0..f175af401 100644 --- a/crates/horizon-client/src/game/armor_stands.rs +++ b/crates/horizon-client/src/game/armor_stands.rs @@ -461,14 +461,14 @@ impl Game<'_> { count: 1, ..h.clone() }); - self.inventory[self.selected] = Some(ItemStack { + *self.held_mut() = Some(ItemStack { count: h.count - 1, ..h }); } h => { self.armor_stands[i].equipment[slot] = h; - self.inventory[self.selected] = current; + *self.held_mut() = current; } } let p = self.armor_stands[i].position; diff --git a/crates/horizon-client/src/game/creatures.rs b/crates/horizon-client/src/game/creatures.rs index 442c37237..7d872a574 100644 --- a/crates/horizon-client/src/game/creatures.rs +++ b/crates/horizon-client/src/game/creatures.rs @@ -2413,13 +2413,14 @@ impl Game<'_> { self.spawn_item(rest, self.eye_position().unwrap_or([0.0; 3]), [0.0; 3], 40); } } else { - self.inventory[self.selected] = Some(filled); + *self.held_mut() = Some(filled); } self.swing_arm(); return Ok(true); } let creative = self.creative; - let selected = self.selected; + // The hand's slot (Player.interactOn passes the hand). + let selected = self.held_slot(); if self.interact_zombie_villager(index, &item) { return Ok(true); } @@ -2451,10 +2452,10 @@ impl Game<'_> { // PiglinAi.mobInteract: hand over something gold to admire. if self.mobs[index].alive() && self.give_piglin(index, &item) { self.swing_arm(); - if !creative && let Some(stack) = self.inventory[selected].as_mut() { + if !creative && let Some(stack) = self.stack_in_mut(selected).as_mut() { stack.count -= 1; if stack.count == 0 { - self.inventory[selected] = None; + *self.stack_in_mut(selected) = None; } } return Ok(true); @@ -2765,11 +2766,11 @@ impl Game<'_> { } if consume && !creative - && let Some(stack) = self.inventory[selected].as_mut() + && let Some(stack) = self.stack_in_mut(selected).as_mut() { stack.count -= 1; if stack.count == 0 { - self.inventory[selected] = None; + *self.stack_in_mut(selected) = None; } } if let Some(g) = give { @@ -2779,8 +2780,8 @@ impl Game<'_> { damage: 0, extra: None, }; - if self.inventory[selected].is_none() { - self.inventory[selected] = Some(stack); + if self.stack_in(selected).is_none() { + *self.stack_in_mut(selected) = Some(stack); } else if let Some(rest) = self.give(stack) { let at = self.eye_position().unwrap_or(center); self.spawn_item(rest, at, [0.0, 0.0, 0.0], 40); @@ -2812,13 +2813,17 @@ impl Game<'_> { if self.creative { return; } - if let Some(stack) = self.inventory[self.selected].as_mut() - && let Some(info) = self.res.items().get(&stack.item) - && info.max_damage > 0 + let slot = self.held_slot(); + let max_damage = self + .held() + .and_then(|s| self.res.items().get(&s.item)) + .map_or(0, |i| i.max_damage); + if max_damage > 0 + && let Some(stack) = self.stack_in_mut(slot).as_mut() { stack.damage += 1; - if stack.damage >= info.max_damage { - self.inventory[self.selected] = None; + if stack.damage >= max_damage { + *self.stack_in_mut(slot) = None; } } } diff --git a/crates/horizon-client/src/game/lan_actions.rs b/crates/horizon-client/src/game/lan_actions.rs index aaefaad06..1cd14b83b 100644 --- a/crates/horizon-client/src/game/lan_actions.rs +++ b/crates/horizon-client/src/game/lan_actions.rs @@ -974,9 +974,14 @@ impl Game<'_> { .look_at_entity(host, gi, p.id, Some(p.location)) .is_some() { + // handleInteract: the entity and that hand only; a click the + // entity passes comes back as UseItem. + let hand = if p.hand == 1 { Hand::Off } else { Hand::Main }; let swung = self.as_guest(host, conn, |g| { + g.guest_use = Some(GuestUse::Entity(hand)); let swings = g.swings_started; let _ = g.use_item(); + g.guest_use = None; g.swings_started != swings }); self.lan_swing_back(host, conn, swung); diff --git a/crates/horizon-client/src/game/leads.rs b/crates/horizon-client/src/game/leads.rs index ae5d87fff..3a5112967 100644 --- a/crates/horizon-client/src/game/leads.rs +++ b/crates/horizon-client/src/game/leads.rs @@ -202,10 +202,10 @@ impl Game<'_> { self.mobs[index].extra.leash = Some(Holder::Player); self.lead_sound("tied", at); // The lead is always used up. - if let Some(stack) = self.inventory[self.selected].as_mut() { + if let Some(stack) = self.held_mut().as_mut() { stack.count -= 1; if stack.count == 0 { - self.inventory[self.selected] = None; + *self.held_mut() = None; } } return true; diff --git a/crates/horizon-client/src/game/mounts.rs b/crates/horizon-client/src/game/mounts.rs index c10d7a458..fa4bbc209 100644 --- a/crates/horizon-client/src/game/mounts.rs +++ b/crates/horizon-client/src/game/mounts.rs @@ -104,7 +104,7 @@ impl Game<'_> { } /// `AbstractHorse.mobInteract`. Returns whether the click was used. pub(super) fn interact_mount(&mut self, index: usize, item: &str) -> bool { - let held = self.inventory[self.selected].clone(); + let held = self.held().cloned(); let m = &self.mobs[index]; let species = m.species(); // A server player rides it already (`isVehicle`: no seat, no feeding). diff --git a/crates/horizon-client/src/game/remote.rs b/crates/horizon-client/src/game/remote.rs index fff79a7f2..32613e42a 100644 --- a/crates/horizon-client/src/game/remote.rs +++ b/crates/horizon-client/src/game/remote.rs @@ -3739,7 +3739,10 @@ impl Game<'_> { horizon_client::interaction_input::use_on_target(&mut RemoteUseWorld(self), entity); } - fn remote_use_entity(&mut self) -> bool { + /// `Minecraft.startUseItem`'s entity turn for `hand`: Interact goes to + /// the server, and whether the click ends there is what this client's + /// copy of the entity answers (`MultiPlayerGameMode.interact`). + fn remote_use_entity(&mut self, hand: Hand) -> bool { let sneaking = self.keys.contains(&KeyCode::ShiftLeft); // A boat, minecart, item frame, armor stand or painting nearer than // any mob: the server uses it (AbstractBoat.interact boards it). @@ -3747,6 +3750,10 @@ impl Game<'_> { && self.mob_hit().is_none_or(|(_, d)| hit.distance < d) && self.before_block(hit.distance) { + // The main hand's turn takes it; there is no off hand turn. + if hand == Hand::Off { + return false; + } self.send(S::Interact(play::Interact { id: hit.id, hand: 0, @@ -3762,18 +3769,18 @@ impl Game<'_> { let id = self.mobs[i].id as i32; self.send(S::Interact(play::Interact { id, - hand: 0, + hand: hand_id(hand), location: [0.0, 1.0, 0.0], secondary: sneaking, })); - // Player.interactOn: another player passes, and the held item is - // used instead (Minecraft.startUseItem). + // Player.interactOn: another player passes, and so does a mob + // the held item means nothing to: the item is used instead. let player = self .remote .as_ref() .is_some_and(|r| r.level_players.contains_key(&id)); - if !player { - self.swing_arm(); + if !player && self.remote_mob_takes(i, hand) { + self.with_hand(hand, Game::swing_arm); return true; } } @@ -4030,7 +4037,13 @@ impl Game<'_> { if self.remote_use_item(Hand::Main) { return; } - if !self.entity_targeted() && self.remote_use_block(Hand::Off) { + // The off hand's turn: the entity again, or the block. + let off_target = if self.entity_targeted() { + self.remote_use_entity(Hand::Off) + } else { + self.remote_use_block(Hand::Off) + }; + if off_target { return; } self.remote_use_item(Hand::Off); @@ -5135,7 +5148,7 @@ struct RemoteUseWorld<'g, 'a>(&'g mut Game<'a>); impl horizon_client::interaction_input::TargetUseWorld for RemoteUseWorld<'_, '_> { fn use_entity(&mut self) -> bool { - self.0.remote_use_entity() + self.0.remote_use_entity(Hand::Main) } fn use_block(&mut self) -> bool { self.0.remote_use_block(Hand::Main) diff --git a/crates/horizon-client/src/game/remote_mob_use.rs b/crates/horizon-client/src/game/remote_mob_use.rs new file mode 100644 index 000000000..9575cf925 --- /dev/null +++ b/crates/horizon-client/src/game/remote_mob_use.rs @@ -0,0 +1,91 @@ +//! A server's client right-clicking a mob: vanilla's client runs +//! `Player.interactOn` on its own level (`MultiPlayerGameMode.interact`) to +//! learn whether the click ends on the mob or goes on to the held item +//! (`Minecraft.startUseItem` then sends UseItem). The server does the real +//! interaction; this is what the client's copy of the mob answers. +use super::Game; +use horizon_client::{ + first_person::Hand, + mobs::{Species, equine, llama}, +}; + +impl Game<'_> { + /// Whether mob `i` takes a right click with `hand`'s item on this + /// client (`Mob.interact`'s result consumes the action). + pub(super) fn remote_mob_takes(&self, i: usize, hand: Hand) -> bool { + let Some(m) = self.mobs.get(i).filter(|m| m.alive()) else { + return false; + }; + let stack = match hand { + Hand::Main => self.stack_in(self.selected), + Hand::Off => self.offhand.as_ref(), + }; + let item = stack.map_or("", |s| &*s.item); + let baby = m.is_baby(); + // Mob.checkAndHandleImportantInteractions: a lead, a named name tag, + // a spawn egg of the mob's own kind. + if item == "minecraft:lead" + || item == "minecraft:name_tag" && stack.is_some_and(|s| s.custom_name().is_some()) + || item.strip_suffix("_spawn_egg") == Some(m.kind.id.as_str()) + { + return true; + } + // Animal.mobInteract: its food is CONSUME on a client. + if m.kind.flags.animal && m.kind.food.iter().any(|f| f.as_str() == item) { + return true; + } + let sneaking = self.keys.contains(&winit::keyboard::KeyCode::ShiftLeft); + match m.species() { + // Villager / WanderingTrader.mobInteract: trading, or a baby's head shake. + Species::Villager | Species::WanderingTrader => item != "minecraft:villager_spawn_egg", + // AbstractHorse, Camel: ridden (or their inventory opened); a baby only eats. + s if equine::is_equine(s) + || llama::is_llama(s) + || matches!(s, Species::Camel | Species::CamelHusk) => + { + !baby + } + // Pig / Strider.mobInteract: a saddled one is ridden. + Species::Pig | Species::Strider => m.extra.saddled && !sneaking, + // HappyGhast.mobInteract: a harnessed adult is ridden. + Species::HappyGhast => !baby && m.extra.head.is_some(), + // TamableAnimal (wolf, cat, parrot) on a client: CONSUME once tame. + Species::Wolf | Species::Cat | Species::Parrot => m.extra.tame, + // Allay.mobInteract: gives an item or takes it back. + Species::Allay => !item.is_empty() || m.extra.main_hand.is_some(), + Species::Cow | Species::Goat => item == "minecraft:bucket" && !baby, + Species::Mooshroom => { + matches!( + item, + "minecraft:bucket" | "minecraft:bowl" | "minecraft:shears" + ) && !baby + } + Species::Sheep => item == "minecraft:shears" || item.ends_with("_dye"), + // Bucketable.bucketMobPickup. + Species::Cod + | Species::Salmon + | Species::TropicalFish + | Species::Pufferfish + | Species::Axolotl + | Species::Tadpole => item == "minecraft:water_bucket", + Species::Armadillo => item == "minecraft:brush", + // ZombieVillager.mobInteract: CONSUME for a golden apple. + Species::ZombieVillager => item == "minecraft:golden_apple", + // Creeper.mobInteract: CREEPER_IGNITERS. + Species::Creeper => { + matches!(item, "minecraft:flint_and_steel" | "minecraft:fire_charge") + } + // PiglinAi.mobInteract: an adult admires what it loves. + Species::Piglin => { + !baby + && self + .res + .items() + .item_tags + .get("minecraft:piglin_loved") + .is_some_and(|tag| tag.contains(item)) + } + _ => false, + } + } +} diff --git a/crates/horizon-client/src/lan/entity.rs b/crates/horizon-client/src/lan/entity.rs index 676fd0adc..ae3089006 100644 --- a/crates/horizon-client/src/lan/entity.rs +++ b/crates/horizon-client/src/lan/entity.rs @@ -489,12 +489,16 @@ impl ServerEntity { // A value back at its default is left out of the state, but the // clients still hold the old one: Entity's shared flags and pose go // back to 0 (a player standing up again, a mob no longer on fire), - // a sleeper's bed to none. + // a sleeper's bed to none, an item frame's item to empty and its + // rotation to 0 (ItemFrame.DATA_ITEM and DATA_ROTATION). + let frame = e.kind.ends_with("item_frame"); for (index, kind, _) in &self.meta { let default = match (*index, *kind) { (0, serializer::BYTE) => Value::Byte(0), (6, serializer::POSE) => Value::Id(0), (14, serializer::OPTIONAL_BLOCK_POS) => Value::OptPos(None), + (9, serializer::ITEM_STACK) if frame => Value::Item(None), + (10, serializer::INT) if frame => Value::Int(0), _ => match e.defaults.iter().find(|d| (d.0, d.1) == (*index, *kind)) { Some(d) => d.2.clone(), None => continue, @@ -1106,6 +1110,39 @@ mod tests { assert!(changes(&mut s, &e).is_empty()); } + #[test] + fn an_emptied_item_frame_sends_its_empty_item_and_rotation() { + let mut e = state(0.0); + e.kind = "minecraft:item_frame".into(); + let mut s = added(&e); + changes(&mut s, &e); + e.meta = vec![ + ( + 9, + serializer::ITEM_STACK, + Value::Item(Some(Stack::new(5, 1))), + ), + (10, serializer::INT, Value::Int(3)), + ]; + changes(&mut s, &e); + // Punched out (ItemFrame.removeFramedMap, setItem(EMPTY)): both back to the default. + e.meta.clear(); + let data = changes(&mut s, &e) + .into_iter() + .find_map(|p| match p { + play::Clientbound::SetEntityData(d) => Some(d), + _ => None, + }) + .expect("the empty frame is sent"); + assert_eq!( + data.values, + vec![ + (9, serializer::ITEM_STACK, Value::Item(None)), + (10, serializer::INT, Value::Int(0)), + ] + ); + } + #[test] fn a_value_back_at_a_listed_default_is_sent() { let mut e = state(0.0); diff --git a/tools/lan_e2e.py b/tools/lan_e2e.py index 4551ed82e..5ba25e99a 100755 --- a/tools/lan_e2e.py +++ b/tools/lan_e2e.py @@ -142,6 +142,11 @@ address. The script then checks, from both sides, what a guest's game used to ge it (#1222). - frames: the host and the guest each put a diamond in an item frame and turn it, and put a helmet on an armor stand and take it back (#1222). +- hands: the host and the guest each, at a cow that cares for none of it: draw a bow and shoot, and + let go of a golden apple at once without eating it (the click goes on to the item); + milk the cow with a bucket in the off hand and feed it wheat from the off hand; and + punch the diamond out of an item frame, which then shows empty on both sides (#1350, + #1355, #1362). - mounts: the host and the guest each open a tamed horse's, donkey's and llama's inventory (shift + right click, then the inventory key while riding), put on a saddle, armour or a carpet and fill the chest by shift-clicking. @@ -216,7 +221,7 @@ ROOT = Path(__file__).resolve().parents[1] GUEST_NAME = 'Guest' # The host plays single player on its server thread (--server-thread). SERVER_THREAD = False -CHECKS = ['tab', 'self', 'armour', 'nametags', 'walls', 'chest', 'crafting', 'sign', 'damage', 'mobs', 'hazards', 'pvp', 'arrows', 'kills', 'hurt', 'looks', 'leads', 'respawn', 'containers', 'feedback', 'titles', 'chat', 'commands', 'recipes', 'machines', 'brewing', 'loom', 'stonecutter', 'grindstone', 'anvil', 'smithing', 'enchanting', 'beacon', 'crafter', 'lectern', 'cartography', 'trials', 'clicks', 'sleep', 'predict', 'push', 'eat', 'eating', 'xp', 'objects', 'projectiles', 'thrown', 'sparks', 'hud', 'sidebar', 'border', 'particles', 'worn', 'blast', 'barter', 'deflect', 'fireball', 'light', 'time', 'swings', 'cracks', 'plates', 'effects', 'portals', 'distance', 'growth', 'flight', 'ladder', 'boats', 'minecarts', 'frames', 'lightning', 'riding', 'mounts', 'worldspawn', 'beds', 'shield', 'deathmining', 'contacts', 'absorption', 'breath', 'lava', 'levels', 'drops', 'underwater'] +CHECKS = ['tab', 'self', 'armour', 'nametags', 'walls', 'chest', 'crafting', 'sign', 'damage', 'mobs', 'hazards', 'pvp', 'arrows', 'kills', 'hurt', 'looks', 'leads', 'respawn', 'containers', 'feedback', 'titles', 'chat', 'commands', 'recipes', 'machines', 'brewing', 'loom', 'stonecutter', 'grindstone', 'anvil', 'smithing', 'enchanting', 'beacon', 'crafter', 'lectern', 'cartography', 'trials', 'clicks', 'sleep', 'predict', 'push', 'eat', 'eating', 'xp', 'objects', 'projectiles', 'thrown', 'sparks', 'hud', 'sidebar', 'border', 'particles', 'worn', 'blast', 'barter', 'deflect', 'fireball', 'light', 'time', 'swings', 'cracks', 'plates', 'effects', 'portals', 'distance', 'growth', 'flight', 'ladder', 'boats', 'minecarts', 'frames', 'hands', 'lightning', 'riding', 'mounts', 'worldspawn', 'beds', 'shield', 'deathmining', 'contacts', 'absorption', 'breath', 'lava', 'levels', 'drops', 'underwater'] class Game: @@ -3676,6 +3681,88 @@ def check_frames(host, guest, out): return result +def check_hands(host, guest, out): + """#1350, #1355, #1362: right clicks a cow passes go on to the item, the off hand gets its + turn on the cow, and a frame punched empty is empty for everyone.""" + result = {} + spots = apart(host, guest) + for label, player, other in (('host', host, guest), ('guest', guest, host)): + x, y, z = spots[label] + player('command', command='gamemode survival') + player('command', command='clear @s') + player('command', command='effect clear @s') + # A cow two blocks ahead that stays put, and a framed diamond on a wall behind the player. + player('command', command=f'summon minecraft:cow {x + 0.5} {y} {z + 3.5} {{NoAI:1b}}') + player('command', command=f'fill {x - 1} {y} {z - 2} {x + 1} {y + 2} {z - 2} minecraft:stone') + player('command', command=f'summon minecraft:item_frame {x + 0.5} {y + 1.5} {z - 0.97} ' + f'{{block_pos:[I;{x},{y + 1},{z - 1}],Facing:3b,Item:{{id:"minecraft:diamond",count:1}}}}') + player.wait(20) + counts = lambda: player('inventory')['counts'] + aim_cow = lambda: player.raw('look-at', f'{x + 0.5:.2f}', f'{y + 0.8:.2f}', f'{z + 3.5:.2f}') + try: + player('command', command='give @s minecraft:bow') + player('command', command='give @s minecraft:arrow 6') + player.wait(5) + player.raw('select', 'minecraft:bow') + aim_cow() + assert player('looking_at')['kind'] == 'entity', f'the {label} does not aim at the cow' + # Half drawn: a full draw is a crit, up to 10 damage (AbstractArrow.onHitEntity), which + # kills the 10 health cow one shot in five. Under 20 ticks the arrow does at most 6. + player.raw('mouse', 'right', 'down') + player.wait(10) + drawn = player('state')['using'] + player.raw('mouse', 'right', 'up') + player.wait(20) + assert drawn, f'the {label}\'s bow is not drawn at the cow' + assert counts().get('minecraft:arrow') == 5, f'the {label} shot no arrow: {counts()}' + aim_cow() + cow = player('looking_at').get('entity') or {} + assert cow.get('health', 0) > 0, f'the {label}\'s arrow killed the cow: {cow}' + player('command', command='clear @s') + player('command', command='give @s minecraft:golden_apple') + player.wait(5) + player.raw('select', 'minecraft:golden_apple') + aim_cow() + player.raw('mouse', 'right', 'down') + player.wait(5) + player.raw('mouse', 'right', 'up') + player.wait(40) + assert counts().get('minecraft:golden_apple') == 1, f'the {label} ate the apple let go of: {counts()}' + # The main hand empty, a bucket and then wheat in the off hand. + player('command', command='clear @s') + player('command', command='item replace entity @s weapon.offhand with minecraft:bucket') + player.wait(5) + aim_cow() + player.raw('mouse', 'right', 'click') + player.wait(15) + offhand = player('inventory')['offhand'] + assert offhand and offhand['item'] == 'minecraft:milk_bucket', f'the {label}\'s off hand holds {offhand}' + player('command', command='item replace entity @s weapon.offhand with minecraft:wheat 3') + player.wait(5) + aim_cow() + player.raw('mouse', 'right', 'click') + player.wait(15) + offhand = player('inventory')['offhand'] + assert offhand and offhand['count'] == 2, f'the {label}\'s cow ate no off hand wheat: {offhand}' + # The framed diamond, punched out. + frame = [o for o in player('status')['objects'] if o['kind'].endswith('item_frame') + and o['position'] == [x, y + 1, z - 1]] + assert frame and frame[0]['item'] == 'minecraft:diamond', f'the {label} sees the frame as {frame}' + player.raw('look-at', f'{x + 0.5:.2f}', f'{y + 1.5:.2f}', f'{z - 0.95:.2f}') + player.raw('mouse', 'left', 'click') + player.wait(20) + for side, game in ((label, player), ('other side', other)): + seen = [o for o in game('status')['objects'] if o['kind'].endswith('item_frame') + and o['position'] == [x, y + 1, z - 1]] + assert seen and seen[0].get('item') is None, f'the {side} sees the punched frame as {seen}' + result[label] = {'bow': 'shot', 'apple': 'kept', 'off hand': 'milked, fed', 'frame': 'emptied'} + finally: + player('command', command=f'kill @e[type=!minecraft:player,x={x - 3},y={y - 1},z={z - 3},dx=6,dy=4,dz=8]') + player('command', command=f'fill {x - 1} {y} {z - 2} {x + 1} {y + 2} {z - 2} minecraft:air') + player('command', command='clear @s') + return result + + # Animals a player rides: (kind, summon NBT, what readies it, what is held to ride, the test # while riding). `move` walks forward, `jump` charges the horse's jump bar, `rise` holds jump on # a happy ghast, `sit` only rides (a llama goes where it likes). @@ -4231,7 +4318,7 @@ CHECK_FNS = {'tab': check_tab, 'self': check_self, 'armour': check_armour, 'flight': check_flight, 'fireball': check_fireball, 'deflect': check_deflect, 'barter': check_barter, 'worn': check_worn, 'kills': check_kills, 'arrows': check_arrows, 'predict': check_predict, 'ladder': check_ladder, - 'boats': check_boats, 'minecarts': check_minecarts, 'frames': check_frames, + 'boats': check_boats, 'minecarts': check_minecarts, 'frames': check_frames, 'hands': check_hands, 'lightning': check_lightning, 'riding': check_riding, 'mounts': check_mounts, 'worldspawn': check_world_spawn, 'beds': check_beds, 'shield': check_shield, 'deathmining': check_death_mining, 'contacts': check_contacts, 'absorption': check_absorption, 'breath': check_breath,