本文整理汇总了Java中org.bukkit.util.Vector.setY方法的典型用法代码示例。如果您正苦于以下问题:Java Vector.setY方法的具体用法?Java Vector.setY怎么用?Java Vector.setY使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.util.Vector
的用法示例。
在下文中一共展示了Vector.setY方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onItemDamage
import org.bukkit.util.Vector; //导入方法依赖的package包/类
@EventHandler
public void onItemDamage(EntityDamageEvent event) {
if (event.getEntityType() == EntityType.DROPPED_ITEM && (event.getCause() == DamageCause.LAVA || event.getCause() == DamageCause.FIRE_TICK || event.getCause() == DamageCause.FIRE)) {
Vector v = Vector.getRandom().normalize();
v = v.setX(v.getX() - 0.5f);
v = v.setZ(v.getZ() - 0.5f);
v = v.multiply(0.35);
if (v.getX() > 0 && v.getX() < 0.10)
v.setX(0.10);
if (v.getZ() > 0 && v.getZ() < 0.10)
v.setZ(0.10);
if (v.getX() < 0 && v.getX() > -0.10)
v.setX(-0.10);
if (v.getZ() < 0 && v.getZ() > -0.10)
v.setZ(-0.10);
v.setY(0.3);
event.getEntity().setVelocity(v);
event.setCancelled(true);
RScheduler.schedule(plugin, () -> {
event.getEntity().setFireTicks(0);
}, RTicks.seconds(1));
}
if (event.getEntityType() == EntityType.ARMOR_STAND && (event.getCause() == DamageCause.LAVA || event.getCause() == DamageCause.FIRE_TICK || event.getCause() == DamageCause.FIRE)) {
event.setCancelled(true);
}
}
示例2: getVectorsNormal
import org.bukkit.util.Vector; //导入方法依赖的package包/类
private ArrayList<Vector> getVectorsNormal(LivingEntity e) {
ArrayList<Vector> vectors = new ArrayList<Vector>();
Vector v = e.getEyeLocation().getDirection().normalize();
v.setY(0);
vectors.add(v);
double z = v.getZ();
double x = v.getX();
double radians = Math.atan(z / x);
if (x < 0)
radians += Math.PI;
for (int k = 1; k < 4; k++) {
Vector v2 = new Vector();
v2.setY(v.getY());
v2.setX(Math.cos(radians + k * Math.PI / 2));
v2.setZ(Math.sin(radians + k * Math.PI / 2));
vectors.add(v2.normalize());
}
return vectors;
}
示例3: boost
import org.bukkit.util.Vector; //导入方法依赖的package包/类
private boolean boost(Entity source, Entity receiver) {
if (!(source instanceof Player) || !(receiver instanceof Player) || !isPlaying((Player) source) || !isPlaying((Player) receiver))
return false;
receiver.sendMessage(ChatColor.GREEN + "Whoosh!");
Vector toSender = source.getVelocity().subtract(receiver.getVelocity());
toSender.setY(0);
double distance = toSender.length();
if(distance > 0) {
toSender.multiply(1D / distance);
} else {
float yaw = source.getLocation().getYaw();
toSender.setX(-1 * Math.sin(toRad(yaw)));
toSender.setZ(Math.cos(toRad(yaw)));
}
toSender.multiply(2.5D);
toSender.setY(2);
receiver.setVelocity(toSender);
return true;
}
示例4: startDungeon
import org.bukkit.util.Vector; //导入方法依赖的package包/类
/**Dungeon activation function called when a player gives the /start command. Calls the genEntry() function at that players position.
* @param p The player that gave the /start command.
*/
private void startDungeon(Player p) {
// calc starting location in front of player on level ground:
// also check if ground is solid. if not then paste over the gras etc.
int initDist = 10; // distance to player
Vector start = new Vector(p.getLocation().getBlockX(),p.getLocation().getBlockY(),p.getLocation().getBlockZ());
Direc playerDirec = Helper.getPlayerDirec(p);
int deltaX = (int)Math.round(-Helper.sind(playerDirec.degree())*initDist);
int deltaZ = (int)Math.round(+Helper.cosd(playerDirec.degree())*initDist);
start.add(new Vector(deltaX,0,deltaZ));
int solidOffset = 0;
if (world.getHighestBlockAt(start.getBlockX(), start.getBlockZ()).getType().isSolid()) {
solidOffset = 1;
}
start.setY(world.getHighestBlockYAt(start.getBlockX(), start.getBlockZ())+solidOffset);
genEntry(start, playerDirec);
}
示例5: onRun
import org.bukkit.util.Vector; //导入方法依赖的package包/类
@Override
public void onRun() {
Location location = getLocation();
location.add(0, 0.5, 0);
for (int i = 0; i < particles; i++) {
float alpha = ((MathUtils.PI / compilation) / particles) * i;
double phi = Math.pow(Math.abs(MathUtils.sin(2 * compilation * alpha)) + factorInnerSpike * Math.abs(MathUtils.sin(compilation * alpha)), 1 / compressYFactorTotal);
Vector vector = new Vector();
vector.setY(phi * (MathUtils.sin(alpha) + MathUtils.cos(alpha)) * yFactor);
vector.setZ(phi * (MathUtils.cos(alpha) - MathUtils.sin(alpha)) * zFactor);
VectorUtils.rotateVector(vector, 0, -location.getYaw() * MathUtils.degreesToRadians + (Math.PI / 2f), 0);
display(particle, location.add(vector), RUtils.randomColor());
location.subtract(vector);
}
}
示例6: onRun
import org.bukkit.util.Vector; //导入方法依赖的package包/类
@Override
public void onRun() {
Location location = getLocation();
for (int i = 1; i <= strands; i++) {
double angle = 2 * i * Math.PI / strands + rotation;
for (int j = 1; j <= particlesStrand; j++) {
float ratio = (float) j / particlesStrand;
double x, y, z;
x = Math.cos(angle) * radius * ratio;
y = Math.sin(Math.PI * j / particlesStrand) * height;
z = Math.sin(angle) * radius * ratio;
location.add(x, y, z);
display(particle, location);
location.subtract(x, y, z);
}
}
for (int i = 0; i < particlesSpout; i++) {
Vector v = RandomUtils.getRandomCircleVector().multiply(RandomUtils.random.nextFloat() * radius * radiusSpout);
v.setY(RandomUtils.random.nextFloat() * heightSpout);
location.add(v);
display(particle, location);
location.subtract(v);
}
}
示例7: onRun
import org.bukkit.util.Vector; //导入方法依赖的package包/类
@Override
public void onRun() {
Location location = getLocation();
location.add(0, 2, 0);
float radius = 3 * innerRadius / MathUtils.SQRT_3;
for (int i = 0; i < spikesHalf * 2; i++) {
double xRotation = i * Math.PI / spikesHalf;
for (int x = 0; x < particles; x++) {
double angle = 2 * Math.PI * x / particles;
float height = RandomUtils.random.nextFloat() * spikeHeight;
Vector v = new Vector(Math.cos(angle), 0, Math.sin(angle));
v.multiply((spikeHeight - height) * radius / spikeHeight);
v.setY(innerRadius + height);
VectorUtils.rotateAroundAxisX(v, xRotation);
location.add(v);
display(particle, location);
location.subtract(v);
VectorUtils.rotateAroundAxisX(v, Math.PI);
VectorUtils.rotateAroundAxisY(v, Math.PI / 2);
location.add(v);
display(particle, location);
location.subtract(v);
}
}
}
示例8: getVectorsNormal
import org.bukkit.util.Vector; //导入方法依赖的package包/类
private ArrayList<Vector> getVectorsNormal(LivingEntity e) {
ArrayList<Vector> vectors = new ArrayList<Vector>();
Vector v = e.getEyeLocation().getDirection().normalize();
v.setY(0);
vectors.add(v);
double z = v.getZ();
double x = v.getX();
double radians = Math.atan(z / x);
if (x < 0)
radians += Math.PI;
for (int k = 1; k < 12; k++) {
Vector v2 = new Vector();
v2.setY(v.getY());
v2.setX(Math.cos(radians + k * Math.PI / 6));
v2.setZ(Math.sin(radians + k * Math.PI / 6));
vectors.add(v2.normalize());
}
return vectors;
}
示例9: FiniteBlockRegion
import org.bukkit.util.Vector; //导入方法依赖的package包/类
public FiniteBlockRegion(Collection<BlockVector> positions) {
this.positions = BlockVectorSet.of(positions);
// calculate AABB
final Vector min = new Vector(Double.MAX_VALUE);
final Vector max = new Vector(-Double.MAX_VALUE);
for(BlockVector pos : this.positions) {
min.setX(Math.min(min.getX(), pos.getBlockX()));
min.setY(Math.min(min.getY(), pos.getBlockY()));
min.setZ(Math.min(min.getZ(), pos.getBlockZ()));
max.setX(Math.max(max.getX(), pos.getBlockX() + 1));
max.setY(Math.max(max.getY(), pos.getBlockY() + 1));
max.setZ(Math.max(max.getZ(), pos.getBlockZ() + 1));
}
this.bounds = Cuboid.between(min, max);
}
示例10: getVectors
import org.bukkit.util.Vector; //导入方法依赖的package包/类
public ArrayList<Vector> getVectors(Player p) {
ArrayList<Vector> vectors = new ArrayList<Vector>();
Vector v = p.getEyeLocation().getDirection().normalize();
v.setY(0);
vectors.add(v);
double z = v.getZ();
double x = v.getX();
double radians = Math.atan(z / x);
if (x < 0)
radians += Math.PI;
for (int k = 1; k < 24; k++) {
Vector v2 = new Vector();
v2.setY(v.getY());
v2.setX(Math.cos(radians + k * Math.PI / 12));
v2.setZ(Math.sin(radians + k * Math.PI / 12));
vectors.add(v2.normalize());
}
return vectors;
}
示例11: getDirection
import org.bukkit.util.Vector; //导入方法依赖的package包/类
/**
* Returns the launch Direction for the cannon
*
* @param player player
* @return launchDirection
*/
private Vector getDirection(Player player) {
final Vector vector = new Vector();
final double rotX = player.getLocation().getYaw();
final double rotY = player.getLocation().getPitch();
vector.setY(-Math.sin(Math.toRadians(rotY)));
final double h = Math.cos(Math.toRadians(rotY));
vector.setX(-h * Math.sin(Math.toRadians(rotX)));
vector.setZ(h * Math.cos(Math.toRadians(rotX)));
vector.setY(0.5);
return vector.multiply(3);
}
示例12: castSpell
import org.bukkit.util.Vector; //导入方法依赖的package包/类
public void castSpell(final LivingEntity caster, final MobData md, Player target) {
Vector v = caster.getLocation().toVector();
for (Entity e : RMath.getNearbyEntities(caster.getLocation(), range)) {
if (e instanceof Player) {
Player p = (Player) e;
if (p != null && p.isOnline()) {
if (Spell.canDamage(p, false)) {
Vector pullVector = p.getLocation().toVector().subtract(v).normalize().multiply(-1.8);
pullVector.setY(pullVector.getY() + 0.35);
p.setVelocity(pullVector);
}
}
}
}
}
示例13: getRandomVector
import org.bukkit.util.Vector; //导入方法依赖的package包/类
public static Vector getRandomVector() {
Vector vector = new Vector();
vector.setX(0.0D + Math.random() - Math.random());
vector.setY(Math.random());
vector.setZ(0.0D + Math.random() - Math.random());
return vector;
}
示例14: onProjectileLaunch
import org.bukkit.util.Vector; //导入方法依赖的package包/类
@EventHandler
public void onProjectileLaunch(final ProjectileLaunchEvent event) {
if (event.getEntityType() == EntityType.SPLASH_POTION) {
final Projectile projectile = event.getEntity();
if (projectile.getShooter() instanceof Player && ((Player) projectile.getShooter()).isSprinting()) {
final Vector velocity = projectile.getVelocity();
velocity.setY(velocity.getY() - 0.8);
projectile.setVelocity(velocity);
}
}
}
示例15: getDirection
import org.bukkit.util.Vector; //导入方法依赖的package包/类
/**
* Returns the launch direction for holding pets.
*
* @param player player
* @return launchDirection
*/
private Vector getDirection(Player player) {
final Vector vector = new Vector();
final double rotX = player.getLocation().getYaw();
final double rotY = player.getLocation().getPitch();
vector.setY(-Math.sin(Math.toRadians(rotY)));
final double h = Math.cos(Math.toRadians(rotY));
vector.setX(-h * Math.sin(Math.toRadians(rotX)));
vector.setZ(h * Math.cos(Math.toRadians(rotX)));
return vector.multiply(1.2);
}