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


Java Entity.addVelocity方法代码示例

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


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

示例1: collideWithEntities

import net.minecraft.entity.Entity; //导入方法依赖的package包/类
/**
 * Pushes all entities inside the list away from the enderdragon.
 */
private void collideWithEntities(List<Entity> p_70970_1_)
{
    double d0 = (this.dragonPartBody.getEntityBoundingBox().minX + this.dragonPartBody.getEntityBoundingBox().maxX) / 2.0D;
    double d1 = (this.dragonPartBody.getEntityBoundingBox().minZ + this.dragonPartBody.getEntityBoundingBox().maxZ) / 2.0D;

    for (Entity entity : p_70970_1_)
    {
        if (entity instanceof EntityLivingBase)
        {
            double d2 = entity.posX - d0;
            double d3 = entity.posZ - d1;
            double d4 = d2 * d2 + d3 * d3;
            entity.addVelocity(d2 / d4 * 4.0D, 0.20000000298023224D, d3 / d4 * 4.0D);
        }
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:20,代码来源:EntityDragon.java

示例2: collideWithEntities

import net.minecraft.entity.Entity; //导入方法依赖的package包/类
/**
 * Pushes all entities inside the list away from the enderdragon.
 */
private void collideWithEntities(List<Entity> p_70970_1_)
{
    double d0 = (this.dragonPartBody.getEntityBoundingBox().minX + this.dragonPartBody.getEntityBoundingBox().maxX) / 2.0D;
    double d1 = (this.dragonPartBody.getEntityBoundingBox().minZ + this.dragonPartBody.getEntityBoundingBox().maxZ) / 2.0D;

    for (Entity entity : p_70970_1_)
    {
        if (entity instanceof EntityLivingBase)
        {
            double d2 = entity.posX - d0;
            double d3 = entity.posZ - d1;
            double d4 = d2 * d2 + d3 * d3;
            entity.addVelocity(d2 / d4 * 4.0D, 0.20000000298023224D, d3 / d4 * 4.0D);

            if (!this.phaseManager.getCurrentPhase().getIsStationary() && ((EntityLivingBase)entity).getRevengeTimer() < entity.ticksExisted - 2)
            {
                entity.attackEntityFrom(DamageSource.causeMobDamage(this), 5.0F);
                this.applyEnchantments(this, entity);
            }
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:26,代码来源:EntityDragon.java

示例3: attackEntityAsMob

import net.minecraft.entity.Entity; //导入方法依赖的package包/类
public boolean attackEntityAsMob(Entity entityIn)
{
    float f = (float)this.getEntityAttribute(SharedMonsterAttributes.attackDamage).getAttributeValue();
    int i = 0;

    if (entityIn instanceof EntityLivingBase)
    {
        f += EnchantmentHelper.func_152377_a(this.getHeldItem(), ((EntityLivingBase)entityIn).getCreatureAttribute());
        i += EnchantmentHelper.getKnockbackModifier(this);
    }

    boolean flag = entityIn.attackEntityFrom(DamageSource.causeMobDamage(this), f);

    if (flag)
    {
        if (i > 0)
        {
            entityIn.addVelocity((double)(-MathHelper.sin(this.rotationYaw * (float)Math.PI / 180.0F) * (float)i * 0.5F), 0.1D, (double)(MathHelper.cos(this.rotationYaw * (float)Math.PI / 180.0F) * (float)i * 0.5F));
            this.motionX *= 0.6D;
            this.motionZ *= 0.6D;
        }

        int j = EnchantmentHelper.getFireAspectModifier(this);

        if (j > 0)
        {
            entityIn.setFire(j * 4);
        }

        this.applyEnchantments(this, entityIn);
    }

    return flag;
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:35,代码来源:EntityMob.java

示例4: attackDirect

import net.minecraft.entity.Entity; //导入方法依赖的package包/类
public void attackDirect(Entity target, double pushForce) {
	if (!this.world.isRemote) {
		if (!this.hitEntities.contains(target)) {
			this.hitEntities.add(target);
			float distance = (float) TF2Util.getDistanceBox(this.shootingEntity, target.posX, target.posY, target.posZ, target.width+0.1, target.height+0.1);
			int critical = TF2Util.calculateCritPost(target, shootingEntity, this.getCritical(),
					this.usedWeapon);
			float dmg = TF2Util.calculateDamage(target, world, this.shootingEntity, usedWeapon, critical,
					distance);
			boolean proceed=((ItemProjectileWeapon)this.usedWeapon.getItem()).onHit(usedWeapon, this.shootingEntity, target, dmg, critical);
			if(!proceed || TF2Util.dealDamage(target, this.world, this.shootingEntity, this.usedWeapon, critical, dmg,
					TF2Util.causeBulletDamage(this.usedWeapon, this.shootingEntity, critical, this))) {
				if (!((ItemWeapon) this.usedWeapon.getItem()).canPenetrate(this.usedWeapon,this.shootingEntity))
					this.setDead();
				if(proceed) {
					Vec3d pushvec=new Vec3d(this.motionX,this.motionY,this.motionZ).normalize();
					pushvec=pushvec.scale(((ItemWeapon) this.usedWeapon.getItem()).getWeaponKnockback(this.usedWeapon, shootingEntity)
							*  0.01625D*dmg);
					if(target instanceof EntityLivingBase) {
						pushvec=pushvec.scale(1-((EntityLivingBase) target).getAttributeMap().getAttributeInstance(SharedMonsterAttributes.KNOCKBACK_RESISTANCE)
						.getAttributeValue());
					}
					target.addVelocity(pushvec.x, pushvec.y, pushvec.z);
					target.isAirBorne = target.isAirBorne || -(pushvec.y) > 0.02D;
					if(target instanceof EntityPlayerMP)
						TF2weapons.network.sendTo(new TF2Message.VelocityAddMessage(pushvec,target.isAirBorne), (EntityPlayerMP) target);
				}
			}
		}
	}
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:32,代码来源:EntityProjectileBase.java

示例5: onUpdate

import net.minecraft.entity.Entity; //导入方法依赖的package包/类
@Override
public void onUpdate() {

	this.lastTickPosX = this.posX;
	this.lastTickPosY = this.posY;
	this.lastTickPosZ = this.posZ;
	super.onUpdate();

	this.ticksExisted++;
	this.width += 0.02;
	this.height += 0.04;

	Vec3 currentPos = Vec3.createVectorHelper(this.posX, this.posY, this.posZ);
	Vec3 nextPos = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + 0.02, this.posZ + this.motionZ);
	MovingObjectPosition movingobjectposition = this.worldObj.rayTraceBlocks(currentPos, nextPos);

	if (movingobjectposition != null) {
		if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK && this.worldObj.getBlock(movingobjectposition.blockX, movingobjectposition.blockY, movingobjectposition.blockZ) == Blocks.portal) {
			this.setInPortal();
		}
		nextPos = Vec3.createVectorHelper(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord);
	}

	AxisAlignedBB axisalignedbb = this.boundingBox.expand(this.width, this.height, this.width);
	List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, axisalignedbb.addCoord(this.motionX, 0, this.motionZ));
	EntityPlayer player = this.getOwner();

	for (Object o : list) {
		Entity entity = (Entity)o;
		if (entity == player) {
			continue;
		}
		entity.attackEntityFrom(DamageSource.causePlayerDamage(this.getOwner()).setProjectile(), getDamage(exp));
		//entity.setVelocity(this.motionX, 0.1, this.motionZ);
		//entity.isAirBorne = true;
		entity.addVelocity(this.motionX / 10, 0.02, this.motionZ / 10);
		entity.fallDistance = 0;
	}	

       this.posX = nextPos.xCoord;
       this.posY = nextPos.yCoord;
       this.posZ = nextPos.zCoord;

       float f2 = velocityDecreaseRate;
       if (this.isInWater()) {
           for (int i = 0; i < 4; ++i) {
               float f4 = 0.25F;
               this.worldObj.spawnParticle("bubble", this.posX - this.motionX * (double)f4, this.posY - this.motionY * (double)f4, this.posZ - this.motionZ * (double)f4, this.motionX, this.motionY, this.motionZ);
           }

           f2 = 0.8F;
       }

       this.motionX *= (double)f2;
       this.motionY *= (double)f2;
       this.motionZ *= (double)f2;
       
       this.setPosition(this.posX, this.posY, this.posZ);
       
       this.rotationYaw += 5;

       if (this.ticksExisted >= this.age)
       	this.setDead();
   }
 
开发者ID:Kanbe-Kotori,项目名称:ExtraAcC,代码行数:65,代码来源:EntityUpdraft.java


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