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.
Example 1
Project: Backmemed   File: WorldServer.java   Source Code and License 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 2
Project: CustomWorldGen   File: WorldServer.java   Source Code and License 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 3
Project: BaseClient   File: WorldServer.java   Source Code and License 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: BaseClient   File: WorldServer.java   Source Code and License 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 5
Project: BaseClient   File: TileEntityChest.java   Source Code and License 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 6
Project: CustomWorldGen   File: Entity.java   Source Code and License 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 7
Project: Backmemed   File: TileEntityShulkerBox.java   Source Code and License 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 8
Project: BaseClient   File: TileEntityChest.java   Source Code and License 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 9
Project: Bewitchment   File: ContainerApiary.java   Source Code and License Vote up 4 votes
@Override
public boolean canInteractWith(EntityPlayer playerIn) {
	return !playerIn.isSpectator();
}
 
Example 10
Project: Backmemed   File: BlockShulkerBox.java   Source Code and License 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 11
Project: Backmemed   File: VillageSiege.java   Source Code and License 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 12
Project: CustomWorldGen   File: VillageSiege.java   Source Code and License 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 13
Project: BaseClient   File: Entity.java   Source Code and License 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();
}