1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//! Other mods — Yog's and Java ones — from a Yog mod: whether one is
//! loaded ([`crate::mod_loaded`]), and calls into a Java mod's API by
//! reflection ([`call`]).
//!
//! ```ignore
//! use yog_api::java;
//! use yog_api::yog_data::Value;
//! if yog_api::mod_loaded("pehkui") {
//! let entity = Value::Ref(yog_api::yog_data::Ref::new("entity", uuid));
//! let scale = java::call("virtuoel.pehkui.api.ScaleTypes.BASE.getScaleData($0).getScale()", &[entity])
//! .and_then(|v| v.as_f64());
//! }
//! ```
use YogStr;
use Value;
use crateglobal_api;
/// Whether mod `id` is loaded: a Yog mod, or a Java mod in Fabric's,
/// Forge's or NeoForge's mod list. Content and code for another mod —
/// an optional integration — go behind it.
/// Calls a Java mod's API: `expr` is a chain from a class —
/// `virtuoel.pehkui.api.ScaleTypes.BASE.getScaleData($0).getScale()` —
/// fields and methods, `$n` the `n`-th of `args`. Numbers, strings,
/// booleans and null cross as they are; an entity is
/// `Value::Ref(Ref::new("entity", uuid))` both ways. `None` when the call
/// failed (the log says why). For other mods' APIs only: Minecraft's own
/// classes are renamed at run time on some loaders.