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


Java Entity.getVelocity方法代码示例

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


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

示例1: pullEntityToLocation

import org.bukkit.entity.Entity; //导入方法依赖的package包/类
public void pullEntityToLocation(Entity e, Location loc) {
    Location entityLoc = e.getLocation();
    entityLoc.setY(entityLoc.getY() + 0.5D);
    e.teleport(entityLoc);
    double g = -0.08D;
    if (loc.getWorld() != entityLoc.getWorld())
        return;
    double d = loc.distance(entityLoc);
    double t = d;
    double v_x = (1.0D + 0.07000000000000001D * t) * (loc.getX() - entityLoc.getX()) / t;
    double v_y = (1.0D + 0.03D * t) * (loc.getY() - entityLoc.getY()) / t - 0.5D * g * t;
    double v_z = (1.0D + 0.07000000000000001D * t) * (loc.getZ() - entityLoc.getZ()) / t;
    Vector v = e.getVelocity();
    v.setX(v_x);
    v.setY(v_y);
    v.setZ(v_z);
    e.setVelocity(v);
    e.setFallDistance(0f);
}
 
开发者ID:edasaki,项目名称:ZentrelaRPG,代码行数:20,代码来源:GrappleManager.java

示例2: execute

import org.bukkit.entity.Entity; //导入方法依赖的package包/类
@Override
protected void execute(Event e) {
	Entity ent = entity.getSingle(e);
	Location to = towards.getSingle(e);
	if (ent == null || to == null) {
		return;
	}
	Vector velocity = ent.getVelocity();
	float fallDistance = ent.getFallDistance();
	Location from = ent.getLocation();
	Vector direction = isToward ? MathUtils.vectorFromLocations(from, to) : MathUtils.vectorFromLocations(to, from);
	ent.teleport(new Location(
		ent.getWorld(),
		from.getX(),
		from.getY(),
		from.getZ(),
		MathUtils.notchYaw(MathUtils.getYaw(direction)),
		MathUtils.notchPitch(MathUtils.getPitch(direction))
	));
	ent.setVelocity(velocity);
	ent.setFallDistance(fallDistance);
}
 
开发者ID:Syst3ms,项目名称:QuarSK,代码行数:23,代码来源:EffOrientTowards.java

示例3: movePlayer

import org.bukkit.entity.Entity; //导入方法依赖的package包/类
public void movePlayer(Entity p, int dx, int dy, int dz) {
	NavyCraft.instance.DebugMessage("Moving player", 4);
	int mccraftspeed = craft.speed;
	if (mccraftspeed > 2) {
		mccraftspeed = 2;
	}

	Vector pVel = p.getVelocity();

	if (dx > 0) {
		dx = craft.speed;
	} else {
		dx = craft.speed * -1;
	}
	if (dy > 0) {
		dy = craft.speed;
	} else {
		dy = craft.speed * -1;
	}
	if (dz > 0) {
		dz = craft.speed;
	} else {
		dz = craft.speed * -1;
	}
	pVel = pVel.add(new Vector(dx, dy, dz));


	if ((pVel.getX() > 10) || (pVel.getZ() > 10) || (pVel.getY() > 10)) {

		System.out.println("Velocity is too high, have to teleport " + p.getEntityId());
		Location pLoc = p.getLocation();
		pLoc.setX(pLoc.getX() + pVel.getX());
		pLoc.setY(pLoc.getY() + pVel.getY() + .05);
		pLoc.setZ(pLoc.getZ() + pVel.getZ());
		p.teleport(pLoc);
	} else {
		p.setVelocity(pVel);
	}
}
 
开发者ID:Maximuspayne,项目名称:NavyCraft2-Lite,代码行数:40,代码来源:CraftMover.java

示例4: fixEntityDamage

import org.bukkit.entity.Entity; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true)
public void fixEntityDamage(EntityDamageByEntityEvent event) {
    Entity projectile = event.getDamager();
    if(projectile.hasMetadata("customProjectile")) {

        // If the custom projectile replaced an arrow, recreate some effects specific to arrows
        if(projectile.hasMetadata("damage")) {
            boolean critical = projectile.getMetadata("critical").get(0).asBoolean();
            int knockback = projectile.getMetadata("knockback").get(0).asInt();
            double damage = projectile.getMetadata("damage").get(0).asDouble();
            double speed = projectile.getVelocity().length();

            // Reproduce the damage calculation from nms.EntityArrow with the addition of our modifier
            int finalDamage = (int) Math.ceil(speed * damage * this.velocityMod);
            if(critical) {
                finalDamage += random.nextInt(finalDamage / 2 + 2);
            }
            event.setDamage(finalDamage);

            // Flame arrows - target burns for 5 seconds always
            if(projectile.getFireTicks() > 0) {
                event.getEntity().setFireTicks(100);
            }

            // Reproduce the knockback calculation for punch bows
            if(knockback > 0) {
                Vector projectileVelocity = projectile.getVelocity();
                double horizontalSpeed = Math.sqrt(projectileVelocity.getX() * projectileVelocity.getX() +
                                                   projectileVelocity.getZ() * projectileVelocity.getZ());
                Vector velocity = event.getEntity().getVelocity();
                velocity.setX(velocity.getX() + projectileVelocity.getX() * knockback * 0.6 / horizontalSpeed);
                velocity.setY(velocity.getY() + 0.1);
                velocity.setZ(velocity.getZ() + projectileVelocity.getZ() * knockback * 0.6 / horizontalSpeed);
                event.getEntity().setVelocity(velocity);
            }
        }

        // Apply any potion effects attached to the projectile
        if(event.getEntity() instanceof LivingEntity) {
            for(PotionEffect potionEffect : this.potionEffects) {
                ((LivingEntity) event.getEntity()).addPotionEffect(potionEffect);
            }
        }
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:46,代码来源:ModifyBowProjectileMatchModule.java


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