Add the crafter to the menu engine and click harness

The crafter menu follows CrafterMenu: slots refuse items while their disabled flag is set, and the result slot is non-interactive. Random disabled flags are part of the harness cases.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Ludovic Marie
2026-10-10 07:30:07 +02:00
parent 5041496f08
commit 3318a04819
2 changed files with 33 additions and 4 deletions
+30 -1
View File
@@ -54,6 +54,7 @@ pub enum Kind {
/// The cooking recipe type: smelting, blasting or smoking.
Furnace(&'static str),
Brewing,
Crafter,
}
impl Kind {
@@ -71,6 +72,7 @@ impl Kind {
"blast_furnace" => Self::Furnace("blasting"),
"smoker" => Self::Furnace("smoking"),
"brewing" => Self::Brewing,
"crafter" => Self::Crafter,
_ => return None,
})
}
@@ -88,6 +90,10 @@ enum Role {
Output,
/// `ResultSlot` of a crafting grid.
CraftResult,
/// `CrafterSlot`: refuses items while its disabled flag (data slot) is set.
CrafterIn,
/// `NonInteractiveResultSlot`.
Inert,
/// `BrewingStandMenu.PotionSlot`.
Potion,
/// `BrewingStandMenu.IngredientsSlot`.
@@ -230,6 +236,17 @@ impl Menu {
slots.extend(main(27, Role::Shulker));
player(&mut slots);
}
Kind::Crafter => {
containers[MAIN] = vec![None; 9];
slots.extend(main(9, Role::CrafterIn));
player(&mut slots);
slots.push(Slot {
container: RESULT,
index: 0,
role: Role::Inert,
});
data = 10;
}
Kind::Brewing => {
containers[MAIN] = vec![None; 5];
for (index, role) in [
@@ -379,7 +396,8 @@ impl Menu {
.unwrap_or(false),
Role::Shulker => Self::fits_inside(stack),
Role::Fuel => Self::is_fuel(env, stack) || Self::is_bucket(stack),
Role::Output | Role::CraftResult => false,
Role::Output | Role::CraftResult | Role::Inert => false,
Role::CrafterIn => self.data.get(self.slots[s].index) != Some(&1),
Role::Potion => {
env.brewing.is_bottle(stack)
|| env
@@ -398,6 +416,7 @@ impl Menu {
fn may_pickup(&self, s: usize) -> bool {
match self.slots[s].role {
Role::Inert => false,
Role::Armor(_) => match self.slot(s) {
Some(stack) => {
self.creative || stack.enchantment_level("minecraft:binding_curse") == 0
@@ -836,6 +855,16 @@ impl Menu {
return None;
}
}
Kind::Crafter => {
after_take = true;
if index < 9 {
if !self.move_to(env, &mut stack, 9, 45, true) {
return None;
}
} else if !self.move_to(env, &mut stack, 0, 9, false) {
return None;
}
}
Kind::Furnace(recipe) => {
after_take = true;
if index == 2 {
+3 -3
View File
@@ -19,8 +19,8 @@ except ImportError:
import lab
MENUS = {'inventory': 46, 'crafting': 46, 'chest1': 45, 'chest2': 54, 'chest3': 63, 'chest4': 72, 'chest5': 81,
'chest6': 90, 'hopper': 41, 'dispenser': 45, 'shulker': 63, 'furnace': 39, 'blast_furnace': 39, 'smoker': 39, 'brewing': 41}
DATA = {'furnace': 4, 'blast_furnace': 4, 'smoker': 4, 'brewing': 4}
'chest6': 90, 'hopper': 41, 'dispenser': 45, 'shulker': 63, 'furnace': 39, 'blast_furnace': 39, 'smoker': 39, 'brewing': 41, 'crafter': 46}
DATA = {'furnace': 4, 'blast_furnace': 4, 'smoker': 4, 'brewing': 4, 'crafter': 10}
COMMON = ['stone', 'dirt', 'cobblestone', 'oak_planks', 'stick', 'coal', 'iron_ingot', 'diamond', 'apple', 'bread',
'oak_log', 'sand', 'bucket', 'water_bucket', 'lava_bucket', 'ender_pearl', 'snowball', 'egg', 'white_wool',
'iron_helmet', 'diamond_chestplate', 'leather_leggings', 'iron_boots', 'shield', 'carved_pumpkin',
@@ -132,7 +132,7 @@ def main():
if menu in ('inventory', 'crafting') and rng.random() < 0.6:
g.recipe(slots, 2 if menu == 'inventory' else 3)
cases.append({'menu': menu, 'creative': rng.random() < 0.25, 'slots': slots,
'carried': g.stack() if rng.random() < 0.5 else '-', 'data': [0] * DATA.get(menu, 0),
'carried': g.stack() if rng.random() < 0.5 else '-', 'data': [rng.choice([0, 0, 1]) if menu == 'crafter' else 0 for _ in range(DATA.get(menu, 0))],
'ops': g.ops(size)})
(work / 'cases.jsonl').write_text(''.join(json.dumps(c) + '\n' for c in cases))
vanilla.run('VanillaMenuOracle', work / 'cases.jsonl', work / 'native.txt')