Topic category: Help with Minecraft modding (Java Edition)
Hi all,
So currently, I am trying to make bats hunt silverfish. I cannot use the pathfinding function to do this as bat's movements are too sporadic. So I figured, what if the bats instead do a homing attack every 5 seconds?
So: Get the position of the silverfish and the position of the bat and define a vector with these two points. This vector specifies the difference in x, y, and z coords between the two mobs. To get x, y, and z velocities out of this vector, we need a time to divide each coord by a time. In my case, I want the move to be made in 1 second, so the magnitude of the velocity for each coord is just equal to the direction for each coord. Makes sense, right?
Look at the code: https://imgur.com/a/mcreator-code-7-22-2024-7Y9E0om
Can anyone tell me why this doesn't work? The bats seem to have more velocity than I expect, and often move away from the silverfish rather than toward. Sometimes they even disappear (I think they are moving underground). I have tried to define the vector going from silverfish to bat (the code as shown is going from bat to silverfish), and that has not worked either.
Thank you.
Edit: This has now been solved, the code works but it wasn't working either because of updating my MCreator version or my Minecraft and Forge version while updating the mod. The fix was to delete and recreate the procedure as written. Not really an elegant solution since I am not sure how it broke in the first place, but oh well.
https://imgur.com/rnPQYep
Now bats always move to silverfishes position
I am unsure how this is different from what I am currently doing, since you are doing batx - silverx and then doing 0 minus the result as opposed to my silverPosX - batPosX. In any case, I am seeing the same behavior I saw before. Are we using different versions or something? I am on MC 1.20.1, MCreator 2024.2
looking at both procedures I noticed that they're literally the same too (I didn't check before because I assumed yours didn't work so I just made it different) now I did some tests and my procedure works for me, and yours works too, bats actually dash towards silverfish (MCreator version is the same), the velocity thing is normal, but if bats still go to the opposite direction I don't know how it's possible that they don't for me
Bruh. The only other thing I can think of, are you testing within MCreator or in a separate Minecraft client? I have no idea why that would matter, maybe the Forge version is different and messing something up...
I'm testing within MCreator, maybe you could put your workspace on google drive and send me the link to download it so I can check if it doesn't work using yours, or I could send you mine and you check if it works or not
No need. I made a new workspace and only included the procedure for my code. Annoyingly, it now works... so now I have to just add all of the features of the mod I was working on to a new workspace. It seems updating the game version is what caused the issue. Maybe debugging the client can fix it...
That's really weird, but at least you have some kind of solution now