Started by
blahblahbal
on
Topic category: Help with Minecraft modding (Java Edition)
Just what the title says. I know you can set the "motion" of the player, but that locks the other 2 directions to 0. Also, is there some sort of documentation on Minecraft methods/method names somewhere? I'm fairly positive I'd have to do some custom code to accomplish this, but I don't know any of the method names or anything.
Okay, so I think I figured it out; there is setVelocity method that can be used. But there's another issue: How do I make an action "run once" instead of continuing to run while the redstone circuit is powered? I'm trying to make Player Pistons (which push the player), and I'm setting the velocity of the player to a certain value depending on the redstone power level, but if I run into the front of the piston while the circuit is still active, it pushes me again. So how would I make it run the "push" code only once?
Just out of curiosity, where is this setVelocity method? I'm trying to find it in MCreator 2021.1 (snapshot), but I don't see it (I'm looking in the procedure blocks, by the way).
The method is in PlayerEntity I think; I had to edit the procedure's code to use it, but it turns out that ServerPlayerEntity doesn't have setVelocity, so it pseudo crashes your game when on a server. I fixed it by using a combination of getMotion() and setMotion(), using a Vec3d to get the motion and setting the other 2 motion(s) to the getMotion().x or z, like this:
This is for the facing up player piston.
Still unsure how to make it only run once though, instead of while the redstone circuit is active, continually power the piston.
Make it have a nbt variable timer than sets to 200 after it launches you. Every tick you decrease this nbt variable giving a cooldown for the piston. If the cooldown variable is equal to or less than zero allow it to launch you.