Skip to main content

Module java

Module java 

Source
Expand description

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).

ⓘ
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());
}

Functions§

call
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.
mod_loaded
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.