Source:
<code>public void onPlaceBlock(ActivateEvent event, EntityRef item) { if (!event.getTarget().exists()) { event.consume(); return; } BlockItemComponent blockItem = item.getComponent(BlockItemComponent.class); BlockFamily blockFamily = blockItem.blockFamily; Side surfaceSide = Side.inDirection(event.getHitNormal()); BlockComponent blockComponent = event.getTarget().getComponent(BlockComponent.class); if (blockComponent == null) { event.consume(); return; } Vector3i targetBlock = new Vector3i(blockComponent.position); Vector3i placementPos = new Vector3i(targetBlock); placementPos.add(surfaceSide.getVector3i()); Vector3f targetPosition = event.getTargetLocation(); <START> Vector2f relativePlacementPosition; if (targetPosition != null) { relativePlacementPosition = getSideHitPosition(event.getHitPosition(), targetPosition); } else { relativePlacementPosition = new Vector2f(); } <END> Block block = blockFamily.getBlockForPlacement(new BlockPlacementData( JomlUtil.from(placementPos), surfaceSide, JomlUtil.from(event.getDirection()), relativePlacementPosition )); if (canPlaceBlock(block, targetBlock, placementPos)) { if (networkSystem.getMode().isAuthority()) { PlaceBlocks placeBlocks = new PlaceBlocks(placementPos, block, event.getInstigator()); worldProvider.getWorldEntity().send(placeBlocks); if (!placeBlocks.isConsumed()) { item.send(new OnBlockItemPlaced(placementPos, blockEntityRegistry.getBlockEntityAt(placementPos), event.getInstigator())); } else { event.consume(); } } recordBlockPlaced(event, blockFamily); event.getInstigator().send(new PlaySoundEvent(Assets.getSound("engine:PlaceBlock").get(), 0.5f)); } else { event.consume(); } }</code><technical_language>moving null check getSideHitPosition? suggestion Vector2f relativePlacementPosition = getSideHitPosition(event.getHitPosition(), targetPosition);</technical_language>

Target:
public void onPlaceBlock(ActivateEvent event, EntityRef item) { if (!event.getTarget().exists()) { event.consume(); return; } BlockItemComponent blockItem = item.getComponent(BlockItemComponent.class); BlockFamily blockFamily = blockItem.blockFamily; Side surfaceSide = Side.inDirection(event.getHitNormal()); BlockComponent blockComponent = event.getTarget().getComponent(BlockComponent.class); if (blockComponent == null) { event.consume(); return; } Vector3i targetBlock = new Vector3i(blockComponent.position); Vector3i placementPos = new Vector3i(targetBlock); placementPos.add(surfaceSide.getVector3i()); Vector2f relativeAttachmentPosition = getRelativeAttachmentPosition(event); Block block = blockFamily.getBlockForPlacement(new BlockPlacementData( JomlUtil.from(placementPos), surfaceSide, JomlUtil.from(event.getDirection()), relativeAttachmentPosition )); if (canPlaceBlock(block, targetBlock, placementPos)) { if (networkSystem.getMode().isAuthority()) { PlaceBlocks placeBlocks = new PlaceBlocks(placementPos, block, event.getInstigator()); worldProvider.getWorldEntity().send(placeBlocks); if (!placeBlocks.isConsumed()) { item.send(new OnBlockItemPlaced(placementPos, blockEntityRegistry.getBlockEntityAt(placementPos), event.getInstigator())); } else { event.consume(); } } recordBlockPlaced(event, blockFamily); event.getInstigator().send(new PlaySoundEvent(Assets.getSound("engine:PlaceBlock").get(), 0.5f)); } else { event.consume(); } }