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

The following are Jave code examples for showing how to use isSpectator() 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.
+ Save this method
Example 1
Project: DecompiledMinecraft   File: WorldServer.java   View Source Code 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: DecompiledMinecraft   File: WorldServer.java   View Source Code Vote up 6 votes
public boolean areAllPlayersAsleep()
{
    if (this.allPlayersSleeping && !this.isRemote)
    {
        for (EntityPlayer entityplayer : this.playerEntities)
        {
            if (entityplayer.isSpectator() || !entityplayer.isPlayerFullyAsleep())
            {
                return false;
            }
        }

        return true;
    }
    else
    {
        return false;
    }
}
 
Example 3
Project: DecompiledMinecraft   File: WorldServer.java   View Source Code Vote up 6 votes
public boolean areAllPlayersAsleep()
{
    if (this.allPlayersSleeping && !this.isRemote)
    {
        for (EntityPlayer entityplayer : this.playerEntities)
        {
            if (entityplayer.isSpectator() || !entityplayer.isPlayerFullyAsleep())
            {
                return false;
            }
        }

        return true;
    }
    else
    {
        return false;
    }
}
 
Example 4
Project: Backmemed   File: WorldServer.java   View Source Code Vote up 6 votes
/**
 * Checks if all players in this world are sleeping.
 */
public boolean areAllPlayersAsleep()
{
    if (this.allPlayersSleeping && !this.isRemote)
    {
        for (EntityPlayer entityplayer : this.playerEntities)
        {
            if (!entityplayer.isSpectator() && !entityplayer.isPlayerFullyAsleep())
            {
                return false;
            }
        }

        return true;
    }
    else
    {
        return false;
    }
}
 
Example 5
Project: CustomWorldGen   File: WorldServer.java   View Source Code Vote up 6 votes
/**
 * Checks if all players in this world are sleeping.
 */
public boolean areAllPlayersAsleep()
{
    if (this.allPlayersSleeping && !this.isRemote)
    {
        for (EntityPlayer entityplayer : this.playerEntities)
        {
            if (!entityplayer.isSpectator() && !entityplayer.isPlayerFullyAsleep())
            {
                return false;
            }
        }

        return true;
    }
    else
    {
        return false;
    }
}
 
Example 6
Project: BaseClient   File: WorldServer.java   View Source Code Vote up 6 votes
public boolean areAllPlayersAsleep()
{
    if (this.allPlayersSleeping && !this.isRemote)
    {
        for (EntityPlayer entityplayer : this.playerEntities)
        {
            if (entityplayer.isSpectator() || !entityplayer.isPlayerFullyAsleep())
            {
                return false;
            }
        }

        return true;
    }
    else
    {
        return false;
    }
}
 
Example 7
Project: BaseClient   File: WorldServer.java   View Source Code Vote up 6 votes
public boolean areAllPlayersAsleep()
{
    if (this.allPlayersSleeping && !this.isRemote)
    {
        for (EntityPlayer entityplayer : this.playerEntities)
        {
            if (entityplayer.isSpectator() || !entityplayer.isPlayerFullyAsleep())
            {
                return false;
            }
        }

        return true;
    }
    else
    {
        return false;
    }
}
 
Example 8
Project: BaseClient   File: TileEntityChest.java   View Source Code Vote up 5 votes
public void closeInventory(EntityPlayer player)
{
    if (!player.isSpectator() && this.getBlockType() instanceof BlockChest)
    {
        --this.numPlayersUsing;
        this.worldObj.addBlockEvent(this.pos, this.getBlockType(), 1, this.numPlayersUsing);
        this.worldObj.notifyNeighborsOfStateChange(this.pos, this.getBlockType());
        this.worldObj.notifyNeighborsOfStateChange(this.pos.down(), this.getBlockType());
    }
}
 
Example 9
Project: CustomWorldGen   File: Entity.java   View Source Code Vote up 5 votes
/**
 * Only used by renderer in EntityLivingBase subclasses.
 * Determines if an entity is visible or not to a specfic player, if the entity is normally invisible.
 * For EntityLivingBase subclasses, returning false when invisible will render the entity semitransparent.
 */
@SideOnly(Side.CLIENT)
public boolean isInvisibleToPlayer(EntityPlayer player)
{
    if (player.isSpectator())
    {
        return false;
    }
    else
    {
        Team team = this.getTeam();
        return team != null && player != null && player.getTeam() == team && team.getSeeFriendlyInvisiblesEnabled() ? false : this.isInvisible();
    }
}
 
Example 10
Project: DecompiledMinecraft   File: TileEntityChest.java   View Source Code Vote up 5 votes
public void openInventory(EntityPlayer player)
{
    if (!player.isSpectator())
    {
        if (this.numPlayersUsing < 0)
        {
            this.numPlayersUsing = 0;
        }

        ++this.numPlayersUsing;
        this.worldObj.addBlockEvent(this.pos, this.getBlockType(), 1, this.numPlayersUsing);
        this.worldObj.notifyNeighborsOfStateChange(this.pos, this.getBlockType());
        this.worldObj.notifyNeighborsOfStateChange(this.pos.down(), this.getBlockType());
    }
}
 
Example 11
Project: Backmemed   File: TileEntityShulkerBox.java   View Source Code Vote up 5 votes
public void closeInventory(EntityPlayer player)
{
    if (!player.isSpectator())
    {
        --this.field_190598_h;
        this.world.addBlockEvent(this.pos, this.getBlockType(), 1, this.field_190598_h);

        if (this.field_190598_h <= 0)
        {
            this.world.playSound((EntityPlayer)null, this.pos, SoundEvents.field_191261_fA, SoundCategory.BLOCKS, 0.5F, this.world.rand.nextFloat() * 0.1F + 0.9F);
        }
    }
}
 
Example 12
Project: DecompiledMinecraft   File: TileEntityChest.java   View Source Code Vote up 5 votes
public void openInventory(EntityPlayer player)
{
    if (!player.isSpectator())
    {
        if (this.numPlayersUsing < 0)
        {
            this.numPlayersUsing = 0;
        }

        ++this.numPlayersUsing;
        this.worldObj.addBlockEvent(this.pos, this.getBlockType(), 1, this.numPlayersUsing);
        this.worldObj.notifyNeighborsOfStateChange(this.pos, this.getBlockType());
        this.worldObj.notifyNeighborsOfStateChange(this.pos.down(), this.getBlockType());
    }
}
 
Example 13
Project: BaseClient   File: TileEntityChest.java   View Source Code Vote up 5 votes
public void openInventory(EntityPlayer player)
{
    if (!player.isSpectator())
    {
        if (this.numPlayersUsing < 0)
        {
            this.numPlayersUsing = 0;
        }

        ++this.numPlayersUsing;
        this.worldObj.addBlockEvent(this.pos, this.getBlockType(), 1, this.numPlayersUsing);
        this.worldObj.notifyNeighborsOfStateChange(this.pos, this.getBlockType());
        this.worldObj.notifyNeighborsOfStateChange(this.pos.down(), this.getBlockType());
    }
}
 
Example 14
Project: Bewitchment   File: ContainerApiary.java   View Source Code Vote up 4 votes
@Override
public boolean canInteractWith(EntityPlayer playerIn) {
	return !playerIn.isSpectator();
}
 
Example 15
Project: DecompiledMinecraft   File: VillageSiege.java   View Source Code Vote up 4 votes
private boolean func_75529_b()
{
    List<EntityPlayer> list = this.worldObj.playerEntities;
    Iterator iterator = list.iterator();

    while (true)
    {
        if (!iterator.hasNext())
        {
            return false;
        }

        EntityPlayer entityplayer = (EntityPlayer)iterator.next();

        if (!entityplayer.isSpectator())
        {
            this.theVillage = this.worldObj.getVillageCollection().getNearestVillage(new BlockPos(entityplayer), 1);

            if (this.theVillage != null && this.theVillage.getNumVillageDoors() >= 10 && this.theVillage.getTicksSinceLastDoorAdding() >= 20 && this.theVillage.getNumVillagers() >= 20)
            {
                BlockPos blockpos = this.theVillage.getCenter();
                float f = (float)this.theVillage.getVillageRadius();
                boolean flag = false;

                for (int i = 0; i < 10; ++i)
                {
                    float f1 = this.worldObj.rand.nextFloat() * (float)Math.PI * 2.0F;
                    this.field_75532_g = blockpos.getX() + (int)((double)(MathHelper.cos(f1) * f) * 0.9D);
                    this.field_75538_h = blockpos.getY();
                    this.field_75539_i = blockpos.getZ() + (int)((double)(MathHelper.sin(f1) * f) * 0.9D);
                    flag = false;

                    for (Village village : this.worldObj.getVillageCollection().getVillageList())
                    {
                        if (village != this.theVillage && village.func_179866_a(new BlockPos(this.field_75532_g, this.field_75538_h, this.field_75539_i)))
                        {
                            flag = true;
                            break;
                        }
                    }

                    if (!flag)
                    {
                        break;
                    }
                }

                if (flag)
                {
                    return false;
                }

                Vec3 vec3 = this.func_179867_a(new BlockPos(this.field_75532_g, this.field_75538_h, this.field_75539_i));

                if (vec3 != null)
                {
                    break;
                }
            }
        }
    }

    this.field_75534_e = 0;
    this.field_75533_d = 20;
    return true;
}
 
Example 16
Project: Backmemed   File: BlockShulkerBox.java   View Source Code Vote up 4 votes
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing heldItem, float side, float hitX, float hitY)
{
    if (worldIn.isRemote)
    {
        return true;
    }
    else if (playerIn.isSpectator())
    {
        return true;
    }
    else
    {
        TileEntity tileentity = worldIn.getTileEntity(pos);

        if (tileentity instanceof TileEntityShulkerBox)
        {
            EnumFacing enumfacing = (EnumFacing)state.getValue(field_190957_a);
            boolean flag;

            if (((TileEntityShulkerBox)tileentity).func_190591_p() == TileEntityShulkerBox.AnimationStatus.CLOSED)
            {
                AxisAlignedBB axisalignedbb = FULL_BLOCK_AABB.addCoord((double)(0.5F * (float)enumfacing.getFrontOffsetX()), (double)(0.5F * (float)enumfacing.getFrontOffsetY()), (double)(0.5F * (float)enumfacing.getFrontOffsetZ())).func_191195_a((double)enumfacing.getFrontOffsetX(), (double)enumfacing.getFrontOffsetY(), (double)enumfacing.getFrontOffsetZ());
                flag = !worldIn.collidesWithAnyBlock(axisalignedbb.offset(pos.offset(enumfacing)));
            }
            else
            {
                flag = true;
            }

            if (flag)
            {
                playerIn.addStat(StatList.field_191272_ae);
                playerIn.displayGUIChest((IInventory)tileentity);
            }

            return true;
        }
        else
        {
            return false;
        }
    }
}
 
Example 17
Project: Backmemed   File: VillageSiege.java   View Source Code Vote up 4 votes
private boolean trySetupSiege()
{
    List<EntityPlayer> list = this.worldObj.playerEntities;
    Iterator iterator = list.iterator();

    while (true)
    {
        if (!iterator.hasNext())
        {
            return false;
        }

        EntityPlayer entityplayer = (EntityPlayer)iterator.next();

        if (!entityplayer.isSpectator())
        {
            this.theVillage = this.worldObj.getVillageCollection().getNearestVillage(new BlockPos(entityplayer), 1);

            if (this.theVillage != null && this.theVillage.getNumVillageDoors() >= 10 && this.theVillage.getTicksSinceLastDoorAdding() >= 20 && this.theVillage.getNumVillagers() >= 20)
            {
                BlockPos blockpos = this.theVillage.getCenter();
                float f = (float)this.theVillage.getVillageRadius();
                boolean flag = false;

                for (int i = 0; i < 10; ++i)
                {
                    float f1 = this.worldObj.rand.nextFloat() * ((float)Math.PI * 2F);
                    this.spawnX = blockpos.getX() + (int)((double)(MathHelper.cos(f1) * f) * 0.9D);
                    this.spawnY = blockpos.getY();
                    this.spawnZ = blockpos.getZ() + (int)((double)(MathHelper.sin(f1) * f) * 0.9D);
                    flag = false;

                    for (Village village : this.worldObj.getVillageCollection().getVillageList())
                    {
                        if (village != this.theVillage && village.isBlockPosWithinSqVillageRadius(new BlockPos(this.spawnX, this.spawnY, this.spawnZ)))
                        {
                            flag = true;
                            break;
                        }
                    }

                    if (!flag)
                    {
                        break;
                    }
                }

                if (flag)
                {
                    return false;
                }

                Vec3d vec3d = this.findRandomSpawnPos(new BlockPos(this.spawnX, this.spawnY, this.spawnZ));

                if (vec3d != null)
                {
                    break;
                }
            }
        }
    }

    this.nextSpawnTime = 0;
    this.siegeCount = 20;
    return true;
}
 
Example 18
Project: DecompiledMinecraft   File: VillageSiege.java   View Source Code Vote up 4 votes
private boolean func_75529_b()
{
    List<EntityPlayer> list = this.worldObj.playerEntities;
    Iterator iterator = list.iterator();

    while (true)
    {
        if (!iterator.hasNext())
        {
            return false;
        }

        EntityPlayer entityplayer = (EntityPlayer)iterator.next();

        if (!entityplayer.isSpectator())
        {
            this.theVillage = this.worldObj.getVillageCollection().getNearestVillage(new BlockPos(entityplayer), 1);

            if (this.theVillage != null && this.theVillage.getNumVillageDoors() >= 10 && this.theVillage.getTicksSinceLastDoorAdding() >= 20 && this.theVillage.getNumVillagers() >= 20)
            {
                BlockPos blockpos = this.theVillage.getCenter();
                float f = (float)this.theVillage.getVillageRadius();
                boolean flag = false;

                for (int i = 0; i < 10; ++i)
                {
                    float f1 = this.worldObj.rand.nextFloat() * (float)Math.PI * 2.0F;
                    this.field_75532_g = blockpos.getX() + (int)((double)(MathHelper.cos(f1) * f) * 0.9D);
                    this.field_75538_h = blockpos.getY();
                    this.field_75539_i = blockpos.getZ() + (int)((double)(MathHelper.sin(f1) * f) * 0.9D);
                    flag = false;

                    for (Village village : this.worldObj.getVillageCollection().getVillageList())
                    {
                        if (village != this.theVillage && village.func_179866_a(new BlockPos(this.field_75532_g, this.field_75538_h, this.field_75539_i)))
                        {
                            flag = true;
                            break;
                        }
                    }

                    if (!flag)
                    {
                        break;
                    }
                }

                if (flag)
                {
                    return false;
                }

                Vec3 vec3 = this.func_179867_a(new BlockPos(this.field_75532_g, this.field_75538_h, this.field_75539_i));

                if (vec3 != null)
                {
                    break;
                }
            }
        }
    }

    this.field_75534_e = 0;
    this.field_75533_d = 20;
    return true;
}
 
Example 19
Project: CustomWorldGen   File: VillageSiege.java   View Source Code Vote up 4 votes
private boolean trySetupSiege()
{
    List<EntityPlayer> list = this.worldObj.playerEntities;
    Iterator iterator = list.iterator();

    while (true)
    {
        if (!iterator.hasNext())
        {
            return false;
        }

        EntityPlayer entityplayer = (EntityPlayer)iterator.next();

        if (!entityplayer.isSpectator())
        {
            this.theVillage = this.worldObj.getVillageCollection().getNearestVillage(new BlockPos(entityplayer), 1);

            if (this.theVillage != null && this.theVillage.getNumVillageDoors() >= 10 && this.theVillage.getTicksSinceLastDoorAdding() >= 20 && this.theVillage.getNumVillagers() >= 20)
            {
                BlockPos blockpos = this.theVillage.getCenter();
                float f = (float)this.theVillage.getVillageRadius();
                boolean flag = false;

                for (int i = 0; i < 10; ++i)
                {
                    float f1 = this.worldObj.rand.nextFloat() * ((float)Math.PI * 2F);
                    this.spawnX = blockpos.getX() + (int)((double)(MathHelper.cos(f1) * f) * 0.9D);
                    this.spawnY = blockpos.getY();
                    this.spawnZ = blockpos.getZ() + (int)((double)(MathHelper.sin(f1) * f) * 0.9D);
                    flag = false;

                    for (Village village : this.worldObj.getVillageCollection().getVillageList())
                    {
                        if (village != this.theVillage && village.isBlockPosWithinSqVillageRadius(new BlockPos(this.spawnX, this.spawnY, this.spawnZ)))
                        {
                            flag = true;
                            break;
                        }
                    }

                    if (!flag)
                    {
                        break;
                    }
                }

                if (flag)
                {
                    return false;
                }

                Vec3d vec3d = this.findRandomSpawnPos(new BlockPos(this.spawnX, this.spawnY, this.spawnZ));

                if (vec3d != null)
                {
                    break;
                }
            }
        }
    }

    this.nextSpawnTime = 0;
    this.siegeCount = 20;
    return true;
}
 
Example 20
Project: BaseClient   File: Entity.java   View Source Code Vote up 2 votes
/**
 * Only used by renderer in EntityLivingBase subclasses.
 * Determines if an entity is visible or not to a specfic player, if the entity is normally invisible.
 * For EntityLivingBase subclasses, returning false when invisible will render the entity semitransparent.
 */
public boolean isInvisibleToPlayer(EntityPlayer player)
{
    return player.isSpectator() ? false : this.isInvisible();
}