Posted April 29, 20205 yr BlockPos spawn = worldIn.getSpawnPoint(); @Nullable BlockPos bed = playerIn.getBedLocation(DimensionType.OVERWORLD); if(bed != null && worldIn.getBlockState(bed).getBlock().toString().contains("bed")) { playerIn.setPositionAndUpdate(bed.getX(), bed.getY(), bed.getZ()); } else { playerIn.setPositionAndUpdate(spawn.getX(), spawn.getY(), spawn.getZ()); } Make sure when getting your bed it's nullable or you can get an error This may not be the best solution but it works Edited May 1, 20205 yr by Slastic
April 30, 20205 yr 32 minutes ago, Slastic said: I was trying to figure out how to ensure the bed exists since it still teleported you there, even if there was no bed. Always lead with what you are actually trying to accomplish, from a gameplay standpoint. makes the path to the answer considerably shorter in most cases!
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.