mojira.dev
MC-255073

Bed still explodes in the nether and the end, if I am too far away

If I right click the bed in the nether or the end and it is is too far away it still explodes. It should say You may not rest now; the bed is too far away.

Attachments

Comments 3

I can confirm this behavior, though after looking through the code, I'm inclined to believe that this is working as intended similar to MC-255074, however, that isn't my decision 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

public class BedBlock extends HorizontalDirectionalBlock implements EntityBlock {
   ...
   @Override
   public InteractionResult use(BlockState blockState, Level level, BlockPos blockPos, Player player, InteractionHand interactionHand, BlockHitResult blockHitResult) {
      ...
      if (!BedBlock.canSetSpawn(level)) {
         level.removeBlock(blockPos, false);
         BlockPos blockPos2 = blockPos.relative(blockState.getValue(FACING).getOpposite());
         if (level.getBlockState(blockPos2).is(this)) {
            level.removeBlock(blockPos2, false);
         }
         level.explode(null, DamageSource.badRespawnPointExplosion(), null, (double)blockPos.getX() + 0.5, (double)blockPos.getY() + 0.5, (double)blockPos.getZ() + 0.5, 5.0f, true, Explosion.BlockInteraction.DESTROY);
         return InteractionResult.SUCCESS;
      }
      ...

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 whether or not you're too far away from it.

@unknown my girlfriend and I are confused what you mean by "noot". Your comment sounds like you are speaking Africaans and forgot to translate it to English and actually mean "bill".

My apologies. It was just a typo; "noot" instead of "not". I've edited the comment and corrected this error. 🙂

Wryboyon

(Unassigned)

Community Consensus

Player

1.19.2

Retrieved