Recover inventory space when gathering supplies
This commit is contained in:
1 parent
1b4dc21ea4
commit
1a7bdb2be4
4 files changed
+435
-13
No files matched your search
@@ -2,7 +2,9 @@ import io
|
||||
import unittest
|
||||
|
||||
from munch import Munch
|
||||
from minecraft.networking.modern import ClientTickEnd, ContainerOpenPacket
|
||||
from minecraft.networking.modern import (
|
||||
ClientTickEnd, ContainerOpenPacket, ContainerClickSwapPacket,
|
||||
)
|
||||
from minecraft.networking.packets import PacketBuffer
|
||||
|
||||
from mosfet.game import (
|
||||
@@ -52,6 +54,22 @@ class TestInventoryDrain(unittest.TestCase):
|
||||
self.assertEqual(payload.get_writable(), bytes.fromhex(
|
||||
'0007002d00040000'))
|
||||
|
||||
def test_swap_container_slot_with_hotbar_uses_current_window_state(self):
|
||||
connection = FakeConnection()
|
||||
game = Game.__new__(Game)
|
||||
game.g = Munch(
|
||||
connection=connection,
|
||||
window=Munch(window_id=4, state_id=8),
|
||||
inventory_state_ids={4: 9},
|
||||
)
|
||||
|
||||
self.assertTrue(game.swap_container_slot_with_hotbar(2, 37))
|
||||
packet = connection.packets[0][0]
|
||||
self.assertIsInstance(packet, ContainerClickSwapPacket)
|
||||
self.assertEqual((packet.container_id, packet.state_id,
|
||||
packet.slot, packet.button), (4, 9, 2, 1))
|
||||
self.assertIsInstance(connection.packets[1][0], ClientTickEnd)
|
||||
|
||||
def test_quick_move_packet_encodes_shift_click(self):
|
||||
packet = ContainerClickQuickMovePacket(
|
||||
container_id=3, state_id=7, slot=42)
|
||||
|
||||
Reference in new issue
Block a user