I'm making a plugin. It basically pushes everyone in a 5 blocks radius from the player away. How would I do this(I suck at thinking when it comes to vectors =\ )?
I was going to make something like this, but never knew how... Maybe getNearbyEntities and set their location 5 blocks away from yours? Maybe not...
WarmakerT Code: Integer dist = 5; List<Entity> nearby = player.getNearbyEntities(dist, dist, dist); for (Entity e : nearby) { Location loc = player.getLocation(); Location mloc = e.getLocation(); Double distance = mloc.distance(loc); if (distance <= dist) { e.setVelocity((new Vector(mloc.getX() - loc.getX(), mloc.getY() - loc.getY(), mloc.getZ() - loc.getZ())).multiply(dist - distance).add(e.getVelocity())); } } You can change 'dist' to anything
WarmakerT Sure, just use this line instead of the other: Code: e.setVelocity((new Vector(mloc.getX() - loc.getX(), 0, mloc.getZ() - loc.getZ())).multiply(dist - distance).add(e.getVelocity()));