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
@@ -183,10 +183,19 @@ public final class VanillaMenuOracle {
case "anvil" -> new AnvilMenu(0, inv);
case "smithing" -> new SmithingMenu(0, inv);
case "enchanting" -> new EnchantmentMenu(0, inv);
case "beacon" -> new BeaconMenu(0, inv);
default -> throw new IllegalArgumentException(kind);
};
}
/** A SET_BEACON power: a mob effect's name, or null for none. */
static Optional<net.minecraft.core.Holder<net.minecraft.world.effect.MobEffect>> effect(JsonElement name) {
if (name.isJsonNull()) return Optional.empty();
return net.minecraft.core.registries.BuiltInRegistries.MOB_EFFECT
.get(net.minecraft.resources.Identifier.parse(name.getAsString()))
.map(h -> (net.minecraft.core.Holder<net.minecraft.world.effect.MobEffect>) h);
}
static String state(AbstractContainerMenu menu, Inventory inv) throws Exception {
StringBuilder out = new StringBuilder();
for (int i = 0; i < menu.slots.size(); i++) {
@@ -267,6 +276,12 @@ public final class VanillaMenuOracle {
out.println(clickState(menu, inv));
continue;
}
if (kind.equals("SET_BEACON")) {
// ServerGamePacketListenerImpl.handleSetBeaconPacket: BeaconMenu.updateEffects
if (menu instanceof BeaconMenu beacon) beacon.updateEffects(effect(op.get(3)), effect(op.get(4)));
out.println(clickState(menu, inv));
continue;
}
if (kind.equals("SLOT_STATE")) {
// handleContainerSlotStateChanged: CrafterBlockEntity.setSlotState
if (slot >= 0 && slot < 9) crafter.setSlotState(slot, button == 1);