Beacon on the menu engine; LAN guests use beacons

BeaconMenu now runs on horizon_client::menu (Kind::Beacon): the payment
slot (beacon_payment_items, one item), quickMoveStack and updateEffects
with BeaconBlockEntity.validateEffects, verified against the vanilla class
by test_menu_click_parity with a new SET_BEACON op (valid and invalid
powers for each pyramid level).

ServerboundSetBeaconPacket is now in the protocol. The LAN host opens
minecraft:beacon for guests with the block entity's levels and powers as
data slots (kept current while the menu is open), applies a guest's
powers to the block entity (power_select while the beam is up) and drops
the payment when the menu closes, as BeaconMenu.removed does. Guests show
the server's levels and powers and their Done button sends the packet.
Single player's beacon clicks go through the engine too.

Part of #868.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Ludovic Marie
2026-10-22 07:11:32 +02:00
parent b5a92262c8
commit ca5404e52d
14 changed files with 370 additions and 29 deletions
@@ -1719,6 +1719,11 @@ packet!(
/// ServerboundRenameItemPacket: `AnvilMenu.setItemName`.
RenameItem { name: String => Str }
);
packet!(
/// ServerboundSetBeaconPacket: `BeaconMenu.updateEffects`, each power an
/// optional `mob_effect` id.
SetBeacon { primary: Option<i32> => Opt<VarInt>, secondary: Option<i32> => Opt<VarInt> }
);
packet!(Interact { id: i32 => VarInt, hand: i32 => VarInt, location: [f64; 3] => LpVec3, secondary: bool => Bool });
packet!(
/// ServerboundMovePlayerPacket flags: 1 on ground, 2 horizontal collision.
@@ -1805,6 +1810,7 @@ packet_enum!(Serverbound, crate::ids::play::serverbound {
Punch(Empty) = PUNCH,
ResourcePack(ResourcePackResponse) = RESOURCE_PACK,
SelectTrade(SelectTrade) = SELECT_TRADE,
SetBeacon(SetBeacon) = SET_BEACON,
SetCarriedItem(SetCarriedItem) = SET_CARRIED_ITEM,
SetCreativeModeSlot(SetCreativeModeSlot) = SET_CREATIVE_MODE_SLOT,
UseItem(UseItem) = USE_ITEM,
@@ -2384,6 +2390,13 @@ mod tests {
});
assert_eq!(&rename.encode()[1..], &[5, b'B', b'l', b'a', b'd', b'e']);
round_trip(rename, Serverbound::encode, Serverbound::decode);
// Two optional mob effect ids: a presence byte, then the VarInt.
let beacon = Serverbound::SetBeacon(SetBeacon {
primary: Some(2),
secondary: None,
});
assert_eq!(&beacon.encode()[1..], &[1, 2, 0]);
round_trip(beacon, Serverbound::encode, Serverbound::decode);
}
#[test]