net.minecraft.block.BedBlock Java Examples
The following examples show how to use
net.minecraft.block.BedBlock.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PlayerPonyRenderer.java From MineLittlePony with MIT License | 5 votes |
@Override protected void renderLabelIfPresent(AbstractClientPlayerEntity entity, Text name, MatrixStack stack, VertexConsumerProvider renderContext, int maxDistance) { stack.push(); if (entity.isSleeping()) { if (entity.getSleepingPosition().isPresent() && entity.getEntityWorld().getBlockState(entity.getSleepingPosition().get()).getBlock() instanceof BedBlock) { double bedRad = Math.toRadians(entity.getSleepingDirection().asRotation()); stack.translate(Math.cos(bedRad), 0, -Math.sin(bedRad)); } } stack.translate(0, manager.getNamePlateYOffset(entity), 0); super.renderLabelIfPresent(entity, name, stack, renderContext, maxDistance); stack.pop(); }
Example #2
Source File: IForgeBlock.java From patchwork-api with GNU Lesser General Public License v2.1 | 3 votes |
/** * Returns the position that the sleeper is moved to upon * waking up, or respawning at the bed. * * @param entityType the sleeper's entity type * @param state The current state * @param world The current world * @param pos Block position in world * @param sleeper The sleeper or camera entity, null in some cases. * @return The spawn position */ default Optional<Vec3d> getBedSpawnPosition(EntityType<?> entityType, BlockState state, CollisionView world, BlockPos pos, @Nullable LivingEntity sleeper) { if (world instanceof World) { return BedBlock.findWakeUpPosition(entityType, world, pos, 0); } return Optional.empty(); }
Example #3
Source File: IForgeBlock.java From patchwork-api with GNU Lesser General Public License v2.1 | 2 votes |
/** * Called when a user either starts or stops sleeping in the bed. * * @param state The current state * @param world The current world * @param pos Block position in world * @param sleeper The sleeper or camera entity, null in some cases. * @param occupied True if we are occupying the bed, or false if they are stopping use of the bed */ default void setBedOccupied(BlockState state, CollisionView world, BlockPos pos, LivingEntity sleeper, boolean occupied) { if (world instanceof ModifiableWorld) { ((ModifiableWorld) world).setBlockState(pos, state.with(BedBlock.OCCUPIED, occupied), 4); } }
Example #4
Source File: IForgeBlock.java From patchwork-api with GNU Lesser General Public License v2.1 | 2 votes |
/** * Determines if the current block is the foot half of the bed. * * @param state The current state * @param world The current world * @param pos Block position in world * @return True if the current block is the foot side of a bed. */ default boolean isBedFoot(BlockState state, CollisionView world, BlockPos pos) { return state.get(BedBlock.PART) == BedPart.FOOT; }