MCTantrum Wiki
  • MCTantrum
  • 🍕General
    • Rules
      • Auto-Clickers and AFK
      • Alt Accounts
    • Policies
      • Replacement Policy
      • Referrals
    • Voting
    • Server Resource Pack
      • Craftables
      • Custom Building Blocks
      • Calamity
        • Fusion Catalysts
        • Swords
        • Axes
        • Pickaxes
        • Fishing Rods
        • Bows
        • Crossbows
      • ❌DEPRECATED - Pokemon
        • ❌DEPRECATED - PokeCache
        • ❌DEPRECATED - Breeding and Incense
        • ❌DEPRECATED - Quests
      • Slimefun Textures
    • Commands
      • Basic Commands
      • McMMO Commands
      • Lands
      • Economy Related Commands
      • Slimefun Commands
      • Plugin Specific/Misc
      • Permission Based
    • Land Claims
    • Custom Crafting
      • Minecraft +
      • Key Fragments
      • Spawner Keys
      • ❌DEPRECATED - Summoning
      • Shiny Wares
      • Misc
    • Enchantments
      • AdvancedEnchantments (AE)
        • Enchantments List
    • Mob and Item Stacking
    • Worlds
      • Overworld
      • Nether
      • The End
      • Resource World
      • 🆕Badlands
        • 🆕Elite Mobs
    • Dragons
      • Loot Tables
    • Tips and Info
  • 🏆Ranks
    • Ranks
      • Default (new player)
      • Chicken
      • Sheep
      • Turtle
      • Strider
      • Panda
      • Wolf
      • Spider
      • Piglin
      • Husk
      • Creeper
      • Ravager
      • Guardian
      • Blaze
      • Wither
      • Dragon
      • Cod
    • Prestige Ranks
  • ⚔️Tantrum Gear Progression
    • Crate Key and Upgrade Tokens
    • Tier 1 - Tantrum
      • Tantrum Coif
      • Tantrum Plate
      • Tantrum Wings
      • Tantrum Pants
      • Tantrum Greaves
      • Bobby the Rat
      • Tantrum Blade
      • Tantrum Bow
      • Tantrum Crossbow
      • Tantrum Trident
      • Tantrum Pick
      • Tantrum Shovel
      • Tantrum Hoe
      • Tantrum Pole
    • Tier 2 - Polished
      • Polished Crown
      • Polished Chestpiece
      • Polished Wings
      • Polished Platelegs
      • Polished Warboots
      • Polished Battleaxe
      • Polished Claymore
      • Polished Longbow
      • Polished Recurve Crossbow
      • Polished Javelin
      • Polished Earth-Grinder
      • Polished Spade
      • Polished Hoe
      • Polished Pole
    • Tier 3 - Pristine
      • Pristine Greathelm
      • Pristine Battleplate
      • Pristine Wings
      • Pristine Legguards
      • Pristine Sabatons
      • Pristine Broadaxe
      • Pristine Gladius
      • Pristine Compound Bow
      • Pristine Compound Crossbow
      • Pristine Pikestaff
      • Pristine Terraformer
      • Pristine Excavator
      • Pristine Hoe of Loyalty
      • Pristine Pole
  • 💰Economy
    • Dynamic Shop and Auction House
    • Sign Shop, Plots, and Warps
    • Bits, Heads, and Spawners
    • Crates
      • Spawner Crate
      • Specific Spawner Crates
      • Vote Crate
        • Fusion Catalyst Voucher
        • Wheel of Fortune
      • Mystery Crate
      • Ω Mystery Crate
      • Slimefun Crate
      • Slimefun Junior Crate
      • Spawn Egg Crate
      • Tantrum Crate
      • Poggy Crate
      • Brewery Crate
      • Armory Crate
      • Head Accessories Crate
    • Tokens and Tokenshop
      • Charms
      • AE Items
      • Calamity Voucher
      • Job Boosters
  • 💡Things to Do
    • Dungeons
      • The Forsaken Chambers
      • Forgotten Mine
      • Slimefun Scourge
    • Events
    • Delves
      • Level 1
      • Level 2
      • Level 3
      • Level 4
      • Level 5
      • Level 6
      • Level 7
    • Quests
    • Brewery
    • ArtMap
  • 🟩Slimefun
    • Slimefun
      • (Research Groups)
      • Weapons
      • Useful Items
      • Basic Machines
      • Tools
      • Resources
        • Dusts
        • Ingots
        • Alloy Ingots
        • Irradiated Materials
        • Valuables and Misc
      • Food
      • Magical Items
      • Magical Armor
      • Technical Components
      • Miscellaneous Items
      • Armor
      • Talismans (Tier I)
      • Magical Gadgets
      • Technical Gadgets
      • Ender Talismans (Tier II)
      • Energy and Electricity
      • GPS-based Machines
      • Programmable Androids
      • Cargo Management
    • Addons
      • Advancements
      • Dyed Backpacks
      • Supreme Expansion
      • Lucky Blocks
      • LiteXpansion
      • Slimefun Ore Chunks
      • Fluffy Machines
      • Sensible Toolbox (STB)
        • Access Control
        • API
          • Overview
          • Method Overriding
        • Changelog
        • Commands
        • Configuration
        • Credits
        • Item Reference
        • Items
          • Basic
          • Building
          • Components
          • Ender Storage
          • Energy
          • Farming
          • Machines
          • Painting
          • Routing
          • Storage
        • Permissions
        • Protection
        • Quick Start Guide
        • Roadmap
        • Videos
      • Infinity Expansion
        • Infinity Materials
        • Basic Machines
        • Advanced Machines
        • Storage
        • Mob Simulation
        • Singularity Materials
        • Infinity Recipes
      • Networks
      • SlimeTinker
      • Crystamae Historia
      • Tantrum Gizmos (Slime Customizer)
      • SFCalc
Powered by GitBook
On this page
  • Add STB as a Build Dependency
  • Add a plugin.yml dependency
  • Defining a Custom Item/Block Class
  • Hooking SensibleToolbox and Registering your Item(s)
  • An Example Plugin

Was this helpful?

  1. Slimefun
  2. Addons
  3. Sensible Toolbox (STB)
  4. API

Overview

PreviousAPINextMethod Overriding

Last updated 2 years ago

Was this helpful?

STB offers an API to make it easy for other plugins to define their own custom items and blocks, and benefit from STB's framework of automated event routing, energy system, GUI methods and block persistence.

As of v0.0.4 the API has settled down somewhat and later versions of STB should (hopefully!) not introduce any API breakage without good warning via deprecation.

The basic steps to creating an STB-based plugin are:

  1. Add SensibleToolbox as a build dependency to your plugin

  2. Add a dependency on SensibleToolbox (soft or hard, depends on how you're using STB) in your plugin's plugin.yml file

  3. Define your custom item/block class(es) in your plugin

  4. Attempt to hook SensibleToolbox in your plugin's onEnable() method

  5. If you successfully hook SensibleToolbox, register your custom item/block class(es) with a simple API call

The above steps will now be explained in more detail...

Add STB as a Build Dependency

If you build your plugin with Maven (recommended!), just add these lines to your pom.xml:

<!--add this to your repositories section -->
<repository>
  <id>hawkfalcon-repo</id>
  <name>Hawkfalcon Repository</name>
  <url>http://ci.hawkfalcon.com/plugin/repository/everything</url>
</repository>

<!--add this to your dependencies section -->
<dependency>
  <groupId>me.desht</groupId>
  <artifactId>sensibletoolbox</artifactId>
  <version>0.0.4</version>
  <scope>provided</scope>
</dependency>

I recommend using an explicit <version> number there. The current release version at time of writing is 0.0.4.

Add a plugin.yml dependency

Easy enough; just add this line to your plugin.yml:

depend: [ ProtocolLib, SensibleToolbox ]

or if your plugin already depends on other plugins, add it to the list:

depend: [ ProtocolLib, SensibleToolbox ]

Defining a Custom Item/Block Class

This is most complex part. Defining a new STB item or block basically consists of creating a class which extends one of the existing base classes provided by SensibleToolbox, overriding several mandatory methods, and optionally overriding many more methods. The useful base classes to extend are:

The Javadocs contain a full reference of the methods which must be or may be overridden in your new subclass.

Hooking SensibleToolbox and Registering your Item(s)

You'll want to use code similar to the following in your onEnable():

public void onEnable() {
  // ... do other stuff

  Plugin stb = pm.getPlugin("SensibleToolbox");
  if (stb != null && stb.isEnabled()) {
    SensibleToolbox.getItemRegistry().registerItem(this, new YourCustomItemClass());
  }

  // ...
}

An Example Plugin

The STBTest plugin has been created to use as a testbed for hooking into Sensible Toolbox, but also to serve as example code on how the Sensible Toolbox API can be used:

  • https://github.com/desht/stbtest/

So far, only one new item has been added, the Lightning Gun: https://github.com/desht/stbtest/blob/master/src/main/java/me/desht/stbtest/LightningGun.java - the code is heavily commented and worth browsing to get an idea of how a simple STB item would be created. It includes concepts such as freezing/thawing item data, storing and using SCU, and using custom STB ingredients in its crafting recipe.

If you don't use Maven, you'll need to and manually add it as a build dependency in your IDE.

BaseSTBItem - extend this class if your new item is just an item, and not placeable in the world as a block. Example:

BaseSTBBlock - extend this class if your new item is a generic block (but read on for more specific types of block). Example:

BaseSTBMachine - extend this class if your new item is a generic machine, with input/output slots, an energy cell slot and can be charged with SCU. Example:

AbstractProcessingMachine - extend this class if your machine will have a progress bar to indicate its progress. Note that this can also be used to indicate any kind of numeric quantity, e.g. see (the processing indicator here shows the number of items in the BSU)

AbstractIOMachine - extend this class if your machine does simple input->output item processing, with possible custom recipes. Example:

🟩
API Javadocs
download the desired version of SensibleToolbox.jar
https://github.com/desht/sensibletoolbox/blob/master/src/main/java/me/desht/sensibletoolbox/items/TapeMeasure.java
https://github.com/desht/sensibletoolbox/blob/master/src/main/java/me/desht/sensibletoolbox/blocks/RedstoneClock.java
https://github.com/desht/sensibletoolbox/blob/master/src/main/java/me/desht/sensibletoolbox/blocks/machines/FiftyKBatteryBox.java
https://github.com/desht/sensibletoolbox/blob/master/src/main/java/me/desht/sensibletoolbox/blocks/machines/BigStorageUnit.java
https://github.com/desht/sensibletoolbox/blob/master/src/main/java/me/desht/sensibletoolbox/blocks/machines/Masher.java