Started by
Oreli
on
Topic category: Help with Minecraft modding (Java Edition)
i'm currently trying to make a grappling hook in my mod. it's a ranged item, and the projectile is supposed to launch you towards the block it lands on. how would i go about doing this?
I don't know how to launch a player toward it but I can make it so you teleport there here is how.
first create a ranged item then fill all information. when this is done click green plus next to when bullet hits block and put execute command / "clear" at x: x y: y z: z where it says clear change it to tp @s. this block is found in world management tab. it should work but I have not tested yet
i'd prefer it not just work as a damageless enderpearl, but thanks for the help regardless
alternatively, if i had a way to set the player's motion to the bullet's motion, that might work as well, but every attempt i've had using the attempt to override motion block has failed. even if i just set it to some random numbers instead of the velocity of the bullet, nothing works.
can anyone help with this?
Hmm, you could take the coordonny of the projectile when you it a block then you compare it with the player coordonny and you creat velocity in X, Y and Y to launch the player in the right direction, let me see this on MCreator
Something like this? https://mcreator.net/forum/78422/very-simple-webslinger-tutorial
while that webslinger concept isn't exactly what i'd hoped for, it's the best i've seen so far. thank you
Hmm. You might be able to fiddle around with this command thought: /tp @p ^ ^ ^1
It teleports the player 1 block in the direction they're looking. So then you could try making it so that when the bullet is shot, it will automatically spawn a new entity (Invisible, no AI, no movement entity) and that entity points in a specific direction that the player was looking at, then it continuously runs the tp @p ^ ^ ^1 then tp @p ^ ^ ^2 and so on until when the bullet you threw hits the ground, it kills that entity and stops the player's movement. This one might take a while to do though, so maybe there's 3 variables: Where the bullet lands x, y and z. It compares this to the player that threw the bullet. Then it kinda slowly teleports the player there little by little. Let's say the player's coordinates were 0 0 0. And the bullet landed at 10 20 -30. First, it calculates the distance the X value traveled by. 10-0=10. Next the difference in Y. 20-0=20. And Z. -30-0=-30. Next, let's say you want to teleport there in a series of 10 teleports. It'll divide all three values by 10 to get 1, 2, -3. Each time the player will teleport 1X, 2Y and -3Z. That way, after 10 teleports the player will be at 10 20 -30. Sorry if my explaining was bad.
i've given up on trying to get this fixed, sorry for wasting all your time