Merge pull request #2047 from ESHAYAT102/fix/cushion-placement
🤖 Agent: Gate check by Ludovic's AI agent (Claude). I checked CushionItem.useOn and Cushion.interact against the 26.3 bytecode with rea_vanilla and pushed three leftovers. (1) An occupied cushion now returns PASS, as Cushion.interact does. (2) A cushion placed in fire burns at once (destroyIfInFire). (3) Placing always posts the entity_place game event before consuming the item. I also merged main into the branch (lan_e2e.py). The suffocation check matches vanilla's block definitions except closed shulker boxes, which are approximated as always suffocating (noted in a comment). Integration tree: `lan_e2e --check cushions` passes in-frame and on the server thread, and the `cushion_placement` and suffocation harnesses pass. Thanks @ESHAYAT102!
This commit is contained in:
@@ -6955,5 +6955,51 @@ CHECKS += ['sonic']
|
||||
CHECK_FNS['sonic'] = check_sonic
|
||||
|
||||
|
||||
def check_cushions(host, guest, out):
|
||||
"""#1935: place a colored cushion, consume it, track it, sit, dismount and break it."""
|
||||
seen = {}
|
||||
for label, player, color in (('host', host, 'red'), ('guest', guest, 'blue')):
|
||||
x, y, z = (int(v // 1) for v in pos_of(player))
|
||||
at = (x + 0.5, y, z + 2.5)
|
||||
host('command', command=f'fill {x - 1} {y} {z + 1} {x + 1} {y + 3} {z + 3} minecraft:air')
|
||||
host('command', command=f'setblock {x} {y - 1} {z + 2} minecraft:stone')
|
||||
player('command', command='gamemode survival')
|
||||
player('command', command=f'item replace entity @s weapon.mainhand with minecraft:{color}_cushion')
|
||||
player.wait(10)
|
||||
player.raw('look-at', *at)
|
||||
player.raw('mouse', 'right', 'click')
|
||||
player.wait(15)
|
||||
def cushions(game):
|
||||
return [o for o in game('status')['objects'] if o['kind'] == 'minecraft:cushion'
|
||||
and abs(o['position'][0] - at[0]) < .1 and abs(o['position'][2] - at[2]) < .1]
|
||||
server, client = cushions(host), cushions(player)
|
||||
seen[label] = {'server': server, 'client': client,
|
||||
'remaining': player('inventory')['counts'].get(f'minecraft:{color}_cushion', 0)}
|
||||
assert len(server) == len(client) == 1, seen
|
||||
assert server[0]['color'] == client[0]['color'] == color, seen
|
||||
assert seen[label]['remaining'] == 0, seen
|
||||
player.shot(out, 'cushion-placed')
|
||||
player.raw('look-at', at[0], at[1] + .125, at[2])
|
||||
player.raw('mouse', 'right', 'click')
|
||||
player.wait(10)
|
||||
seen[label]['riding'] = player('status').get('riding')
|
||||
assert seen[label]['riding'] == server[0]['id'], seen
|
||||
player.raw('key', 'shift', 'down')
|
||||
player.wait(5)
|
||||
player.raw('key', 'shift', 'up')
|
||||
player.wait(5)
|
||||
assert player('status').get('riding') is None, seen
|
||||
player('command', command='gamemode creative')
|
||||
player.raw('look-at', at[0], at[1] + .125, at[2])
|
||||
player.raw('mouse', 'left', 'click')
|
||||
player.wait(10)
|
||||
assert not cushions(host) and not cushions(player), seen
|
||||
return seen
|
||||
|
||||
|
||||
CHECKS += ['cushions']
|
||||
CHECK_FNS['cushions'] = check_cushions
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Compare cushion support, burial and coverage against vanilla's real checks."""
|
||||
import json
|
||||
import random
|
||||
|
||||
try:
|
||||
from . import lab, oracle_harness as harness
|
||||
except ImportError:
|
||||
import lab, oracle_harness as harness
|
||||
|
||||
|
||||
def make_input(build):
|
||||
full = [[0, 0, 0, 1, 1, 1]]
|
||||
shapes = [[], full, [[0, 0, 0, 1, .5, 1]], [[0, .5, 0, 1, 1, 1]],
|
||||
[[.375, 0, .375, .625, 1.5, .625]], [[0, 0, 0, .5, 1, 1]],
|
||||
[[0, 0, 0, .5, 1, 1], [.5, 0, 0, 1, 1, 1]]]
|
||||
rows = []
|
||||
for x, z in ((0, 0), (-2, -3), (17, 31)):
|
||||
for y in (0, .125, .5, .875, 1, 1.00000001, 1.015625, 1.125):
|
||||
for outline in shapes:
|
||||
for collision in shapes:
|
||||
for suffocating in (False, True):
|
||||
rows.append(dict(pos=[x + .5, y, z + .5],
|
||||
cells=[[x, 0, z, outline, collision, suffocating]]))
|
||||
rng = random.Random(1935)
|
||||
for _ in range(500):
|
||||
cells = []
|
||||
for y in (-1, 0, 1):
|
||||
for x in (-1, 0, 1):
|
||||
for z in (-1, 0, 1):
|
||||
if rng.random() < .3:
|
||||
cells.append([x, y, z, rng.choice(shapes), rng.choice(shapes), bool(rng.randrange(2))])
|
||||
rows.append(dict(pos=[rng.choice((0, .5, 1)), rng.choice((0, .5, 1, 1.125)), rng.choice((0, .5, 1))], cells=cells))
|
||||
path = build / 'inputs.jsonl'
|
||||
path.write_text(''.join(json.dumps(row) + '\n' for row in rows))
|
||||
return path, len(rows)
|
||||
|
||||
|
||||
def main():
|
||||
harness.differential(
|
||||
'rust-cushion-placement-parity', 'VanillaCushionPlacementOracle',
|
||||
'cushion_placement_probe', make_input,
|
||||
'Actual Cushion.canBePlacedAt and wouldSurviveAt, with controlled outline, collision '
|
||||
'and suffocation queries. Includes partial supports, burial, complete coverage, '
|
||||
'overhanging outlines, negative coordinates and boundary heights. Item use, '
|
||||
'entity tracking, interaction and persistence are checked separately.',
|
||||
sources=[lab.ROOT / 'crates/horizon-client/src/cushion.rs'])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in New Issue
Block a user