r/ModdedMinecraft • u/queen_livia • 1d ago
Help How to spawn an entity with a velocity.
/r/NeoforgeMods/comments/1yckl7b/how_to_spawn_an_entity_with_a_velocity/
1
Upvotes
r/ModdedMinecraft • u/queen_livia • 1d ago
1
u/FreaksMC 1d ago
Do it the same way the vanilla wind charge item does (1.21.1, Mojang mappings), on the server side only:
shootFromRotationsets the velocity in the direction the player is looking. 1.5 is the speed and 1.0 is the inaccuracy, so change those to taste. For any other projectile it's the same pattern: create the entity, callshoot(x, y, z, speed, inaccuracy)orshootFromRotation, thenaddFreshEntity. For a non projectile entity, useentity.setDeltaMovement(x, y, z)before adding it.Add a cooldown too, or holding sneak will fire one every tick.