本文整理匯總了Java中com.flowpowered.math.vector.Vector3d.add方法的典型用法代碼示例。如果您正苦於以下問題:Java Vector3d.add方法的具體用法?Java Vector3d.add怎麽用?Java Vector3d.add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.flowpowered.math.vector.Vector3d
的用法示例。
在下文中一共展示了Vector3d.add方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: groundEntity
import com.flowpowered.math.vector.Vector3d; //導入方法依賴的package包/類
private static Handler groundEntity()
{
return mount -> {
double speed = mount.currentSpeed();
Vector3d rotation = mount.player.getHeadRotation();
Vector3d velocity = rotationToVelocity(mount.player.getRotation(), speed, 0).add(0, mount.vehicle.getVelocity().getY(), 0);
Vector3d ahead = direction(rotation).mul(1, 0, 1);
Optional<PassableProperty> passable = mount.vehicle.getLocation().add(ahead).getProperty(PassableProperty.class);
if (!passable.map(AbstractProperty::getValue).orElse(true) && canJump(mount.vehicle))
{
velocity = velocity.add(0, 0.15 + (speed * 0.15), 0);
}
mount.vehicle.setVelocity(velocity);
mount.vehicle.setRotation(rotation);
};
}
示例2: updateProgress
import com.flowpowered.math.vector.Vector3d; //導入方法依賴的package包/類
private void updateProgress(Vector3i pipePos, Direction dest, boolean toCenter) {
Vector3d target = pipePos.toDouble().add(0.5, 0.3, 0.5);
if (!toCenter) {
target = target.add(dest.asOffset().mul(0.5));
}
double dist;
if (dest == Direction.WEST) {// (-1, 0, 0)
dist = this.pos.getX() - pipePos.getX();
} else if (dest == Direction.EAST) {// (1, 0, 0)
dist = (pipePos.getX() + 1) - this.pos.getX();
} else if (dest == Direction.NORTH) {// (0, 0, -1
dist = this.pos.getZ() - pipePos.getZ();
} else if (dest == Direction.SOUTH) {// (0, 0, 1)
dist = (pipePos.getZ() + 1) - this.pos.getZ();
} else if (dest == Direction.UP) {// (0, 1, 0)
dist = (pipePos.getY() + 0.8) - this.pos.getY();
} else if (dest == Direction.DOWN) {// (0, -1, 0)
dist = (this.pos.getY() + 0.3) - pipePos.getY();
} else {
return;
}
if (toCenter) {
dist -= 0.5;
}
if (dist <= 0) { // On or past the target
this.pos = target;
this.itemStand.setLocation(this.itemStand.getLocation().setPosition(target));
this.finish = true;
} else {
this.finish = false;
}
}