You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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)
publicstaticvoidonTeleport(EntityTeleportEventevent) {
vartargetBlockPos = 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?
The text was updated successfully, but these errors were encountered:
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:
The above code should work for the said purpose. However, I can see at least two cases where it won't work well:
/execute in minecraft:nether run tp @p <x> <y> <z>
from overworld.For case 2, I understand that I can specifically subscribe to
EntityTeleportEvent$EnderPearl
, and retrieve the correct dimension viapearlEntity
.For case 1, however - I do not have any information about which dimension I am being teleported to.
Would it be possible to either
EntityTeleportEvent
, orEntityTeleportEvent$TeleportCommand
?The text was updated successfully, but these errors were encountered: