Play Strawberry Docs
Scripts

Play Strawberry's tools

Add your own items, textures, models and animated characters, and show menus that use them, with the strawberry-tools crate.

What the tools are

Two scripts run on every Play Strawberry server beside yours and do the heavy work in one place, the cheap way:

  • the model tool puts your textures, item models, armour looks and animated characters into the server's resource pack, for Java and Bedrock, hands your items to players and plays your characters' animations;
  • the interface tool shows your menus, dialogs and notices on both editions and tells your script what the player pressed.

You do not install them. Your script asks them, and the strawberry-tools crate builds every request and reads every answer, so you write ordinary Rust calls.

Add the crate

strawberry-tools 0.1.1 is made for SDK 0.2.4. Add it beside that SDK release in your Cargo.toml:

toml
[dependencies]
strawberry-plugin-api = { version = "=0.2.4", registry = "strawberry" }
strawberry-tools = { version = "=0.1.1", registry = "strawberry" }

Name both tools in your script's metadata, so your script loads after them:

rust
dependencies: vec!["custom-models".into(), "user_interface".into()],

Add an item with its own texture

Register your models in on_load. A flat item needs one picture; a 3D item a Blockbench "Java Block/Item" export (model.json) with its textures as textures/<name>.png.

rust
use strawberry_tools::models::{self, Behaviour, Model};

const COIN: Model<'static> = Model {
    name: "coin",
    names: &[("en", "Coin"), ("es", "Moneda"), ("tr", "Jeton")],
    base: None,
    stack: None,
    files: &[("texture.png", include_bytes!("../models/coin.png"))],
    wear: None,
    behaviour: Behaviour::NONE,
    variant_of: None,
};

let coin = models::register(&COIN)?; // coin.id is "<your script>.coin"

The answer says ready once players get the model in the server's pack. Then models::give(&player, &coin.id, 1) gives it, models::hand puts it into a hand, and models::model_id(&stack) tells whether a stack is one of yours (never treat that alone as proof of value: a creative player can copy an item).

The same crate registers armour looks (models::armour), retextured vanilla blocks (models::retexture), sounds (models::sound), names in four languages (models::line), pictures players write in chat as :name: (models::picture), blocks, furniture, crops, vehicles, recipes and drops. Each function's documentation lists what it takes.

Add an entity model with animations

A Blockbench Generic Model with bones and animations becomes a mob that walks, fights and plays its animations: models::character registers the model, models::mob the mob that carries it (health, attack, an animation for each state), and models::mob_spawn puts one in the world. The tool plays the animations for every mob of every script from one place; your script is never woken for a keyframe. The page Animated characters shows a complete example and the limits.

Show your item in a menu

The interface tool can draw the models you registered. A button that names one of your models shows that item, its model on Java and its Bedrock look on Bedrock; until players have it in the pack, the button shows its own item.

rust
use strawberry_tools::ui::{self, Button, Screen, Text};

let shop = Screen::menu("shop", Text::languages("Shop", "Boutique", "Tienda", "Dükkan"))
    .rows(1)
    .button(
        Button::new("buy", Text::plain("Buy a coin"))
            .item("minecraft:paper")
            .model_item(&coin.id)
            .slot(4),
    );
ui::open(&player, &shop)?;

What the player does comes back as a script message from the interface tool. Read it in your script's handle_ipc_message with ui::event(&from, &message): it gives Click, Submit (with the inputs) or Close, and gives nothing for a message from any other script, so another script cannot fake a click. ui::update changes an open screen, ui::close closes it.

What the server decides

  • Your content is yours alone. Everything you register is named <your script>.<name> and kept in your own folder of the pack. A request that names another script's model (to give it, to show it in a menu, to spawn its mob) is refused.
  • Every file is checked when you register it: sizes, picture sizes, the model's parts and animations. A request that breaks a limit is refused whole, with the number that was too high, and what you registered before stays.
  • What changes the game's own files (a vanilla block's look, a boss bar's pictures) waits until the server owner approves it in the Play Strawberry panel.
  • Register when your script loads. Registrations carry files; giving, spawning and opening screens are what your script does while it runs.

An example on GitHub

villager-bucket (a bucket that carries a villager with everything it knows) is public at github.com/playstrawberry/villager-bucket. It registers its bucket model with strawberry-tools, gives it, recognises it again, and falls back to a plain bucket when the model tool is missing.

Bedrock players

Items, armour looks, block looks and pictures reach Bedrock players too, from the same registration. Menus become Bedrock forms. Animated characters are drawn for Java players only; give their mobs a name so Bedrock players see where they are.

On this page