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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • When I first heard about Bitcoin back in 2018, I was skeptical. The idea of a decentralized, digital currency seemed too good to be true. But I was intrigued as I learned more about the technology behind it and its potential. I started small, investing just a few hundred dollars, dipping my toes into the cryptocurrency waters. At first, it was exhilarating to watch the value of my investment grow exponentially. I felt like I was part of the future, an early adopter of this revolutionary new asset. But that euphoria was short-lived. One day, I logged into my digital wallet only to find it empty - my Bitcoin had vanished without a trace. It turned out that the online exchange I had trusted had been hacked, and my funds were stolen. I was devastated, both financially and emotionally. All the potential I had seen in Bitcoin was tainted by the harsh reality that with decentralization came a lack of regulation and oversight. My hard-earned money was gone, lost to the ether of the digital world. This experience taught me a painful lesson about the price of trust in the uncharted territory of cryptocurrency. While the technology holds incredible promise, the risks can be catastrophic if you don't approach it with extreme caution. My Bitcoin investment gamble had failed, and I was left to pick up the pieces, wiser but poorer for having placed my faith in the wrong hands. My sincere appreciation goes to MUYERN TRUST HACKER. You are my hero in recovering my lost funds. Send a direct m a i l ( muyerntrusted ( @ ) mail-me ( . )c o m ) or message on whats app : + 1 ( 4-4-0 ) ( 3 -3 -5 ) ( 0-2-0-5 )
    • You could try posting a log (if there is no log at all, it may be the launcher you are using, the FAQ may have info on how to enable the log) as described in the FAQ, however this will probably need to be reported to/remedied by the mod author.
    • So me and a couple of friends are playing with a shitpost mod pack and one of the mods in the pack is corail tombstone and for some reason there is a problem with it, where on death to fire the player will get kicked out of the server and the tombstone will not spawn basically deleting an entire inventory, it doesn't matter what type of fire it is, whether it's from vanilla fire/lava, or from modded fire like ice&fire/lycanites and it's common enough to where everyone on the server has experienced at least once or twice and it doesn't give any crash log. a solution to this would be much appreciated thank you!
    • It is 1.12.2 - I have no idea if there is a 1.12 pack
  • Topics

×
×
  • Create New...

Important Information

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