|
43 | 43 | import net.minecraft.world.BlockView; |
44 | 44 | import net.minecraft.world.World; |
45 | 45 | import net.minecraft.world.WorldProperties; |
| 46 | +import net.minecraft.world.attribute.EnvironmentAttributes; |
46 | 47 | import org.jetbrains.annotations.NotNull; |
47 | 48 | import org.slf4j.Logger; |
48 | 49 |
|
@@ -232,14 +233,10 @@ private static boolean isAir(BlockState state, BlockPos pos, Entity entity) { |
232 | 233 |
|
233 | 234 | private static boolean maySleep(final Entity entity, final BlockPos pos) { |
234 | 235 | if (entity instanceof ServerPlayerEntity player) { |
235 | | - final var result = EntitySleepEvents.ALLOW_SLEEP_TIME.invoker().allowSleepTime(player, pos, false); |
236 | | - if (result.isAccepted()) { |
237 | | - return true; |
| 236 | + final var result = EntitySleepEvents.ALLOW_SLEEPING.invoker().allowSleep(player, pos); |
| 237 | + if (result != null) { |
| 238 | + return false; |
238 | 239 | } |
239 | | - if (result == ActionResult.PASS) { |
240 | | - return !player.getEntityWorld().isDay(); |
241 | | - } |
242 | | - return false; |
243 | 240 | } |
244 | 241 |
|
245 | 242 | return !entity.getEntityWorld().isDay(); |
@@ -274,7 +271,9 @@ public static ActionResult sit(@NotNull final World world, @NotNull final BlockS |
274 | 271 | if (state.getBlock() instanceof BedBlock && !maySleep(entity, pos)) { |
275 | 272 | if (!command && entity instanceof ServerPlayerEntity player) { |
276 | 273 | // Let the bed explode as it should normally. |
277 | | - if (!BedBlock.isBedWorking(world)) { |
| 274 | + final var rule = world.getEnvironmentAttributes() |
| 275 | + .getAttributeValue(EnvironmentAttributes.BED_RULE_GAMEPLAY, pos); |
| 276 | + if (rule.explodes()) { |
278 | 277 | return ActionResult.PASS; |
279 | 278 | } |
280 | 279 |
|
|
0 commit comments