@@ -142,7 +142,7 @@ object PlaceManager : RequestHandler<PlaceRequest>(
142142 * @see placeBlock
143143 */
144144 fun SafeContext.processRequest (request : PlaceRequest ) {
145- logger.debug(" Processing request ( ${ request.requestID} ) at tick stage ${tickStage?. run { this :: class .qualifiedName }} " )
145+ logger.debug(" Processing request" , request)
146146
147147 if (request.fresh) populateFrom(request)
148148
@@ -153,20 +153,25 @@ object PlaceManager : RequestHandler<PlaceRequest>(
153153
154154 if (ctx.sneak) shouldSneak = true
155155 if (! ctx.requestDependencies(request)) {
156- logger.warning(" Dependencies failed for ${request.requestID} " )
156+ logger.warning(" Dependencies failed for context " , ctx, request )
157157 return
158158 }
159159 if (! validSneak(player)) return
160160 // if (tickStage !in request.build.placing.placeStageMask) return
161161
162162 val actionResult = placeBlock(ctx, request, Hand .MAIN_HAND )
163- if (! actionResult.isAccepted) warn(" Placement interaction failed with $actionResult " )
163+ if (! actionResult.isAccepted) {
164+ logger.warning(" Placement interaction failed with $actionResult " , ctx, request)
165+ warn(" Placement interaction failed with $actionResult " )
166+ }
164167 placementsThisTick++
165168 iterator.remove()
166169 }
167170 if (potentialPlacements.isEmpty()) {
168- if (activeRequest != null ) logger.debug(" Clearing active request" )
169- activeRequest = null
171+ if (activeRequest != null ) {
172+ logger.debug(" Clearing active request" , activeRequest)
173+ activeRequest = null
174+ }
170175 }
171176 }
172177
@@ -177,7 +182,7 @@ object PlaceManager : RequestHandler<PlaceRequest>(
177182 * @see isPosBlocked
178183 */
179184 private fun populateFrom (request : PlaceRequest ) {
180- logger.debug(" Populating from request ( ${ request.requestID} ) " )
185+ logger.debug(" Populating from request" , request)
181186 setPendingConfigs(request.build)
182187 potentialPlacements = request.contexts
183188 .filter { ! isPosBlocked(it.blockPos) }
@@ -197,11 +202,11 @@ object PlaceManager : RequestHandler<PlaceRequest>(
197202 interaction.syncSelectedSlot()
198203 val hitResult = placeContext.result
199204 if (! world.worldBorder.contains(hitResult.blockPos)) {
200- logger.error(" Placement position outside the world border at ${ placeContext.blockPos.toShortString()} " )
205+ logger.error(" Placement position outside the world border" , placeContext, request )
201206 return ActionResult .FAIL
202207 }
203208 if (gamemode == GameMode .SPECTATOR ) {
204- logger.error(" Player is in spectator mode" )
209+ logger.error(" Player is in spectator mode" , placeContext, request )
205210 return ActionResult .PASS
206211 }
207212 return interactBlockInternal(placeContext, request, request.build.placing, hand, hitResult)
@@ -224,13 +229,13 @@ object PlaceManager : RequestHandler<PlaceRequest>(
224229 if (! cantInteract) {
225230 val blockState = blockState(hitResult.blockPos)
226231 if (! connection.hasFeature(blockState.block.requiredFeatures)) {
227- logger.error(" Required features not met for $blockState " )
232+ logger.error(" Required features not met for $blockState " , placeContext, request )
228233 return ActionResult .FAIL
229234 }
230235
231236 val actionResult = blockState.onUse(world, player, hitResult)
232237 if (actionResult.isAccepted) {
233- logger.error(" Block state ($blockState ) onUse not accepted" )
238+ logger.error(" Block state ($blockState ) onUse not accepted" , placeContext, request )
234239 return actionResult
235240 }
236241 }
@@ -270,12 +275,12 @@ object PlaceManager : RequestHandler<PlaceRequest>(
270275 val cantModifyWorld = ! player.abilities.allowModifyWorld
271276 val cantPlaceOn = ! itemStack.canPlaceOn(cachedBlockPosition)
272277 if (cantModifyWorld && cantPlaceOn) {
273- logger.error(" Cannot modify world" )
278+ logger.error(" Cannot modify world" , placeContext, request )
274279 return ActionResult .PASS
275280 }
276281
277282 val item = (itemStack.item as ? BlockItem ) ? : run {
278- logger.error(" Item ${itemStack.item.name} is not a block item" )
283+ logger.error(" Item ${itemStack.item.name} is not a block item" , placeContext, request )
279284 return ActionResult .PASS
280285 }
281286
@@ -297,20 +302,20 @@ object PlaceManager : RequestHandler<PlaceRequest>(
297302 context : ItemPlacementContext
298303 ): ActionResult {
299304 if (! item.block.isEnabled(world.enabledFeatures)) {
300- logger.error(" Block ${item.block.name} is not enabled" )
305+ logger.error(" Block ${item.block.name} is not enabled" , placeContext, request )
301306 return ActionResult .FAIL
302307 }
303308 if (! context.canPlace()) {
304- logger.error(" Cannot place at ${placeContext.blockPos} with current state ${placeContext.cachedState} " )
309+ logger.error(" Cannot place at ${placeContext.blockPos} with current state ${placeContext.cachedState} " , placeContext, request )
305310 return ActionResult .FAIL
306311 }
307312
308313 val itemPlacementContext = item.getPlacementContext(context) ? : run {
309- logger.error(" Could not retrieve item placement context" )
314+ logger.error(" Could not retrieve item placement context" , placeContext, request )
310315 return ActionResult .FAIL
311316 }
312317 val blockState = item.getPlacementState(itemPlacementContext) ? : run {
313- logger.error(" Could not retrieve placement state" )
318+ logger.error(" Could not retrieve placement state" , placeContext, request )
314319 return ActionResult .FAIL
315320 }
316321
@@ -347,7 +352,7 @@ object PlaceManager : RequestHandler<PlaceRequest>(
347352 // "AwaitThenPlace" confirmation setting is enabled, as the block state setting methods that validate these
348353 // rules are not called.
349354 if (! item.place(itemPlacementContext, blockState)) {
350- logger.error(" Could not place block client side at ${placeContext.blockPos} with placement state ${placeContext.expectedState} " )
355+ logger.error(" Could not place block client side at ${placeContext.blockPos} with placement state ${placeContext.expectedState} " , placeContext, request )
351356 return ActionResult .FAIL
352357 }
353358
@@ -365,7 +370,7 @@ object PlaceManager : RequestHandler<PlaceRequest>(
365370 request.onPlace?.invoke(placeContext.blockPos)
366371 }
367372
368- logger.success(" Placed ${placeContext.expectedState} at ${placeContext.blockPos} " )
373+ logger.success(" Placed ${placeContext.expectedState} at ${placeContext.blockPos} " , placeContext, request )
369374
370375 return ActionResult .SUCCESS
371376 }
0 commit comments