Paper icon indicating copy to clipboard operation
Paper copied to clipboard

Fix allowEnteringNetherUsingPortals gamerule not being respected

Open niho2 opened this issue 2 months ago • 10 comments

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 avatar Oct 31 '25 07:10 niho2

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

electronicboy avatar Oct 31 '25 10:10 electronicboy

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

niho2 avatar Oct 31 '25 12:10 niho2

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

electronicboy avatar Oct 31 '25 12:10 electronicboy

https://github.com/PaperMC/Paper/blob/9934c17322980f2f67e2a47d09b08fb8a8a881c6/paper-server/patches/sources/net/minecraft/world/entity/Entity.java.patch#L1277-L1280 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 avatar Oct 31 '25 12:10 lynxplay

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.

lynxplay avatar Nov 01 '25 19:11 lynxplay

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.

niho2 avatar Nov 02 '25 09:11 niho2

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.

lynxplay avatar Nov 02 '25 10:11 lynxplay

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

niho2 avatar Nov 02 '25 11:11 niho2

Is it ready to merge?

niho2 avatar Nov 26 '25 18:11 niho2

I moved the base to 1.21.10. The merger needs to also port this to .11 / main branch.

lynxplay avatar Dec 07 '25 21:12 lynxplay