Skip to content

Commit e0c55e7

Browse files
committed
start to an inventory manager
1 parent 837f5a9 commit e0c55e7

File tree

5 files changed

+98
-10
lines changed

5 files changed

+98
-10
lines changed

common/src/main/kotlin/com/lambda/config/groups/InventoryConfig.kt

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,21 @@ import com.lambda.interaction.material.ContainerSelection
2121
import com.lambda.interaction.material.ContainerSelection.Companion.selectContainer
2222
import com.lambda.interaction.material.StackSelection
2323
import com.lambda.interaction.material.container.MaterialContainer
24+
import com.lambda.interaction.request.RequestConfig
25+
import com.lambda.interaction.request.inventory.InventoryManager
26+
import com.lambda.interaction.request.inventory.InventoryRequest
2427
import net.minecraft.block.Block
2528

26-
interface InventoryConfig {
27-
val disposables: Set<Block>
28-
val swapWithDisposables: Boolean
29-
val providerPriority: Priority
30-
val storePriority: Priority
29+
abstract class InventoryConfig : RequestConfig<InventoryRequest>() {
30+
abstract val disposables: Set<Block>
31+
abstract val swapWithDisposables: Boolean
32+
abstract val providerPriority: Priority
33+
abstract val storePriority: Priority
3134

32-
val accessShulkerBoxes: Boolean
33-
val accessEnderChest: Boolean
34-
val accessChests: Boolean
35-
val accessStashes: Boolean
35+
abstract val accessShulkerBoxes: Boolean
36+
abstract val accessEnderChest: Boolean
37+
abstract val accessChests: Boolean
38+
abstract val accessStashes: Boolean
3639

3740
val containerSelection: ContainerSelection get() = selectContainer {
3841
val allowedContainers = mutableSetOf<MaterialContainer.Rank>().apply {
@@ -45,6 +48,10 @@ interface InventoryConfig {
4548
ofAnyType(*allowedContainers.toTypedArray())
4649
}
4750

51+
override fun requestInternal(request: InventoryRequest, queueIfClosed: Boolean) {
52+
InventoryManager.request(request, queueIfClosed)
53+
}
54+
4855
enum class Priority {
4956
WithMinItems,
5057
WithMaxItems;

common/src/main/kotlin/com/lambda/config/groups/InventorySettings.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import com.lambda.util.item.ItemUtils
2323
class InventorySettings(
2424
c: Configurable,
2525
vis: () -> Boolean = { true },
26-
) : InventoryConfig {
26+
) : InventoryConfig() {
2727
val page by c.setting("Inventory Page", Page.Container, "The page to open when the module is enabled", vis)
2828

2929
override val disposables by c.setting("Disposables", ItemUtils.defaultDisposables, "Items that will be included when checking for a free slot / are allowed to be droped when inventory is full") { vis() && page == Page.Container}

common/src/main/kotlin/com/lambda/event/events/UpdateManagerEvent.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import com.lambda.event.Event
2121

2222
sealed class UpdateManagerEvent {
2323
data object Rotation : Event
24+
data object Inventory: Event
2425
data object Hotbar : Event
2526
data object Break : Event
2627
data object Place : Event
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Copyright 2025 Lambda
3+
*
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
18+
package com.lambda.interaction.request.inventory
19+
20+
import com.lambda.context.SafeContext
21+
import com.lambda.event.EventFlow.post
22+
import com.lambda.event.events.TickEvent
23+
import com.lambda.event.events.UpdateManagerEvent
24+
25+
import com.lambda.interaction.request.RequestHandler
26+
import com.lambda.interaction.request.inventory.InventoryManager.activeRequest
27+
import com.lambda.interaction.request.inventory.InventoryManager.processRequest
28+
29+
object InventoryManager : RequestHandler<InventoryRequest>(
30+
1,
31+
TickEvent.Pre,
32+
TickEvent.Input.Pre,
33+
TickEvent.Input.Post,
34+
TickEvent.Player.Post,
35+
onOpen = { activeRequest?.let { processRequest(it) } }
36+
) {
37+
var activeRequest: InventoryRequest? = null
38+
39+
override fun load(): String {
40+
return "Loaded Inventory Manager"
41+
}
42+
43+
override fun SafeContext.handleRequest(request: InventoryRequest) {
44+
TODO("Not yet implemented")
45+
}
46+
47+
fun SafeContext.processRequest(request: InventoryRequest) {
48+
49+
}
50+
51+
override fun preEvent() = UpdateManagerEvent.Inventory.post()
52+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright 2025 Lambda
3+
*
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
18+
package com.lambda.interaction.request.inventory
19+
20+
import com.lambda.config.groups.InventoryConfig
21+
import com.lambda.interaction.request.Request
22+
23+
class InventoryRequest(
24+
override val config: InventoryConfig
25+
) : Request() {
26+
override val done: Boolean
27+
get() = TODO("Not yet implemented")
28+
}

0 commit comments

Comments
 (0)