Define a ShogiValue that exposes one of your mod's properties to Shogi while keeping a safe default when no rule override applies.
Your mod could expose a property like yourmod:your_property like this:
public class YourModRules {
public static final ShogiValue<Entity, Integer> yourProperty =
Shogi.intValue(id("your_property"), entity -> entity.totalExperience);
}
This creates an integer-backed value with:
yourmod:your_propertyEntity resolution contextUse the typed helper that matches the value you want to expose:
public class ExampleModRules {
public static final ShogiValue<Player, Boolean> preventDeath =
Shogi.booleanValue(id("prevent_death"), player -> ExampleModConfig.getActive().preventDeath);
public static final ShogiValue<Entity, Integer> fallingHeight =
Shogi.intValue(id("falling_height"), entity -> entity.level().getHeight());
public static final ShogiValue<Player, String> titleText =
Shogi.stringValue(id("title_text"), player -> "Hello World");
}
Available helpers:
Shogi.intValue(...)Shogi.floatValue(...)Shogi.booleanValue(...)Shogi.stringValue(...)Shogi.componentValue(...)Once defined, resolve it wherever your mod needs the final value:
int targetHeight = ForgivingVoidRules.fallingHeight.getOrDefault(entity);
Common resolution methods:
getOrDefault(context) to use your default provider on failuregetOrElse(context, fallback) to supply a one-off fallbackgetOrThrow(context) to fail hard if resolution does not produce a success valueSome rules can only be resolved on the server and must be synchronized to clients. ShogiValues that are marked as .networked() will resolve to the authorative server value when resolved on the client. The server will automatically sync updates to this value whenever it is resolved to a new value.
public static final ShogiValue<Player, Boolean> canUseOverlay =
Shogi.booleanValue(id("can_use_overlay"), player -> true).networked();
shogi-api alone will not perform any special handling for networked values.When using the helpers from the Shogi class (such as Shogi.intValue), your values will be registered on the default scope.
You can also create a custom scope and define values there. You can register specialized effects onto your custom scope that should only be available for rules on values defined on that scope.
Learn more on the Custom Scopes page.
After defining the a Shogi value, users can target it with rules such as:
{
"forgivingvoid:falling_height": [
"is_dimension('minecraft:the_nether') -> 180",
"220"
]
}
Rules can be configured in the config/<scopeNamespace>.<scopePath>.json file, or individually in a datapack file via data/<propertyNamespace>/<scopeNamespace>/<scopePath>/<propertyPath>.json.
For a yourmod:example property on the default scope, that would be in config/shogi.rules.json and data/yourmod/shogi/rules/example.json.