benbaptist / minecraft-wrapper

A simple & intuitive Minecraft Server wrapper. Supports IRC, backups, a plugin system, and more.
http://wrapper.benbaptist.com/
Other
72 stars 20 forks source link

Add inter-dimensional TP (1.8+) #306

Open suresttexas00 opened 8 years ago

suresttexas00 commented 8 years ago

self.pktSB.SPECTATE:

"Teleports the player to the given entity. The player must be in spectator mode.The Notchian client only uses this to teleport to players, but it appears to accept any type of entity. The entity does not need to be in the same dimension as the player; if necessary, the player will be respawned in the right world."

            """ Inter-dimensional TP ! """  

Seems simple code-wise:

get the players gamemode. switch him to gm3. send this spectate packet switch back to the original gamemode

benbaptist commented 8 years ago

How would you know what entities are in the other dimension to teleport to?

Worst case scenario, a significantly more convoluted but theoretically possible way of doing this would be to disconnect the player from the server (secretly), modifying their player.dat file, adjusting coordinates to something more acceptable as well, and then re-logging them back in. I'm pretty certain the Minecraft server does not cache player data after a logout, as I can usually modify them straight after logging out, save, and everything is good when I log back in. Not sure about rapid-fire doing this, though.

Worst case scenario, it might have to have a few seconds of delay/lag to make this method possible.

suresttexas00 commented 8 years ago

I seems to me that since this is a serverbound packet, it would be up to the server to send all the chunk and entity info... However, if it were really so easy, any hacked client to do a TP, so I am missing something somewhere to be sure..

suresttexas00 commented 8 years ago

Looking at this again, I don't see why the server would object since the player must already be in Spectator mode..

Spectate
Teleports the player to the given entity. The player must be in spectator mode.

The Notchian client only uses this to teleport to players, but it appears to accept any 
type of entity. The entity does not need to be in the same dimension as the player; if 
necessary, the player will be respawned in the right world. If the given entity cannot 
be found (or isn't loaded), this packet will be ignored. It will also be ignored if the 
player attempts to teleport to themselves.

Packet ID   State   Bound To    Field Name  Field Type  Notes
0x1B    Play    Server  Target Player   UUID    UUID of the player to teleport to (can also be an entity UUID)

Really looks to me like if we send the server this packet, we can effect a player to player (interdimensional) TP... and the server should handle the dimensional lighting and chunks and everything.

Also, I was not proposing player to living entity teleport... although we are getting the needed UUID's to try it... Don't know how you would pick an entity to go to... I have to look again at what info I am collecting from entities... I am mostly just concerned with their existence and location.

suresttexas00 commented 7 years ago

I tested this and IT WORKS!

        ...gamemode 3 player1...
        otherperson = self.api.minecraft.getPlayer("some player2 in other dimension")
        otheruuid = otherperson.offlineUuid
        player.getClient().server_connection.packet.sendpkt(0x1b, [16,], (otheruuid,))
        ...gamemode 0 player1...

This does underscore the need for a public api for sending packets to the server and client... and SOON.

I think this might find application with getting players to respawn properly in HUBs too.