@@ -69,15 +69,13 @@ import net.minecraft.item.BlockItem
6969import net.minecraft.item.ItemPlacementContext
7070import net.minecraft.item.ItemUsageContext
7171import net.minecraft.registry.RegistryKeys
72- import net.minecraft.state.property.Properties
7372import net.minecraft.util.Hand
7473import net.minecraft.util.hit.BlockHitResult
7574import net.minecraft.util.math.BlockPos
7675import net.minecraft.util.math.Box
7776import net.minecraft.util.math.Direction
7877import net.minecraft.util.math.Vec3d
7978import net.minecraft.util.shape.VoxelShapes
80- import kotlin.jvm.optionals.getOrNull
8179import kotlin.math.pow
8280
8381object BuildSimulator {
@@ -243,7 +241,7 @@ object BuildSimulator {
243241 // ToDo: For each hand and sneak or not?
244242 val fakePlayer = copyPlayer(player).apply {
245243 setPos(eye.x, eye.y - standingEyeHeight, eye.z)
246- if (place.rotateForPlace) this .rotation = checkedHit.targetRotation
244+ this .rotation = RotationManager .serverRotation
247245 }
248246
249247 val checkedResult = checkedHit.hit
@@ -311,11 +309,26 @@ object BuildSimulator {
311309 }
312310 }
313311
314- simulatePlaceState()?.let simulatePlaceState@ { basePlaceResult ->
315- if (! place.axisRotate) {
312+ var currentDirIsInvalid = false
313+ simulatePlaceState()?.let { basePlaceResult ->
314+ if (! place.rotate) {
316315 acc.add(basePlaceResult)
317316 return @forEach
318317 }
318+
319+ currentDirIsInvalid = true
320+ }
321+
322+ if (place.rotateForPlace && ! place.axisRotate) {
323+ fakePlayer.rotation = checkedHit.targetRotation
324+ simulatePlaceState()?.let { rotatedPlaceResult ->
325+ acc.add(rotatedPlaceResult)
326+ return @forEach
327+ }
328+ rot = checkedHit.targetRotation
329+ }
330+
331+ if (place.axisRotate) run axisRotations@ {
319332 placementRotations.forEachIndexed direction@ { index, angle ->
320333 fakePlayer.rotation = angle
321334
@@ -332,8 +345,8 @@ object BuildSimulator {
332345 }
333346
334347 else -> {
335- rot = fakePlayer.rotation
336- return @simulatePlaceState
348+ rot = angle
349+ return @axisRotations
337350 }
338351 }
339352 }
@@ -343,9 +356,6 @@ object BuildSimulator {
343356 val hitBlock = blockState(blockHit.blockPos).block
344357 val shouldSneak = hitBlock::class in BlockUtils .interactionBlocks
345358
346- val primeDirection =
347- (target as ? TargetState .State )?.blockState?.getOrEmpty(Properties .HORIZONTAL_FACING )?.getOrNull()
348-
349359 val placeContext = PlaceContext (
350360 eye,
351361 blockHit,
@@ -358,7 +368,7 @@ object BuildSimulator {
358368 target,
359369 shouldSneak,
360370 false ,
361- primeDirection
371+ currentDirIsInvalid
362372 )
363373
364374 val currentHandStack = player.getStackInHand(Hand .MAIN_HAND )
0 commit comments