@@ -34,6 +34,7 @@ import com.lambda.interaction.material.StackSelection.Companion.select
3434import com.lambda.interaction.material.StackSelection.Companion.selectStack
3535import com.lambda.interaction.material.container.ContainerManager.containerWithMaterial
3636import com.lambda.interaction.material.container.MaterialContainer
37+ import com.lambda.interaction.request.placing.PlaceConfig
3738import com.lambda.interaction.request.rotation.Rotation.Companion.rotation
3839import com.lambda.interaction.request.rotation.Rotation.Companion.rotationTo
3940import com.lambda.interaction.request.rotation.RotationConfig
@@ -72,6 +73,7 @@ import net.minecraft.util.math.BlockPos
7273import net.minecraft.util.math.Box
7374import net.minecraft.util.math.Direction
7475import net.minecraft.util.math.Vec3d
76+ import net.minecraft.util.shape.VoxelShapes
7577import kotlin.jvm.optionals.getOrNull
7678import kotlin.math.pow
7779
@@ -87,11 +89,11 @@ object BuildSimulator {
8789 checkRequirements(pos, target, build)?.let {
8890 return @flatMap setOf (it)
8991 }
90- checkPlaceResults(pos, target, eye, interact, rotation, inventory).let {
92+ checkPlaceResults(pos, target, eye, build.placeSettings, interact, rotation, inventory).let {
9193 if (it.isEmpty()) return @let
9294 return @flatMap it
9395 }
94- checkBreakResults(pos, eye, interact, rotation, inventory, build).let {
96+ checkBreakResults(pos, eye, build.placeSettings, interact, rotation, inventory, build).let {
9597 if (it.isEmpty()) return @let
9698 return @flatMap it
9799 }
@@ -148,6 +150,7 @@ object BuildSimulator {
148150 pos : BlockPos ,
149151 target : TargetState ,
150152 eye : Vec3d ,
153+ place : PlaceConfig ,
151154 interact : InteractionConfig ,
152155 rotation : RotationConfig ,
153156 inventory : InventoryConfig
@@ -160,10 +163,15 @@ object BuildSimulator {
160163 val preprocessing = target.findProcessorForState()
161164
162165 preprocessing.sides.forEach { neighbor ->
163- val hitPos = if (targetPosState.isAir || targetPosState.isLiquid) pos.offset(neighbor) else pos
166+ val hitPos = if (! place.airPlace.isEnabled() && targetPosState.isAir || targetPosState.isLiquid)
167+ pos.offset(neighbor)
168+ else pos
164169 val hitSide = neighbor.opposite
165170
166- val voxelShape = blockState(hitPos).getOutlineShape(world, hitPos)
171+ val voxelShape = blockState(hitPos).getOutlineShape(world, hitPos).let { outlineShape ->
172+ if (! outlineShape.isEmpty || ! place.airPlace.isEnabled()) outlineShape
173+ else VoxelShapes .fullCube()
174+ }
167175 if (voxelShape.isEmpty) return @forEach
168176
169177 val boxes = voxelShape.boundingBoxes.map { it.offset(hitPos) }
@@ -220,7 +228,7 @@ object BuildSimulator {
220228 // ToDo: For each hand and sneak or not?
221229 val fakePlayer = copyPlayer(player).apply {
222230 setPos(eye.x, eye.y - standingEyeHeight, eye.z)
223- this .rotation = checkedHit.targetRotation
231+ if (place.rotateForPlace) this .rotation = checkedHit.targetRotation
224232 }
225233
226234 val checkedResult = checkedHit.hit
@@ -329,6 +337,7 @@ object BuildSimulator {
329337 private fun SafeContext.checkBreakResults (
330338 pos : BlockPos ,
331339 eye : Vec3d ,
340+ place : PlaceConfig ,
332341 interact : InteractionConfig ,
333342 rotation : RotationConfig ,
334343 inventory : InventoryConfig ,
@@ -356,7 +365,7 @@ object BuildSimulator {
356365
357366 /* liquid needs to be submerged first to be broken */
358367 if (! state.fluidState.isEmpty && state.isReplaceable) {
359- val submerge = checkPlaceResults(pos, TargetState .Solid , eye, interact, rotation, inventory)
368+ val submerge = checkPlaceResults(pos, TargetState .Solid , eye, place, interact, rotation, inventory)
360369 acc.add(BreakResult .Submerge (pos, state, submerge))
361370 acc.addAll(submerge)
362371 return acc
@@ -371,9 +380,9 @@ object BuildSimulator {
371380 acc.add(BreakResult .BlockedByLiquid (pos, state))
372381 adjacentLiquids.forEach { liquidPos ->
373382 val submerge = if (blockState(liquidPos).isReplaceable) {
374- checkPlaceResults(liquidPos, TargetState .Solid , eye, interact, rotation, inventory)
383+ checkPlaceResults(liquidPos, TargetState .Solid , eye, place, interact, rotation, inventory)
375384 } else {
376- checkBreakResults(liquidPos, eye, interact, rotation, inventory, build)
385+ checkBreakResults(liquidPos, eye, place, interact, rotation, inventory, build)
377386 }
378387 acc.addAll(submerge)
379388 }
0 commit comments