Jump to content

[1.6.4] teleport(Entity entity, double x, double y, double z, int dimension)


Recommended Posts

Posted

Hello guys!

 

I'm implementing another type of cross-dimension teleporter.

And I'm having issues with actual teleportation. Actually, I've tried two versions of teleportation code so far, and none of them works as expected.

This code: https://github.com/ShadedDimension/enhanced-portals/blob/master/src/main/java/uk/co/shadeddimensions/ep3/portal/EntityManager.java has issues with ridden minecarts - when player comes on a minecart through portal, there's another minecart appearing behind.

This code: https://github.com/StevenRS11/DimDoors/blob/master/src/main/java/StevenDimDoors/mod_pocketDim/core/DDTeleporter.java results in player being dismounted at exit point.

So here comes a question. Can anyone please point me out towards precise entity teleportation code, which can move entity both inside dimension and between them, handling mounts, riders and mounts properly? Only entity and its 4D destination. No biometrics, orientation change etc.

 

Thanks.

Posted

Hello guys!

 

I'm implementing another type of cross-dimension teleporter.

And I'm having issues with actual teleportation. Actually, I've tried two versions of teleportation code so far, and none of them works as expected.

This code: https://github.com/ShadedDimension/enhanced-portals/blob/master/src/main/java/uk/co/shadeddimensions/ep3/portal/EntityManager.java has issues with ridden minecarts - when player comes on a minecart through portal, there's another minecart appearing behind.

This code: https://github.com/StevenRS11/DimDoors/blob/master/src/main/java/StevenDimDoors/mod_pocketDim/core/DDTeleporter.java results in player being dismounted at exit point.

So here comes a question. Can anyone please point me out towards precise entity teleportation code, which can move entity both inside dimension and between them, handling mounts, riders and mounts properly? Only entity and its 4D destination. No biometrics, orientation change etc.

 

Thanks.

 

 

Fun fact: I have the same problem: my players are dismounted to(same with horses). I decided to just ignore it. Tell me if someone has an (easy) idea how to do it.

Here could be your advertisement!

Posted

...

This code: https://github.com/ShadedDimension/enhanced-portals/blob/master/src/main/java/uk/co/shadeddimensions/ep3/portal/EntityManager.java has issues with ridden minecarts - when player comes on a minecart through portal, there's another minecart appearing behind.

...

 

 

Fun fact: I have the same problem: my players are dismounted to(same with horses). I decided to just ignore it. Tell me if someone has an (easy) idea how to do it.

 

The first algo from Enhanced Portals seems to remount entities properly, it just dupes player's mount. I'm working on this issue now. Seems there's some trouble with how mounts are stored in NBT - as they're part of their riders' NBTs.

 

Also I'm experiencing random 'backflips', i.e. entity is immediately teleported back. The only idea I'm having for now is to handle per-portal entity list with timestamps, so any given entity can't come through the same portal immediately. I personally don't like idea of per-entity teleport cooldown.

 

UPD

Backflips were for players jumping into portal, and it seems I've solved them.

As for cart doubling, it happens for any minecart with a riding entity. And I'm assuming this is due to how ridden entities are updated. It could've been solved by marking entity as dead. The problem is, this makes game crash when a player rides minecart. Any entities like sheep ride minecarts just fine through a portal.

Posted

UPD:

I've figured out what was the case. It's that nasty removePlayerEntityDangerously. Guess what it does? It removes player from the list of loaded entities.

So here's what happens:

1. A player riding minecart touches my portal. Teleport function runs as a result of onEntityCollidedWithBlock. Which happens - you guessed, as a part of entity update, thus inside World.updateEntities(). Also note that teleport is triggered by minecart.

2. Teleport function breaks mount-rider binding and teleports both entities. Order seems to not matter.

3. When a cart is teleported, it's just marked as dead and dropped from chunk it's registered in.

4. Then, a player is teleported. Here comes removePlayerEntityDangerously - it removes player from the list of loaded entities - effectively breaking its indexing.

5. After entity update tick, dead flag is checked for a minecart. And we're trying to remove minecart from the loaded entities list already changed by player. Then Kaboom happens.

I changed the logic by using ordinary removeEntity and then adding player to unloadedEntitiesList - it should effectively drop player from world's loaded entities on next tick.

The only trouble I'm having for now is the exit position flicker for minecart with player.

Posted

Okie, so here's where I am.

I've solved almost all issues with teleport code. Except one. You guess it - teleporting a riding player through a portal.

When this happens, player is left like desynced with server - no minecart, standing at destination point, and can't trigger block collision reaction - at example he can't teleport back, as teleportation is triggered by colliding a block. But if you re-login, you'll appear at the point where minecart should end, properly riding it.

Code is here:

https://github.com/target-san/Gateway/blob/master/src/targetsan/mcmods/gateway/Teleporter.java

Any help with that last bug would be greatly appreciated.

Posted

I don't know the solution to your issue, but I'll end up working on it soon too. 

 

I've got a portal system setup that works with the screen wobble, effect, delay time to port, any size, ect.  I'm currently fighting the player acting like it has damage after teleport.  Once I get that fixed, i'll loook at riding entities as well.

 

My question for you is on your code.  Why the choice of

 

    ((EntityPlayerMP)entity).setPositionAndUpdate(x, y, z);

 

vs.

 

  entity.setLocationAndAngles(x, y, z, entity.rotationYaw, entity.rotationPitch);

 

I'm wondering if I change that on mine if it will solve the issue.

Long time Bukkit & Forge Programmer

Happy to try and help

Posted

My question for you is on your code.  Why the choice of

 

    ((EntityPlayerMP)entity).setPositionAndUpdate(x, y, z);

 

vs.

 

  entity.setLocationAndAngles(x, y, z, entity.rotationYaw, entity.rotationPitch);

 

I'm wondering if I change that on mine if it will solve the issue.

Dunno if it would in your case, though the first one should be preferrable to players as it explicitly sends packet about position change to player which controls player entity. Also I've checked that my code doesn't impose any 'damage' status over player.

 

UPD: fixed stupid bug in code, I forgot to perform standard onEntityRemove and chunk removal. Also I faced some really strange bug with total desync on another PC. This could be result of no onEntityREmove, or something else.

 

UPD2: I must warn you from using my algorithm. In some cases it causes player's total desync, where player is left floating in void at client side. As for mount/dismount, I'm having an idea on lending the whole work to TileEntity, so it would allow both mount and rider to have one update tick in new world and then re-unite them.

 

P.S: Heck, that player removal/addition for worlds is pretty nasty. I don't even think there are any state invariants for client-server. Couldn't those guys just add utility "teleport anything anywhere" func?

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.