Merge pull request #1085 from ludovic111/fix/place-blocked-by-entities

🤖 Agent: merged. Blocks can't be placed into entities (fixes #1052, Visivel). Integration proof (main + #1079 #1081 #1082 #1083 #1085 #1086 #1087), 2026-10-21: desktop parity 103/105; the 2 others (world_reopen, save_roundtrip) need a display and pass on the Mac mini. Verify passed.
This commit is contained in:
Ludovic Marie
2026-10-21 18:05:21 +02:00
committed by GitHub
4 changed files with 126 additions and 22 deletions
+35 -1
View File
@@ -2,7 +2,8 @@
"""Compare a player's right click on a block with vanilla's, for items that are
both food and blocks (sweet and glow berries, carrots, potatoes), for sweet
berry bushes, for spawn eggs used on a monster spawner, for shears carving
pumpkins, for respawn anchors and for beds in the Nether and the End.
pumpkins, for blocks placed where mobs and armor stands stand, for respawn
anchors and for beds in the Nether and the End.
Every case has a block at the origin, something above it, and a player three
blocks south, survival or creative, hungry or full, sneaking or not, who
@@ -179,6 +180,31 @@ def pumpkin_case(rng, states, case):
case['cells'] = cells
# Entities a block may be placed into (`Entity.blocksBuilding`), and blocks to place.
BLOCKERS = ['skeleton', 'zombie', 'pig', 'chicken', 'cow', 'armor_stand', 'slime', 'bat']
PLACED = ['obsidian', 'stone', 'oak_slab', 'oak_fence', 'white_carpet', 'torch', 'glass', 'oak_trapdoor', 'snow']
def blocked_case(rng, states, case):
"""A block placed on top of the origin where a mob or an armor stand stands, in its box or beside it
(`BlockItem.canPlace`'s `Level.isUnobstructed`)."""
case['cells'] = [[0, 0, 0, states.get(rng.choice(['stone', 'grass_block', 'dirt']))]]
entities = []
for _ in range(rng.choice([1, 1, 2])):
kind = rng.choice(BLOCKERS)
offset = [rng.choice([0, 0, 0.3, -0.45, 0.7, -1.2]), rng.choice([0, 0, 0.5, 0.95, 1.02, -0.5]),
rng.choice([0, 0, 0.3, -0.6, 0.9])]
e = {'type': f'minecraft:{kind}', 'pos': [0.5 + offset[0], 1 + offset[1], 0.5 + offset[2]]}
if kind == 'armor_stand' and rng.random() < 0.3:
e['marker'] = True
if kind in ('pig', 'cow', 'chicken') and rng.random() < 0.3:
e['baby'] = True
entities.append(e)
case['entities'] = entities
case['use_item'] = {'item': d_plain(rng.choice(PLACED), rng.choice([1, 16])), 'creative': rng.random() < 0.3,
'sneaking': False, 'food': 20}
def cases(facts, count, seed):
rng = random.Random(seed)
states = d.States(facts)
@@ -204,6 +230,12 @@ def cases(facts, count, seed):
case['mode'] = 'dispense'
yield case
continue
if rng.random() < 0.1:
blocked_case(rng, states, case)
case['items'] = []
case['mode'] = 'dispense'
yield case
continue
if rng.random() < 0.12:
pumpkin_case(rng, states, case)
case['items'] = []
@@ -261,6 +293,8 @@ def kind(case, facts):
return f'respawn at {first}'
item = case['use_item']['item']
item = item.split('"')[1].split(':')[1] if item != '-' else 'empty hand'
if 'entities' in case:
return f'{item} placed by ' + ', '.join(e['type'].split(':')[1] for e in case['entities'])
return f'{item} on {first}'