Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-5136

EntityPortalEvent getting called on interdimensional entity teleports

XMLWordPrintable

    • git-Spigot-d05d3c1-604c8bf (MC: 1.14.3) (Implementing API version 1.14.3-R0.1-SNAPSHOT)
    • Yes

      Issue:

      The teleport(Location) Method of entities fires an EntityPortalEvent, even though the javadocs state it is only supposed to fire when an entity actually touches a portal. The issue first appeared in the 1.14.3 API for me (could also be in earlier 1.14 versions, I just tested 1.13.2 and 1.14.3. In 1.13.2 it still worked as it was supposed to, using the exact same code).

       

      Edit: I should probably also explain why this is an issue: I have a plugin that blocks all EntityPortalEvents to prevent vanilla portals and especially automatically generating nether portals from messing up the worlds. So that's why I made custom portals and a system to take animals with you through those portals, which no longer worked due to this change.  I managed to find a workaround, so that both my portals and blocking vanilla portals work again, but still, it would be a lot cleaner if I had a reliable way of distinguishing portal teleportations and plugin induced teleportations.

      How to recreate:

      Simply listen for the EntityPortalEvent with some debug output and try teleporting an Entity (does not apply to players) using Bukkits teleport method (I've tested it with villagers and pigs, but it should work with everything except players) into a different world (normal teleports within the same world still work fine, without firing the event).

      Cause:

      After looking at some craftbukkit and nms code, i found the method responsible for interdimensional teleports in the nms Entity class:

      @Nullable public Entity teleportTo(DimensionManager dimensionmanager, BlockPosition location)
      

      (The above method is called by CraftEntity, when it notices that the teleport destination is in a different world)

      It's pretty obvious from there: The method just fires the EntityPortalEvent, even though it can also be called without the entity actually entering a vanilla portal (for example using the teleport method from the Bukkit API).

       

      Since I'm not that familiar with vanilla Minecraft's internal workings, I don't really know where the Event call should be moved to fix the bug, but I think it's safe to say that either this method is not the right place for the EntityPortalEvent or Bukkit is handling entity teleportation wrongly.

            Unassigned Unassigned
            Mark_2205 M
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: