Java Code Examples for net.minecraft.entity.player.EntityPlayer.isPlayerSleeping()

The following are Jave code examples for showing how to use isPlayerSleeping() of the net.minecraft.entity.player.EntityPlayer class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: BaseClient   File: WorldServer.java   Source Code and License Vote up 6 votes
/**
 * Updates the flag that indicates whether or not all players in the world are sleeping.
 */
public void updateAllPlayersSleepingFlag()
{
    this.allPlayersSleeping = false;

    if (!this.playerEntities.isEmpty())
    {
        int i = 0;
        int j = 0;

        for (EntityPlayer entityplayer : this.playerEntities)
        {
            if (entityplayer.isSpectator())
            {
                ++i;
            }
            else if (entityplayer.isPlayerSleeping())
            {
                ++j;
            }
        }

        this.allPlayersSleeping = j > 0 && j >= this.playerEntities.size() - i;
    }
}
 
Example 2
Project: CustomWorldGen   File: WorldServer.java   Source Code and License Vote up 6 votes
/**
 * Updates the flag that indicates whether or not all players in the world are sleeping.
 */
public void updateAllPlayersSleepingFlag()
{
    this.allPlayersSleeping = false;

    if (!this.playerEntities.isEmpty())
    {
        int i = 0;
        int j = 0;

        for (EntityPlayer entityplayer : this.playerEntities)
        {
            if (entityplayer.isSpectator())
            {
                ++i;
            }
            else if (entityplayer.isPlayerSleeping())
            {
                ++j;
            }
        }

        this.allPlayersSleeping = j > 0 && j >= this.playerEntities.size() - i;
    }
}
 
Example 3
Project: Backmemed   File: WorldServer.java   Source Code and License Vote up 6 votes
/**
 * Updates the flag that indicates whether or not all players in the world are sleeping.
 */
public void updateAllPlayersSleepingFlag()
{
    this.allPlayersSleeping = false;

    if (!this.playerEntities.isEmpty())
    {
        int i = 0;
        int j = 0;

        for (EntityPlayer entityplayer : this.playerEntities)
        {
            if (entityplayer.isSpectator())
            {
                ++i;
            }
            else if (entityplayer.isPlayerSleeping())
            {
                ++j;
            }
        }

        this.allPlayersSleeping = j > 0 && j >= this.playerEntities.size() - i;
    }
}
 
Example 4
Project: Backmemed   File: WorldServer.java   Source Code and License Vote up 6 votes
protected void wakeAllPlayers()
{
    this.allPlayersSleeping = false;

    for (EntityPlayer entityplayer : this.playerEntities)
    {
        if (entityplayer.isPlayerSleeping())
        {
            entityplayer.wakeUpPlayer(false, false, true);
        }
    }

    if (this.getGameRules().getBoolean("doWeatherCycle"))
    {
        this.resetRainAndThunder();
    }
}
 
Example 5
Project: CustomWorldGen   File: WorldServer.java   Source Code and License Vote up 5 votes
protected void wakeAllPlayers()
{
    this.allPlayersSleeping = false;

    for (EntityPlayer entityplayer : this.playerEntities)
    {
        if (entityplayer.isPlayerSleeping())
        {
            entityplayer.wakeUpPlayer(false, false, true);
        }
    }

    this.resetRainAndThunder();
}
 
Example 6
Project: CustomWorldGen   File: BlockBed.java   Source Code and License Vote up 5 votes
@Nullable
private EntityPlayer getPlayerInBed(World worldIn, BlockPos pos)
{
    for (EntityPlayer entityplayer : worldIn.playerEntities)
    {
        if (entityplayer.isPlayerSleeping() && entityplayer.bedLocation.equals(pos))
        {
            return entityplayer;
        }
    }

    return null;
}
 
Example 7
Project: BaseClient   File: WorldServer.java   Source Code and License Vote up 5 votes
protected void wakeAllPlayers()
{
    this.allPlayersSleeping = false;

    for (EntityPlayer entityplayer : this.playerEntities)
    {
        if (entityplayer.isPlayerSleeping())
        {
            entityplayer.wakeUpPlayer(false, false, true);
        }
    }

    this.resetRainAndThunder();
}
 
Example 8
Project: BaseClient   File: BlockBed.java   Source Code and License Vote up 5 votes
private EntityPlayer getPlayerInBed(World worldIn, BlockPos pos)
{
    for (EntityPlayer entityplayer : worldIn.playerEntities)
    {
        if (entityplayer.isPlayerSleeping() && entityplayer.playerLocation.equals(pos))
        {
            return entityplayer;
        }
    }

    return null;
}
 
Example 9
Project: BaseClient   File: WorldServer.java   Source Code and License Vote up 5 votes
protected void wakeAllPlayers()
{
    this.allPlayersSleeping = false;

    for (EntityPlayer entityplayer : this.playerEntities)
    {
        if (entityplayer.isPlayerSleeping())
        {
            entityplayer.wakeUpPlayer(false, false, true);
        }
    }

    this.resetRainAndThunder();
}
 
Example 10
Project: BaseClient   File: BlockBed.java   Source Code and License Vote up 5 votes
private EntityPlayer getPlayerInBed(World worldIn, BlockPos pos)
{
    for (EntityPlayer entityplayer : worldIn.playerEntities)
    {
        if (entityplayer.isPlayerSleeping() && entityplayer.playerLocation.equals(pos))
        {
            return entityplayer;
        }
    }

    return null;
}
 
Example 11
Project: Backmemed   File: BlockBed.java   Source Code and License Vote up 5 votes
@Nullable
private EntityPlayer getPlayerInBed(World worldIn, BlockPos pos)
{
    for (EntityPlayer entityplayer : worldIn.playerEntities)
    {
        if (entityplayer.isPlayerSleeping() && entityplayer.bedLocation.equals(pos))
        {
            return entityplayer;
        }
    }

    return null;
}
 
Example 12
Project: Wurst-MC-1.12   File: TracersMod.java   Source Code and License Vote up 4 votes
@Override
public void onRender(float partialTicks)
{
	// GL settings
	GL11.glEnable(GL11.GL_BLEND);
	GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
	GL11.glEnable(GL11.GL_LINE_SMOOTH);
	GL11.glLineWidth(2);
	GL11.glDisable(GL11.GL_TEXTURE_2D);
	GL11.glEnable(GL11.GL_CULL_FACE);
	GL11.glDisable(GL11.GL_DEPTH_TEST);
	
	GL11.glPushMatrix();
	GL11.glTranslated(-mc.getRenderManager().renderPosX,
		-mc.getRenderManager().renderPosY,
		-mc.getRenderManager().renderPosZ);
	
	// set start position
	Vec3d start = RotationUtils.getClientLookVec()
		.addVector(0, WMinecraft.getPlayer().getEyeHeight(), 0)
		.addVector(mc.getRenderManager().renderPosX,
			mc.getRenderManager().renderPosY,
			mc.getRenderManager().renderPosZ);
	
	GL11.glBegin(GL11.GL_LINES);
	for(EntityPlayer entity : WMinecraft.getWorld().playerEntities)
	{
		if(entity == WMinecraft.getPlayer()
			|| entity instanceof EntityFakePlayer)
			continue;
		
		// fake entities with crazy vertical position
		if(Math.abs(entity.posY - WMinecraft.getPlayer().posY) > 1e6)
			continue;
		
		if(!wurst.special.targetSpf.sleepingPlayers.isChecked()
			&& entity.isPlayerSleeping())
			continue;
		
		if(!wurst.special.targetSpf.invisiblePlayers.isChecked()
			&& entity.isInvisible())
			continue;
		
		// set end position
		Vec3d end = entity.boundingBox.getCenter()
			.subtract(new Vec3d(entity.posX, entity.posY, entity.posZ)
				.subtract(entity.prevPosX, entity.prevPosY, entity.prevPosZ)
				.scale(1 - partialTicks));
		
		// set color
		if(wurst.friends.contains(entity.getName()))
			GL11.glColor4f(0, 0, 1, 0.5F);
		else
		{
			float factor =
				WMinecraft.getPlayer().getDistanceToEntity(entity) / 40F;
			if(factor > 1)
				factor = 1;
			
			GL11.glColor4f(2 - factor * 2F, factor * 2F, 0, 0.5F);
		}
		
		// draw line
		GL11.glVertex3d(start.xCoord, start.yCoord, start.zCoord);
		GL11.glVertex3d(end.xCoord, end.yCoord, end.zCoord);
	}
	GL11.glEnd();
	
	GL11.glPopMatrix();
	
	// GL resets
	GL11.glEnable(GL11.GL_DEPTH_TEST);
	GL11.glEnable(GL11.GL_TEXTURE_2D);
	GL11.glDisable(GL11.GL_BLEND);
	GL11.glDisable(GL11.GL_LINE_SMOOTH);
}
 
Example 13
Project: Wurst-MC-1.12   File: PlayerEspMod.java   Source Code and License Vote up 4 votes
@Override
public void onRender(float partialTicks)
{
	// GL settings
	GL11.glEnable(GL11.GL_BLEND);
	GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
	GL11.glEnable(GL11.GL_LINE_SMOOTH);
	GL11.glLineWidth(2);
	GL11.glDisable(GL11.GL_TEXTURE_2D);
	GL11.glDisable(GL11.GL_DEPTH_TEST);
	
	GL11.glPushMatrix();
	GL11.glTranslated(-mc.getRenderManager().renderPosX,
		-mc.getRenderManager().renderPosY,
		-mc.getRenderManager().renderPosZ);
	
	// draw boxes
	for(EntityPlayer entity : WMinecraft.getWorld().playerEntities)
	{
		if(entity == WMinecraft.getPlayer()
			|| entity instanceof EntityFakePlayer)
			continue;
		
		if(!wurst.special.targetSpf.sleepingPlayers.isChecked()
			&& entity.isPlayerSleeping())
			continue;
		
		if(!wurst.special.targetSpf.invisiblePlayers.isChecked()
			&& entity.isInvisible())
			continue;
		
		// set color
		if(wurst.friends.contains(entity.getName()))
			GL11.glColor4f(0, 0, 1, 0.5F);
		else
		{
			float factor =
				WMinecraft.getPlayer().getDistanceToEntity(entity) / 20F;
			if(factor > 2)
				factor = 2;
			GL11.glColor4f(2 - factor, factor, 0, 0.5F);
		}
		
		// set position
		GL11.glPushMatrix();
		GL11.glTranslated(
			entity.prevPosX
				+ (entity.posX - entity.prevPosX) * partialTicks,
			entity.prevPosY
				+ (entity.posY - entity.prevPosY) * partialTicks,
			entity.prevPosZ
				+ (entity.posZ - entity.prevPosZ) * partialTicks);
		
		// draw box
		RenderUtils.drawOutlinedBox(PLAYER_BOX);
		
		GL11.glPopMatrix();
	}
	
	GL11.glPopMatrix();
	
	// GL resets
	GL11.glEnable(GL11.GL_DEPTH_TEST);
	GL11.glEnable(GL11.GL_TEXTURE_2D);
	GL11.glDisable(GL11.GL_BLEND);
	GL11.glDisable(GL11.GL_LINE_SMOOTH);
}
 
Example 14
Project: Zombe-Modpack   File: ZWrapper.java   Source Code and License Vote up 4 votes
public static boolean isSleeping(EntityPlayer ent) {
    return ent.isPlayerSleeping();
}
 
Example 15
Project: Zombe-Modpack   File: ZWrapper.java   Source Code and License Vote up 4 votes
@Deprecated
public static boolean getSleeping(EntityPlayer ent) {
    return ent.isPlayerSleeping();
}