Fix missing sapling report in tree planting

This commit is contained in:
Tanner
2026-11-06 00:04:37 +00:00
parent c323ea8373
commit a60d913c60
2 changed files with 22 additions and 1 deletions
+1 -1
View File
@@ -45,8 +45,8 @@ class PlantTreeStates:
self.state = self.cleanup self.state = self.cleanup
return return
if self.g.game.select_item([sapling_item]):
sapling_type = items.get_name(sapling_item) sapling_type = items.get_name(sapling_item)
if self.g.game.select_item([sapling_item]):
self.g.look_at = utils.padd(p, path.BLOCK_BELOW) self.g.look_at = utils.padd(p, path.BLOCK_BELOW)
self.state = self.wait_select self.state = self.wait_select
self.wait_time = 1 self.wait_time = 1
+21
View File
@@ -0,0 +1,21 @@
import unittest
from munch import Munch
from mosfet.jobs.plant_tree import PlantTreeStates
class PlantTreeTests(unittest.TestCase):
def test_missing_inventory_sapling_aborts_without_crashing(self):
class FakeGame:
@staticmethod
def select_item(_item_ids):
return False
state = PlantTreeStates(Munch(
pos=(0, 64, 0), chopped_tree='oak', game=FakeGame()))
state.select_sapling()
self.assertIs(state.state.__func__, state.cleanup.__func__)
if __name__ == '__main__':
unittest.main()