Find chest openings within interaction range

This commit is contained in:
Tanner
2026-11-07 19:48:51 +00:00
vanhempi 688297e968
commit 9783631f94
6 muutettua tiedostoa jossa 337 lisäystä ja 27 poistoa
+9 -7
Näytä tiedosto
@@ -385,7 +385,7 @@ class LegacyGame:
packet.face = 1
self.g.connection.write_packet(packet)
def open_container(self, location):
def open_container(self, location, face=BlockFace.TOP, cursor=None):
location = tuple(int(value) for value in location)
positions = {location}
world = self.g.get('world')
@@ -399,7 +399,7 @@ class LegacyGame:
'positions': tuple(sorted(positions)),
'requested_at': time.monotonic(),
}
self.place_block(location, BlockFace.TOP)
self.place_block(location, face, cursor=cursor)
def handle_window(self, packet):
print(packet)
@@ -1048,14 +1048,16 @@ class Game(LegacyGame):
return True
def place_block(self, location, face, hand=0, cursor_y=None,
sneaking=False):
sneaking=False, cursor=None):
location = tuple(int(value) for value in location)
if cursor_y is None:
cursor_y = 0.99 if int(face) == 1 else 0.5
if cursor is None:
if cursor_y is None:
cursor_y = 0.99 if int(face) == 1 else 0.5
cursor = (0.5, cursor_y, 0.5)
packet = UseItemOnBlockPacket(
hand=hand, location=location, face=int(face),
cursor_x=0.5, cursor_y=cursor_y,
cursor_z=0.5, inside_block=False, world_border_hit=False,
cursor_x=float(cursor[0]), cursor_y=float(cursor[1]),
cursor_z=float(cursor[2]), inside_block=False, world_border_hit=False,
sequence=self._next_sequence())
if sneaking:
self.g.connection.write_packet(PlayerInputPacket(flags=0x20),