Bed still explodes in the nether and the end, if there are monsters nearby
Resolved
Works As Intended
2
If I right click a bed in the nether and the end it still explodes if there are monsters nearby. It should say You may not rest now there are monsters nearby.
I can confirm this behavior, though after looking through the code, I'm inclined to believe that this is working as intended, however, that isn't my call to make.
Code Analysis:
The following is based on a decompiled version of Minecraft 1.19.2 using Mojang mappings.
If we look at the above class, we can see that only one check is carried out before a bed is able to explode upon it being interacted with. This check is to see if the bed is able to set the player's spawnpoint. Since the canSetSpawn boolean returns false when the bed is placed in dimensions other than the overworld, the bed is simply then designed to explode when the player attempts to sleep in it, regardless of surrounding nearby monsters.
I can confirm this behavior, though after looking through the code, I'm inclined to believe that this is working as intended, however, that isn't my call to make.
Code Analysis:
The following is based on a decompiled version of Minecraft 1.19.2 using Mojang mappings.
net.minecraft.world.level.block.BedBlock.java
If we look at the above class, we can see that only one check is carried out before a bed is able to explode upon it being interacted with. This check is to see if the bed is able to set the player's spawnpoint. Since the
canSetSpawn
boolean returnsfalse
when the bed is placed in dimensions other than the overworld, the bed is simply then designed to explode when the player attempts to sleep in it, regardless of surrounding nearby monsters.