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


Java EntityLivingBase.setPositionAndUpdate方法代码示例

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


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

示例1: onItemRightClick

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand) {
	
	List<EntityLivingBase> elb = acquireAllLookTargets(player, 32, 3);
	for (EntityLivingBase target : elb) {
		if (target.canEntityBeSeen(player) && !(target instanceof EntityPlayer)) {
			BlockPos targetpos = target.getPosition();
			BlockPos playerpos = player.getPosition();
			if (!world.isRemote) {
				target.setPositionAndUpdate(playerpos.getX(), playerpos.getY(), playerpos.getZ());
				player.setPositionAndUpdate(targetpos.getX(), targetpos.getY(), targetpos.getZ());
				if (target instanceof EntityWolf && world.rand.nextInt(100) == 0)
					target.entityDropItem(UCItems.generic.createStack(EnumItems.DOGRESIDUE), 1);
				stack.damageItem(1, player);
				return new ActionResult(EnumActionResult.SUCCESS, stack);
			}
		}
	}
	return new ActionResult(EnumActionResult.PASS, stack);
}
 
开发者ID:bafomdad,项目名称:uniquecrops,代码行数:21,代码来源:ItemEnderSnooker.java

示例2: performEffect

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@Override
public void performEffect(RayTraceResult rtrace, EntityLivingBase caster, World world) {
	if (caster != null) {
		BlockPos dest = new BlockPos(caster.getPositionVector().add(caster.getLookVec().scale(2).addVector(0, 1, 0)));
		if (!world.getBlockState(dest).causesSuffocation()) {
			caster.setPositionAndUpdate(dest.getX(), dest.getY(), dest.getZ());
		}
	}
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:10,代码来源:SpellLesserBlinking.java

示例3: runAnimationTick

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
public void runAnimationTick()
{
	updateFrameTime();
	if (activeAnimation != null)
	{
		if(entityPosAnimations != null) {
			float[] values = AnimationSequence.getPartValueAtTime(entityPosAnimations, MathHelper.floor(frameTime));
			
			float entityPosX = values[0];
			float entityPosZ = values[2];
							
			float strafe = entityPosX - prevEntityPosX;
			float forward = entityPosZ - prevEntityPosZ;
			
			float f4 = MathHelper.sin(entity.rotationYaw * (float)Math.PI / 180.0F);
			float f5 = MathHelper.cos(entity.rotationYaw * (float)Math.PI / 180.0F);
			
			double posX = entity.posX + (double)(strafe * f5 - forward * f4);
			double posY = entity.posY;
			double posZ = entity.posZ + (double)(forward * f5 + strafe * f4);	
			
			if(entity instanceof EntityLivingBase && !(entity instanceof EntityPlayer)) {
				EntityLivingBase elb = (EntityLivingBase) entity;
				elb.setPositionAndUpdate(posX, posY, posZ);
			}
			
			prevEntityPosX = entityPosX;
			prevEntityPosZ = entityPosZ;
		}

		while (frameTime > nextFrame)
		{
			fireActions(nextFrame);
			ObsidianAPI.EVENT_BUS.dispatchAnimationEvent(new AnimationEvent(nextFrame, entityName, activeAnimation, entity));
			nextFrame++;
		}

		if (frameTime > activeAnimationLength)
		{
			ObsidianAPI.EVENT_BUS.dispatchAnimationEvent(new AnimationEvent(AnimationEventType.END, entityName, activeAnimation, entity));
			if (loop)
				setActiveAnimation(AnimationRegistry.getAnimation(entityName, activeAnimation), true, 0f, false);
			else if(onFinished != null)
				onFinished.run();
			else
				returnToIdle();
		}
	}
}
 
开发者ID:ObsidianSuite,项目名称:ObsidianSuite,代码行数:50,代码来源:EntityAnimationProperties.java

示例4: onImpact

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

示例5: teleportTo

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
private static boolean teleportTo(EntityLivingBase entity, double xx, double yy, double zz) {
	EnderTeleportEvent event = new EnderTeleportEvent(entity, xx, yy, zz, 0);
	if (MinecraftForge.EVENT_BUS.post(event))
		return false;

	double d3 = entity.posX;
	double d4 = entity.posY;
	double d5 = entity.posZ;
	entity.posX = event.targetX;
	entity.posY = event.targetY;
	entity.posZ = event.targetZ;
	boolean flag = false;
	int i = MathHelper.floor_double(entity.posX);
	int j = MathHelper.floor_double(entity.posY);
	int k = MathHelper.floor_double(entity.posZ);

	if (entity.worldObj.blockExists(i, j, k)) {
		boolean flag1 = false;
		while (!flag1 && j > 0) {
			Block block = entity.worldObj.getBlock(i, j - 1, k);
			if (block.getMaterial().blocksMovement())
				flag1 = true;
			else {
				entity.posY--;
				j--;
			}
		}

		if (flag1) {
			entity.setPositionAndUpdate(entity.posX, entity.posY, entity.posZ);
			if (entity.worldObj.getCollidingBoundingBoxes(entity, entity.boundingBox).isEmpty() && !entity.worldObj.isAnyLiquid(entity.boundingBox))
				flag = true;
		}
	}

	if (!flag) {
		entity.setPosition(d3, d4, d5);
		return false;
	} else {
		short short1 = 128;

		for (int l = 0; l < short1; l++) {
			double d6 = l / (short1 - 1.0D);
			float f = (entity.getRNG().nextFloat() - 0.5F) * 0.2F;
			float f1 = (entity.getRNG().nextFloat() - 0.5F) * 0.2F;
			float f2 = (entity.getRNG().nextFloat() - 0.5F) * 0.2F;
			double d7 = d3 + (entity.posX - d3) * d6 + (entity.getRNG().nextDouble() - 0.5D) * entity.width * 2.0D;
			double d8 = d4 + (entity.posY - d4) * d6 + entity.getRNG().nextDouble() * entity.height;
			double d9 = d5 + (entity.posZ - d5) * d6 + (entity.getRNG().nextDouble() - 0.5D) * entity.width * 2.0D;
			entity.worldObj.spawnParticle("portal", d7, d8, d9, f, f1, f2);
		}

		entity.worldObj.playSoundEffect(d3, d4, d5, "mob.endermen.portal", 1.0F, 1.0F);
		entity.playSound("mob.endermen.portal", 1.0F, 1.0F);
		return true;
	}
}
 
开发者ID:jm-organization,项目名称:connor41-etfuturum2,代码行数:58,代码来源:ChorusFruit.java

示例6: 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

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