Jump to content

Recommended Posts

Posted

At the end of Block.class you'll see forge already added things to make beds work.

Your new bed block will need to override them.

 

    /**
     * Determines if this block is classified as a Bed, Allowing 
     * players to sleep in it, though the block has to specifically 
     * perform the sleeping functionality in it's activated event.
     * 
     * @param world The current world
     * @param x X Position
     * @param y Y Position
     * @param z Z Position
     * @param player The player or camera entity, null in some cases.
     * @return True to treat this as a bed
     */
    public boolean isBed(World world, int x, int y, int z, EntityLiving player)
    {
        return blockID == Block.bed.blockID;
    }
    
    /**
     * Returns the position that the player is moved to upon 
     * waking up, or respawning at the bed.
     * 
     * @param world The current world
     * @param x X Position
     * @param y Y Position
     * @param z Z Position
     * @param player The player or camera entity, null in some cases.
     * @return The spawn position
     */
    public ChunkCoordinates getBedSpawnPosition(World world, int x, int y, int z, EntityPlayer player)
    {
        return BlockBed.getNearestEmptyChunkCoordinates(world, x, y, z, 0);
    }

    /**
     * Called when a user either starts or stops sleeping in the bed.
     *  
     * @param world The current world
     * @param x X Position
     * @param y Y Position
     * @param z Z Position
     * @param player The player 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
     */
    public void setBedOccupied(World world, int x, int y, int z, EntityPlayer player, boolean occupied)
    {
        BlockBed.setBedOccupied(world,  x, y, z, occupied);        
    }

    /**
     * Returns the direction of the block. Same values that 
     * are returned by BlockDirectional
     * 
     * @param world The current world
     * @param x X Position
     * @param y Y Position
     * @param z Z Position
     * @return Bed direction
     */
    public int getBedDirection(IBlockAccess world, int x, int y, int z) 
    {
        return BlockBed.getDirection(world.getBlockMetadata(x,  y, z));
    }
    
    /**
     * Determines if the current block is the foot half of the bed.
     * 
     * @param world The current world
     * @param x X Position
     * @param y Y Position
     * @param z Z Position
     * @return True if the current block is the foot side of a bed.
     */
    public boolean isBedFoot(IBlockAccess world, int x, int y, int z)
    {
        return BlockBed.isBlockHeadOfBed(world.getBlockMetadata(x,  y, z));
    }

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.