Skip to content

Commit 5b78774

Browse files
committed
place manager cleanup
1 parent 1a112fe commit 5b78774

File tree

1 file changed

+6
-13
lines changed
  • common/src/main/kotlin/com/lambda/interaction/request/placing

1 file changed

+6
-13
lines changed

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

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -175,18 +175,12 @@ object PlaceManager : RequestHandler<PlaceRequest>(), PositionBlocking {
175175
false
176176
}
177177

178-
private fun SafeContext.placeBlock(request: PlaceRequest, hand: Hand) =
179-
interactBlock(request, request.buildConfig.placeSettings, hand, request.placeContext.result)
180-
181-
private fun SafeContext.interactBlock(
182-
request: PlaceRequest,
183-
placeConfig: PlaceConfig,
184-
hand: Hand,
185-
hitResult: BlockHitResult
186-
): ActionResult {
178+
private fun SafeContext.placeBlock(request: PlaceRequest, hand: Hand): ActionResult {
187179
interaction.syncSelectedSlot()
180+
val hitResult = request.placeContext.result
188181
if (!world.worldBorder.contains(hitResult.blockPos)) return ActionResult.FAIL
189-
return interactBlockInternal(request, placeConfig, hand, hitResult)
182+
if (gamemode == GameMode.SPECTATOR) return ActionResult.PASS
183+
return interactBlockInternal(request, request.buildConfig.placeSettings, hand, hitResult)
190184
}
191185

192186
private fun SafeContext.interactBlockInternal(
@@ -195,9 +189,6 @@ object PlaceManager : RequestHandler<PlaceRequest>(), PositionBlocking {
195189
hand: Hand,
196190
hitResult: BlockHitResult
197191
): ActionResult {
198-
val itemStack = player.getStackInHand(hand)
199-
if (gamemode == GameMode.SPECTATOR) return ActionResult.PASS
200-
201192
val handNotEmpty = player.getStackInHand(hand).isEmpty.not()
202193
val cantInteract = player.shouldCancelInteraction() && handNotEmpty
203194
if (!cantInteract) {
@@ -214,6 +205,8 @@ object PlaceManager : RequestHandler<PlaceRequest>(), PositionBlocking {
214205
// }
215206
}
216207

208+
val itemStack = player.getStackInHand(hand)
209+
217210
if (!itemStack.isEmpty && !isItemOnCooldown(itemStack.item)) {
218211
val itemUsageContext = ItemUsageContext(player, hand, hitResult)
219212
return if (gamemode.isCreative) {

0 commit comments

Comments
 (0)