r/MinecraftCommands • • 1d ago

Help | Java 26.3 Need help fixing a 3D Langton's Ant/Conways Game of Life style project using a datapack in Minecraft [java] 26.3

https://drive.google.com/file/d/1TjRwfA5JOjtH3x7RHVl7uoeoHSPn4oTQ/view?usp=sharing

Video that completely inspired the project: https://www.youtube.com/watch?v=Wj47IQfvU20

All heavily made by AI as I have zero coding experience but love predictable randomness so I apolagise about that.

I'm trying to recreate or copy this video in a way where I can go to the datapack, edit something from saying up to down, or left to right super easily in order to get a new pattern, this will be to represent chaos theory and cause its really cool

The entity is preferably an enderman with NoAI:1b. All movement happens through commands and teleportation (/tp), rather than normal entity movement or gravity as i've learnt NoAI:1b kinda removes gravity.

The entity follows these five rules:

One-block-high wall directly ahead: Destroy the block underneath the itself and teleport itself down one block. (Or even better implement gravity in some way to a NoAI:1b entity. This makes the wall effectively two blocks high relative to the ant. Keep facing the same direction. See image below

Wall two or more blocks high: Climb upwards until the entity can get over it with a single jump and forward once. Excluding that last example every upward teleport must place a support block underneath the ant. Then teleport forward onto the top and reassess the terrain. See image below

Level ground: Remove the block underneath the ant and teleport down one block. Turn left exactly 90 degrees. See image below

One-block drop ahead: Teleport up one block, place a support block underneath, and turn left 90 degrees. See image below

Drop of two or more blocks ahead: Teleport up one block, place a block underneath, and continue straight without turning. See image below

  • The entity must should relative to its current facing direction, not fixed world coordinates if possible.
  • It must check that both the space for its feet and the space for its head are clear before moving forward.
  • It must correctly distinguish between a one-block wall, a two-block wall, level ground, a one-block drop and a deeper drop.
  • Only one rule should execute at a time.
  • After each action, it must reassess the terrain before deciding what to do next.
  • It must not take fall damage unless through teleportation fall damage is not really gonna happen as I cant see it happening anyway due to No Ai being immune to gravity.
  • All movement must be controlled through teleportation.

I've tried making this with multiple .mcfunction files, but I've run into problems with terrain detection, relative coordinates, and functions triggering multiple rules in the same tick. For example, the ant sometimes gets stuck repeatedly placing and destroying blocks beneath itself.

I'm open to rebuilding the datapack from scratch if necessary.

Could someone help me build a reliable system for this?

Video that inspired the project: https://www.youtube.com/watch?v=Wj47IQfvU20

Any help whatsoever would be extremely appreciated

1 Upvotes

1 comment sorted by

1

u/Ericristian_bros Command Experienced 1d ago
# function example:spawn_ant
## Run this function to spawn the mob
exwcute align xz run summon enderman ~0.5 ~ ~0.5 {Tags:["ant"],NoAI:true}

# function example:step
execute if entity @e[limit=1,tag=ant,type=enderman] run schedule function example:step 1t
execute as @e[tag=ant,type=enderman] at @s run function example:logic

# function example:logic
## Type the logic here
## 1 block wall ahead
execute unless block ^ ^ ^1 #replaceable if block ^ ^1 ^1 #replaceable run return run function example:rule/1

# 2+ block walls ahead
execute unless block ^ ^ ^1 #replaceable unless block ^ ^1 ^1 #replaceable run return run function example:rule/2

# flat ground
execute if block ^ ^ ^1 #replaceable unless block ^ ^-1 ^1 #replaceable run return run function example:rule/3

# fall ahead
execute if block ^ ^ ^1 #replaceable if block ^ ^-1 ^1 #replaceable unless block ^ ^-2 ^1 #replaceable run return run function example:rule/4

# 2+ block fall
execute if block ^ ^ ^1 #replaceable if block ^ ^-1 ^1 #replaceable if block ^ ^-2 ^1 #replaceable run return run function example:rule/5

execute unless block ~ ~-1 ~ #replaceable run function example:fall

# function example:rule/1
setblock ~ ~-1 ~ air
tp @s ~ ~-1 ~

# function example:rule/2
setblock ~ ~ ~ stone
tp @s ~ ~1 ~
execute unless block ^ ^ ^1 #replaceable run return run function example:rule/2
tp @s ^ ^ ^1

# function example:rule/3
setblock ~ ~-1 ~ air
tp @s ~ ~-1 ~
rotate @s ~90 0

# function example:rule/4
setblock ~ ~ ~ stone
tp @s ~ ~1 ~
rotate @s ~90 0

# function example:rule/5
setblock ~ ~ ~ stone
tp @s ^ ^1 ^1

# function example:fall
tp @s ~ ~-1 ~
execute unless block ~ ~-1 ~ #replaceable run function example:fall

To stop the movement

schedule clear example:step

Backup your world, because recursive functions can cause crashes if something goes wrong (fall function and rule 2).

I haven't tested the pack, so typos are possible, let me know if something does not work as expected