Java Code Examples for net.minecraft.init.Blocks.bed()

The following are Jave code examples for showing how to use bed() of the net.minecraft.init.Blocks class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: BaseClient   File: EntityPlayer.java   View Source Code Vote up 6 votes
/**
 * Return null if bed is invalid
 */
public static BlockPos getBedSpawnLocation(World worldIn, BlockPos bedLocation, boolean forceSpawn)
{
    Block block = worldIn.getBlockState(bedLocation).getBlock();

    if (block != Blocks.bed)
    {
        if (!forceSpawn)
        {
            return null;
        }
        else
        {
            boolean flag = block.func_181623_g();
            boolean flag1 = worldIn.getBlockState(bedLocation.up()).getBlock().func_181623_g();
            return flag && flag1 ? bedLocation : null;
        }
    }
    else
    {
        return BlockBed.getSafeExitLocation(worldIn, bedLocation, 0);
    }
}
 
Example 2
Project: DecompiledMinecraft   File: EntityPlayer.java   View Source Code Vote up 6 votes
/**
 * Return null if bed is invalid
 */
public static BlockPos getBedSpawnLocation(World worldIn, BlockPos bedLocation, boolean forceSpawn)
{
    Block block = worldIn.getBlockState(bedLocation).getBlock();

    if (block != Blocks.bed)
    {
        if (!forceSpawn)
        {
            return null;
        }
        else
        {
            boolean flag = block.func_181623_g();
            boolean flag1 = worldIn.getBlockState(bedLocation.up()).getBlock().func_181623_g();
            return flag && flag1 ? bedLocation : null;
        }
    }
    else
    {
        return BlockBed.getSafeExitLocation(worldIn, bedLocation, 0);
    }
}
 
Example 3
Project: DecompiledMinecraft   File: EntityPlayer.java   View Source Code Vote up 6 votes
/**
 * Return null if bed is invalid
 */
public static BlockPos getBedSpawnLocation(World worldIn, BlockPos bedLocation, boolean forceSpawn)
{
    Block block = worldIn.getBlockState(bedLocation).getBlock();

    if (block != Blocks.bed)
    {
        if (!forceSpawn)
        {
            return null;
        }
        else
        {
            boolean flag = block.func_181623_g();
            boolean flag1 = worldIn.getBlockState(bedLocation.up()).getBlock().func_181623_g();
            return flag && flag1 ? bedLocation : null;
        }
    }
    else
    {
        return BlockBed.getSafeExitLocation(worldIn, bedLocation, 0);
    }
}
 
Example 4
Project: BaseClient   File: EntityPlayer.java   View Source Code Vote up 6 votes
/**
 * Return null if bed is invalid
 */
public static BlockPos getBedSpawnLocation(World worldIn, BlockPos bedLocation, boolean forceSpawn)
{
    Block block = worldIn.getBlockState(bedLocation).getBlock();

    if (block != Blocks.bed)
    {
        if (!forceSpawn)
        {
            return null;
        }
        else
        {
            boolean flag = block.func_181623_g();
            boolean flag1 = worldIn.getBlockState(bedLocation.up()).getBlock().func_181623_g();
            return flag && flag1 ? bedLocation : null;
        }
    }
    else
    {
        return BlockBed.getSafeExitLocation(worldIn, bedLocation, 0);
    }
}
 
Example 5
Project: DecompiledMinecraft   File: EntityAIOcelotSit.java   View Source Code Vote up 5 votes
/**
 * Return true to set given position as destination
 */
protected boolean shouldMoveTo(World worldIn, BlockPos pos)
{
    if (!worldIn.isAirBlock(pos.up()))
    {
        return false;
    }
    else
    {
        IBlockState iblockstate = worldIn.getBlockState(pos);
        Block block = iblockstate.getBlock();

        if (block == Blocks.chest)
        {
            TileEntity tileentity = worldIn.getTileEntity(pos);

            if (tileentity instanceof TileEntityChest && ((TileEntityChest)tileentity).numPlayersUsing < 1)
            {
                return true;
            }
        }
        else
        {
            if (block == Blocks.lit_furnace)
            {
                return true;
            }

            if (block == Blocks.bed && iblockstate.getValue(BlockBed.PART) != BlockBed.EnumPartType.HEAD)
            {
                return true;
            }
        }

        return false;
    }
}
 
Example 6
Project: DecompiledMinecraft   File: EntityPlayer.java   View Source Code Vote up 5 votes
/**
 * Wake up the player if they're sleeping.
 */
public void wakeUpPlayer(boolean p_70999_1_, boolean updateWorldFlag, boolean setSpawn)
{
    this.setSize(0.6F, 1.8F);
    IBlockState iblockstate = this.worldObj.getBlockState(this.playerLocation);

    if (this.playerLocation != null && iblockstate.getBlock() == Blocks.bed)
    {
        this.worldObj.setBlockState(this.playerLocation, iblockstate.withProperty(BlockBed.OCCUPIED, Boolean.valueOf(false)), 4);
        BlockPos blockpos = BlockBed.getSafeExitLocation(this.worldObj, this.playerLocation, 0);

        if (blockpos == null)
        {
            blockpos = this.playerLocation.up();
        }

        this.setPosition((double)((float)blockpos.getX() + 0.5F), (double)((float)blockpos.getY() + 0.1F), (double)((float)blockpos.getZ() + 0.5F));
    }

    this.sleeping = false;

    if (!this.worldObj.isRemote && updateWorldFlag)
    {
        this.worldObj.updateAllPlayersSleepingFlag();
    }

    this.sleepTimer = p_70999_1_ ? 0 : 100;

    if (setSpawn)
    {
        this.setSpawnPoint(this.playerLocation, false);
    }
}
 
Example 7
Project: DecompiledMinecraft   File: EntityZombie.java   View Source Code Vote up 5 votes
/**
 * Return the amount of time decremented from conversionTime every tick.
 */
protected int getConversionTimeBoost()
{
    int i = 1;

    if (this.rand.nextFloat() < 0.01F)
    {
        int j = 0;
        BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();

        for (int k = (int)this.posX - 4; k < (int)this.posX + 4 && j < 14; ++k)
        {
            for (int l = (int)this.posY - 4; l < (int)this.posY + 4 && j < 14; ++l)
            {
                for (int i1 = (int)this.posZ - 4; i1 < (int)this.posZ + 4 && j < 14; ++i1)
                {
                    Block block = this.worldObj.getBlockState(blockpos$mutableblockpos.func_181079_c(k, l, i1)).getBlock();

                    if (block == Blocks.iron_bars || block == Blocks.bed)
                    {
                        if (this.rand.nextFloat() < 0.3F)
                        {
                            ++i;
                        }

                        ++j;
                    }
                }
            }
        }
    }

    return i;
}
 
Example 8
Project: DecompiledMinecraft   File: EntityAIOcelotSit.java   View Source Code Vote up 5 votes
/**
 * Return true to set given position as destination
 */
protected boolean shouldMoveTo(World worldIn, BlockPos pos)
{
    if (!worldIn.isAirBlock(pos.up()))
    {
        return false;
    }
    else
    {
        IBlockState iblockstate = worldIn.getBlockState(pos);
        Block block = iblockstate.getBlock();

        if (block == Blocks.chest)
        {
            TileEntity tileentity = worldIn.getTileEntity(pos);

            if (tileentity instanceof TileEntityChest && ((TileEntityChest)tileentity).numPlayersUsing < 1)
            {
                return true;
            }
        }
        else
        {
            if (block == Blocks.lit_furnace)
            {
                return true;
            }

            if (block == Blocks.bed && iblockstate.getValue(BlockBed.PART) != BlockBed.EnumPartType.HEAD)
            {
                return true;
            }
        }

        return false;
    }
}
 
Example 9
Project: DecompiledMinecraft   File: EntityPlayer.java   View Source Code Vote up 5 votes
/**
 * Wake up the player if they're sleeping.
 */
public void wakeUpPlayer(boolean p_70999_1_, boolean updateWorldFlag, boolean setSpawn)
{
    this.setSize(0.6F, 1.8F);
    IBlockState iblockstate = this.worldObj.getBlockState(this.playerLocation);

    if (this.playerLocation != null && iblockstate.getBlock() == Blocks.bed)
    {
        this.worldObj.setBlockState(this.playerLocation, iblockstate.withProperty(BlockBed.OCCUPIED, Boolean.valueOf(false)), 4);
        BlockPos blockpos = BlockBed.getSafeExitLocation(this.worldObj, this.playerLocation, 0);

        if (blockpos == null)
        {
            blockpos = this.playerLocation.up();
        }

        this.setPosition((double)((float)blockpos.getX() + 0.5F), (double)((float)blockpos.getY() + 0.1F), (double)((float)blockpos.getZ() + 0.5F));
    }

    this.sleeping = false;

    if (!this.worldObj.isRemote && updateWorldFlag)
    {
        this.worldObj.updateAllPlayersSleepingFlag();
    }

    this.sleepTimer = p_70999_1_ ? 0 : 100;

    if (setSpawn)
    {
        this.setSpawnPoint(this.playerLocation, false);
    }
}
 
Example 10
Project: DecompiledMinecraft   File: EntityZombie.java   View Source Code Vote up 5 votes
/**
 * Return the amount of time decremented from conversionTime every tick.
 */
protected int getConversionTimeBoost()
{
    int i = 1;

    if (this.rand.nextFloat() < 0.01F)
    {
        int j = 0;
        BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();

        for (int k = (int)this.posX - 4; k < (int)this.posX + 4 && j < 14; ++k)
        {
            for (int l = (int)this.posY - 4; l < (int)this.posY + 4 && j < 14; ++l)
            {
                for (int i1 = (int)this.posZ - 4; i1 < (int)this.posZ + 4 && j < 14; ++i1)
                {
                    Block block = this.worldObj.getBlockState(blockpos$mutableblockpos.func_181079_c(k, l, i1)).getBlock();

                    if (block == Blocks.iron_bars || block == Blocks.bed)
                    {
                        if (this.rand.nextFloat() < 0.3F)
                        {
                            ++i;
                        }

                        ++j;
                    }
                }
            }
        }
    }

    return i;
}
 
Example 11
Project: DecompiledMinecraft   File: RenderManager.java   View Source Code Vote up 5 votes
public void cacheActiveRenderInfo(World worldIn, FontRenderer textRendererIn, Entity livingPlayerIn, Entity pointedEntityIn, GameSettings optionsIn, float partialTicks)
{
    this.worldObj = worldIn;
    this.options = optionsIn;
    this.livingPlayer = livingPlayerIn;
    this.pointedEntity = pointedEntityIn;
    this.textRenderer = textRendererIn;

    if (livingPlayerIn instanceof EntityLivingBase && ((EntityLivingBase)livingPlayerIn).isPlayerSleeping())
    {
        IBlockState iblockstate = worldIn.getBlockState(new BlockPos(livingPlayerIn));
        Block block = iblockstate.getBlock();

        if (block == Blocks.bed)
        {
            int i = ((EnumFacing)iblockstate.getValue(BlockBed.FACING)).getHorizontalIndex();
            this.playerViewY = (float)(i * 90 + 180);
            this.playerViewX = 0.0F;
        }
    }
    else
    {
        this.playerViewY = livingPlayerIn.prevRotationYaw + (livingPlayerIn.rotationYaw - livingPlayerIn.prevRotationYaw) * partialTicks;
        this.playerViewX = livingPlayerIn.prevRotationPitch + (livingPlayerIn.rotationPitch - livingPlayerIn.prevRotationPitch) * partialTicks;
    }

    if (optionsIn.thirdPersonView == 2)
    {
        this.playerViewY += 180.0F;
    }

    this.viewerPosX = livingPlayerIn.lastTickPosX + (livingPlayerIn.posX - livingPlayerIn.lastTickPosX) * (double)partialTicks;
    this.viewerPosY = livingPlayerIn.lastTickPosY + (livingPlayerIn.posY - livingPlayerIn.lastTickPosY) * (double)partialTicks;
    this.viewerPosZ = livingPlayerIn.lastTickPosZ + (livingPlayerIn.posZ - livingPlayerIn.lastTickPosZ) * (double)partialTicks;
}
 
Example 12
Project: BaseClient   File: EntityAIOcelotSit.java   View Source Code Vote up 5 votes
/**
 * Return true to set given position as destination
 */
protected boolean shouldMoveTo(World worldIn, BlockPos pos)
{
    if (!worldIn.isAirBlock(pos.up()))
    {
        return false;
    }
    else
    {
        IBlockState iblockstate = worldIn.getBlockState(pos);
        Block block = iblockstate.getBlock();

        if (block == Blocks.chest)
        {
            TileEntity tileentity = worldIn.getTileEntity(pos);

            if (tileentity instanceof TileEntityChest && ((TileEntityChest)tileentity).numPlayersUsing < 1)
            {
                return true;
            }
        }
        else
        {
            if (block == Blocks.lit_furnace)
            {
                return true;
            }

            if (block == Blocks.bed && iblockstate.getValue(BlockBed.PART) != BlockBed.EnumPartType.HEAD)
            {
                return true;
            }
        }

        return false;
    }
}
 
Example 13
Project: BaseClient   File: EntityPlayer.java   View Source Code Vote up 5 votes
/**
 * Wake up the player if they're sleeping.
 */
public void wakeUpPlayer(boolean p_70999_1_, boolean updateWorldFlag, boolean setSpawn)
{
    this.setSize(0.6F, 1.8F);
    IBlockState iblockstate = this.worldObj.getBlockState(this.playerLocation);

    if (this.playerLocation != null && iblockstate.getBlock() == Blocks.bed)
    {
        this.worldObj.setBlockState(this.playerLocation, iblockstate.withProperty(BlockBed.OCCUPIED, Boolean.valueOf(false)), 4);
        BlockPos blockpos = BlockBed.getSafeExitLocation(this.worldObj, this.playerLocation, 0);

        if (blockpos == null)
        {
            blockpos = this.playerLocation.up();
        }

        this.setPosition((double)((float)blockpos.getX() + 0.5F), (double)((float)blockpos.getY() + 0.1F), (double)((float)blockpos.getZ() + 0.5F));
    }

    this.sleeping = false;

    if (!this.worldObj.isRemote && updateWorldFlag)
    {
        this.worldObj.updateAllPlayersSleepingFlag();
    }

    this.sleepTimer = p_70999_1_ ? 0 : 100;

    if (setSpawn)
    {
        this.setSpawnPoint(this.playerLocation, false);
    }
}
 
Example 14
Project: BaseClient   File: EntityZombie.java   View Source Code Vote up 5 votes
/**
 * Return the amount of time decremented from conversionTime every tick.
 */
protected int getConversionTimeBoost()
{
    int i = 1;

    if (this.rand.nextFloat() < 0.01F)
    {
        int j = 0;
        BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();

        for (int k = (int)this.posX - 4; k < (int)this.posX + 4 && j < 14; ++k)
        {
            for (int l = (int)this.posY - 4; l < (int)this.posY + 4 && j < 14; ++l)
            {
                for (int i1 = (int)this.posZ - 4; i1 < (int)this.posZ + 4 && j < 14; ++i1)
                {
                    Block block = this.worldObj.getBlockState(blockpos$mutableblockpos.func_181079_c(k, l, i1)).getBlock();

                    if (block == Blocks.iron_bars || block == Blocks.bed)
                    {
                        if (this.rand.nextFloat() < 0.3F)
                        {
                            ++i;
                        }

                        ++j;
                    }
                }
            }
        }
    }

    return i;
}
 
Example 15
Project: BaseClient   File: EntityZombie.java   View Source Code Vote up 5 votes
/**
 * Return the amount of time decremented from conversionTime every tick.
 */
protected int getConversionTimeBoost()
{
    int i = 1;

    if (this.rand.nextFloat() < 0.01F)
    {
        int j = 0;
        BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();

        for (int k = (int)this.posX - 4; k < (int)this.posX + 4 && j < 14; ++k)
        {
            for (int l = (int)this.posY - 4; l < (int)this.posY + 4 && j < 14; ++l)
            {
                for (int i1 = (int)this.posZ - 4; i1 < (int)this.posZ + 4 && j < 14; ++i1)
                {
                    Block block = this.worldObj.getBlockState(blockpos$mutableblockpos.func_181079_c(k, l, i1)).getBlock();

                    if (block == Blocks.iron_bars || block == Blocks.bed)
                    {
                        if (this.rand.nextFloat() < 0.3F)
                        {
                            ++i;
                        }

                        ++j;
                    }
                }
            }
        }
    }

    return i;
}
 
Example 16
Project: BaseClient   File: EntityAIOcelotSit.java   View Source Code Vote up 5 votes
/**
 * Return true to set given position as destination
 */
protected boolean shouldMoveTo(World worldIn, BlockPos pos)
{
    if (!worldIn.isAirBlock(pos.up()))
    {
        return false;
    }
    else
    {
        IBlockState iblockstate = worldIn.getBlockState(pos);
        Block block = iblockstate.getBlock();

        if (block == Blocks.chest)
        {
            TileEntity tileentity = worldIn.getTileEntity(pos);

            if (tileentity instanceof TileEntityChest && ((TileEntityChest)tileentity).numPlayersUsing < 1)
            {
                return true;
            }
        }
        else
        {
            if (block == Blocks.lit_furnace)
            {
                return true;
            }

            if (block == Blocks.bed && iblockstate.getValue(BlockBed.PART) != BlockBed.EnumPartType.HEAD)
            {
                return true;
            }
        }

        return false;
    }
}
 
Example 17
Project: BaseClient   File: EntityPlayer.java   View Source Code Vote up 5 votes
/**
 * Wake up the player if they're sleeping.
 */
public void wakeUpPlayer(boolean p_70999_1_, boolean updateWorldFlag, boolean setSpawn)
{
    this.setSize(0.6F, 1.8F);
    IBlockState iblockstate = this.worldObj.getBlockState(this.playerLocation);

    if (this.playerLocation != null && iblockstate.getBlock() == Blocks.bed)
    {
        this.worldObj.setBlockState(this.playerLocation, iblockstate.withProperty(BlockBed.OCCUPIED, Boolean.valueOf(false)), 4);
        BlockPos blockpos = BlockBed.getSafeExitLocation(this.worldObj, this.playerLocation, 0);

        if (blockpos == null)
        {
            blockpos = this.playerLocation.up();
        }

        this.setPosition((double)((float)blockpos.getX() + 0.5F), (double)((float)blockpos.getY() + 0.1F), (double)((float)blockpos.getZ() + 0.5F));
    }

    this.sleeping = false;

    if (!this.worldObj.isRemote && updateWorldFlag)
    {
        this.worldObj.updateAllPlayersSleepingFlag();
    }

    this.sleepTimer = p_70999_1_ ? 0 : 100;

    if (setSpawn)
    {
        this.setSpawnPoint(this.playerLocation, false);
    }
}
 
Example 18
Project: DecompiledMinecraft   File: EntityPlayer.java   View Source Code Vote up 4 votes
private boolean isInBed()
{
    return this.worldObj.getBlockState(this.playerLocation).getBlock() == Blocks.bed;
}
 
Example 19
Project: BaseClient   File: RenderManager.java   View Source Code Vote up 4 votes
public void cacheActiveRenderInfo(World worldIn, FontRenderer textRendererIn, Entity livingPlayerIn, Entity pointedEntityIn, GameSettings optionsIn, float partialTicks)
{
    this.worldObj = worldIn;
    this.options = optionsIn;
    this.livingPlayer = livingPlayerIn;
    this.pointedEntity = pointedEntityIn;
    this.textRenderer = textRendererIn;

    if (livingPlayerIn instanceof EntityLivingBase && ((EntityLivingBase)livingPlayerIn).isPlayerSleeping())
    {
        IBlockState iblockstate = worldIn.getBlockState(new BlockPos(livingPlayerIn));
        Block block = iblockstate.getBlock();

        if (Reflector.callBoolean(Reflector.ForgeBlock_isBed, new Object[] {worldIn, new BlockPos(livingPlayerIn), (EntityLivingBase)livingPlayerIn}))
        {
            EnumFacing enumfacing = (EnumFacing)Reflector.call(block, Reflector.ForgeBlock_getBedDirection, new Object[] {worldIn, new BlockPos(livingPlayerIn)});
            int i = enumfacing.getHorizontalIndex();
            this.playerViewY = (float)(i * 90 + 180);
            this.playerViewX = 0.0F;
        }
        else if (block == Blocks.bed)
        {
            int j = ((EnumFacing)iblockstate.getValue(BlockBed.FACING)).getHorizontalIndex();
            this.playerViewY = (float)(j * 90 + 180);
            this.playerViewX = 0.0F;
        }
    }
    else
    {
        this.playerViewY = livingPlayerIn.prevRotationYaw + (livingPlayerIn.rotationYaw - livingPlayerIn.prevRotationYaw) * partialTicks;
        this.playerViewX = livingPlayerIn.prevRotationPitch + (livingPlayerIn.rotationPitch - livingPlayerIn.prevRotationPitch) * partialTicks;
    }

    if (optionsIn.thirdPersonView == 2)
    {
        this.playerViewY += 180.0F;
    }

    this.viewerPosX = livingPlayerIn.lastTickPosX + (livingPlayerIn.posX - livingPlayerIn.lastTickPosX) * (double)partialTicks;
    this.viewerPosY = livingPlayerIn.lastTickPosY + (livingPlayerIn.posY - livingPlayerIn.lastTickPosY) * (double)partialTicks;
    this.viewerPosZ = livingPlayerIn.lastTickPosZ + (livingPlayerIn.posZ - livingPlayerIn.lastTickPosZ) * (double)partialTicks;
}
 
Example 20
Project: BaseClient   File: EntityPlayer.java   View Source Code Vote up 4 votes
private boolean isInBed()
{
    return this.worldObj.getBlockState(this.playerLocation).getBlock() == Blocks.bed;
}