Skip to content

Conversation

@niho2
Copy link

@niho2 niho2 commented Oct 31, 2025

Description

The allowEnteringNetherUsingPortals gamerule was being ignored when players attempted to use nether portals. This PR adds a check in NetherPortalBlock#getPortalDestination to return null (preventing teleportation) when the gamerule is set to false.

Testing

  • Set /gamerule allowEnteringNetherUsingPortals false
  • Attempted to enter a nether portal
  • Confirmed that the player is NOT teleported to the Nether
  • Set the gamerule back to true and confirmed normal portal behavior works

Fixes #13261

@niho2 niho2 requested a review from a team as a code owner October 31, 2025 07:51
@github-project-automation github-project-automation bot moved this to Awaiting review in Paper PR Queue Oct 31, 2025
@electronicboy
Copy link
Member

The question would generally be, where is the OG check for this and why isn't it doing what is expected here? Looks like the OG check just needs to consider the level when it gets the gamemode, no need to manually patch this in

@niho2
Copy link
Author

niho2 commented Oct 31, 2025

I think that is because there is a new gamerule since 1.21.9 and not just the config file.

@electronicboy
Copy link
Member

Yes, but mojang already has this check implemented, it just doesn't consider the level so likely needs to be fixed to get the gamerule value from the level instead of the server

@lynxplay
Copy link
Contributor

- if (serverLevel.getServer().isAllowedToEnterPortal(level)
- && (level.dimension() == serverLevel.dimension() || this.canTeleport(serverLevel, level))) {
+ if (this instanceof ServerPlayer // CraftBukkit - always call event for players
+ || (level != null && (level.dimension() == serverLevel.dimension() || this.canTeleport(serverLevel, level)))) { // CraftBukkit
is the offending bit.

I am pretty sure that is some of the spigot fuckery required to call PortalEvent which I thought we no longer do anyway?

@lynxplay
Copy link
Contributor

lynxplay commented Nov 1, 2025

No I think we'd want to revert the CB diff there completely?
We haven't called the PortalEvent for non-enabled worlds in forever, the diff there just hurts us.

@niho2
Copy link
Author

niho2 commented Nov 2, 2025

I've reverted the CraftBukkit diff completely as suggested. The fix now simply changes serverLevel.getServer() to level.getServer() so that isAllowedToEnterPortal() checks the gamerule from the destination level instead of the source level.

Tested and confirmed working - the allowEnteringNetherUsingPortals gamerule is now properly respected.

@lynxplay
Copy link
Contributor

lynxplay commented Nov 2, 2025

The fix now simply changes serverLevel.getServer() to level.getServer() so that isAllowedToEnterPortal() checks the gamerule from the destination level instead of the source level.

which level you fetch the server from does not matter... you are still just defaulting to the servers overworld.
You'll need to update the isAllowedToEnterPortal to pass the level to check the gamerules from.

@niho2
Copy link
Author

niho2 commented Nov 2, 2025

Updated the implementation as requested. The isAllowedToEnterPortal method now accepts both source and destination levels as parameters and checks the allowEnteringNetherUsingPortals gamerule from the source level (where the entity is teleporting FROM) rather than defaulting to the server's overworld gamerules.

Changes made:

  1. Reverted the CraftBukkit diff that was removing the check entirely
  2. Updated the method signature to isAllowedToEnterPortal(Level sourceLevel, Level destinationLevel)
  3. Modified the logic to check the gamerule from the source level: sourceLevel.getGameRules().getBoolean(GameRules.RULE_ALLOW_NETHER)

Testing:
Tested in-game and confirmed working correctly:

  • When allowEnteringNetherUsingPortals is set to false in the overworld, entities cannot use nether portals to enter the nether
  • When set to true, portal teleportation works normally
  • Per-world gamerule configuration now works as expected

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Awaiting review

Development

Successfully merging this pull request may close these issues.

allowEnteringNetherUsingPortals is not respected

3 participants