当前位置: 首页>>代码示例>>Java>>正文


Java EntityPlayerMP.isPlayerSleeping方法代码示例

本文整理汇总了Java中net.minecraft.entity.player.EntityPlayerMP.isPlayerSleeping方法的典型用法代码示例。如果您正苦于以下问题:Java EntityPlayerMP.isPlayerSleeping方法的具体用法?Java EntityPlayerMP.isPlayerSleeping怎么用?Java EntityPlayerMP.isPlayerSleeping使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraft.entity.player.EntityPlayerMP的用法示例。


在下文中一共展示了EntityPlayerMP.isPlayerSleeping方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onImpact

import net.minecraft.entity.player.EntityPlayerMP; //导入方法依赖的package包/类
/**
 * Called when this EntityThrowable hits a block or entity.
 */
protected void onImpact(MovingObjectPosition p_70184_1_)
{
    EntityLivingBase entitylivingbase = this.getThrower();

    if (p_70184_1_.entityHit != null)
    {
        if (p_70184_1_.entityHit == this.field_181555_c)
        {
            return;
        }

        p_70184_1_.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, entitylivingbase), 0.0F);
    }

    for (int i = 0; i < 32; ++i)
    {
        this.worldObj.spawnParticle(EnumParticleTypes.PORTAL, this.posX, this.posY + this.rand.nextDouble() * 2.0D, this.posZ, this.rand.nextGaussian(), 0.0D, this.rand.nextGaussian(), new int[0]);
    }

    if (!this.worldObj.isRemote)
    {
        if (entitylivingbase instanceof EntityPlayerMP)
        {
            EntityPlayerMP entityplayermp = (EntityPlayerMP)entitylivingbase;

            if (entityplayermp.playerNetServerHandler.getNetworkManager().isChannelOpen() && entityplayermp.worldObj == this.worldObj && !entityplayermp.isPlayerSleeping())
            {
                if (this.rand.nextFloat() < 0.05F && this.worldObj.getGameRules().getBoolean("doMobSpawning"))
                {
                    EntityEndermite entityendermite = new EntityEndermite(this.worldObj);
                    entityendermite.setSpawnedByPlayer(true);
                    entityendermite.setLocationAndAngles(entitylivingbase.posX, entitylivingbase.posY, entitylivingbase.posZ, entitylivingbase.rotationYaw, entitylivingbase.rotationPitch);
                    this.worldObj.spawnEntityInWorld(entityendermite);
                }

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

                entitylivingbase.setPositionAndUpdate(this.posX, this.posY, this.posZ);
                entitylivingbase.fallDistance = 0.0F;
                entitylivingbase.attackEntityFrom(DamageSource.fall, 5.0F);
            }
        }
        else if (entitylivingbase != null)
        {
            entitylivingbase.setPositionAndUpdate(this.posX, this.posY, this.posZ);
            entitylivingbase.fallDistance = 0.0F;
        }

        this.setDead();
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:58,代码来源:EntityEnderPearl.java

示例2: onImpact

import net.minecraft.entity.player.EntityPlayerMP; //导入方法依赖的package包/类
@Override
protected void onImpact(RayTraceResult result) {
	EntityLivingBase entitylivingbase = getThrower();

	if (result.entityHit != null) {
		if (result.entityHit == thrower) {
			return;
		}
		else {
			if (entitylivingbase != null && result.entityHit instanceof EntityCreature && !(result.entityHit instanceof EntityMob)) {
				EntityCreature passiveEntity = (EntityCreature) result.entityHit;
				passiveEntity.setPositionAndUpdate(entitylivingbase.posX, entitylivingbase.posY, entitylivingbase.posZ);
				passiveEntity.fallDistance = 0.0F;
				setDead();
				return;
			}
		}
	}

	if (result.typeOfHit == RayTraceResult.Type.BLOCK) {
		BlockPos blockpos = result.getBlockPos();
		TileEntity tileentity = EasyMappings.world(this).getTileEntity(blockpos);

		if (tileentity instanceof TileEntityEndGateway) {
			TileEntityEndGateway tileentityendgateway = (TileEntityEndGateway) tileentity;

			if (entitylivingbase != null) {
				tileentityendgateway.teleportEntity(entitylivingbase);
				setDead();
				return;
			}

			tileentityendgateway.teleportEntity(this);
			return;
		}
	}
	if (FMLCommonHandler.instance().getSide() == Side.CLIENT) {
		for (int i = 0; i < 32; ++i) {
			ParticleUtil.spawn(EnumParticles.LOVE, EasyMappings.world(this), posX, posY + rand.nextDouble() * 2.0D, posZ, rand.nextGaussian(), 0.0D, rand.nextGaussian());
		}
	}

	if (!EasyMappings.world(this).isRemote) {
		if (entitylivingbase instanceof EntityPlayerMP) {
			EntityPlayerMP entityplayermp = (EntityPlayerMP) entitylivingbase;

			if (entityplayermp.connection.getNetworkManager().isChannelOpen() && EasyMappings.world(entityplayermp) == EasyMappings.world(this) && !entityplayermp.isPlayerSleeping()) {
				EnderTeleportEvent event = new EnderTeleportEvent(entityplayermp, posX, posY, posZ, 5.0F);
				if (!MinecraftForge.EVENT_BUS.post(event)) {

					if (entitylivingbase.isRiding()) {
						entitylivingbase.dismountRidingEntity();
					}

					entitylivingbase.setPositionAndUpdate(event.getTargetX(), event.getTargetY(), event.getTargetZ());
					entitylivingbase.fallDistance = 0.0F;
				}
			}
		}
		else if (entitylivingbase != null) {
			entitylivingbase.setPositionAndUpdate(posX, posY, posZ);
			entitylivingbase.fallDistance = 0.0F;
		}

		setDead();
	}
}
 
开发者ID:p455w0rd,项目名称:EndermanEvolution,代码行数:68,代码来源:EntityFrienderPearl.java

示例3: onImpact

import net.minecraft.entity.player.EntityPlayerMP; //导入方法依赖的package包/类
/**
 * Called when this EntityThrowable hits a block or entity.
 */
protected void onImpact(RayTraceResult result)
{
    EntityLivingBase entitylivingbase = this.getThrower();

    if (result.entityHit != null)
    {
        if (result.entityHit == this.thrower)
        {
            return;
        }

        result.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, entitylivingbase), 0.0F);
    }

    if (result.typeOfHit == RayTraceResult.Type.BLOCK)
    {
        BlockPos blockpos = result.getBlockPos();
        TileEntity tileentity = this.world.getTileEntity(blockpos);

        if (tileentity instanceof TileEntityEndGateway)
        {
            TileEntityEndGateway tileentityendgateway = (TileEntityEndGateway)tileentity;

            if (entitylivingbase != null)
            {
                tileentityendgateway.teleportEntity(entitylivingbase);
                this.setDead();
                return;
            }

            tileentityendgateway.teleportEntity(this);
            return;
        }
    }

    for (int i = 0; i < 32; ++i)
    {
        this.world.spawnParticle(EnumParticleTypes.PORTAL, this.posX, this.posY + this.rand.nextDouble() * 2.0D, this.posZ, this.rand.nextGaussian(), 0.0D, this.rand.nextGaussian(), new int[0]);
    }

    if (!this.world.isRemote)
    {
        if (entitylivingbase instanceof EntityPlayerMP)
        {
            EntityPlayerMP entityplayermp = (EntityPlayerMP)entitylivingbase;

            if (entityplayermp.connection.getNetworkManager().isChannelOpen() && entityplayermp.world == this.world && !entityplayermp.isPlayerSleeping())
            {
                if (this.rand.nextFloat() < 0.05F && this.world.getGameRules().getBoolean("doMobSpawning"))
                {
                    EntityEndermite entityendermite = new EntityEndermite(this.world);
                    entityendermite.setSpawnedByPlayer(true);
                    entityendermite.setLocationAndAngles(entitylivingbase.posX, entitylivingbase.posY, entitylivingbase.posZ, entitylivingbase.rotationYaw, entitylivingbase.rotationPitch);
                    this.world.spawnEntityInWorld(entityendermite);
                }

                if (entitylivingbase.isRiding())
                {
                    entitylivingbase.dismountRidingEntity();
                }

                entitylivingbase.setPositionAndUpdate(this.posX, this.posY, this.posZ);
                entitylivingbase.fallDistance = 0.0F;
                entitylivingbase.attackEntityFrom(DamageSource.fall, 5.0F);
            }
        }
        else if (entitylivingbase != null)
        {
            entitylivingbase.setPositionAndUpdate(this.posX, this.posY, this.posZ);
            entitylivingbase.fallDistance = 0.0F;
        }

        this.setDead();
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:79,代码来源:EntityEnderPearl.java


注:本文中的net.minecraft.entity.player.EntityPlayerMP.isPlayerSleeping方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。