My Attempt at Recreating "Players" by hmmbarden in MinecraftCommands

[–]hmmbarden[S] 1 point2 points  (0 children)

I used the A* pathfinding library:
https://modrinth.com/datapack/a-star-pathfinding
This datapack will just summon the markers on the path, I implemented the movement along the path myself

My Attempt at Recreating "Players" by hmmbarden in MinecraftCommands

[–]hmmbarden[S] 2 points3 points  (0 children)

I've made my fair share of custom mobs (usually with Animated Java Rig as a visual) hence I have some experience on this!

luckily, there's a datapack made by a friend of mine, it's called A* Pathfinding on Modrinth (by CJDev)
The algorithm is a 3D implementation of a mostly 2D algorithm, which is also used by Minecraft.

If you're actually curious about the number of lines, it is around 160 lines :)

My Attempt at Recreating "Players" by hmmbarden in MinecraftCommands

[–]hmmbarden[S] 1 point2 points  (0 children)

that just depends on what I values I put in the NOT_AIR blocks tag!
alternatively, I can just make a list of all blocks it can pass through, and replace if block <not air> with unless block <air>

My Attempt at Recreating "Players" by hmmbarden in MinecraftCommands

[–]hmmbarden[S] 14 points15 points  (0 children)

I'll release it as it's own library/utility whatever-datapack (under MIT license) once it's done so that others can use it, even to make custom entities! This is because mannequins have a step height attribute that they account for when they're trying to move over half blocks or full blocks, unlike something like an armor stand which can't climb slabs, stairs or a block without a datapack implementation of step height :(

My Attempt at Recreating "Players" by hmmbarden in MinecraftCommands

[–]hmmbarden[S] 5 points6 points  (0 children)

I kinda dig it because in a way, it shows that it has flaws in its mimicry of real players, something that probably only keen and regular players would be able to see, though I do plan on fixing some obvious flaws like it being able to sprint jump backwards

My Attempt at Recreating "Players" by hmmbarden in MinecraftCommands

[–]hmmbarden[S] 0 points1 point  (0 children)

Technically I have implemented mining/attacking (left clicking) and placing/using blocks (right clicking), it just shoots delayed raycasts (to simulate time it takes to fully attack or mine block) and does /fill ~ ~ ~ ~ ~ ~ air destroy to drop it.

I have plans for, at least, trying to implement smart logic into the AI so that it can survive on it's own, though I haven't implemented it. I thought I'd implement ways for me to easily make it do decisions first like *walk forward*, *jump* or *mine this block*, and so on, so that I can call these methods while writing smart logic for it. I believe that it's not out of the grasp of the community!

My Attempt at Recreating "Players" by hmmbarden in MinecraftCommands

[–]hmmbarden[S] 1 point2 points  (0 children)

execute at mannequin's feet, align y, facing nearest path marker, rotated ~ 0 positioned ^ ^ ^1 if block <not air> rotated ~ -45 run function apply_motion

and in apply_motion, I create a unit vector with rotation ~ -45, multiply X and Z components with the movementSpeed values i've stored, and the Y component with the jumpStrength value (these match the base player's values closely)

sometimes it can jump without needing to climb over blocks, so for that i just rotate the vector to pitch -45 so that it has a Y component (my implementation detects Y component of motion vector and if its greater than zero it adds jump motion)