當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。