File tree Expand file tree Collapse file tree 2 files changed +8
-7
lines changed
src/main/kotlin/com/lambda/interaction/material/container/containers Expand file tree Collapse file tree 2 files changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ data object CreativeContainer : MaterialContainer(Rank.Creative) {
4949 listen<TickEvent .Pre > {
5050 if (! gamemode.isCreative) {
5151 // ToDo: Maybe switch gamemode?
52- throw NotInCreativeModeException ()
52+ failure( NotInCreativeModeException () )
5353 }
5454
5555 inventoryRequest {
@@ -80,7 +80,7 @@ data object CreativeContainer : MaterialContainer(Rank.Creative) {
8080
8181 if (! gamemode.isCreative) {
8282 // ToDo: Maybe switch gamemode?
83- throw NotInCreativeModeException ()
83+ failure( NotInCreativeModeException () )
8484 }
8585
8686 inventoryRequest {
@@ -91,7 +91,7 @@ data object CreativeContainer : MaterialContainer(Rank.Creative) {
9191 return @listen
9292 }
9393
94- throw NoOptimalStackException ( )
94+ failure( IllegalStateException ( " Cannot move item: no optimal stack " ) )
9595 }
9696 }
9797 }
@@ -101,5 +101,4 @@ data object CreativeContainer : MaterialContainer(Rank.Creative) {
101101 override fun withdraw (selection : StackSelection ) = CreativeWithdrawal (selection, automated)
102102
103103 class NotInCreativeModeException : IllegalStateException (" Insufficient permission: not in creative mode" )
104- class NoOptimalStackException : IllegalStateException (" Cannot move item: no optimal stack" )
105104}
Original file line number Diff line number Diff line change @@ -66,7 +66,11 @@ object MainHandContainer : MaterialContainer(Rank.MainHand) {
6666 return @inventoryRequest
6767 }
6868
69- val slot = player.currentScreenHandler.slots.firstOrNull { it.stack == moveStack } ? : throw NotInInventoryException ()
69+ val slot = player.currentScreenHandler.slots.firstOrNull { it.stack == moveStack }
70+ ? : run {
71+ failure(IllegalStateException (" Cannot find stack in inventory" ))
72+ return @inventoryRequest
73+ }
7074 swap(slot.id, player.inventory.selectedSlot)
7175
7276 if (hand == Hand .OFF_HAND ) swapHands()
@@ -79,6 +83,4 @@ object MainHandContainer : MaterialContainer(Rank.MainHand) {
7983
8084 context(automated: Automated )
8185 override fun deposit (selection : StackSelection ) = HandDeposit (selection, Hand .MAIN_HAND , automated)
82-
83- class NotInInventoryException : IllegalStateException (" Cannot find stack in inventory" )
8486}
You can’t perform that action at this time.
0 commit comments