Triphion Posted September 5, 2017 Share Posted September 5, 2017 So i have made myself a teleportation staff that works fine and all but there is a small issue. Every time i teleport myself to a block, lets say a dirt/grass block while looking down from a high place, i get teleported inside the block i was aiming at. Looking to fix this and hopefully also remove fall damage for a brief period since when you use it while falling under high speed, you take fall damage depending on how fast you were falling. Code - https://gist.github.com/triphion/c5bb47baa2bdf47242e0e9a2183cf2bb Quote Link to comment Share on other sites More sharing options...
IceMetalPunk Posted September 5, 2017 Share Posted September 5, 2017 Doesn't the RayTraceResult provide the position of the block you're looking at? If so, then teleporting the player to that location would of course teleport them into the block. You'll want to call BlockPos#offset() before grabbing the coordinates, to offset the position based on the RayTraceResult's sideHit value (it's a public member). Quote Whatever Minecraft needs, it is most likely not yet another tool tier. Link to comment Share on other sites More sharing options...
Triphion Posted September 5, 2017 Author Share Posted September 5, 2017 (edited) Thanks for the reply, i'll look into it. There's also this thing, the item doesn't seem to work online, i do think this is because i do not have a worldIn call at the end on the code. But i do not know what it should be after the worldIn call. Edited September 5, 2017 by Triphion Quote Link to comment Share on other sites More sharing options...
IceMetalPunk Posted September 5, 2017 Share Posted September 5, 2017 What do you mean it doesn't work "online"? And you don't need to reference worldIn for your particular code, as EntityPlayer#rayTrace simply uses the world that's bound to the player instance. Quote Whatever Minecraft needs, it is most likely not yet another tool tier. Link to comment Share on other sites More sharing options...
Triphion Posted September 5, 2017 Author Share Posted September 5, 2017 (edited) I can't use it to teleport. It doesn't use it nor teleports me anywhere. However, it does work when i play singleplayer, but not on a server. Edited September 5, 2017 by Triphion Quote Link to comment Share on other sites More sharing options...
Draco18s Posted September 5, 2017 Share Posted September 5, 2017 That's because of this: else{ return new ActionResult(EnumActionResult.FAIL, playerIn.getHeldItem(handIn)); } Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given. Link to comment Share on other sites More sharing options...
Triphion Posted September 5, 2017 Author Share Posted September 5, 2017 (edited) Okey, so i should remove that actionresult that has fail in it, is that it? Is it gonna work in servers now? Then also, when people write 6 hours ago, IceMetalPunk said: You'll want to call BlockPos#offset() As an example, what exactly do they mean with that hashtag? I mean, what does it stand for? Is it a dot or a method? Edit: It doesn't teleport me anywhere in servers, only in singleplayer still. Edited September 5, 2017 by Triphion Quote Link to comment Share on other sites More sharing options...
Draco18s Posted September 5, 2017 Share Posted September 5, 2017 The hashtag there means that the method is not static. BlockPos.offset(...) implies that you can just call it like that: foo = BlockPos.offset(bar); When that is in fact not the case, you need an instance of BlockPos instead: BlockPos foo = ... foo.offset(bar); Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given. Link to comment Share on other sites More sharing options...
Triphion Posted September 5, 2017 Author Share Posted September 5, 2017 (edited) Uhmm, and what should i type instead of facing(bar)? And you do mean i have to create a new instance like this right? BlockPos foo = new BlockPos(); Tho im not sure what should be in the two checks. Edited September 5, 2017 by Triphion Quote Link to comment Share on other sites More sharing options...
Draco18s Posted September 5, 2017 Share Posted September 5, 2017 You already have the position, it's the position that isn't working. Now you need to get the facing (which side of the block that was hit by the raycast) and offset that position by 1 in that direction. Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given. Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.