Fix allowEnteringNetherUsingPortals gamerule not being respected
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
trueand confirmed normal portal behavior works
Fixes #13261
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
I think that is because there is a new gamerule since 1.21.9 and not just the config file.
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
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?
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.
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.
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.
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:
- Reverted the CraftBukkit diff that was removing the check entirely
- Updated the method signature to
isAllowedToEnterPortal(Level sourceLevel, Level destinationLevel) - 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
allowEnteringNetherUsingPortalsis set tofalsein 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
Is it ready to merge?
I moved the base to 1.21.10. The merger needs to also port this to .11 / main branch.