Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EntityTeleportEvent has no way to tell which dimension target will be teleported to #1526

Open
3TUSK opened this issue Sep 9, 2024 · 0 comments · May be fixed by #1531
Open

EntityTeleportEvent has no way to tell which dimension target will be teleported to #1526

3TUSK opened this issue Sep 9, 2024 · 0 comments · May be fixed by #1531
Labels
enhancement New (or improvement to existing) feature or request

Comments

@3TUSK
Copy link

3TUSK commented Sep 9, 2024

Suppose that I marked a "restricted area" and disallowed anyone to entering this area by any means. Which means I do not want players to teleport into this area. Consider the following snippet:

@SubscribeEvent(priority = EventPriority.HIGHEST)
public static void onTeleport(EntityTeleportEvent event) {
    var targetBlockPos = BlockPos.containing(event.getTargetX(), event.getTargetY(), event.getTargetZ());
    if (/* Teleport target is in the restricted area*/) {
        event.setCanceled(true);
        actor.sendSystemMessage(Component.literal("Refuse to teleport you into restricted area"));
    }
}

The above code should work for the said purpose. However, I can see at least two cases where it won't work well:

  • The said area is in The Nether; a player attempts to /execute in minecraft:nether run tp @p <x> <y> <z> from overworld.
  • The said area is in The Nether, and (conveniently) there is a nether portal nearby; a player attempts to trespass the restricted area by throwing an Ender Pearl through the portal

For case 2, I understand that I can specifically subscribe to EntityTeleportEvent$EnderPearl, and retrieve the correct dimension via pearlEntity.
For case 1, however - I do not have any information about which dimension I am being teleported to.

Would it be possible to either

  • Have a "target dimension" in EntityTeleportEvent, or
  • Provide extra context in EntityTeleportEvent$TeleportCommand?
@3TUSK 3TUSK added the enhancement New (or improvement to existing) feature or request label Sep 9, 2024
@HenryLoenwind HenryLoenwind linked a pull request Sep 10, 2024 that will close this issue
@sciwhiz12 sciwhiz12 linked a pull request Sep 12, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New (or improvement to existing) feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant