Aim and click beds from grounded openings

This commit is contained in:
Tanner committed 2026-11-18 20:39:47 +00:00
1 parent 838bac6680
commit 37f72d674f
3 files changed
+264 -44

No files matched your search

+16 -5
View File
@@ -125,18 +125,29 @@ class BedPacketsAndWorldTests(unittest.TestCase):
self.assertTrue(force)
self.assertIsInstance(connection.packets[1][0], ClientTickEnd)
def test_existing_bed_use_aims_inside_the_short_bed_collision_shape(self):
def test_bed_click_targets_the_top_of_its_collision_shape(self):
connection = FakeConnection()
game = Game.__new__(Game)
game.g = Munch(connection=connection)
bed = (-175, 70, -312)
bed_state = next(
state for state in blocks.BED_IDS
if blocks.PROPS[state].get('part') == 'foot')
game.g = Munch(
connection=connection,
world=Munch(block_at=lambda *position: bed_state))
game.sequence = 0
game.place_block((-175, 70, -312), 1, cursor_y=0.5)
interaction = game.bed_interaction_point(bed)
self.assertIsNotNone(interaction)
self.assertTrue(game.click_bed(bed, cursor=interaction[0]))
packet = connection.packets[0][0]
self.assertIsInstance(packet, UseItemOnBlockPacket)
self.assertEqual(packet.location, (-175, 70, -312))
self.assertEqual(packet.cursor_y, 0.5)
self.assertEqual(packet.location, bed)
self.assertEqual(packet.face, 1)
self.assertEqual((packet.cursor_x, packet.cursor_y, packet.cursor_z),
interaction[0])
self.assertAlmostEqual(packet.cursor_y, 0.5625)
self.assertIsInstance(connection.packets[1][0], ClientTickEnd)
def test_bed_in_offhand_is_selectable_without_swapping_inventory(self):