Jump to content

[1.7.2] Teleporting to where your cursor is at?


MegaGEN50

Recommended Posts

You'll need to look into ray tracing in minecraft forge. Either find a forum topic about it, or look in the essentials of the vanilla code to see how it's used (e.g. when a block is even selected).

 

I've haven't ever done anything like this, so that's all I can tell you, sorry :P

 

 

I like to make mods, just like you. Here's one worth checking out

Link to comment
Share on other sites

You could cheat and make an invisible entity that is not affected by gravity, so when the player uses the item it shoots out one of those and teleports the player upon impact.

 

If you want to be able to teleport somewhere even if the player isn't looking at a block (or don't want to use an entity), then you can traverse the player's look vector using for loops to increment each posX/Y/Z by the vector's corresponding coordinates until you either have run 128 iterations (traveled 128 block distances) or hit a block, at which point you teleport the player to that position (or that position minus one or two, if you hit a block).

Link to comment
Share on other sites

Ray Tracing is probably a good idea, I'll take a look at that stuff.

What I'm probably thinking about doing is writing a code that simulates the /tp command, but instead of using the coords or target player, it would use the block you're looking at.

Link to comment
Share on other sites

I made a teleport wand (cursor location) a few weeks ago, in Forge 10.12.0.997, I will tell you how I did it :P

 

[ !!! INCOMING: WALL OF TEXT !!! ]

 

I created a special class for the teleportation and made a method [void] method with (World, EntityPlayer) for the whatchamacallit [forgot ><, someone please tell me] Checking if the world is NOT remote, I get the player's look location [getLook] and position [getPosition] through vectors (Vec3) [vector, lookVector], and multiplying the lookVector (x, y, z) by 50 doubles (50D) to another vector (addedVector).

Then I used (World.clip(Vec3, Vec3)) as a MovingObjectPosition to create an object (that helps locate the error you are looking at). Checking if the moving object is not null, and the thing it hits is a block, I save the coordinates of where it hits, and teleport the player to the location of the saved coordinates through the server net handler, making fall distance to 0F to remove fall damage.

 

I might give you PSUEDO CODE if you need more help/this makes NO sense.

Link to comment
Share on other sites

  • 2 weeks later...

I made a teleport wand (cursor location) a few weeks ago, in Forge 10.12.0.997, I will tell you how I did it :P

 

[ !!! INCOMING: WALL OF TEXT !!! ]

 

I created a special class for the teleportation and made a method [void] method with (World, EntityPlayer) for the whatchamacallit [forgot ><, someone please tell me] Checking if the world is NOT remote, I get the player's look location [getLook] and position [getPosition] through vectors (Vec3) [vector, lookVector], and multiplying the lookVector (x, y, z) by 50 doubles (50D) to another vector (addedVector).

Then I used (World.clip(Vec3, Vec3)) as a MovingObjectPosition to create an object (that helps locate the error you are looking at). Checking if the moving object is not null, and the thing it hits is a block, I save the coordinates of where it hits, and teleport the player to the location of the saved coordinates through the server net handler, making fall distance to 0F to remove fall damage.

 

I might give you PSUEDO CODE if you need more help/this makes NO sense.

I know what you're trying to say, but a bit of code might help. :P

Thanks tho! :D

Link to comment
Share on other sites

I made a similar item and this worked for me. I also didn't want the y to increase but I think you can figure that out

 

In onItemRightClick

double distance = 128;
double a = Math.toRadians(player.rotationYaw);
double dx = -Math.sin(a) * distance;
double dz = Math.cos(a) * distance;
player.setPositionAndUpdate(player.posX + dx, player.posY, player.posZ + dz);// takes in account for collisions with blocks.

Link to comment
Share on other sites

I'll try and give you the basic fields you need and you can rearrange them (if you really know how to use these, if not I'll give you cheats).

* looks at 1 month old stuff *

This might be a long post, but worth it for people to learn some things.

 

Like I said I created a Teleportation Handler with a teleport method.

public void teleport(World world, EntityPlayer player)

 

I checked if the world is not remote[server]:  (!world.isRemote)

Then got the player's position - adding the yCoord (++) by 1 to make sure you aren't inside the block.

Vec3 vec3 = player.getPosition(1.0F);
vec3.yCoord++;

 

Then I get the look position, and send an invisible MovingObjectPosition - we'll save the block coord it hits later. ;)

I use [World#clip] because its a hardcoded method that helps with this - don't know what to call it :P

Vec3 lookVec = player.getLook(1.0F);
Vec3 aVector = vec3.addVector(lookVec.xCoord * 50.0D, lookVec.yCoord * 50.0D, lookVec.zCoord * 50.0D);
MovingObjectPosition movingObjPos = world.clip(vec3, aVector);

 

I then check if the MovingObject [movingObjPos] is not null, and the [typeOfHit] is a block (MovingObjectPosition.MovingObjectType.BLOCK)

proceeding, I create 3 ints and put each int with the [blockX, blockY, blockZ] of the MovingObject [movingObjPos]

 

I create an instance of the player as EntityPlayerMP - below if you are confused and/or need help.

EntityPlayerMP playerMP = (EntityPlayerMP)player;

 

Once again, I check if EntityPlayerMP's ServerNetHandler's Connection is not closed.

if (!playerMP.playerNetServerHandler.connectionClosed) 

 

I set the PlayerMP's position whilst updating it (setPositionAndUpdate):

playerMP.setPositionAndUpdate((double) blockX, (double) ((float) blockY + 1F), (double) blockZ);

 

Be sure after that you set the player's fallDistance to 0 floats [0F].

 

 

Phew. I'm done :D

 

Link to comment
Share on other sites

I'll try and give you the basic fields you need and you can rearrange them (if you really know how to use these, if not I'll give you cheats).

* looks at 1 month old stuff *

This might be a long post, but worth it for people to learn some things.

 

Like I said I created a Teleportation Handler with a teleport method.

public void teleport(World world, EntityPlayer player)

 

I checked if the world is not remote[server]:  (!world.isRemote)

Then got the player's position - adding the yCoord (++) by 1 to make sure you aren't inside the block.

Vec3 vec3 = player.getPosition(1.0F);
vec3.yCoord++;

 

Then I get the look position, and send an invisible MovingObjectPosition - we'll save the block coord it hits later. ;)

I use [World#clip] because its a hardcoded method that helps with this - don't know what to call it :P

Vec3 lookVec = player.getLook(1.0F);
Vec3 aVector = vec3.addVector(lookVec.xCoord * 50.0D, lookVec.yCoord * 50.0D, lookVec.zCoord * 50.0D);
MovingObjectPosition movingObjPos = world.clip(vec3, aVector);

 

I then check if the MovingObject [movingObjPos] is not null, and the [typeOfHit] is a block (MovingObjectPosition.MovingObjectType.BLOCK)

proceeding, I create 3 ints and put each int with the [blockX, blockY, blockZ] of the MovingObject [movingObjPos]

 

I create an instance of the player as EntityPlayerMP - below if you are confused and/or need help.

EntityPlayerMP playerMP = (EntityPlayerMP)player;

 

Once again, I check if EntityPlayerMP's ServerNetHandler's Connection is not closed.

if (!playerMP.playerNetServerHandler.connectionClosed) 

 

I set the PlayerMP's position whilst updating it (setPositionAndUpdate):

playerMP.setPositionAndUpdate((double) blockX, (double) ((float) blockY + 1F), (double) blockZ);

 

Be sure after that you set the player's fallDistance to 0 floats [0F].

 

 

Phew. I'm done :D

Not to be that guy again, but you should be aware that EntityLivingBase#getPosition is CLIENT side only - you can not use this method when on a server or you will crash. You need to create your own Vec3 using the player's position coordinates:

// you can add 1 to the player's posY directly while creating the vector if you want:
Vec3 positionVector = world.getWorldVec3Pool().getVecFromPool(player.posX, player.posY + 1, player.posZ);

Anyway, the rest of the code should work, just thought it worth mentioning (I learned this one the hard way :P )

Link to comment
Share on other sites

Take a look at OgreSean's old Teleport Swords mod: http://www.minecraftforum.net/topic/157524-v181ogreseans-mods-mods-updated-for-181/

 

It's old, but the vector math is still relevant, you'd just need to change a couple of things to keep it relevant in today's methods. He also has a bit in there about adding "randomness" to the teleport, but you can just get rid of that stuff.

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Dalam dunia perjudian online yang berkembang pesat, mencari platform yang dapat memberikan kemenangan maksimal dan hasil terbaik adalah impian setiap penjudi. OLXTOTO, dengan bangga, mempersembahkan dirinya sebagai jawaban atas pencarian itu. Sebagai platform terbesar untuk kemenangan maksimal dan hasil optimal, OLXTOTO telah menciptakan gelombang besar di komunitas perjudian online. Satu dari banyak keunggulan yang dimiliki OLXTOTO adalah koleksi permainan yang luas dan beragam. Dari togel hingga slot online, dari live casino hingga permainan kartu klasik, OLXTOTO memiliki sesuatu untuk setiap pemain. Dibangun dengan teknologi terkini dan dikembangkan oleh para ahli industri, setiap permainan di platform ini dirancang untuk memberikan pengalaman yang tak tertandingi bagi para penjudi. Namun, keunggulan OLXTOTO tidak hanya terletak pada variasi permainan yang mereka tawarkan. Mereka juga menonjol karena komitmen mereka terhadap keamanan dan keadilan. Dengan sistem keamanan tingkat tinggi dan proses audit yang ketat, OLXTOTO memastikan bahwa setiap putaran permainan berjalan dengan adil dan transparan. Para pemain dapat merasa aman dan yakin bahwa pengalaman berjudi mereka di OLXTOTO tidak akan terganggu oleh masalah keamanan atau keadilan. Tak hanya itu, OLXTOTO juga terkenal karena layanan pelanggan yang luar biasa. Tim dukungan mereka selalu siap sedia untuk membantu para pemain dengan segala pertanyaan atau masalah yang mereka hadapi. Dengan respon cepat dan solusi yang efisien, OLXTOTO memastikan bahwa pengalaman berjudi para pemain tetap mulus dan menyenangkan. Dengan semua fitur dan keunggulan yang ditawarkannya, tidak mengherankan bahwa OLXTOTO telah menjadi pilihan utama bagi jutaan penjudi online di seluruh dunia. Jika Anda mencari platform yang dapat memberikan kemenangan maksimal dan hasil optimal, tidak perlu mencari lebih jauh dari OLXTOTO. Bergabunglah dengan OLXTOTO hari ini dan mulailah petualangan Anda menuju kemenangan besar dan hasil terbaik!
    • Selamat datang di OLXTOTO, situs slot gacor terpanas yang sedang booming di industri perjudian online. Jika Anda mencari pengalaman bermain yang luar biasa, maka OLXTOTO adalah tempat yang tepat untuk Anda. Dapatkan sensasi tidak biasa dengan variasi slot online terlengkap dan peluang memenangkan jackpot slot maxwin yang sering. Di sini, Anda akan merasakan keseruan yang luar biasa dalam bermain judi slot. DAFTAR OLXTOTO DISINI LOGIN OLXTOTO DISINI AKUN PRO OLXTOTO DISINI   Jackpot Slot Maxwin Sering Untuk Peluang Besar Di OLXTOTO, kami tidak hanya memberikan hadiah slot biasa, tapi juga memberikan kesempatan kepada pemain untuk memenangkan jackpot slot maxwin yang sering. Dengan demikian, Anda dapat meraih keberuntungan besar dan memenangkan ribuan rupiah sebagai hadiah jackpot slot maxwin kami. Jackpot slot maxwin merupakan peluang besar bagi para pemain judi slot untuk meraih keuntungan yang lebih besar. Dalam permainan kami, Anda tidak harus terpaku pada kemenangan biasa saja. Kami hadir dengan jackpot slot maxwin yang sering, sehingga Anda memiliki peluang yang lebih besar untuk meraih kemenangan besar dengan hadiah yang menggiurkan. Dalam permainan judi slot, pengalaman bermain bukan hanya tentang keseruan dan hiburan semata. Kami memahami bahwa para pemain juga menginginkan kesempatan untuk meraih keberuntungan besar. Oleh karena itu, OLXTOTO hadir dengan jackpot slot maxwin yang sering untuk memberikan peluang besar kepada para pemain kami. Peluang Besar Menang Jackpot Slot Maxwin Peluang menang jackpot slot maxwin di OLXTOTO sangatlah besar. Anda tidak perlu khawatir tentang batasan atau pembatasan dalam meraih jackpot tersebut. Kami ingin memberikan kesempatan kepada semua pemain kami untuk merasakan sensasi menang dalam jumlah yang luar biasa. Jackpot slot maxwin kami dibuka untuk semua pemain judi slot di OLXTOTO. Anda memiliki peluang yang sama dengan pemain lainnya untuk memenangkan hadiah jackpot yang besar. Kami percaya bahwa semua orang memiliki kesempatan untuk meraih keberuntungan besar, dan itulah mengapa kami menyediakan jackpot slot maxwin yang sering untuk memenuhi harapan dan keinginan Anda.   Kesimpulan OLXTOTO adalah situs slot gacor terbaik yang memberikan pengalaman bermain judi slot online yang tak terlupakan. Dengan variasi slot online terlengkap dan peluang memenangkan jackpot slot maxwin yang sering, OLXTOTO menjadi pilihan terbaik bagi para pemain yang mencari kesenangan dan kemenangan besar dalam perjudian online. Di samping itu, OLXTOTO juga menawarkan layanan pelanggan yang ramah dan responsif, siap membantu setiap pemain dalam mengatasi masalah teknis atau pertanyaan seputar perjudian online. Kami menjaga integritas game dan memberikan lingkungan bermain yang adil serta menjalankan kebijakan perlindungan pelanggan yang cermat. Bergabunglah dengan OLXTOTO sekarang dan nikmati pengalaman bermain slot online yang luar biasa. Jadilah bagian dari komunitas perjudian yang mengagumkan ini dan raih kesempatan untuk meraih kemenangan besar. Dapatkan akses mudah dan praktis ke situs OLXTOTO dan rasakan sensasi bermain judi slot yang tak terlupakan.  
    • OLXTOTO: Platform Maxwin dan Gacor Terbesar Sepanjang Masa Di dunia perjudian online yang begitu kompetitif, mencari platform yang dapat memberikan kemenangan maksimal (Maxwin) dan hasil terbaik (Gacor) adalah prioritas bagi para penjudi yang cerdas. Dalam upaya ini, OLXTOTO telah muncul sebagai pemain kunci yang mengubah lanskap perjudian online dengan menawarkan pengalaman tanpa tandingan.     Sejak diluncurkan, OLXTOTO telah menjadi sorotan industri perjudian online. Dikenal sebagai "Platform Maxwin dan Gacor Terbesar Sepanjang Masa", OLXTOTO telah menarik perhatian pemain dari seluruh dunia dengan reputasinya yang solid dan kinerja yang luar biasa. Salah satu fitur utama yang membedakan OLXTOTO dari pesaingnya adalah komitmen mereka untuk memberikan pengalaman berjudi yang unik dan memuaskan. Dengan koleksi game yang luas dan beragam, termasuk togel, slot online, live casino, dan banyak lagi, OLXTOTO menawarkan sesuatu untuk semua orang. Dibangun dengan teknologi terkini dan didukung oleh tim ahli yang berdedikasi, platform ini memastikan bahwa setiap pengalaman berjudi di OLXTOTO tidak hanya menghibur, tetapi juga menguntungkan. Namun, keunggulan OLXTOTO tidak hanya terletak pada permainan yang mereka tawarkan. Mereka juga terkenal karena keamanan dan keadilan yang mereka berikan kepada para pemain mereka. Dengan sistem keamanan tingkat tinggi dan audit rutin yang dilakukan oleh otoritas regulasi independen, para pemain dapat yakin bahwa setiap putaran permainan di OLXTOTO adalah adil dan transparan. Tidak hanya itu, OLXTOTO juga dikenal karena layanan pelanggan yang luar biasa. Dengan tim dukungan yang ramah dan responsif, para pemain dapat yakin bahwa setiap pertanyaan atau masalah mereka akan ditangani dengan cepat dan efisien. Dengan semua fitur dan keunggulan yang ditawarkannya, tidak mengherankan bahwa OLXTOTO telah menjadi platform pilihan bagi para penjudi online yang mencari kemenangan maksimal dan hasil terbaik. Jadi, jika Anda ingin bergabung dengan jutaan pemain yang telah merasakan keajaiban OLXTOTO, jangan ragu untuk mendaftar dan mulai bermain hari ini!  
    • OLXTOTO adalah bandar slot yang terkenal dan terpercaya di Indonesia. Mereka menawarkan berbagai jenis permainan slot yang menarik dan menghibur. Dengan tampilan yang menarik dan grafis yang berkualitas tinggi, pemain akan merasa seperti berada di kasino sungguhan. OLXTOTO juga menyediakan layanan pelanggan yang ramah dan responsif, siap membantu pemain dengan segala pertanyaan atau masalah yang mereka hadapi. Daftar =  https://surkale.me/Olxtotodotcom1
    • DAFTAR & LOGIN BIGO4D   Bigo4D adalah situs slot online yang populer dan menarik perhatian banyak pemain slot di Indonesia. Dengan berbagai game slot yang unik dan menarik, Bigo4D menjadi tempat yang ideal untuk pemula dan pahlawan slot yang berpengalaman. Dalam artikel ini, kami akan membahas tentang Bigo4D sebagai situs slot terbesar dan menarik yang saat ini banyak dijajaki oleh pemain slot online.
  • Topics

×
×
  • Create New...

Important Information

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