@@ -19,6 +19,7 @@ package com.lambda.interaction.construction.verify
1919
2020import com.lambda.context.AutomatedSafeContext
2121import com.lambda.context.SafeContext
22+ import com.lambda.interaction.construction.processing.ProcessorRegistry.intermediaryBlockMap
2223import com.lambda.interaction.material.container.ContainerManager.findDisposable
2324import com.lambda.util.BlockUtils.blockState
2425import com.lambda.util.BlockUtils.emptyState
@@ -51,10 +52,10 @@ sealed class TargetState(val type: Type) : StateMatcher {
5152 ) = state.isEmpty
5253
5354 context(_: AutomatedSafeContext )
54- override fun getStack (pos : BlockPos ): ItemStack = ItemStack .EMPTY
55+ override fun getStack (pos : BlockPos , state : BlockState ): ItemStack = ItemStack .EMPTY
5556
5657 context(automatedSafeContext: AutomatedSafeContext )
57- override fun getState (pos : BlockPos ) = automatedSafeContext.blockState(pos).emptyState
58+ override fun getState (pos : BlockPos , state : BlockState ) = automatedSafeContext.blockState(pos).emptyState
5859
5960 override fun isEmpty () = true
6061 }
@@ -70,10 +71,10 @@ sealed class TargetState(val type: Type) : StateMatcher {
7071 ) = state.isAir
7172
7273 context(_: AutomatedSafeContext )
73- override fun getStack (pos : BlockPos ): ItemStack = ItemStack .EMPTY
74+ override fun getStack (pos : BlockPos , state : BlockState ): ItemStack = ItemStack .EMPTY
7475
7576 context(_: AutomatedSafeContext )
76- override fun getState (pos : BlockPos ): BlockState = Blocks .AIR .defaultState
77+ override fun getState (pos : BlockPos , state : BlockState ): BlockState = Blocks .AIR .defaultState
7778
7879 override fun isEmpty () = true
7980 }
@@ -89,15 +90,15 @@ sealed class TargetState(val type: Type) : StateMatcher {
8990 ) = with (safeContext) { state.isSolidBlock(world, pos) && state.block !in replace }
9091
9192 context(automatedSafeContext: AutomatedSafeContext )
92- override fun getStack (pos : BlockPos ) =
93+ override fun getStack (pos : BlockPos , state : BlockState ) =
9394 with (automatedSafeContext) {
9495 findDisposable()?.stacks?.firstOrNull {
9596 it.item.block in inventoryConfig.disposables && it.item.block !in replace
9697 } ? : ItemStack (Items .NETHERRACK )
9798 }
9899
99100 context(_: AutomatedSafeContext )
100- override fun getState (pos : BlockPos ): BlockState = getStack(pos).item.block.defaultState
101+ override fun getState (pos : BlockPos , state : BlockState ): BlockState = getStack(pos, state ).item.block.defaultState
101102
102103 override fun isEmpty () = false
103104 }
@@ -116,15 +117,15 @@ sealed class TargetState(val type: Type) : StateMatcher {
116117 }
117118
118119 context(automatedSafeContext: AutomatedSafeContext )
119- override fun getStack (pos : BlockPos ) =
120+ override fun getStack (pos : BlockPos , state : BlockState ) =
120121 with (automatedSafeContext) {
121122 findDisposable()?.stacks?.firstOrNull {
122123 it.item.block in inventoryConfig.disposables
123124 } ? : ItemStack (Items .NETHERRACK )
124125 }
125126
126127 context(_: AutomatedSafeContext )
127- override fun getState (pos : BlockPos ): BlockState = getStack(pos).item.block.defaultState
128+ override fun getState (pos : BlockPos , state : BlockState ): BlockState = getStack(pos, state ).item.block.defaultState
128129
129130 override fun isEmpty () = false
130131 }
@@ -141,11 +142,12 @@ sealed class TargetState(val type: Type) : StateMatcher {
141142 state.matches(blockState, ignoredProperties)
142143
143144 context(automatedSafeContext: AutomatedSafeContext )
144- override fun getStack (pos : BlockPos ): ItemStack =
145- blockState.block.getPickStack(automatedSafeContext.world, pos, blockState, true )
145+ override fun getStack (pos : BlockPos , state : BlockState ): ItemStack =
146+ intermediaryBlockMap[blockState.block]?.startBlock?.item?.defaultStack
147+ ? : blockState.block.getPickStack(automatedSafeContext.world, pos, blockState, true )
146148
147149 context(_: AutomatedSafeContext )
148- override fun getState (pos : BlockPos ): BlockState = blockState
150+ override fun getState (pos : BlockPos , state : BlockState ): BlockState = blockState
149151
150152 override fun isEmpty () = blockState.isEmpty
151153 }
@@ -161,11 +163,11 @@ sealed class TargetState(val type: Type) : StateMatcher {
161163 ) = state.block == block
162164
163165 context(automatedSafeContext: AutomatedSafeContext )
164- override fun getStack (pos : BlockPos ): ItemStack =
166+ override fun getStack (pos : BlockPos , state : BlockState ): ItemStack =
165167 block.getPickStack(automatedSafeContext.world, pos, block.defaultState, true )
166168
167169 context(_: AutomatedSafeContext )
168- override fun getState (pos : BlockPos ): BlockState = block.defaultState
170+ override fun getState (pos : BlockPos , state : BlockState ): BlockState = block.defaultState
169171
170172 override fun isEmpty () = block.defaultState.isEmpty
171173 }
@@ -184,11 +186,11 @@ sealed class TargetState(val type: Type) : StateMatcher {
184186 ) = state.block == block
185187
186188 context(automatedSafeContext: AutomatedSafeContext )
187- override fun getStack (pos : BlockPos ): ItemStack =
188- itemStack
189+ override fun getStack (pos : BlockPos , state : BlockState ): ItemStack =
190+ intermediaryBlockMap[getState(pos, state).block]?.startBlock?.item?.defaultStack ? : itemStack
189191
190192 context(_: AutomatedSafeContext )
191- override fun getState (pos : BlockPos ): BlockState = block.defaultState
193+ override fun getState (pos : BlockPos , state : BlockState ): BlockState = block.defaultState
192194
193195 override fun isEmpty () = false
194196 }
0 commit comments