SulfurLabSulfurLab

SulfurLab API

##SulfurLab API

The SulfurLab API lets you spawn fully configured Sulfur Cubes from your own plugin — no Bukkit boilerplate. It centers on a fluent SulfurCubeBuilder and the ready-made presets in SulfurCubes.

INFO

The API is independent from the plugin's registry and persistence — it only creates and configures cubes. Cubes spawned through the API are not named, saved to sulfurs.json, or manageable with /sulfurlab. Use it when you want cubes your own plugin owns.


###Installation

Add the JitPack repository and the dependency. Replace the version with the latest published tag.

<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>

<dependency>
    <groupId>com.github.33drygo</groupId>
    <artifactId>SulfurLab</artifactId>
    <version>1.0.0</version>
    <scope>provided</scope>
</dependency>

Then soft-depend SulfurLab in your plugin.yml:

name: MyPlugin
main: com.example.MyPlugin
version: 1.0
softdepend:   # use depend instead if SulfurLab is required
  - SulfurLab

###Quick start

import dev.drygo.sulfurlab.api.SulfurCubes;
import org.bukkit.Material;
import org.bukkit.entity.SulfurCube;

// A bouncy cube wearing a slime block.
SulfurCube cube = SulfurCubes.bouncy()
        .block(Material.SLIME_BLOCK)
        .spawn(location);

###SulfurCubes

Convenience entry point and physics presets. Everything is static on dev.drygo.sulfurlab.api.SulfurCubes.

INFO

The presets return a SulfurCubeBuilder you can keep tweaking before calling spawn(...) — so SulfurCubes.bouncy().block(Material.SLIME_BLOCK).spawn(loc) is valid.

Entry points
  • ####SulfurCubeBuilder builder()

    A fresh builder with default physics.

  • ####SulfurCube spawn(Location location)

    Spawns a default Sulfur Cube.

  • ####SulfurCube spawn(Location location, Material block)

    Spawns a default cube showing the given block.

SulfurCube cube = SulfurCubes.spawn(location, Material.GOLD_BLOCK);
Presets

Each returns a pre-tuned builder; call .spawn(location) (and tweak further if you like).

Preset Physics Feel
bouncy() bounciness 1.0, friction 1.0, airDrag 0.2 Very springy, keeps bouncing (1.0 is the max bounciness Minecraft allows).
slippery() friction 0.05, bounciness 0.5 Slides far, almost no friction.
floaty() airDrag 0.9, bounciness 0.5 Drifts down slowly, high air drag.
heavy() bounciness 0.0, friction 2.0, airDrag 0.1 Dead weight: no bounce, lots of friction.
SulfurCube slider = SulfurCubes.slippery().spawn(location);

###SulfurCubeBuilder

A fluent builder to configure and spawn a cube, on dev.drygo.sulfurlab.api.SulfurCubeBuilder. Create one with SulfurCubeBuilder.create() or SulfurCubes.builder().

Defaults: bounciness 1.0, friction 1.0, airDrag 0.2, block minecraft:sulfur. size and glowing are left at the vanilla default unless set.

Configuration
  • ####SulfurCubeBuilder bounciness(double value)

    How springy the cube is.

  • ####SulfurCubeBuilder friction(double value)

    How much it slows on surfaces.

  • ####SulfurCubeBuilder airDrag(double value)

    How much the air slows it.

  • ####SulfurCubeBuilder block(Material material) / block(String blockId)

    The block the cube displays (its absorbed block, shown on the BODY equipment slot). Pass null/blank to clear it.

  • ####SulfurCubeBuilder size(int size)

    The cube's size. Left at vanilla default if not set.

  • ####SulfurCubeBuilder glowing(boolean glowing)

    Whether the cube glows. Left as-is if not set.

Spawning & applying
  • ####SulfurCube spawn(Location location)

    Spawns a new cube at the location with this configuration. Throws IllegalArgumentException if the location has no world.
SulfurCube cube = SulfurCubeBuilder.create()
        .bounciness(1.0)
        .friction(0.1)
        .block(Material.SLIME_BLOCK)
        .spawn(location);
  • ####void apply(SulfurCube cube)

    Applies this configuration to an existing cube. Unset size / glowing are left untouched — handy for reconfiguring a cube you already have a reference to.

###How physics maps to Minecraft

Under the hood the builder sets vanilla entity attributes on the Sulfur Cube:

Builder method Attribute
bounciness(...) Attribute.BOUNCINESS
friction(...) Attribute.FRICTION_MODIFIER
airDrag(...) Attribute.AIR_DRAG_MODIFIER
block(...) the EquipmentSlot.BODY item

The same valid ranges as the commands apply — see the Getting Started table (bounciness 0.0–1.0, friction 0.0–10.0, air drag 0.0–100.0).


###Notes

  • The API does not register cubes with the plugin — they won't appear in /sulfurlab list or persist across restarts. Manage those through the plugin commands instead.
  • spawn(...) must run on the main thread, like any Bukkit entity spawn.
  • block(Material) ignores non-item materials; block(String) matches via Material.matchMaterial(...).
  • apply(...) only touches size / glowing when you've set them, so it's safe for partial reconfiguration.

###References