Java 类net.minecraft.entity.player.EntityPlayer.EnumStatus 实例源码

项目:4Space-5    文件:TileEntityCryogenicChamber.java   
@Override
public boolean onActivated(EntityPlayer entityPlayer)
{
    if (this.worldObj.isRemote)
    {
        return false;
    }

    EnumStatus enumstatus = this.sleepInBedAt(entityPlayer, this.xCoord, this.yCoord, this.zCoord);

    switch (enumstatus)
    {
    case OK:
        ((EntityPlayerMP) entityPlayer).playerNetServerHandler.setPlayerLocation(entityPlayer.posX, entityPlayer.posY, entityPlayer.posZ, entityPlayer.rotationYaw, entityPlayer.rotationPitch);
        GalacticraftCore.packetPipeline.sendTo(new PacketSimpleMars(EnumSimplePacketMars.C_BEGIN_CRYOGENIC_SLEEP, new Object[] { this.xCoord, this.yCoord, this.zCoord }), (EntityPlayerMP) entityPlayer);
        return true;
    case NOT_POSSIBLE_NOW:
        entityPlayer.addChatMessage(new ChatComponentText(GCCoreUtil.translateWithFormat("gui.cryogenic.chat.cantUse", GCPlayerStats.get((EntityPlayerMP) entityPlayer).cryogenicChamberCooldown / 20)));
        return false;
    default:
        return false;
    }
}
项目:Morph    文件:EventHandler.java   
@SubscribeEvent
public void onPlayerSleep(PlayerSleepInBedEvent event)
{
    EntityPlayer player = (EntityPlayer)event.entityPlayer;
    EnumStatus stats = EnumStatus.OTHER_PROBLEM;
    if(Morph.config.getSessionInt("canSleepMorphed") == 0)
    {
        if(FMLCommonHandler.instance().getEffectiveSide().isServer() && Morph.proxy.tickHandlerServer.getPlayerMorphInfo(player) != null)
        {
            event.result = stats;
            player.addChatMessage(new ChatComponentTranslation("morph.denySleep"));
        }
        else if(FMLCommonHandler.instance().getEffectiveSide().isClient() && Morph.proxy.tickHandlerClient.playerMorphInfo.containsKey(player.getCommandSenderName()))
        {
            event.result = stats;
        }
    }
}
项目:4Space-5    文件:TileEntityCryogenicChamber.java   
public EnumStatus sleepInBedAt(EntityPlayer entityPlayer, int par1, int par2, int par3)
{
    if (!this.worldObj.isRemote)
    {
        if (entityPlayer.isPlayerSleeping() || !entityPlayer.isEntityAlive())
        {
            return EnumStatus.OTHER_PROBLEM;
        }

        if (this.worldObj.getBiomeGenForCoords(par1, par3) == BiomeGenBase.hell)
        {
            return EnumStatus.NOT_POSSIBLE_HERE;
        }

        if (GCPlayerStats.get((EntityPlayerMP) entityPlayer).cryogenicChamberCooldown > 0)
        {
            return EnumStatus.NOT_POSSIBLE_NOW;
        }
    }

    if (entityPlayer.isRiding())
    {
        entityPlayer.mountEntity((Entity) null);
    }

    entityPlayer.setPosition(this.xCoord + 0.5F, this.yCoord + 1.9F, this.zCoord + 0.5F);

    entityPlayer.sleeping = true;
    entityPlayer.sleepTimer = 0;
    entityPlayer.playerLocation = new ChunkCoordinates(this.xCoord, this.yCoord, this.zCoord);
    entityPlayer.motionX = entityPlayer.motionZ = entityPlayer.motionY = 0.0D;

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

    return EnumStatus.OK;
}
项目:4Space-5    文件:EventHandlerMars.java   
@SubscribeEvent
public void onPlayerWakeUp(EventWakePlayer event)
{
    ChunkCoordinates c = event.entityPlayer.playerLocation;
    Block blockID = event.entityPlayer.worldObj.getBlock(c.posX, c.posY, c.posZ);
    int metadata = event.entityPlayer.worldObj.getBlockMetadata(c.posX, c.posY, c.posZ);

    if (blockID == MarsBlocks.machine && metadata >= BlockMachineMars.CRYOGENIC_CHAMBER_METADATA)
    {
        if (!event.flag1 && event.flag2 && event.flag3)
        {
            event.result = EnumStatus.NOT_POSSIBLE_HERE;

            if (event.entityPlayer.worldObj.isRemote && event.bypassed && event.entityPlayer instanceof EntityClientPlayerMP)
            {
                GalacticraftCore.packetPipeline.sendToServer(new PacketSimpleMars(EnumSimplePacketMars.S_WAKE_PLAYER, new Object[] { }));
            }
        }
        else if (!event.flag1 && !event.flag2 && event.flag3)
        {
            if (!event.entityPlayer.worldObj.isRemote)
            {
                event.entityPlayer.heal(5.0F);
                GCPlayerStats.get((EntityPlayerMP) event.entityPlayer).cryogenicChamberCooldown = 6000;

                for (WorldServer worldServer : MinecraftServer.getServer().worldServers)
                {
                    worldServer.setWorldTime(0);
                }
            }
        }
    }
}
项目:AdvancedRocketry    文件:PlanetEventHandler.java   
@SubscribeEvent
public void sleepEvent(PlayerSleepInBedEvent event) {

    if(event.entity.worldObj.provider instanceof WorldProviderPlanet && 
            AtmosphereHandler.hasAtmosphereHandler(event.entity.worldObj.provider.dimensionId) && !AtmosphereHandler.getOxygenHandler(event.entity.worldObj.provider.dimensionId).getAtmosphereType(event.x, event.y, event.z).isBreathable()) {
        event.result = EnumStatus.OTHER_PROBLEM;
    }
}
项目:TRHS_Club_Mod_2016    文件:EnumHelper.java   
public static EnumStatus addStatus(String name)
{
    return addEnum(EnumStatus.class, name);
}
项目:CauldronGit    文件:EnumHelper.java   
public static EnumStatus addStatus(String name)
{
    return addEnum(EnumStatus.class, name);
}
项目:Cauldron    文件:EnumHelper.java   
public static EnumStatus addStatus(String name)
{
    return addEnum(EnumStatus.class, name);
}
项目:Cauldron    文件:EnumHelper.java   
public static EnumStatus addStatus(String name)
{
    return addEnum(EnumStatus.class, name);
}
项目:Cauldron    文件:EnumHelper.java   
public static EnumStatus addStatus(String name)
{
    return addEnum(EnumStatus.class, name);
}
项目:carpentersblocks    文件:BlockCarpentersBed.java   
@Override
/**
 * Called upon block activation (right click on the block.)
 */
protected void postOnBlockActivated(TEBase TE, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ, ActionResult actionResult)
{
    actionResult.setAltered();
    World world = TE.getWorldObj();

    int x = TE.xCoord;
    int y = TE.yCoord;
    int z = TE.zCoord;

    if (!Bed.isHeadOfBed(TE)) {

        TEBase TE_opp = Bed.getOppositeTE(TE);

        if (TE_opp != null) {
            x = TE_opp.xCoord;
            z = TE_opp.zCoord;
        } else {
            return;
        }

    }

    if (world.provider.canRespawnHere() && world.getBiomeGenForCoords(x, z) != BiomeGenBase.hell) {

        if (Bed.isOccupied(TE)) {

            EntityPlayer entityPlayer1 = null;
            Iterator iterator = world.playerEntities.iterator();

            while (iterator.hasNext()) {

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

                if (entityPlayer2.isPlayerSleeping()) {

                    ChunkCoordinates chunkCoordinates = entityPlayer2.playerLocation;

                    if (chunkCoordinates.posX == x && chunkCoordinates.posY == y && chunkCoordinates.posZ == z) {
                        entityPlayer1 = entityPlayer2;
                    }

                }

            }

            if (entityPlayer1 != null) {
                ChatHandler.sendMessageToPlayer("tile.bed.occupied", entityPlayer, false);
                return;
            }

            setBedOccupied(world, x, y, z, entityPlayer, false);

        }

        EnumStatus enumstatus = entityPlayer.sleepInBedAt(x, y, z);

        if (enumstatus == EnumStatus.OK) {

            setBedOccupied(world, x, y, z, entityPlayer, true);

        } else {

            if (enumstatus == EnumStatus.NOT_POSSIBLE_NOW) {
                ChatHandler.sendMessageToPlayer("tile.bed.noSleep", entityPlayer, false);
            } else if (enumstatus == EnumStatus.NOT_SAFE) {
                ChatHandler.sendMessageToPlayer("tile.bed.notSafe", entityPlayer, false);
            }

        }

    } else {

        destroyBlock(world, x, y, z, false);
        world.newExplosion((Entity)null, x + 0.5F, y + 0.5F, z + 0.5F, 5.0F, true, true);

    }
}