Skip to content

About

Makes minecraft:light blocks placeable through Litematica's Easy Place. Client-side Fabric mod.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Easy Place Light Fix

Fabric mod for Litematica. Makes minecraft:light blocks placeable through Easy Place.

Client-side only. Nothing is required on the server.

The problem

Litematica's Easy Place cannot place a light block in mid-air.

On the rewritten path (easyPlacePostRewrite = on) Litematica builds the click through getClickPosition, which branches on easyPlaceClickAdjacent:

if (EASY_PLACE_CLICK_ADJACENT.getBooleanValue())
    return getAdjacentClickPosition(targetPos);
return hitResult;

With the option on ΓÇö the default ΓÇö getAdjacentClickPosition has to find some block to click, because vanilla cannot click air. It walks the target's six neighbours looking for the first one that is not replaceable, and returns null when they are all air:

for (Direction dir : Direction.values()) {
    BlockPos neighbour = targetPos.relative(dir);
    if (!PlacementUtils.isReplaceable(level, neighbour, false))
        return new BlockHitResult(facePoint(neighbour, dir), dir.getOpposite(), neighbour, false);
}
return null;   // every neighbour was air

A light block floating in space has six neighbours of air, so the loop finds nothing, getClickPosition returns null, and handleEasyPlace bails with FAIL at its clickPos == null || hand == null check ΓÇö holding a valid target, a valid item and a valid hand. BlockItem#place accepts a click on an empty cell, so the server is perfectly willing to fill it; only the search above stands in the way.

What this mod does

Three things, all scoped to minecraft:light:

  1. Makes the block visible to Litematica's ray trace. MixinRayTraceUtils redirects BlockState#getShape and answers a full cube for a light block, but only inside Litematica's schematic trace. Vanilla's LightBlock#getShape is untouched, so collision shapes, rendering and every other context see stock behaviour.

  2. Clicks the target cell directly. Instead of searching for a neighbour to click, the mod substitutes a BlockHitResult aimed at the target cell itself. The click location is the centre of the face pointing back at the player's eye; the server only ever range-checks the BlockPos, not the vector. Guarded so it applies only to a minecraft:light target that is present in the loaded schematic and still empty in the client world ΓÇö everything else keeps stock behaviour.

  3. Sends the rotation Litematica Printer sends. A ServerboundMovePlayerPacket.Rot is emitted before the click, from the head of vanilla MultiPlayerGameMode#useItemOn. Only the packet ΓÇö the camera never moves. This is visible to the server and to anti-cheat that tracks look direction; rotateForLightBlocks = false turns it off.

The hook sits on getClickPosition rather than getAdjacentClickPosition because the latter only runs on the easyPlaceClickAdjacent = on branch ΓÇö hooking it there would make this mod a silent no-op with the option off.

Use easyPlacePostRewrite = on

Litematica ships two separate implementations and this option picks between them:

WorldUtils.handleEasyPlace(mc):
    if (EASY_PLACE_POST_REWRITE.getBooleanValue()) return false;   // -> EasyPlaceUtils
    return doEasyPlaceAction(mc);                                  // -> WorldUtils

With the option on, EasyPlaceUtils#handleEasyPlace runs and all three of the fixes above apply.

With the option off, easyplacefix takes over: it works by injecting into doEasyPlaceAction and cancelling it, which happens before this mod's hooks are reached. Light blocks are rejected at that point and no amount of configuration changes it. This is Litematica's option, not this mod's.

Litematica's own easyPlaceClickAdjacent makes no difference either way.

Install

Drop the jar in mods/. Requires Fabric Loader and Litematica 0.28.8 or newer.

Remove any older version of this mod first.

Configuration

config/easyplace_lightfix.properties, created on first launch. All three default to true, which is what makes the mod work without touching anything.

Key Meaning
rotateForLightBlocks Send the rotation packet. Off if anti-cheat is a concern.
rescueLightTarget Recover the target when a closer vanilla block wins the ray.
directClickForLightBlocks Click a light block's target cell directly. Off means a mid-air light block cannot be placed.

Building

Requires JDK 21+.

./gradlew build

Output in build/libs/.

License

MIT. See LICENSE.

About

Makes minecraft:light blocks placeable through Litematica's Easy Place. Client-side Fabric mod.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages