Topic category: Help with Minecraft modding (Java Edition)
Hey guys! congratz on this program again.
Im trying to learn some coding so i can spice my mobs here, i need the codes i must add on my Mcreator mob files so these work; there are 3 things i need to learn to go further, like these:
1) On my Aquatic Mob, i need to understand where and what i must add to make it work; it can only breath underwater so far, it keeps trying to get out of water and it wont swim on Y vector (underwater / 3d movement) (the squid code parts)
2) On Jumping mobs, like rabbits, i cant figger to what i need to add to make it work, trying to make a kangaroo jumps right here... (the rabbit code parts)
3) I Also would apreciate a code to make the mobs climb vertical surfaces, like monkeys on tree, ants on walls, etc (the spider code parts)
Thank you in advance MCreator team and comunity!
I will start with the most likely easiest one - 3
The ability to climb a block is handled by isOnLadder() , technically you could just always return true, but I am not exactly sure what would do it.
The vanilla spider does it in the way, that each game tick there is a check if the entity collides horizontally with any solid block, and if so, it sets a variable (that is actually stored in a DataWatcher, so it is automatically synced across server and clients). This should be done with this code: https://pastebin.com/gRfQEkLc
However, the default pathfinding does not expect that the entity has such ability, so you must assign to your entity modified version.
That is as simple as writing:
Now, the jumping. To be honest, this is quite more complicated, I guess this is maybe easier to write from scratch than getting it directly from EntityRabbit. The logic seems to be that simply at some moments the rabbit calls a function that adds velocity on the Y axis and sets some boolean to prevent it from jumping in air.
For the swimming, most likely you have to do your own AI task. The default can't handle the fact the entity should be able to move freely in all directions. The squid uses EntitySquid.AIMoveRandom to simply randomly move in any direction. I guess you could look on EntityBat, EntityBlaze, EntityGhast for getting some more information.
thank you for that!
im doing great progress on the mobs! for sea ground entities like starfish no problems since they wont move on Y axis, now i use the squid entity AI on my octopus, its moving right, however it wont animate, i wonder if i still can use the squi AI and somehow make it move the tentacles (my own animations), like could i make checking for water with this:
and then maybe doing something like this:
!this.squid.inWater before the animations (final of the file), i just don tknow how to set this condition, or just set it to allways animate, ithat would be good for now...
any ideas? thanks!