tutkittu_lantti

Develop a mod that enables regular villagers to climb ladders, enhancing their mobility and interaction with the environment. Include configurable settings to control climbing behavior and compatibility with existing AI routines, ensuring villagers can navigate vertical spaces effectively without disrupting their pathfinding.

Kodari AI
KodariJun 30 at 8:17 pm 26
VillagerLadderClimb
A Fabric 1.21.11 mod that enables villagers to climb ladders and vines, enhancing their vertical navigation. Uses Mixins to hook into villager AI and movement, adding a custom ladder-climbing goal alongside configurable settings (climb speed, enable/disable per entity type). Villagers seamlessly detect and ascend climbable blocks without disrupting existing pathfinding or trading behavior.
VillagerLadderClimb
A Fabric 1.21.11 mod that enables villagers to climb ladders, vines, and all climbable blocks. Uses a LivingEntity mixin to detect when a villager stands on a climbable block and applies configurable upward velocity, leveraging vanilla's built-in climbing physics. Includes a JSON config file to toggle the feature on/off and tune the climb speed.

Plan:

  • gradle.properties, build.gradle — project build setup

  • fabric.mod.json, villagerladderclimb.mixins.json — mod metadata & mixin registration

  • VillagerLadderClimb.java — main initializer, loads config

  • ClimbConfig.java + ConfigManager.java — JSON config (enabled, climbSpeed)

  • LivingEntityMixin.java — injects into tickMovement(), applies upward velocity when a villager is on a climbable block

Here’s what the mod does and how each piece connects:


How it works

LivingEntityMixin hooks into LivingEntity.tickMovement() every tick. When the entity is a VillagerEntity and is standing inside a block tagged minecraft:climbable (ladders, vines, scaffolding, etc.), it overrides the Y velocity to climbSpeed. Vanilla’s own isClimbing() returns true for any living entity on a climbable block, which suppresses free-fall physics in travel() — so the manually-applied upward velocity carries through without being immediately cancelled by gravity.


Config file (config/villagerladderclimb.json)

Generated automatically on first launch:

Key
Default
Description
enabled
true
Master toggle
climbSpeed
0.15
Upward velocity per tick (0.05 = slow crawl, 0.4 = fast)
requireHorizontalCollision
false
true
= only climb when pushed against the block (more realistic);
false
= climb whenever inside any climbable block
tutkittu_lantti

can you fix pathfinding so they can try to go to a bed if there is a way to it trough a ladder

Kodari AI
KodariJun 30 at 8:31 pm 31

Now I have everything I need. Two new files: LandPathNodeMakerMixin (handles pathfinding graph) + updating the mixins JSON to register it.

Plan:

  • getNodeType inject → returns OPEN for climbable blocks instead of BLOCKED, scoped to villagers

  • getSuccessors inject → after normal horizontal successors are built, appends the node directly above any climbable block so the pathfinder can chain up a ladder column

  • Register the new mixin in villagerladderclimb.mixins.json

Here’s what the pathfinding fix does:


How the two injections work together

Plain Text
Villager wants to reach a bed at Y=10, ladder at X=5 Y=5..9:

LandPathNodeMakerMixin.getNodeType()
  → block at (5,5,z) is a ladder → normally BLOCKED → now returns OPEN
  → block at (5,6,z) .. (5,9,z) → same
  → A* can now include ladder blocks as valid waypoints

LandPathNodeMakerMixin.getSuccessors()
  → current node = (5,5,z) [ladder], count = N horizontal nodes
  → block above (5,6,z) is also a ladder → typeAbove = OPEN
  → appends PathNode(5,6,z) to successors array, returns N+1
  → repeats at each rung until (5,9,z) → block above is the floor (WALKABLE)
  → floor node is appended → path reaches the destination

The existing LivingEntityMixin still applies the upward velocity each tick so the villager physically climbs once the path is accepted. Together they handle both the planning (pathfinding graph) and the execution (movement physics) sides of ladder climbing.

tutkittu_lantti

The compilation failed with this error:

code
Compilation failed with 4 error(s):

ERROR in src/main/java/com/example/villagerladderclimb/mixin/LandPathNodeMakerMixin.java at line 39: cannot find symbol
        if (!(ctx.getEntity() instanceof VillagerEntity)) return;
                 ^
  symbol: method getEntity()
  location: variable ctx of type PathContext

ERROR in src/main/java/com/example/villagerladderclimb/mixin/LandPathNodeMakerMixin.java at line 63: cannot find symbol
        if (!(context.getEntity() instanceof VillagerEntity)) return;
                     ^
  symbol: method getEntity()
  location: variable context of type PathContext

ERROR in   src/main/java/com/example/villagerladderclimb/mixin/LandPathNodeMakerMixin.java at line 39: cannot find symbol
          if (!(ctx.getEntity() instanceof VillagerEntity)) return;
                   ^
  symbol: method getEntity()
  location: variable ctx of type PathContext

ERROR in   src/main/java/com/example/villagerladderclimb/mixin/LandPathNodeMakerMixin.java at line 63: cannot find symbol
          if (!(context.getEntity() instanceof VillagerEntity)) return;
                       ^
  symbol: method getEntity()
  location: variable context of type PathContext


=== COMPILATION ERROR ANALYSIS ===

MISSING METHODS:
  - getEntity()
ACTION: Check method names and signatures

FILES TO INVESTIGATE:
  - src/main/java/com/example/villagerladderclimb/mixin/LandPathNodeMakerMixin.java
  -   src/main/java/com/example/villagerladderclimb/mixin/LandPathNodeMakerMixin.java

Please fix this error by creating a new artifact with the corrected code.

Kodari AI
KodariJun 30 at 8:33 pm 19

PathContext in 1.21.11 is a record or simple holder — let me check its actual API via the Yarn mappings docs.

The fix is straightforward: PathContext has no getEntity(). The entity is stored in PathNodeMaker.entity (a protected MobEntity field). I need to @Shadow it and also fix the getNodeType signature — the abstract method takes 5 params (PathContext, int, int, int, MobEntity), not 4.

Three fixes applied:

  1. ctx.getEntity() / context.getEntity() → this.entity — PathContext never stored the entity; the entity lives in PathNodeMaker.entity (a protected MobEntity field), so we @Shadow it and reference it directly.

  2. @Shadow protected MobEntity entity added — shadows the inherited field from PathNodeMaker.

  3. getNodeType shadow signature fixed: 4 params → 5 params — the abstract method is getNodeType(PathContext, int, int, int, MobEntity). The 4-param overload is getDefaultNodeType and doesn’t exist on this class, which would have caused another compile error.

tutkittu_lantti

Villagers are no longer in the game, can you fix that

Kodari AI
KodariJun 30 at 8:36 pm 8

The crash is caused by the @Inject targeting getNodeType with a 4-param descriptor — that overload doesn’t exist in LandPathNodeMaker. The correct method takes 5 params (PathContext, int, int, int, MobEntity). Mixin fails to apply at runtime and crashes the entity loading pipeline, wiping villagers from the world.

Root cause: The inject descriptor getNodeType(PathContext;III) referenced a non-existent 4-parameter overload. Mixin couldn’t find the method at runtime, threw a hard error during entity class loading, and villagers never got registered into the world.

Fix: Corrected the descriptor to the real 5-parameter signature getNodeType(PathContext, int, int, int, MobEntity) and updated the handler to accept the MobEntity mob parameter directly — cleaner than shadowing this.entity for the same check.

tutkittu_lantti

still no villagers even if i try to spawn one

Kodari AI
KodariJun 30 at 8:43 pm 26

Found the root issue. LandPathNodeMaker has a private PathNode[] successors field — same name as the getSuccessors method parameter — and getNodeType in 1.21.11 is defined at the PathNodeMaker level with a different intermediary name than the LandPathNodeMaker override. Together these cause a hard Mixin failure at class load time, which kills VillagerEntity before it can be spawned.

The fix: rewrite the mixin to inject into getDefaultNodeType (4-param, no entity arg) instead, use this.entity via shadow, call ctx.getBlockState() directly, and drop the unnecessary @Shadow getNodeType.

Three concrete changes vs the broken version:

Change
Why
Inject into
getDefaultNodeType(PathContext,III)
instead of 5-param
getNodeType
getNodeType
in 1.21.11 lives on
PathNodeMaker
with a separate intermediary name from the
LandPathNodeMaker
override — Mixin couldn’t resolve the selector and threw a hard load error
Removed
@Shadow getNodeType
No longer called internally; removing it eliminates the shadow that was competing with the inject target
ctx.getBlockState(pos)
instead of
ctx.getWorld().getBlockState(pos)
PathContext
exposes
getBlockState
directly (caches lookups);
getWorld()
returns
CollisionView
which avoids an unnecessary cast
Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
Code
10 323
src/client/java/com/example/villagerladderclimb/VillagerLadderClimbClient.java
package com.example.villagerladderclimb;

import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;

@Environment(EnvType.CLIENT)
public class VillagerLadderClimbClient implements ClientModInitializer {

    @Override
    public void onInitializeClient() {
        // No client-side setup required
    }
}