can someone help me create a grasshopper

Started by ApertureMax on

Topic category: Help with Minecraft modding (Java Edition)

Joined Oct 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
can someone help me create a grasshopper

So i need a grasshopper that frequently jumps how can i do this? i need actual code since leap at target entity doesn't work. Thanks in advance.

Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Leap at target entity is for…
Sat, 11/18/2023 - 00:08

Leap at target entity is for hostile attacks, like how spiders attack players. Do you want the entity to be hostile?

Either way, you can accomplish this using the 'override motion vector' procedure. It would look something like this:

  • When your entity spawns, use the 'Set custom number NBT' to give the entity an NBT tag, (I'll call it 'timer'), which is set to some number initially. (Something like 100.) You could also accomplish this using a hidden status effect, but I've been told that's really really bad practice and I should stop doing it.
  • Then, make a custom procedure that runs on entity update tick. If the 'timer' is greater than zero, set the NBT tag to its current value, minus one. (This will cause the timer to go down by one every tick.) If the timer instead equals zero, use the 'override motion vector' function to set the entity's x/y/z velocities to its x/z look angle vectors, for the x and z values, and an arbitrary value, (something like 0.5), for the y value. Setting the x and z velocities to look angle vectors will cause the entity to move in the direction it's looking, and the y velocity will cause it to leap upwards in that direction. (You can also multiply all the vectors to make the jump more powerful.) 
  • Lastly, after overriding the motion vector, MAKE SURE to reset the timer to a random value around 100. If the timer stays at zero and isn't reset, the entity will continuously be flung upwards, shooting up into the sky at high speeds, which, while entertaining, probably isn't what you're going for.

This sort of timer system works great for all sorts of entity behaviors you want to occur at specific points. (As long as you can do them using procedures.) I personally use this to make beetles from a mod of mine randomly stop moving and play a sound/animation, before wandering around again, and to control when dragonflies change direction.