Started by
CrystalWarrior1567
on
Topic category: Help with Minecraft modding (Java Edition)
so i'm making an ant mod, and i wanted the leafcutter ants to go up trees and attempt to break the leaf blocks, but i can't find any way to make them always try to find the leaf block, i have no idea how to write custom code.
my idea would be that the entite would look around and then if the leaves were within it's radius, it would go there and collect the block and return, if there weren't any leaves around it would just wander around until it found leaves
same
So you could do this with procedures instead of using entity AI. It would take a lot though. I'll try to make a more in depth tutorial on making custom entity "AI" using procedures. However, It is not real entity AI. You override the movement of the entity and turning the entity's AI off basically. I actually have been working on actually coding custom AI recently with custom code, and I plan to make a plugin for other people to be able to use them, or to try to get them added to MCreator or something if they work good eventually, but that's way down the line.
Step 1: Set a conditional statement on your Entity AI that enables movement. (wandering, flying, following, etc.)
Step 2: In your conditional statement check whether an nbt logic value customAI is true/false. If false, return true.
Step 3: On entity tick, detect if there is a leaf block within your desired area. This can be done easily using 3 repeat loops(x, y, and z iterator directions) to check a 3 dimensional area for a leaf block. If there is one, set nbt logic value of the entity customAI to true, else set it to false. This is what toggles your entity AI on/off to allow you to better override the entity movement vectors.
Step 4: *This is the hard part.* On your entity tick procedure, if your customAI nbt tag is true, do the following. You have to get the block positions of the block you are targeting, then repeatedly set the entity movement vector/rotations to go towards that block. A flying entity is a bit easier, as an entity on the ground has to account for jumping, climbing, etc. I will try to make an example of this eventually when I make the tutorial.
Can u link the tutorial that you did when u make one