Advance world clock between updates
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import io
|
||||
import unittest
|
||||
from contextlib import redirect_stdout
|
||||
from unittest.mock import patch
|
||||
|
||||
from munch import Munch
|
||||
from minecraft.networking.packets import PacketBuffer
|
||||
@@ -96,6 +97,33 @@ class TestSleepWithBed(unittest.TestCase):
|
||||
'partial_tick': 0.5, 'rate': 1.0,
|
||||
}])
|
||||
|
||||
def test_game_advances_world_clock_between_server_updates(self):
|
||||
game = Game.__new__(Game)
|
||||
game.g = Munch(
|
||||
time_base=None, time_update_received_at=None, clock_rate=1.0,
|
||||
time=0.0,
|
||||
connection=Munch(registry_ids={'minecraft:world_clock': {
|
||||
'minecraft:the_end': 1,
|
||||
'minecraft:overworld': 0,
|
||||
}}),
|
||||
dimension='overworld')
|
||||
packet = Munch(age=900000, clock_updates=[
|
||||
{'clock_id': 1, 'total_ticks': 6000,
|
||||
'partial_tick': 0.0, 'rate': 1.0},
|
||||
{'clock_id': 0, 'total_ticks': 13000,
|
||||
'partial_tick': 0.5, 'rate': 1.0},
|
||||
])
|
||||
|
||||
with patch('mosfet.game.time.monotonic', return_value=100.0):
|
||||
game.handle_time_update(packet)
|
||||
self.assertEqual(game.g.time, 13000.5)
|
||||
self.assertEqual(game.g.clock_name, 'minecraft:overworld')
|
||||
|
||||
with patch('mosfet.game.time.monotonic', return_value=100.5):
|
||||
game._advance_world_time()
|
||||
|
||||
self.assertEqual(game.g.time, 13010.5)
|
||||
|
||||
def test_player_command_encodes_stop_sleeping(self):
|
||||
packet = PlayerCommandPacket(
|
||||
entity_id=7, action_id=0, jump_boost=0)
|
||||
|
||||
Reference in New Issue
Block a user