org.bukkit.util.Vector#clone ( )源码实例Demo

下面列出了org.bukkit.util.Vector#clone ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Hawk   文件: HawkPlayer.java
public void updatePositionYawPitch(Vector position, float yaw, float pitch, boolean isPosUpdate) {
    this.previousVelocity = this.velocity;
    this.velocity = new Vector(
            position.getX() - this.position.getX(),
            position.getY() - this.position.getY(),
            position.getZ() - this.position.getZ());
    this.deltaYaw = yaw - this.yaw;
    this.deltaPitch = pitch - this.pitch;

    this.position = position;
    this.yaw = yaw;
    this.pitch = pitch;
    if(isPosUpdate) {
        predictedPosition = position.clone();
        if(hasSentPosUpdate())
            predictedVelocity = velocity.clone();
    }
}
 
源代码2 项目: Hawk   文件: EntityInteractDirectionB.java
private void processHit(InteractEntityEvent e) {
    if(e.getInteractAction() == InteractAction.INTERACT) {
        Vector hitVec = e.getIntersectVector();
        if(hitVec != null) {
            hitVec = hitVec.clone();
            hitVec.add(hawk.getLagCompensator().getHistoryLocation(ServerUtils.getPing(e.getPlayer()), e.getEntity()).toVector());
            lastHitVecMap.put(e.getPlayer().getUniqueId(), hitVec);
        }
    }
}
 
源代码3 项目: ProjectAres   文件: KnockbackSettings.java
public Vector pitchedNormal(Vector delta) {
    delta = delta.clone();
    delta.setY(0);
    if(delta.isZero()) return Vectors.ZERO;
    delta.normalize();
    final double theta = Math.toRadians(pitch);
    final double cos = Math.cos(theta);
    delta.set(cos * delta.getX(),
               Math.sin(theta),
               cos * delta.getZ());
    return delta;
}
 
源代码4 项目: QualityArmory   文件: GunUtil.java
public static void shootHandler(Gun g, Player p, int numberOfBullets) {
	double sway = g.getSway() * AimManager.getSway(g, p.getUniqueId());
	if (g.usesCustomProjctiles()) {
		for (int i = 0; i < numberOfBullets; i++) {
			Vector go = p.getLocation().getDirection().normalize();
			go.add(new Vector((Math.random() * 2 * sway) - sway, (Math.random() * 2 * sway) - sway,
					(Math.random() * 2 * sway) - sway)).normalize();
			Vector two = go.clone();// .multiply();
			g.getCustomProjectile().spawn(g, p.getEyeLocation(), p, two);
		}
	} else {
		shootInstantVector(g, p, sway, g.getDurabilityDamage(), g.getBulletsPerShot(), g.getMaxDistance());
	}
}
 
源代码5 项目: Skript   文件: VectorMath.java
public static Vector rotX(Vector vector, double angle) {
	double sin = Math.sin(angle * DEG_TO_RAD);
	double cos = Math.cos(angle * DEG_TO_RAD);
	Vector vy = new Vector(0, cos, -sin);
	Vector vz = new Vector(0, sin, cos);
	Vector clone = vector.clone();
	vector.setY(clone.dot(vy));
	vector.setZ(clone.dot(vz));
	return vector;
}
 
源代码6 项目: Skript   文件: VectorMath.java
public static Vector rotY(Vector vector, double angle) {
	double sin = Math.sin(angle * DEG_TO_RAD);
	double cos = Math.cos(angle * DEG_TO_RAD);
	Vector vx = new Vector(cos, 0, sin);
	Vector vz = new Vector(-sin, 0, cos);
	Vector clone = vector.clone();
	vector.setX(clone.dot(vx));
	vector.setZ(clone.dot(vz));
	return vector;
}
 
源代码7 项目: Skript   文件: VectorMath.java
public static Vector rotZ(Vector vector, double angle) {
	double sin = Math.sin(angle * DEG_TO_RAD);
	double cos = Math.cos(angle * DEG_TO_RAD);
	Vector vx = new Vector(cos, -sin, 0);
	Vector vy = new Vector(sin, cos, 0);
	Vector clone = vector.clone();
	vector.setX(clone.dot(vx));
	vector.setY(clone.dot(vy));
	return vector;
}
 
源代码8 项目: Sentinel   文件: SentinelUtilities.java
/**
 * Gets a 'launch detail' (starting location with direction vector set to correct firing direction, and a vector holding the exact launch vector, scaled to the correct speed).
 */
public static HashMap.SimpleEntry<Location, Vector> getLaunchDetail(Location start, Location target, Vector lead) {
    double speeda;
    double angt = Double.POSITIVE_INFINITY;
    double sbase = SentinelPlugin.instance.minShootSpeed;
    for (speeda = sbase; speeda <= sbase + 15; speeda += 5) {
        // TODO: Mathematically calculate a valid starting speed, to avoid pointlessly looping on a math utility.
        angt = SentinelUtilities.getArrowAngle(start, target, speeda, 20);
        if (!Double.isInfinite(angt)) {
            break;
        }
    }
    if (Double.isInfinite(angt)) {
        return null;
    }
    double hangT = SentinelUtilities.hangtime(angt, speeda, target.getY() - start.getY(), 20);
    Location to = target.clone().add(lead.clone().multiply(hangT));
    Vector relative = to.clone().subtract(start.toVector()).toVector();
    double deltaXZ = Math.sqrt(relative.getX() * relative.getX() + relative.getZ() * relative.getZ());
    if (deltaXZ == 0) {
        deltaXZ = 0.1;
    }
    for (speeda = sbase; speeda <= sbase + 15; speeda += 5) {
        angt = SentinelUtilities.getArrowAngle(start, to, speeda, 20);
        if (!Double.isInfinite(angt)) {
            break;
        }
    }
    if (Double.isInfinite(angt)) {
        return null;
    }
    relative.setY(Math.tan(angt) * deltaXZ);
    relative = relative.normalize();
    Vector normrel = relative.clone();
    speeda = speeda + (1.188 * hangT * hangT);
    relative = relative.multiply(speeda / 20.0);
    start.setDirection(normrel);
    return new HashMap.SimpleEntry<>(start, relative);
}
 
源代码9 项目: HoloAPI   文件: HologramImpl.java
@Override
public void move(Player observer, Vector to) {
    checkNotNull(observer, "The Player object in HologramImpl#move(Player, Vector) is null");
    checkNotNull(to, "The Vector object in HologramImpl#move(Player, Vector) is null");
    Vector loc = to.clone();
    for (int index = 0; index < this.getTagCount(); index++) {
        this.moveTag(observer, index, loc);
        loc.setY(loc.getY() - Settings.VERTICAL_LINE_SPACING.getValue());
    }
    this.playerToLocationMap.put(IdentUtil.getIdentificationForAsString(observer), to);
}
 
源代码10 项目: EffectLib   文件: DynamicLocation.java
public void addOffset(Vector offset) {
    if (this.offset == null) {
        this.offset = offset.clone();
    } else {
        this.offset.add(offset);
    }
    this.updateOffsets();
}
 
源代码11 项目: EffectLib   文件: DynamicLocation.java
public void addRelativeOffset(Vector offset) {
    if (this.relativeOffset == null) {
        this.relativeOffset = offset.clone();
    } else {
        this.relativeOffset.add(offset);
    }
    this.updateOffsets();
}
 
源代码12 项目: PGM   文件: Bounds.java
public Bounds(Vector min, Vector max) {
  this.min = min.clone();
  this.max = max.clone();
}
 
源代码13 项目: QualityArmory   文件: SentinelQAHandler.java
@SuppressWarnings("deprecation")
@Override
public boolean tryAttack(SentinelTrait st, LivingEntity ent) {
	QAMain.DEBUG("Sentinel about to shoot!");
	if (!(st.getLivingEntity() instanceof Player)) {
		return false;
	}
	ItemStack itm = ((Player) st.getLivingEntity()).getItemInHand();
	Gun g = QualityArmory.getGun(itm);
	QAMain.DEBUG("Getting gun! gun = "+g);
	if (g == null)
		return false;
	// CSDirector direc = (CSDirector)
	// Bukkit.getPluginManager().getPlugin("CrackShot");
	// String node = direc.returnParentNode((Player) st.getLivingEntity());
	// if (node == null) {
	// return false;
	// }
	Vector faceAcc = ent.getEyeLocation().toVector().subtract(st.getLivingEntity().getEyeLocation().toVector());
	if (faceAcc.lengthSquared() > 0.0) {
		faceAcc = faceAcc.normalize();
	}
	faceAcc = st.fixForAcc(faceAcc);
	st.faceLocation(st.getLivingEntity().getEyeLocation().clone().add(faceAcc.multiply(10)));

	double sway = g.getSway() * 0.75;
	if (g.usesCustomProjctiles()) {
		for (int i = 0; i < g.getBulletsPerShot(); i++) {
			Vector go = st.getLivingEntity().getEyeLocation().getDirection().normalize();
			go.add(new Vector((Math.random() * 2 * sway) - sway, (Math.random() * 2 * sway) - sway,
					(Math.random() * 2 * sway) - sway)).normalize();
			Vector two = go.clone();// .multiply();
			g.getCustomProjectile().spawn(g, st.getLivingEntity().getEyeLocation(), (Player) st.getLivingEntity(),
					two);
		}
	} else {
		GunUtil.shootInstantVector(g, ((Player) st.getLivingEntity()), sway, g.getDurabilityDamage(), g.getBulletsPerShot(),
				g.getMaxDistance());
	}

	GunUtil.playShoot(g, (Player) st.getLivingEntity());
	QAMain.DEBUG("Sentinel shooting!");
	
	// direc.csminion.weaponInteraction((Player) st.getLivingEntity(), node, false);
	 ((Player) st.getLivingEntity()).setItemInHand(itm);
	if (st.rangedChase) {
		st.attackHelper.rechase();
		QAMain.DEBUG("Sentinel rechase");
	}
	return true;
}
 
源代码14 项目: Kettle   文件: EntityPortalExitEvent.java
/**
 * Sets the velocity that the entity will have after exiting the portal.
 *
 * @param after the velocity after exiting the portal
 */
public void setAfter(Vector after) {
    this.after = after.clone();
}