Skip to content

Commit de62f07

Browse files
committed
fixed disposables logic. Was using >= 0 rather than > 0
1 parent ff6b87b commit de62f07

File tree

6 files changed

+17
-14
lines changed

6 files changed

+17
-14
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ class InventorySettings(
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}
3030
override val swapWithDisposables by c.setting("Swap With Disposables", true, "Swap items with disposable ones") { vis() && page == Page.Container}
31-
override val providerPriority by c.setting("Provider Priority", InventoryConfig.Priority.WithMinItems, "What container to prefer when retrieving the item from") { vis() && page == Page.Container}
32-
override val storePriority by c.setting("Store Priority", InventoryConfig.Priority.WithMinItems, "What container to prefer when storing the item to") { vis() && page == Page.Container}
31+
override val providerPriority by c.setting("Provider Priority", Priority.WithMinItems, "What container to prefer when retrieving the item from") { vis() && page == Page.Container}
32+
override val storePriority by c.setting("Store Priority", Priority.WithMinItems, "What container to prefer when storing the item to") { vis() && page == Page.Container}
3333

3434
override val accessShulkerBoxes by c.setting("Access Shulker Boxes", true, "Allow access to the player's shulker boxes") { vis() && page == Page.Access}
3535
override val accessEnderChest by c.setting("Access Ender Chest", false, "Allow access to the player's ender chest") { vis() && page == Page.Access}

common/src/main/kotlin/com/lambda/interaction/construction/simulation/BuildSimulator.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ object BuildSimulator {
415415
}
416416

417417
interactionConfig.pointSelection.select(validHits)?.let { checkedHit ->
418-
val optimalStack = targetState.getStack(world, pos)
418+
val optimalStack = targetState.getStack(world, pos, inventory)
419419

420420
// ToDo: For each hand and sneak or not?
421421
val fakePlayer = copyPlayer(player).apply {
@@ -655,7 +655,7 @@ object BuildSimulator {
655655
}
656656

657657
if (fluidState.level - levelDecreasePerBlock > 0) {
658-
accumulator.put(offsetPos, offsetState)
658+
accumulator[offsetPos] = offsetState
659659
return@fold accumulator
660660
}
661661
}

common/src/main/kotlin/com/lambda/interaction/construction/verify/StateMatcher.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
package com.lambda.interaction.construction.verify
1919

20+
import com.lambda.config.groups.InventoryConfig
2021
import net.minecraft.block.BlockState
2122
import net.minecraft.client.world.ClientWorld
2223
import net.minecraft.item.ItemStack
@@ -25,6 +26,6 @@ import net.minecraft.util.math.BlockPos
2526

2627
interface StateMatcher {
2728
fun matches(state: BlockState, pos: BlockPos, world: ClientWorld, ignoredProperties: Collection<Property<*>> = emptySet()): Boolean
28-
fun getStack(world: ClientWorld, pos: BlockPos): ItemStack
29+
fun getStack(world: ClientWorld, pos: BlockPos, inventory: InventoryConfig): ItemStack
2930
fun isEmpty(): Boolean
3031
}

common/src/main/kotlin/com/lambda/interaction/construction/verify/TargetState.kt

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
package com.lambda.interaction.construction.verify
1919

20+
import com.lambda.config.groups.InventoryConfig
2021
import com.lambda.interaction.material.container.ContainerManager.findDisposable
2122
import com.lambda.module.modules.client.TaskFlowModule
2223
import com.lambda.util.BlockUtils.isEmpty
@@ -43,7 +44,7 @@ sealed class TargetState(val type: Type) : StateMatcher {
4344
override fun matches(state: BlockState, pos: BlockPos, world: ClientWorld, ignoredProperties: Collection<Property<*>>) =
4445
state.isEmpty
4546

46-
override fun getStack(world: ClientWorld, pos: BlockPos): ItemStack =
47+
override fun getStack(world: ClientWorld, pos: BlockPos, inventory: InventoryConfig): ItemStack =
4748
ItemStack.EMPTY
4849

4950
override fun isEmpty() = true
@@ -55,7 +56,7 @@ sealed class TargetState(val type: Type) : StateMatcher {
5556
override fun matches(state: BlockState, pos: BlockPos, world: ClientWorld, ignoredProperties: Collection<Property<*>>) =
5657
state.isAir
5758

58-
override fun getStack(world: ClientWorld, pos: BlockPos): ItemStack =
59+
override fun getStack(world: ClientWorld, pos: BlockPos, inventory: InventoryConfig): ItemStack =
5960
ItemStack.EMPTY
6061

6162
override fun isEmpty() = true
@@ -67,8 +68,8 @@ sealed class TargetState(val type: Type) : StateMatcher {
6768
override fun matches(state: BlockState, pos: BlockPos, world: ClientWorld, ignoredProperties: Collection<Property<*>>) =
6869
state.isSolidBlock(world, pos)
6970

70-
override fun getStack(world: ClientWorld, pos: BlockPos) =
71-
findDisposable()?.stacks?.firstOrNull {
71+
override fun getStack(world: ClientWorld, pos: BlockPos, inventory: InventoryConfig) =
72+
findDisposable(inventory)?.stacks?.firstOrNull {
7273
it.item.block in TaskFlowModule.inventory.disposables
7374
} ?: ItemStack(Items.NETHERRACK)
7475

@@ -82,7 +83,7 @@ sealed class TargetState(val type: Type) : StateMatcher {
8283
world.getBlockState(pos.offset(direction)).isSolidBlock(world, pos.offset(direction))
8384
|| state.isSolidBlock(world, pos)
8485

85-
override fun getStack(world: ClientWorld, pos: BlockPos) =
86+
override fun getStack(world: ClientWorld, pos: BlockPos, inventory: InventoryConfig) =
8687
findDisposable()?.stacks?.firstOrNull {
8788
it.item.block in TaskFlowModule.inventory.disposables
8889
} ?: ItemStack(Items.NETHERRACK)
@@ -96,7 +97,7 @@ sealed class TargetState(val type: Type) : StateMatcher {
9697
override fun matches(state: BlockState, pos: BlockPos, world: ClientWorld, ignoredProperties: Collection<Property<*>>) =
9798
state.matches(blockState, ignoredProperties)
9899

99-
override fun getStack(world: ClientWorld, pos: BlockPos): ItemStack =
100+
override fun getStack(world: ClientWorld, pos: BlockPos, inventory: InventoryConfig): ItemStack =
100101
blockState.block.getPickStack(world, pos, blockState)
101102

102103
override fun isEmpty() = blockState.isEmpty
@@ -108,7 +109,7 @@ sealed class TargetState(val type: Type) : StateMatcher {
108109
override fun matches(state: BlockState, pos: BlockPos, world: ClientWorld, ignoredProperties: Collection<Property<*>>) =
109110
state.block == block
110111

111-
override fun getStack(world: ClientWorld, pos: BlockPos): ItemStack =
112+
override fun getStack(world: ClientWorld, pos: BlockPos, inventory: InventoryConfig): ItemStack =
112113
block.getPickStack(world, pos, block.defaultState)
113114

114115
override fun isEmpty() = block.defaultState.isEmpty
@@ -123,7 +124,7 @@ sealed class TargetState(val type: Type) : StateMatcher {
123124
override fun matches(state: BlockState, pos: BlockPos, world: ClientWorld, ignoredProperties: Collection<Property<*>>) =
124125
state.block == block
125126

126-
override fun getStack(world: ClientWorld, pos: BlockPos): ItemStack =
127+
override fun getStack(world: ClientWorld, pos: BlockPos, inventory: InventoryConfig): ItemStack =
127128
itemStack
128129

129130
override fun isEmpty() = false

common/src/main/kotlin/com/lambda/interaction/material/container/ContainerManager.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ object ContainerManager : Loadable {
125125
.filter { inventory.containerSelection.matches(it) }
126126

127127
fun findDisposable(inventory: InventoryConfig = TaskFlowModule.inventory) = container().find { container ->
128-
inventory.disposables.any { container.materialAvailable(it.item.select()) >= 0 }
128+
inventory.disposables.any { container.materialAvailable(it.item.select()) > 0 }
129129
}
130130

131131
class NoContainerFound(selection: StackSelection) : Exception("No container found matching $selection")

common/src/main/kotlin/com/lambda/util/item/ItemUtils.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ object ItemUtils {
105105

106106
val defaultDisposables = setOf(
107107
Blocks.DIRT,
108+
Blocks.GRASS_BLOCK,
108109
Blocks.COBBLESTONE,
109110
Blocks.GRANITE,
110111
Blocks.DIORITE,

0 commit comments

Comments
 (0)