Jump to content

My teleportation item always teleports me inside a block


Triphion

Recommended Posts

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

Link to comment
Share on other sites

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).

Whatever Minecraft needs, it is most likely not yet another tool tier.

Link to comment
Share on other sites

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 by Triphion
Link to comment
Share on other sites

That's because of this:

else{
    return new ActionResult(EnumActionResult.FAIL, playerIn.getHeldItem(handIn));
}

 

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

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 by Triphion
Link to comment
Share on other sites

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);

 

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

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.

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

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.