Posted March 20, 20169 yr Hello In some code I'm working on, one item should teleport you on top of the block you're looking at. If there's no block there, nothing should happen. As it stands, someone else wrote this code and was able to get it almost perfect. The game crashes if you aren't looking at a block, the place you're teleported to isn't completely accurate, etc. I've come up with a series of step that'll enable me to pull this off, but I don't know how to code these (keep in mind that I'm using the latest Forge version for 1.7.10: [*]Extend the player's "reach" to be a massive or unbounded number [*]Get the coordinates of the block they're looking at [*]Return the player's "reach" to normal [*]Add 0.5 to the X and Z values previously acquired, and 1.1 to the Y value (effectively making the new coordinates in the center and on top of the block selected) [*]use setPosition() to send the player to the previously calculated coordinates Is this at all possible in 1.7.10? If so, how would I pull it off? Also, is there a better and/or more efficient way to do this? The code in its current form can be found here
March 21, 20169 yr First of all - learn why you should use logical sides and run logical code on server, where it is supposed to be ran. Second - that is not really how you should do this. Check out vanilla's code for ray tracing blocks. I am unsude where exacly it is in 1.7.10. Why? We alredy have 1.9... cmon man! (update). 1.7.10 is no longer supported by forge, you are on your own.
March 22, 20169 yr Author I am unsude where exacly it is in 1.7.10. Why? We alredy have 1.9... cmon man! (update). Well excuse me for preferring 1.7.10 for Forge but thanks you anyways, I'll see what I can do
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.