All Mods Resource Packs Data Packs Shaders Modpacks Plugins
A* Pathfinding

A* Pathfinding

by CJDev • Downloads: 0 • Followers: 0
Description
Gallery
Changelog
Versions

Please also contribute to this project. I don't have infinite time on my hands 🥺

✅ Features

  • Function to find the path to a destination

📖 Usage

Call the astar:_ function and use the remaining markers tagged astar to guide anything\ The starting position of the path will be located at the current entity, with the end position being the current position in the context\ E.g. execute as @s at @p[distance=1..] run function astar:_\ Note that floating destinations & unreached targets will result in failure

I recommend setting the maxCommandChainLength gamerule high enough for your terrain, or restrict the path to a maximum of ~10 blocks — otherwise, temporary markers may stay once the limit is reached

Config

The configuration is stored in the astar.config scoreboard objective.\ scoreboard players set maxDistance astar.config <maxDistance> — default: 100 (10 blocks) — max distance the pathfinder may travel till finalizing the path.\ scoreboard players set maxStepHeight astar.config <maxStepHeight> — default: 1 — how many blocks it may walk up at once.\ scoreboard players set maxFallDistance astar.config -<maxFallDistance> — default: -3 — negative value, how many blocks it may fall each step.\ To avoid conflicts with others' usage, run function astar:default_config or scoreboard players reset * astar.config before your logic

Block Tags

#astar:climbable — climbable\ #astar:obstructs_floor — traversable, no descent\ #astar:impassable_floor — impassable floor\ #astar:impassable_wall — impassable wall

Penalty Block Tags

#astar:penalty/damage 160 — nearby\ #astar:penalty/danger 80 — nearby\ #astar:penalty/disliked 80

You may add a function to the #astar:eval_node tag to modify costs — return <any> results in only impassable being effective\ — impassable via kill @s — add/remove cost via scoreboard players add/remove @s astar.f <amount>

Penalties increase the cost of a path segment, so the algorithm prefers other routes.

Example code

#code:loop.mcfunction:

data modify storage code:pathfinding points append from entity @s Pos
kill @s
execute as @n[type=marker,tag=astar] at @s run function code:loop


#code:main.mcfunction:

execute store success score found my_score at @n[tag=target] if function astar:_ as @n[type=marker,tag=astar,sort=furthest] at @s run function code:loop
execute unless score found my_score matches 1 run function code:set_direct_target # Walk directly towards target if no path is found

How to Install A* Pathfinding (Datapack)

A* Pathfinding by CJDev is verified for Datapack, Fabric, Forge, Neoforge, Quilt across Minecraft versions 1.21, 1.21-pre1, 1.21-pre2, 1.21-pre3, 1.21-pre4, 1.21-rc1, 1.21.1, 1.21.10 (latest release: 0.7.3+mod, file size: 72 KB). Follow the steps below to install it safely from ModCraft.tv:

  1. Click the Download button above and select your Minecraft version (1.21, 1.21-pre1, 1.21-pre2, 1.21-pre3, 1.21-pre4, 1.21-rc1, 1.21.1, 1.21.10) and platform (Datapack, Fabric, Forge, Neoforge, Quilt).
  2. Make sure you have the compatible loader or environment installed for Datapack, Fabric, Forge, Neoforge, Quilt.
  3. Move the downloaded A* Pathfinding file into your Minecraft .minecraft/saves/<world>/datapacks folder and launch the game.

All Versions

+ Add Version
Name Game version Platforms Published Downloads Actions
26.4.x 26.3.x
Fabric Forge Neoforge Quilt
3mo ago 1
26.4.x 26.3.x
Datapack
3mo ago 1
26.3-snapshot-10
Fabric Forge Neoforge Quilt
3mo ago 1
26.3-snapshot-10
Datapack
3mo ago 1
26.3.x 26.2.x 26.1.x +12
Fabric Forge Neoforge Quilt
7mo ago 1
26.3.x 26.2.x 26.1.x +12
Datapack
7mo ago 1
26.2-snapshot-2 26.1.x 1.21.x
Fabric Forge Neoforge Quilt
last yr. 1
26.2-snapshot-2 26.1.x 1.21.x
Datapack
last yr. 1
25w37a 25w36b 25w36a +9
Fabric Forge Neoforge Quilt
last yr. 1
25w37a 25w36b 25w36a +9
Datapack
last yr. 1
25w37a 25w36b 25w36a +9
Fabric Forge Neoforge Quilt
last yr. 1
25w37a 25w36b 25w36a +9
Datapack
last yr. 1
25w37a 25w36b 25w36a +9
Fabric Forge Neoforge Quilt
last yr. 1
25w37a 25w36b 25w36a +9
Datapack
last yr. 1
25w37a 25w36b 25w36a +9
Fabric Forge Neoforge Quilt
last yr. 1
25w37a 25w36b 25w36a +9
Datapack
last yr. 1
25w37a 25w36b 25w36a +9
Fabric Forge Neoforge Quilt
last yr. 1
25w37a 25w36b 25w36a +9
Datapack
last yr. 1
25w37a 25w36b 25w36a +9
Fabric Forge Neoforge Quilt
last yr. 1
25w37a 25w36b 25w36a +9
Datapack
last yr. 1
25w37a 25w36b 25w36a +9
Fabric Forge Neoforge Quilt
last yr. 1
25w37a 25w36b 25w36a +9
Datapack
last yr. 1
25w37a 25w36b 25w36a +9
Fabric Forge Neoforge Quilt
last yr. 1
25w37a 25w36b 25w36a +9
Datapack
last yr. 1
25w37a 25w36b 25w36a +9
Fabric Forge Neoforge Quilt
last yr. 1
25w37a 25w36b 25w36a +9
Datapack
last yr. 1
25w37a 25w36b 25w36a +9
Fabric Forge Neoforge Quilt
last yr. 1
25w37a 25w36b 25w36a +9
Datapack
last yr. 1
25w37a 25w36b 25w36a +9
Fabric Forge Neoforge Quilt
last yr. 1
25w37a 25w36b 25w36a +9
Datapack
last yr. 1
25w37a 25w36b 25w36a +9
Fabric Forge Neoforge Quilt
last yr. 1
25w37a 25w36b 25w36a +9
Datapack
last yr. 1
bump version\
better performance due to new number providers
bump version\
better performance due to new number providers
bump version
bump version
[0.6.4+mod] 1.21.x+ by CJDev on Dec 16, 2025
Download
  • Fixed not being recognized in 26.1-snapshot-1 and later
[0.6.4] 1.21.x+ by CJDev on Dec 16, 2025
Download
  • Fixed not being recognized in 26.1-snapshot-1 and later
[0.6.3+mod] 1.21.x+ by CJDev on Sep 29, 2025
Download
  • Fixed Penalty Values
  • Fixed Pathfinder searching forever when starting in/on ladder
##### https://github.com/CJDevZ/A-Star-Pathfinding/commit/906887fb82de7cef7779892a3e3b6dfece8d75fe
[0.6.3] 1.21.x+ by CJDev on Sep 29, 2025
Download
  • Fixed Penalty Values
  • Fixed Pathfinder searching forever when starting in/on ladder
##### https://github.com/CJDevZ/A-Star-Pathfinding/commit/906887fb82de7cef7779892a3e3b6dfece8d75fe
[0.6.2+mod] 1.21.x+ by CJDev on Sep 26, 2025
Download
  • Added checks to with 100% make multiple paths possible with no issues
  • Removed unnecessary calculations
  • Changed the #astar:eval_node function tag to check if it returns true due to being nicer to work with
  • The config now only sets default values where there isn't anything set
##### https://github.com/CJDevZ/A-Star-Pathfinding/commit/da59fef4fc50c0837406a63561c8f5269f38feb2
[0.6.2] 1.21.x+ by CJDev on Sep 26, 2025
Download
  • Added checks to with 100% make multiple paths possible with no issues
  • Removed unnecessary calculations
  • Changed the #astar:eval_node function tag to check if it returns true due to being nicer to work with
  • The config now only sets default values where there isn't anything set
##### https://github.com/CJDevZ/A-Star-Pathfinding/commit/da59fef4fc50c0837406a63561c8f5269f38feb2
[0.6.1+mod] 1.21.x+ by CJDev on Sep 26, 2025
Download
  • Readded 1.5x weight on h
  • Fixed pathfinder not going down ladders
  • Pathfinder will now choose the nearest node when the maxDistance is reached
##### https://github.com/CJDevZ/A-Star-Pathfinding/commit/e1bd0c4030c4f2c44e523523ef7c171512070275
[0.6.1] 1.21.x+ by CJDev on Sep 26, 2025
Download
  • Readded 1.5x weight on h
  • Fixed pathfinder not going down ladders
  • Pathfinder will now choose the nearest node when the maxDistance is reached
##### https://github.com/CJDevZ/A-Star-Pathfinding/commit/e1bd0c4030c4f2c44e523523ef7c171512070275
[0.6+mod] 1.21.x+ by CJDev on Sep 25, 2025
Download
  • Added maxStepHeight & maxFallDistance configs
  • Now only directly fails when the target is floating & there's no maxDistance set
##### https://github.com/CJDevZ/A-Star-Pathfinding/commit/02e4466304867d3b3a3e9ac0dc41fd7ddc839261
A* Pathfinding Icon
Download A* Pathfinding
Select game version
Select platform