Dispense chest boats and command block minecarts as vanilla does

BoatDispenseItemBehavior spawns the chest boat or chest raft itself: boats
now carry ChestBoat's 27-slot chest, drawn with its model, saved with its
Items, opened by sneaking, spilt when broken. MinecartDispenseItemBehavior
spawns command block minecarts (an empty command). The dispenser harness
now draws fronts per item (fire, portal frames, anchors, crops, copper,
hives, golem and wither builds), every boat wood, more equipment, spawn
eggs, sulfur cube swallowables and leashed targets, over 6000 cases.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Ludovic Marie
2026-10-11 15:38:13 +02:00
parent a5aaa53ab7
commit f9fcb004a5
10 changed files with 320 additions and 78 deletions
+130 -18
View File
@@ -34,9 +34,15 @@ def plain(item, count=1):
return '{id:"minecraft:%s",count:%d}' % (item, count)
# Items with the blocks and entities in front that exercise their behaviour.
WOODS = ['oak', 'spruce', 'birch', 'jungle', 'acacia', 'cherry', 'dark_oak', 'mangrove', 'pale_oak', 'poplar']
# Items with the blocks and entities in front that exercise their behaviour:
# one entry per DispenseItemBehavior.bootStrap registration family, plus the
# defaults of DispenserBlock.getDefaultDispenseMethod (equippables, sulfur
# cube swallowables, spawn eggs, a plain drop).
ITEMS = {
'drop': [plain('stone', 5), plain('diamond'), plain('stick', 64), plain('oak_sapling', 3), plain('redstone', 2)],
'drop': [plain('stone', 5), plain('diamond'), plain('stick', 64), plain('oak_sapling', 3), plain('redstone', 2), plain('lead'),
plain('wheat_seeds', 7)],
'projectile': [plain('arrow', 3), potion('tipped_arrow', 'poison'), plain('spectral_arrow'), plain('egg', 2), plain('blue_egg'),
plain('brown_egg'), plain('snowball', 4), plain('experience_bottle'), potion('splash_potion', 'healing'),
potion('lingering_potion', 'swiftness'), plain('firework_rocket', 2), plain('fire_charge', 2), plain('wind_charge', 3)],
@@ -45,13 +51,22 @@ ITEMS = {
plain('sulfur_cube_bucket'), plain('bucket'), plain('bucket', 3)],
'block': [plain('bone_meal', 4), plain('tnt', 2), plain('flint_and_steel'), plain('glowstone', 3), plain('honeycomb', 2),
plain('glass_bottle', 2), potion('potion', 'water'), potion('potion', 'healing'), plain('shulker_box'),
plain('red_shulker_box'), plain('carved_pumpkin'), plain('wither_skeleton_skull'), plain('shears'), plain('brush')],
'vehicle': [plain('oak_boat'), plain('bamboo_raft'), plain('minecart'), plain('chest_minecart'),
plain('furnace_minecart'), plain('tnt_minecart'), plain('hopper_minecart'), plain('armor_stand', 2)],
'spawn': [plain('pig_spawn_egg'), plain('sheep_spawn_egg', 2), plain('zombie_spawn_egg'), plain('cow_spawn_egg'), plain('chicken_spawn_egg')],
plain('red_shulker_box'), plain('lime_shulker_box'), plain('carved_pumpkin'), plain('wither_skeleton_skull'),
plain('shears'), plain('brush')],
'vehicle': [plain('oak_boat'), plain('bamboo_raft'), plain('bamboo_chest_raft'), plain('minecart'), plain('chest_minecart'),
plain('furnace_minecart'), plain('tnt_minecart'), plain('hopper_minecart'), plain('command_block_minecart'),
plain('armor_stand', 2), 'BOAT', 'CHEST_BOAT'],
'spawn': [plain('pig_spawn_egg'), plain('sheep_spawn_egg', 2), plain('zombie_spawn_egg'), plain('cow_spawn_egg'),
plain('chicken_spawn_egg'), plain('skeleton_spawn_egg'), plain('creeper_spawn_egg'), plain('villager_spawn_egg'),
plain('wolf_spawn_egg'), plain('horse_spawn_egg'), plain('squid_spawn_egg'), plain('slime_spawn_egg')],
'equipment': [plain('iron_helmet'), plain('diamond_chestplate'), plain('leather_leggings'), plain('golden_boots'),
plain('turtle_helmet'), plain('saddle'), plain('iron_horse_armor'), plain('white_carpet'), plain('chest'),
plain('carved_pumpkin'), plain('elytra'), plain('wolf_armor'), plain('shears'), plain('brush'), plain('player_head')],
plain('chainmail_helmet'), plain('netherite_boots'), plain('turtle_helmet'), plain('saddle'),
plain('iron_horse_armor'), plain('diamond_horse_armor'), plain('leather_horse_armor'), plain('white_carpet'),
plain('red_carpet'), plain('chest'), plain('carved_pumpkin'), plain('elytra'), plain('wolf_armor'), plain('shears'),
plain('brush'), plain('player_head'), plain('zombie_head'), plain('white_harness')],
'swallow': [plain('slime_block'), plain('oak_planks', 3), plain('packed_ice'), plain('soul_sand'), plain('magma_block'),
plain('white_wool'), plain('mud', 2), plain('andesite'), plain('iron_block'), plain('mushroom_stem'),
plain('honeycomb_block'), plain('tube_coral_block'), plain('tnt'), plain('stone')],
}
FRONT = {
@@ -65,29 +80,74 @@ FRONT = {
'vehicle': ['air', 'air', 'water', 'rail', 'powered_rail', 'activator_rail', 'stone', 'detector_rail'],
'spawn': ['air', 'air', 'water', 'stone', 'grass_block'],
'equipment': ['air'],
'swallow': ['air'],
}
# The blocks a behaviour reacts to, drawn for that item most of the time.
FRONT_FOR = {
'flint_and_steel': ['air', 'air', 'air', 'campfire', 'soul_campfire', 'candle', 'blue_candle', 'candle_cake',
'red_candle_cake', 'tnt', 'stone', 'obsidian', 'netherrack', 'water'],
'glowstone': ['respawn_anchor', 'respawn_anchor', 'respawn_anchor', 'air', 'stone', 'glowstone'],
'bone_meal': ['grass_block', 'wheat', 'carrots', 'potatoes', 'beetroots', 'oak_sapling', 'birch_sapling', 'spruce_sapling',
'cherry_sapling', 'mangrove_propagule', 'moss_block', 'sweet_berry_bush', 'cocoa', 'bamboo_sapling', 'bamboo',
'pumpkin_stem', 'melon_stem', 'torchflower_crop', 'pitcher_crop', 'rooted_dirt', 'glow_lichen', 'small_dripleaf',
'big_dripleaf', 'crimson_nylium', 'warped_fungus', 'brown_mushroom', 'kelp', 'sea_pickle', 'seagrass', 'water',
'short_grass', 'fern', 'dandelion', 'pink_petals', 'cave_vines', 'twisting_vines', 'weeping_vines', 'azalea',
'pale_moss_block', 'stone', 'air'],
'honeycomb': ['copper_block', 'exposed_copper', 'weathered_cut_copper', 'oxidized_cut_copper_slab', 'copper_door',
'exposed_copper_trapdoor', 'copper_bulb', 'lightning_rod', 'waxed_copper_block', 'copper_grate', 'stone', 'air'],
'glass_bottle': ['beehive', 'beehive', 'bee_nest', 'bee_nest', 'water', 'water', 'air', 'stone', 'seagrass'],
'potion': ['dirt', 'coarse_dirt', 'rooted_dirt', 'dirt', 'stone', 'air', 'mud', 'water'],
'shears': ['beehive', 'bee_nest', 'beehive', 'air', 'air', 'stone', 'pumpkin'],
'brush': ['air', 'air', 'suspicious_sand', 'stone'],
'tnt': ['air', 'air', 'stone', 'water', 'tnt'],
'shulker_box': ['air', 'air', 'stone', 'water', 'short_grass', 'snow'],
'carved_pumpkin': ['air', 'air', 'stone', 'snow'],
'wither_skeleton_skull': ['air', 'air', 'stone'],
'armor_stand': ['air', 'air', 'stone', 'water', 'short_grass'],
}
# Structures a behaviour completes (golems, the wither, a nether portal).
SCENES = {'carved_pumpkin': ['snow_golem', 'iron_golem'], 'wither_skeleton_skull': ['wither'], 'flint_and_steel': ['portal']}
BELOW = ['air', 'stone', 'water', 'rail', 'grass_block', 'soul_sand', 'dirt', 'farmland', 'netherrack']
TARGETS = {
'iron_helmet': ['zombie', 'skeleton', 'armor_stand', 'pig'],
'chainmail_helmet': ['zombie', 'armor_stand', 'villager'],
'diamond_chestplate': ['zombie', 'armor_stand'],
'leather_leggings': ['skeleton', 'armor_stand'],
'golden_boots': ['zombie', 'armor_stand'],
'netherite_boots': ['zombie', 'piglin', 'armor_stand'],
'turtle_helmet': ['armor_stand', 'zombie'],
'saddle': ['pig', 'horse', 'strider', 'donkey', 'camel', 'llama'],
'saddle': ['pig', 'horse', 'strider', 'donkey', 'camel', 'llama', 'mule', 'skeleton_horse', 'nautilus'],
'iron_horse_armor': ['horse', 'donkey'],
'diamond_horse_armor': ['horse', 'zombie_horse'],
'leather_horse_armor': ['horse'],
'white_carpet': ['llama', 'horse', 'trader_llama'],
'chest': ['donkey', 'mule', 'llama', 'horse'],
'red_carpet': ['llama', 'trader_llama'],
'chest': ['donkey', 'mule', 'llama', 'horse', 'trader_llama'],
'carved_pumpkin': ['zombie', 'armor_stand', 'snow_golem'],
'elytra': ['armor_stand', 'zombie'],
'wolf_armor': ['wolf'],
'shears': ['sheep', 'sheep', 'mooshroom', 'bogged', 'snow_golem'],
'white_harness': ['happy_ghast'],
'shears': ['sheep', 'sheep', 'mooshroom', 'bogged', 'snow_golem', 'sulfur_cube', 'pig', 'cow'],
'brush': ['armadillo'],
'tnt': ['sulfur_cube'],
'flint_and_steel': ['sulfur_cube'],
'stone': ['sulfur_cube'],
'player_head': ['armor_stand', 'zombie'],
'zombie_head': ['armor_stand', 'skeleton'],
}
for _block in ('stone', 'slime_block', 'oak_planks', 'packed_ice', 'soul_sand', 'magma_block', 'white_wool', 'mud', 'andesite',
'iron_block', 'mushroom_stem', 'honeycomb_block', 'tube_coral_block'):
TARGETS[_block] = ['sulfur_cube']
SWALLOWED = ['tnt', 'stone', 'slime_block', 'magma_block', 'white_wool', 'iron_block']
def item_choice(rng, kind):
item = rng.choice(ITEMS[kind])
if item == 'BOAT':
return plain(rng.choice(WOODS) + '_boat')
if item == 'CHEST_BOAT':
return plain(rng.choice(WOODS) + '_chest_boat')
return item
class States:
@@ -110,6 +170,47 @@ class States:
return rng.choice(self.facts.by_block[name])
def build_scene(cells, states, rng, scene, front, facing):
"""Put the rest of a structure the behaviour's block completes around the front."""
x, y, z = front
across = rng.choice([(1, 0, 0), (0, 0, 1)])
def put(at, name, **props):
if at != (0, 0, 0) and at != front:
h.put(cells, at, states.get(name, **props))
def side(at, k):
return (at[0] + across[0] * k, at[1], at[2] + across[2] * k)
if scene == 'snow_golem':
put((x, y - 1, z), 'snow_block')
put((x, y - 2, z), 'snow_block')
elif scene == 'iron_golem':
put((x, y - 1, z), 'iron_block')
put((x, y - 2, z), 'iron_block')
put(side((x, y - 1, z), -1), 'iron_block')
put(side((x, y - 1, z), 1), 'iron_block')
elif scene == 'wither':
put((x, y - 1, z), 'soul_sand')
put((x, y - 2, z), 'soul_sand')
put(side((x, y - 1, z), -1), rng.choice(['soul_sand', 'soul_soil']))
put(side((x, y - 1, z), 1), 'soul_sand')
put(side((x, y, z), -1), 'wither_skeleton_skull')
put(side((x, y, z), 1), rng.choice(['wither_skeleton_skull', 'wither_skeleton_skull', 'skeleton_skull']))
elif scene == 'portal':
# An obsidian frame around a 2x3 inside that holds the front block.
width, height = rng.choice([(2, 3), (2, 3), (3, 4)])
left, low = rng.randrange(width), rng.randrange(height)
for i in range(-1, width + 1):
for j in range(-1, height + 1):
at = side((x, y + j - low, z), i - left)
edge = i in (-1, width) or j in (-1, height)
if edge and not (i in (-1, width) and j in (-1, height)):
put(at, 'obsidian')
elif not edge:
if at not in ((0, 0, 0), front):
h.put(cells, at, states.get('air'))
def front_state(states, rng, name):
"""Mostly the default state, sometimes a random one (charges, honey, ages, lit...)."""
if name in ('respawn_anchor', 'beehive', 'bee_nest', 'campfire', 'candle', 'wheat', 'sweet_berry_bush', 'rail', 'powered_rail',
@@ -124,28 +225,33 @@ def cases(facts, count, seed, only):
kinds = list(ITEMS)
for n in range(count):
kind = kinds[n % len(kinds)]
item = rng.choice(ITEMS[kind])
item = item_choice(rng, kind)
if only and only not in item:
continue
bare = item.split('"')[1].split(':')[1]
facing = rng.choice(DIRECTIONS)
block = 'dropper' if rng.random() < 0.12 else 'dispenser'
cells = [[0, 0, 0, states.get(block, facing=facing, triggered='false')]]
dx, dy, dz = STEP[facing]
front = (dx, dy, dz)
below = (dx, dy - 1, dz)
front_name = rng.choice(FRONT[kind])
palette = FRONT_FOR[bare] if bare in FRONT_FOR and rng.random() < 0.8 else FRONT[kind]
front_name = rng.choice(palette)
if front_name != 'air':
h.put(cells, front, front_state(states, rng, front_name))
if below != (0, 0, 0) and rng.random() < 0.8:
name = rng.choice(BELOW)
if name != 'air':
h.put(cells, below, front_state(states, rng, name))
scene = rng.choice(SCENES[bare]) if bare in SCENES and rng.random() < 0.45 else None
# A few random blocks around (portal frames, fire supports, neighbours).
for _ in range(rng.randrange(0, 6)):
at = (rng.randrange(-2, 3), rng.randrange(-2, 3), rng.randrange(-2, 3))
if at in ((0, 0, 0), front):
continue
h.put(cells, at, states.get(rng.choice(['stone', 'obsidian', 'dirt', 'water', 'soul_sand', 'grass_block', 'oak_planks'])))
if scene:
build_scene(cells, states, rng, scene, front, facing)
items = []
slots = rng.sample(range(9), rng.choice([1, 1, 1, 2, 3, 9]))
for i, slot in enumerate(slots):
@@ -155,8 +261,7 @@ def cases(facts, count, seed, only):
case.pop('thundering', None)
if rng.random() < 0.08:
case['rules'] = {'tnt_explodes': False}
bare = item.split('"')[1].split(':')[1]
if kind == 'equipment' or (bare in TARGETS and rng.random() < 0.5):
if kind in ('equipment', 'swallow') or (bare in TARGETS and rng.random() < 0.5):
entities = []
for _ in range(rng.choice([1, 1, 1, 2])):
target = {'type': 'minecraft:' + rng.choice(TARGETS.get(bare, ['zombie'])),
@@ -165,8 +270,15 @@ def cases(facts, count, seed, only):
if rng.random() < odds:
target[flag] = True
if target['type'] == 'minecraft:sulfur_cube' and rng.random() < 0.5:
target['equip'] = {'body': plain(rng.choice(['tnt', 'stone', 'slime_block']))}
target['equip'] = {'body': plain(rng.choice(SWALLOWED))}
# Leads: tied to an earlier target, or that target holds this one's.
if entities and rng.random() < 0.3:
target['leash'] = rng.randrange(len(entities))
entities.append(target)
if bare == 'shears' and len(entities) == 1 and rng.random() < 0.3:
# A holder out of the dispenser's reach whose lead runs to the target.
entities.append({'type': 'minecraft:' + rng.choice(['cow', 'wolf']), 'pos': [dx + 3.5, dy, dz + 3.5], 'yaw': 0.0})
entities[0]['leash'] = 1
case['entities'] = entities
if block == 'dropper' and rng.random() < 0.5:
h.put(cells, front, states.get(rng.choice(['chest', 'hopper', 'barrel', 'dispenser'])))
@@ -233,7 +345,7 @@ def main():
parser = h.argument_parser(__doc__)
args = parser.parse_args()
if args.count == 40000:
args.count = 3000
args.count = 6000
lock, jars, libraries = base.verify_artifacts()
facts = h.load_facts()
resources = lab.LOCAL / 'horizon-client' / lock['minecraft']['version']