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


Java EntityLivingBase.dismountRidingEntity方法代码示例

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


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

示例1: onItemUseFinish

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
/**
 * Called when the player finishes using this Item (E.g. finishes eating.). Not called when the player stops using
 * the Item before the action is complete.
 */
public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityLivingBase entityLiving)
{
    ItemStack itemstack = super.onItemUseFinish(stack, worldIn, entityLiving);

    if (!worldIn.isRemote)
    {
        double d0 = entityLiving.posX;
        double d1 = entityLiving.posY;
        double d2 = entityLiving.posZ;

        for (int i = 0; i < 16; ++i)
        {
            double d3 = entityLiving.posX + (entityLiving.getRNG().nextDouble() - 0.5D) * 16.0D;
            double d4 = MathHelper.clamp(entityLiving.posY + (double)(entityLiving.getRNG().nextInt(16) - 8), 0.0D, (double)(worldIn.getActualHeight() - 1));
            double d5 = entityLiving.posZ + (entityLiving.getRNG().nextDouble() - 0.5D) * 16.0D;

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

            if (entityLiving.attemptTeleport(d3, d4, d5))
            {
                worldIn.playSound((EntityPlayer)null, d0, d1, d2, SoundEvents.ITEM_CHORUS_FRUIT_TELEPORT, SoundCategory.PLAYERS, 1.0F, 1.0F);
                entityLiving.playSound(SoundEvents.ITEM_CHORUS_FRUIT_TELEPORT, 1.0F, 1.0F);
                break;
            }
        }

        if (entityLiving instanceof EntityPlayer)
        {
            ((EntityPlayer)entityLiving).getCooldownTracker().setCooldown(this, 20);
        }
    }

    return itemstack;
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:42,代码来源:ItemChorusFruit.java

示例2: onItemUseFinish

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
/**
 * Called when the player finishes using this Item (E.g. finishes eating.). Not called when the player stops using
 * the Item before the action is complete.
 */
@Nullable
public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityLivingBase entityLiving)
{
    ItemStack itemstack = super.onItemUseFinish(stack, worldIn, entityLiving);

    if (!worldIn.isRemote)
    {
        double d0 = entityLiving.posX;
        double d1 = entityLiving.posY;
        double d2 = entityLiving.posZ;

        for (int i = 0; i < 16; ++i)
        {
            double d3 = entityLiving.posX + (entityLiving.getRNG().nextDouble() - 0.5D) * 16.0D;
            double d4 = MathHelper.clamp_double(entityLiving.posY + (double)(entityLiving.getRNG().nextInt(16) - 8), 0.0D, (double)(worldIn.getActualHeight() - 1));
            double d5 = entityLiving.posZ + (entityLiving.getRNG().nextDouble() - 0.5D) * 16.0D;

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

            if (entityLiving.attemptTeleport(d3, d4, d5))
            {
                worldIn.playSound((EntityPlayer)null, d0, d1, d2, SoundEvents.ITEM_CHORUS_FRUIT_TELEPORT, SoundCategory.PLAYERS, 1.0F, 1.0F);
                entityLiving.playSound(SoundEvents.ITEM_CHORUS_FRUIT_TELEPORT, 1.0F, 1.0F);
                break;
            }
        }

        if (entityLiving instanceof EntityPlayer)
        {
            ((EntityPlayer)entityLiving).getCooldownTracker().setCooldown(this, 20);
        }
    }

    return itemstack;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:43,代码来源:ItemChorusFruit.java

示例3: onImpact

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的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

示例4: onImpact

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的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.EntityLivingBase.dismountRidingEntity方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。