Find chest openings within interaction range
This commit is contained in:
@@ -2,7 +2,9 @@ import unittest
|
||||
from munch import Munch
|
||||
|
||||
from minecraft.networking.modern import ClientTickEnd, UseItemOnBlockPacket
|
||||
from minecraft.networking.types import BlockFace
|
||||
from mosfet.game import Game
|
||||
from mosfet.info import blocks
|
||||
from mosfet.protocol.modern import PlayerInputPacket
|
||||
|
||||
|
||||
@@ -15,6 +17,28 @@ class FakeConnection:
|
||||
|
||||
|
||||
class SneakPlacementTests(unittest.TestCase):
|
||||
def test_open_container_sends_visible_face_and_hit_cursor(self):
|
||||
chest = (2, 65, -4)
|
||||
connection = FakeConnection()
|
||||
game = Game.__new__(Game)
|
||||
game.g = Munch(
|
||||
connection=connection,
|
||||
chunks=Munch(get_block_at=lambda *position:
|
||||
min(blocks.CHEST_IDS) if tuple(position) == chest
|
||||
else None),
|
||||
world=Munch())
|
||||
game.sequence = 0
|
||||
|
||||
game.open_container(
|
||||
chest, face=BlockFace.EAST, cursor=(0.9375, 0.5, 0.5))
|
||||
|
||||
packet = next(packet for packet, _force in connection.packets
|
||||
if isinstance(packet, UseItemOnBlockPacket))
|
||||
self.assertEqual(packet.location, chest)
|
||||
self.assertEqual(packet.face, BlockFace.EAST)
|
||||
self.assertEqual((packet.cursor_x, packet.cursor_y, packet.cursor_z),
|
||||
(0.9375, 0.5, 0.5))
|
||||
|
||||
def test_sneaking_wraps_block_placement_and_is_released(self):
|
||||
connection = FakeConnection()
|
||||
game = Game.__new__(Game)
|
||||
|
||||
Reference in New Issue
Block a user