本文整理了Java中org.bukkit.util.Vector.multiply()
方法的一些代码示例,展示了Vector.multiply()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Vector.multiply()
方法的具体详情如下:
包路径:org.bukkit.util.Vector
类名称:Vector
方法名:multiply
[英]Performs scalar multiplication, multiplying all components with a scalar.
[中]执行标量乘法,将所有组件与标量相乘。
代码示例来源:origin: GlowstoneMC/Glowstone
@Override
protected void pulsePhysics() {
// drag application
movement.multiply(airDrag);
// convert movement x/z to a velocity
Vector velMovement = getVelocityFromMovement();
velocity.add(velMovement);
super.pulsePhysics();
}
代码示例来源:origin: GlowstoneMC/Glowstone
@Override
public void setDirection(Vector vector) {
setVelocity(vector.normalize().multiply(velocity.length()));
}
代码示例来源:origin: GlowstoneMC/Glowstone
@Override
public Arrow spawnArrow(Location location, Vector velocity, float speed, float spread) {
// Transformative magic
Vector randVec = new Vector(ThreadLocalRandom.current().nextGaussian(), ThreadLocalRandom
.current().nextGaussian(), ThreadLocalRandom.current().nextGaussian());
randVec.multiply(0.0075 * spread);
velocity.normalize();
velocity.add(randVec);
velocity.multiply(speed);
// yaw = Math.atan2(x, z) * 180.0D / 3.1415927410125732D;
// pitch = Math.atan2(y, Math.sqrt(x * x + z * z)) * 180.0D / 3.1415927410125732D
Arrow arrow = spawn(location, Arrow.class);
arrow.setVelocity(velocity);
return arrow;
}
代码示例来源:origin: GlowstoneMC/Glowstone
/**
* Creates a thrown egg with default speed.
*
* @param location the position and facing of the thrower
*/
public GlowEgg(Location location) {
super(location);
setAirDrag(0.99);
setGravityAccel(new Vector(0, VERTICAL_GRAVITY_ACCEL, 0));
setApplyDragBeforeAccel(true);
setVelocity(location.getDirection().multiply(3));
setBoundingBox(0.25, 0.25);
}
代码示例来源:origin: GlowstoneMC/Glowstone
/**
* Creates a thrown snowball with default speed.
*
* @param location the position and facing of the thrower
*/
public GlowSnowball(Location location) {
super(location);
setAirDrag(0.99);
setGravityAccel(new Vector(0, VERTICAL_GRAVITY_ACCEL, 0));
setApplyDragBeforeAccel(true);
setVelocity(location.getDirection().multiply(3));
setBoundingBox(0.25, 0.25);
}
代码示例来源:origin: GlowstoneMC/Glowstone
/**
* Creates a thrown ender pearl.
*
* @param location the position and facing of the thrower
* @param speed the initial speed
*/
public GlowEnderPearl(Location location, float speed) {
super(location);
setAirDrag(0.99);
setGravityAccel(new Vector(0, VERTICAL_GRAVITY_ACCEL, 0));
setApplyDragBeforeAccel(true);
setVelocity(location.getDirection().multiply(speed));
setBoundingBox(0.25, 0.25);
}
代码示例来源:origin: GlowstoneMC/Glowstone
movement.multiply(mag);
movement.multiply(0.02);
} else {
this.slipMultiplier = ((GlowBlock) location.getBlock()).getMaterialValues()
.getSlipperiness();
double slipperiness = slipMultiplier * 0.91;
movement.multiply(0.1 * (0.1627714 / Math.pow(slipperiness, 3)));
代码示例来源:origin: GlowstoneMC/Glowstone
/**
* Creates a fishing bob.
*
* @param location the location
* @param itemStack the fishing rod (used to handle enchantments) or null (equivalent to
* @param angler the player who is casting this fish hook (must be set at spawn time)
*/
public GlowFishingHook(Location location, ItemStack itemStack, Player angler) {
super(location);
setSize(0.25f, 0.25f);
lifeTime = calculateLifeTime();
this.itemStack = InventoryUtil.itemOrEmpty(itemStack).clone();
// TODO: velocity does not match vanilla
Vector direction = location.getDirection();
setVelocity(direction.multiply(1.5));
super.setShooter(angler);
}
代码示例来源:origin: GlowstoneMC/Glowstone
/**
* Spawns a new {@link GlowItem} in the world, as if this HumanEntity had dropped it.
*
* <p>Note that this does NOT remove the item from the inventory.
*
* @param stack The item to drop
* @return the GlowItem that was generated, or null if the spawning was cancelled
* @throws IllegalArgumentException if the stack is empty
*/
public GlowItem drop(ItemStack stack) {
checkArgument(!InventoryUtil.isEmpty(stack), "stack must not be empty");
Location dropLocation = location.clone().add(0, getEyeHeight(true) - 0.3, 0);
GlowItem dropItem = world.dropItem(dropLocation, stack);
/*
These calculations are strictly based off of trial-and-error to find the
closest similar behavior to the official server. May be changed in the future.
*/
Vector vel = location.getDirection().multiply(0.3);
ThreadLocalRandom tlr = ThreadLocalRandom.current();
double randOffset = 0.02;
vel.add(new Vector(
tlr.nextDouble(randOffset) - randOffset / 2,
tlr.nextDouble(0.12),
tlr.nextDouble(randOffset) - randOffset / 2));
dropItem.setVelocity(vel);
return dropItem;
}
代码示例来源:origin: GlowstoneMC/Glowstone
@Override
protected ItemStack dispenseStack(GlowBlock block, ItemStack stack) {
GlowWorld world = block.getWorld();
Vector position = BlockDispenser.getDispensePosition(block);
BlockFace face = BlockDispenser.getFacing(block);
Projectile entity = projectileCreator.apply(
new Location(world, position.getX(), position.getY(), position.getZ()), stack);
entity.setShooter(new GlowDispenser(block));
entity.setVelocity(
new Vector(face.getModX(), face.getModY() + 0.1f, face.getModZ()).multiply(6));
stack.setAmount(stack.getAmount() - 1);
if (stack.getAmount() < 1) {
return null;
}
return stack;
}
代码示例来源:origin: GlowstoneMC/Glowstone
direction.normalize();
direction.multiply(speed);
this.setVelocity(direction);
代码示例来源:origin: GlowstoneMC/Glowstone
launchedProjectile.setVelocity(player.getEyeLocation().getDirection().multiply(
Math.max(5, chargeFraction * MAX_SPEED)));
代码示例来源:origin: GlowstoneMC/Glowstone
LivingEntity livingEntity = (LivingEntity) entity;
Vector rayLength = RayUtil.getVelocityRay(distanceToHead(livingEntity));
rayLength.multiply(exposure);
代码示例来源:origin: GlowstoneMC/Glowstone
currentVelocity.add(rayLength.multiply(((amount + 1) / 2d)));
setVelocity(currentVelocity);
代码示例来源:origin: GlowstoneMC/Glowstone
velocity.add(getGravityAccel());
location.add(getVelocity());
velocity.multiply(airDrag);
} else {
if (supportingBlock(location.getBlock().getType())) {
代码示例来源:origin: GlowstoneMC/Glowstone
@Override
public boolean entityInteract(GlowPlayer player, InteractEntityMessage message) {
super.entityInteract(player, message);
if (message.getAction() == InteractEntityMessage.Action.INTERACT.ordinal()) {
if (player.getGameMode().equals(GameMode.CREATIVE) || player.getGameMode()
.equals(GameMode.SPECTATOR)) {
return false;
}
if (!isAdult()) {
return false;
}
ItemStack hand = InventoryUtil
.itemOrEmpty(player.getInventory().getItem(message.getHandSlot()));
if (!hand.getType().equals(Material.BUCKET)) {
return false;
}
player.getInventory().consumeItemInHand(message.getHandSlot());
if (player.getInventory().firstEmpty() == -1) {
GlowItem item = player.getWorld()
.dropItem(player.getLocation().clone().add(0, 1, 0),
new ItemStack(Material.MILK_BUCKET, 1));
item.setVelocity(getLocation().add(0, -1, 0).clone().toVector()
.subtract(player.getLocation().clone().add(0, 1, 0).toVector()).multiply(0.3));
} else {
player.getInventory().addItem(new ItemStack(Material.MILK_BUCKET, 1));
}
}
return true;
}
代码示例来源:origin: GlowstoneMC/Glowstone
velocity.multiply(liquidDrag);
velocity.setY(velocity.getY() + getGravityAccel().getY() / 4);
} else if (location.getBlock().getType() == Material.LAVA) {
velocity.multiply(liquidDrag - 0.3);
velocity.setY(velocity.getY() + getGravityAccel().getY() / 4);
} else {
代码示例来源:origin: Slikey/EffectLib
@Override
public void onRun() {
Location location = getLocation();
for (int i = 0; i < 20; i++) {
location.add(RandomUtils.getRandomCircleVector().multiply(RandomUtils.random.nextDouble() * 0.6d));
location.add(0, RandomUtils.random.nextFloat() * 2, 0);
display(particle, location);
}
}
代码示例来源:origin: Slikey/EffectLib
@Override
public void onRun() {
Location location = getLocation();
for (int i = 0; i < 10; i++) {
Vector v = RandomUtils.getRandomCircleVector().multiply(RandomUtils.random.nextDouble() * 0.6d);
v.setY(RandomUtils.random.nextFloat() * 1.8);
location.add(v);
display(particle, location);
location.subtract(v);
}
}
代码示例来源:origin: io.github.bedwarsrel/BedwarsRel-Common
public void dropItem(Location dropLocation, ItemStack itemStack) {
Item item = this.game.getRegion().getWorld().dropItemNaturally(dropLocation, itemStack);
item.setPickupDelay(0);
if (this.spread != 1.0) {
item.setVelocity(item.getVelocity().multiply(this.spread));
}
}
内容来源于网络,如有侵权,请联系作者删除!