How would one add to a mod so that they could simply hit the letter "F" and teleport 6 blocks in the direction they are looking. I may be able to find out how to get where a player is looking(tried a few times, failed. Might be able to find it though.), but I have failed twice at getting them to teleport at all. (Second time, screen just decided it wants to "spaz" out when I right click, since I used onItemRightClick() as I do not know how to bind keys.") Anyway, could anyone please help me with this? This is one of the last things I need to complete my mod.
//For client
Minecraft.getMinecraft().thePlayer.setPosition(x, y, z);
//For server
((EntityPlayer)MinecraftServer.getServer().getConfigurationManager().playerEntityList.get(0)).setPosition(x, y, z);
“Computers are incredibly fast, accurate and stupid; humans are incredibly slow, inaccurate and brilliant; together they are powerful beyond imagination."
Well, that is the problem. It needs to be 6 blocks in the direction the look, not 6 blocks in a certain direction from the players current position. (If I did that, I could only make them teleport 6 blocks in a set direction, not where they look)
Also, how would I actually get the game to move the player to the new position after they click "F"?
The player's rotationYaw field is the angle in degrees they make with the positive Z axis. You can use trig to find the position 6 blocks from them. E.g.
Well, that is the problem. It needs to be 6 blocks in the direction the look, not 6 blocks in a certain direction from the players current position. (If I did that, I could only make them teleport 6 blocks in a set direction, not where they look)
Also, how would I actually get the game to move the player to the new position after they click "F"?
(all client sided, this is not a server mod )
I was just showing you the code that you can use to move the player, then use integerArray's post to help you with actual positioning.
Whether you are making it a server mod or not, you need the server code for the integrated server which single player runs on.
Rollback Post to RevisionRollBack
“Computers are incredibly fast, accurate and stupid; humans are incredibly slow, inaccurate and brilliant; together they are powerful beyond imagination."
Just replace the xyz with the position you want.
together they are powerful beyond imagination."
Also, how would I actually get the game to move the player to the new position after they click "F"?
(all client sided, this is not a server mod :))
The player's rotationYaw field is the angle in degrees they make with the positive Z axis. You can use trig to find the position 6 blocks from them. E.g.
Sorry for the crude, under-a-minute diagram.
Also be aware that it's the angle from the POSITIVE Z to the NEGATIVE X.
I was just showing you the code that you can use to move the player, then use integerArray's post to help you with actual positioning.
Whether you are making it a server mod or not, you need the server code for the integrated server which single player runs on.
together they are powerful beyond imagination."
By typing it into your method.
...
...
...
Anyway, does it not work? This is how I've implemented it
Also, it's better to make your own post.
thanks!
code:
oh, silly me. thanks again!
edit: i tried to use TechGuy's code for server-base, and it doesnt work. Guess I'll have to stick with what you gave.
edit: problem with this is sometimes you get stuck in a block because you dont change the player.posY at all.