Skip to content

Commit 17ee6fd

Browse files
committed
allow disabling Rotate For Place while axis rotations are enabled to ignore needless rotation
1 parent 7ea2794 commit 17ee6fd

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class PlaceSettings(
3030
override val airPlace by c.setting("Air Place", AirPlaceMode.None, "Allows for placing blocks without adjacent faces") { vis() }
3131
override val axisRotateSetting by c.setting("Axis Rotate", true, "Overrides the Rotate For Place setting and rotates the player on each axis to air place rotational blocks") { vis() && airPlace.isEnabled() }
3232
override val axisRotate
33-
get() = rotateForPlace && airPlace.isEnabled() && axisRotateSetting
33+
get() = airPlace.isEnabled() && axisRotateSetting
3434
override val placeConfirmationMode by c.setting("Place Confirmation", PlaceConfirmationMode.PlaceThenAwait, "Wait for block placement confirmation") { vis() }
3535
override val maxPendingPlacements by c.setting("Max Pending Placements", 5, 0..30, 1, "The maximum amount of pending placements") { vis() }
3636
override val placementsPerTick by c.setting("Instant Places Per Tick", 1, 1..30, 1, "Maximum instant block places per tick") { vis() }

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ import com.lambda.util.player.copyPlayer
6060
import com.lambda.util.player.gamemode
6161
import com.lambda.util.player.placementRotations
6262
import com.lambda.util.world.raycast.RayCastUtils.blockResult
63+
import net.minecraft.block.BlockState
6364
import net.minecraft.block.OperatorBlock
6465
import net.minecraft.block.pattern.CachedBlockPosition
6566
import net.minecraft.enchantment.Enchantments
@@ -293,10 +294,7 @@ object BuildSimulator {
293294
context = checked
294295
}
295296

296-
var resultState = blockItem.getPlacementState(context) ?: run {
297-
acc.add(PlaceResult.BlockedByEntity(pos))
298-
return@forEach
299-
}
297+
lateinit var resultState: BlockState
300298
var rot = fakePlayer.rotation
301299

302300
val simulatePlaceState = placeState@ {
@@ -308,14 +306,13 @@ object BuildSimulator {
308306
pos, resultState, context, (target as? TargetState.State)?.blockState
309307
)
310308
} else {
311-
rot = fakePlayer.rotation
312309
return@placeState null
313310
}
314311
}
315312

316-
simulatePlaceState()?.let simulatePlaceState@ { placeResult ->
313+
simulatePlaceState()?.let simulatePlaceState@ { basePlaceResult ->
317314
if (!place.axisRotate) {
318-
acc.add(placeResult)
315+
acc.add(basePlaceResult)
319316
return@forEach
320317
}
321318
placementRotations.forEachIndexed direction@ { index, angle ->
@@ -334,6 +331,7 @@ object BuildSimulator {
334331
}
335332

336333
else -> {
334+
rot = fakePlayer.rotation
337335
return@simulatePlaceState
338336
}
339337
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,7 @@ object PlaceManager : RequestHandler<PlaceRequest>(), PositionBlocking {
9797
currentRequest?.let { request ->
9898
val notSneaking = !player.isSneaking
9999
val hotbarRequest = request.hotbarConfig.request(HotbarRequest(request.placeContext.hotbarIndex))
100-
val invalidRotation = request.buildConfig.placeSettings.rotateForPlace && !validRotation
101-
if ((request.placeContext.sneak && notSneaking) || !hotbarRequest.done || invalidRotation)
100+
if ((request.placeContext.sneak && notSneaking) || !hotbarRequest.done || !validRotation)
102101
return@listen
103102

104103
val actionResult = placeBlock(request, Hand.MAIN_HAND)
@@ -128,7 +127,8 @@ object PlaceManager : RequestHandler<PlaceRequest>(), PositionBlocking {
128127
return@onRotate
129128
}
130129

131-
rotation = if (request.buildConfig.placeSettings.rotateForPlace)
130+
val placeConfig = request.buildConfig.placeSettings
131+
rotation = if (placeConfig.rotateForPlace || placeConfig.axisRotate)
132132
request.rotationConfig.request(request.placeContext.rotation)
133133
else null
134134

0 commit comments

Comments
 (0)