Implement item cachine for 26.3
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import unittest
|
||||
|
||||
from munch import Munch
|
||||
|
||||
from mosfet.info import items
|
||||
from mosfet.job import JobStates
|
||||
|
||||
|
||||
class TestCropCaching(unittest.TestCase):
|
||||
def test_crop_farm_runs_silent_cache_machine_and_keeps_seeds(self):
|
||||
old_wanted = items.WANTED_ITEMS
|
||||
crop_state = object()
|
||||
cache_state = Munch(silent=False)
|
||||
jobs = JobStates.__new__(JobStates)
|
||||
jobs.gather_crop_states = crop_state
|
||||
jobs.cache_items_states = cache_state
|
||||
|
||||
try:
|
||||
machines = JobStates.farm_crop(jobs)
|
||||
self.assertEqual(machines, [crop_state, cache_state])
|
||||
self.assertTrue(cache_state.silent)
|
||||
self.assertTrue({
|
||||
items.CARROT_ID, items.POTATO_ID,
|
||||
items.WHEAT_SEEDS_ID, items.BEETROOT_SEEDS_ID,
|
||||
}.issubset(items.WANTED_ITEMS))
|
||||
finally:
|
||||
items.WANTED_ITEMS = old_wanted
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -1,10 +1,13 @@
|
||||
import io
|
||||
import unittest
|
||||
|
||||
from munch import Munch
|
||||
from minecraft.networking.modern import ClientTickEnd
|
||||
from minecraft.networking.modern import ClientTickEnd, ContainerOpenPacket
|
||||
from minecraft.networking.packets import PacketBuffer
|
||||
|
||||
from mosfet.game import ContainerClickDropPacket, Game
|
||||
from mosfet.game import (
|
||||
ContainerClickDropPacket, ContainerClickQuickMovePacket, Game,
|
||||
)
|
||||
from mosfet.protocol.types import Slot
|
||||
|
||||
|
||||
@@ -27,6 +30,24 @@ class TestInventoryDrain(unittest.TestCase):
|
||||
self.assertEqual(payload.get_writable(), bytes.fromhex(
|
||||
'0007002d01040000'))
|
||||
|
||||
def test_quick_move_packet_encodes_shift_click(self):
|
||||
packet = ContainerClickQuickMovePacket(
|
||||
container_id=3, state_id=7, slot=42)
|
||||
payload = PacketBuffer()
|
||||
packet.write_fields(payload)
|
||||
|
||||
self.assertEqual(packet.id, 0x12)
|
||||
self.assertEqual(payload.get_writable(), bytes.fromhex(
|
||||
'0307002a00010000'))
|
||||
|
||||
def test_open_window_packet_decodes_container_metadata(self):
|
||||
# window id, menu type, empty anonymous-NBT title
|
||||
packet = ContainerOpenPacket()
|
||||
packet.read(io.BytesIO(bytes.fromhex('010200')))
|
||||
self.assertEqual(packet.window_id, 1)
|
||||
self.assertEqual(packet.inventory_type, 2)
|
||||
self.assertIsNone(packet.title)
|
||||
|
||||
def test_drain_waits_for_authoritative_slot_update(self):
|
||||
connection = FakeConnection()
|
||||
game = Game.__new__(Game)
|
||||
|
||||
Reference in New Issue
Block a user