Java Code Examples for org.bukkit.util.Vector#add()
The following examples show how to use
org.bukkit.util.Vector#add() .
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: ProximityAlarm.java From PGM with GNU Affero General Public License v3.0 | 6 votes |
private void showFlare() { Vector pos = this.definition.detectRegion.getBounds().getCenterPoint(); float angle = (float) (this.random.nextFloat() * Math.PI * 2); pos.add( new Vector( Math.sin(angle) * this.definition.flareRadius, 0, Math.cos(angle) * this.definition.flareRadius)); Set<Color> colors = new HashSet<>(); for (MatchPlayer player : this.playersInside) { colors.add(player.getParty().getFullColor()); } }
Example 2
Source File: Vectors.java From TabooLib with MIT License | 6 votes |
public static void entityPush(Entity entity, Location to, double velocity) { Location from = entity.getLocation(); Vector test = to.clone().subtract(from).toVector(); double elevation = test.getY(); Double launchAngle = calculateLaunchAngle(from, to, velocity, elevation, 20.0D); double distance = Math.sqrt(Math.pow(test.getX(), 2.0D) + Math.pow(test.getZ(), 2.0D)); if (distance != 0.0D) { if (launchAngle == null) { launchAngle = Math.atan((40.0D * elevation + Math.pow(velocity, 2.0D)) / (40.0D * elevation + 2.0D * Math.pow(velocity, 2.0D))); } double hangTime = calculateHangTime(launchAngle, velocity, elevation, 20.0D); test.setY(Math.tan(launchAngle) * distance); test = normalizeVector(test); Vector noise = Vector.getRandom(); noise = noise.multiply(0.1D); test.add(noise); velocity = velocity + 1.188D * Math.pow(hangTime, 2.0D) + (Numbers.getRandom().nextDouble() - 0.8D) / 2.0D; test = test.multiply(velocity / 20.0D); entity.setVelocity(test); } }
Example 3
Source File: CannonProjectile.java From civcraft with GNU General Public License v2.0 | 6 votes |
public boolean advance() { Vector dir = loc.getDirection(); dir.add(new Vector(0.0f, -0.008, 0.0f)); //Apply 'gravity' loc.setDirection(dir); loc.add(dir.multiply(speed)); loc.getWorld().createExplosion(loc, 0.0f, false); if (ItemManager.getId(loc.getBlock()) != CivData.AIR) { return true; } if (loc.distance(startLoc) > maxRange) { return true; } return false; }
Example 4
Source File: JetpackTask.java From Slimefun4 with GNU General Public License v3.0 | 6 votes |
@Override protected void executeTask() { if (p.getInventory().getChestplate() == null || p.getInventory().getChestplate().getType() == Material.AIR) { return; } if (jetpack.removeItemCharge(p.getInventory().getChestplate(), COST)) { p.getWorld().playSound(p.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, (float) 0.25, 1); p.getWorld().playEffect(p.getLocation(), Effect.SMOKE, 1, 1); p.setFallDistance(0F); Vector vector = new Vector(0, 1, 0); vector.multiply(jetpack.getThrust()); vector.add(p.getEyeLocation().getDirection().multiply(0.2F)); p.setVelocity(vector); } else { Bukkit.getScheduler().cancelTask(id); } }
Example 5
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 6
Source File: MoveEvent.java From Hawk with GNU General Public License v3.0 | 5 votes |
private Vector computeWaterFlowForce() { Vector finalForce = new Vector(); for(Pair<Block, Vector> liquid : liquidsAndDirections) { Material mat = liquid.getKey().getType(); if(mat == Material.STATIONARY_WATER || mat == Material.WATER) { finalForce.add(liquid.getValue()); } } if(finalForce.lengthSquared() > 0 && !pp.isFlying()) { finalForce.normalize(); finalForce.multiply(Physics.WATER_FLOW_FORCE_MULTIPLIER); return finalForce; } return finalForce; }
Example 7
Source File: AccelerationPlayerFacet.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
@Repeatable(scope = MatchScope.LOADED) public void tickForce() { final Vector acceleration = new Vector(); for(PlayerForce force : forces) { acceleration.add(force.acceleration(matchPlayer)); } if(acceleration.lengthSquared() > MIN_FORCE) { player.applyImpulse(acceleration); } }
Example 8
Source File: Ray.java From Hawk with GNU General Public License v3.0 | 4 votes |
public Vector getPointAtDistance(double distance) { Vector dir = new Vector(direction.getX(), direction.getY(), direction.getZ()); Vector orig = new Vector(origin.getX(), origin.getY(), origin.getZ()); return orig.add(dir.multiply(distance)); }