Java Code Examples for org.bukkit.util.Vector#clone()
The following examples show how to use
org.bukkit.util.Vector#clone() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HawkPlayer.java From Hawk with GNU General Public License v3.0 | 6 votes |
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(); } }
Example 2
Source File: EntityInteractDirectionB.java From Hawk with GNU General Public License v3.0 | 5 votes |
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); } } }
Example 3
Source File: KnockbackSettings.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
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; }
Example 4
Source File: GunUtil.java From QualityArmory with GNU General Public License v3.0 | 5 votes |
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()); } }
Example 5
Source File: VectorMath.java From Skript with GNU General Public License v3.0 | 5 votes |
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; }
Example 6
Source File: VectorMath.java From Skript with GNU General Public License v3.0 | 5 votes |
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; }
Example 7
Source File: VectorMath.java From Skript with GNU General Public License v3.0 | 5 votes |
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; }
Example 8
Source File: SentinelUtilities.java From Sentinel with MIT License | 5 votes |
/** * 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); }
Example 9
Source File: HologramImpl.java From HoloAPI with GNU General Public License v3.0 | 5 votes |
@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); }
Example 10
Source File: DynamicLocation.java From EffectLib with MIT License | 5 votes |
public void addOffset(Vector offset) { if (this.offset == null) { this.offset = offset.clone(); } else { this.offset.add(offset); } this.updateOffsets(); }
Example 11
Source File: DynamicLocation.java From EffectLib with MIT License | 5 votes |
public void addRelativeOffset(Vector offset) { if (this.relativeOffset == null) { this.relativeOffset = offset.clone(); } else { this.relativeOffset.add(offset); } this.updateOffsets(); }
Example 12
Source File: Bounds.java From PGM with GNU Affero General Public License v3.0 | 4 votes |
public Bounds(Vector min, Vector max) { this.min = min.clone(); this.max = max.clone(); }
Example 13
Source File: SentinelQAHandler.java From QualityArmory with GNU General Public License v3.0 | 4 votes |
@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; }
Example 14
Source File: EntityPortalExitEvent.java From Kettle with GNU General Public License v3.0 | 2 votes |
/** * 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(); }