Skip to content

Commit e1760ba

Browse files
committed
data objects for update manager events, moved on start callback above on block break for proper order, and cleaned up unused settings in inventory config
1 parent 7e5bcf6 commit e1760ba

File tree

6 files changed

+9
-37
lines changed

6 files changed

+9
-37
lines changed

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

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,8 @@ package com.lambda.config.groups
2020
import com.lambda.interaction.material.ContainerSelection
2121
import com.lambda.interaction.material.ContainerSelection.Companion.selectContainer
2222
import com.lambda.interaction.material.StackSelection
23-
import com.lambda.interaction.material.StackSelection.Companion.selectStack
2423
import com.lambda.interaction.material.container.MaterialContainer
25-
import com.lambda.util.item.ItemUtils
2624
import net.minecraft.block.Block
27-
import net.minecraft.item.Item
28-
import net.minecraft.item.Items
29-
import net.minecraft.item.ToolItem
30-
import net.minecraft.item.ToolMaterial
31-
import net.minecraft.item.ToolMaterials
3225

3326
interface InventoryConfig {
3427
val disposables: Set<Block>
@@ -52,27 +45,6 @@ interface InventoryConfig {
5245
ofAnyType(*allowedContainers.toTypedArray())
5346
}
5447

55-
val useWoodenTools: Boolean
56-
val useStoneTools: Boolean
57-
val useIronTools: Boolean
58-
val useDiamondTools: Boolean
59-
val useNetheriteTools: Boolean
60-
val useGoldTools: Boolean
61-
val useShears: Boolean
62-
val useFlintAndSteel: Boolean
63-
64-
val allowedTools get() = mutableSetOf<Item>().apply {
65-
addAll(ItemUtils.tools)
66-
if (!useWoodenTools) removeIf { it is ToolItem && it.material == ToolMaterials.WOOD }
67-
if (!useStoneTools) removeIf { it is ToolItem && it.material == ToolMaterials.STONE }
68-
if (!useIronTools) removeIf { it is ToolItem && it.material == ToolMaterials.IRON }
69-
if (!useDiamondTools) removeIf { it is ToolItem && it.material == ToolMaterials.DIAMOND }
70-
if (!useNetheriteTools) removeIf { it is ToolItem && it.material == ToolMaterials.NETHERITE }
71-
if (!useGoldTools) removeIf { it is ToolItem && it.material == ToolMaterials.GOLD }
72-
if (!useShears) removeIf { it == Items.SHEARS }
73-
if (!useFlintAndSteel) removeIf { it == Items.FLINT_AND_STEEL }
74-
}
75-
7648
enum class Priority {
7749
WithMinItems,
7850
WithMaxItems;

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ package com.lambda.event.events
2020
import com.lambda.event.Event
2121

2222
sealed class UpdateManagerEvent {
23-
class Rotation : Event
24-
class Hotbar : Event
25-
class Break : Event
26-
class Place : Event
23+
data object Rotation : Event
24+
data object Hotbar : Event
25+
data object Break : Event
26+
data object Place : Event
2727
}

common/src/main/kotlin/com/lambda/interaction/request/breaking/BreakManager.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -629,8 +629,8 @@ object BreakManager : RequestHandler<BreakRequest>(
629629

630630
if (gamemode.isCreative) {
631631
lastPosStarted = ctx.expectedPos
632-
onBlockBreak(info)
633632
info.request.onStart?.invoke(ctx.expectedPos)
633+
onBlockBreak(info)
634634
info.startBreakPacket(world, interaction)
635635
breakCooldown = info.breakConfig.breakDelay
636636
return true
@@ -683,5 +683,5 @@ object BreakManager : RequestHandler<BreakRequest>(
683683
return inRange && correctMaterial
684684
}
685685

686-
override fun preEvent(): Event = UpdateManagerEvent.Break().post()
686+
override fun preEvent(): Event = UpdateManagerEvent.Break.post()
687687
}

common/src/main/kotlin/com/lambda/interaction/request/hotbar/HotbarManager.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,5 +122,5 @@ object HotbarManager : RequestHandler<HotbarRequest>(
122122
}
123123
}
124124

125-
override fun preEvent(): Event = UpdateManagerEvent.Hotbar().post()
125+
override fun preEvent(): Event = UpdateManagerEvent.Hotbar.post()
126126
}

common/src/main/kotlin/com/lambda/interaction/request/placing/PlaceManager.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,5 +365,5 @@ object PlaceManager : RequestHandler<PlaceRequest>(
365365
)
366366
}
367367

368-
override fun preEvent(): Event = UpdateManagerEvent.Place().post()
368+
override fun preEvent(): Event = UpdateManagerEvent.Place.post()
369369
}

common/src/main/kotlin/com/lambda/interaction/request/rotation/RotationManager.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,5 +290,5 @@ object RotationManager : RequestHandler<RotationRequest>(
290290
}
291291
}
292292

293-
override fun preEvent(): Event = UpdateManagerEvent.Rotation().post()
293+
override fun preEvent(): Event = UpdateManagerEvent.Rotation.post()
294294
}

0 commit comments

Comments
 (0)