Maintainers
Pricing
Enterprise
More
More
Documentation
Try Live
Rankings
Install
Blog
Docs7
Ask
New
Add Docs
Jade
https://jademc.readthedocs.io/en/latest/
Admin
Jade is a developer wiki for a Minecraft mod, providing documentation on its features,
...
Tokens:
6,007
Snippets:
84
Trust Score:
8.3
Update:
5 months ago
Context
Chat
Benchmark
78.56
Latest
Show doc for...
Code
Info
Show Results
Tokens:
Raw
Copy
Link
Tokens:
Raw
Copy
Link
### Create a Block Component Provider Source: https://jademc.readthedocs.io/en/latest/plugins22/getting-started Implement IBlockComponentProvider to append custom information to tooltips for specific blocks. This example adds a fuel-related line to furnaces. ```java package snownee.jade.test; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import snownee.jade.api.BlockAccessor; import snownee.jade.api.IBlockComponentProvider; import snownee.jade.api.ITooltip; import snownee.jade.api.config.IPluginConfig; public class ExampleComponentProvider implements IBlockComponentProvider { public static final ExampleComponentProvider INSTANCE = new ExampleComponentProvider(); @Override public void appendTooltip( ITooltip tooltip, BlockAccessor accessor, IPluginConfig config ) { tooltip.add(Component.translatable("mymod.fuel")); } @Override public ResourceLocation getUid() { return ExamplePlugin.FURNACE_FUEL; } } ``` -------------------------------- ### Common Theme Properties Source: https://jademc.readthedocs.io/en/latest/themes/v3 Configures various common properties for a theme, including color schemes, text styles, box styles, opacity, round corners, and auto-enable settings. This example shows how to set text colors and other visual aspects. ```json { // background color is light "lightColorScheme": true, // change the text style "text": { "colors": { "title": "#000000", "normal": "#444444", "info": "#000000", "success": "#198754", "warning": "#FFC107", "danger": "#DC3545", "failure": "#AB296A" }, "shadow": true, "modNameStyle": { "italic": false } }, "tooltipStyle": { /* box style */ }, "nestedBoxStyle": { /* text style */ }, "viewGroupStyle": { /* box style */ }, // default background opacity "changeOpacity": 1, // turn on/off the round border after switching to this theme // do limited effect on theme with background image. in that case, it's recommended to set this to false "changeRoundCorner": false, // automatically enable this theme when the resource pack is enabled "autoEnable": true, // add a frame around the icon "iconSlotSprite": "nine-slice sprite", "iconSlotInflation": -2 } ``` -------------------------------- ### Display Item Icon in Tooltip (Java) Source: https://jademc.readthedocs.io/en/latest/plugins22/getting-started Add a small item icon to the tooltip using `JadeUI.smallItem`. This example shows how to display a clock icon alongside the fuel information. ```java @Override public void appendTooltip( ITooltip tooltip, BlockAccessor accessor, IPluginConfig config ) { Optional<Integer> fuel = ExampleDataProvider.INSTANCE.decodeFromData(accessor); if (fuel.isPresent()) { Element icon = JadeUI.smallItem(new ItemStack(Items.CLOCK)); tooltip.add(icon); tooltip.append(Component.translatable("mymod.fuel", fuel.get())); } } ``` -------------------------------- ### Add Translations in JSON Source: https://jademc.readthedocs.io/en/latest/plugins22/getting-started Define translations for your modded elements in a JSON file. This example includes translations for configuration and the fuel display. ```json { "config.jade.plugin_mymod.furnace_fuel": "Test", "mymod.fuel": "Fuel: %d ticks" } ``` -------------------------------- ### Implement Client Component Provider in Java Source: https://jademc.readthedocs.io/en/latest/plugins22/getting-started Implement `IBlockComponentProvider` on the client to receive and display synced data. Decodes data using `ExampleDataProvider.INSTANCE.decodeFromData` and adds it to the tooltip. ```java package snownee.jade.test; import java.util.List; import java.util.Optional; import net.minecraft.client.gui.components.Button; import net.minecraft.network.chat.ClickEvent; import net.minecraft.network.chat.CommonComponents; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.HoverEvent; import net.minecraft.network.chat.Style; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import snownee.jade.Jade; import snownee.jade.api.BlockAccessor; import snownee.jade.api.IBlockComponentProvider; import snownee.jade.api.ITooltip; import snownee.jade.api.JadeIds; import snownee.jade.api.config.IPluginConfig; import snownee.jade.api.ui.Element; import snownee.jade.api.ui.JadeUI; import snownee.jade.gui.LayoutWithPadding; public class ExampleComponentProvider implements IBlockComponentProvider { public static final ExampleComponentProvider INSTANCE = new ExampleComponentProvider(); @Override public void appendTooltip( ITooltip tooltip, BlockAccessor accessor, IPluginConfig config ) { Optional<Integer> fuel = ExampleDataProvider.INSTANCE.decodeFromData(accessor); if (fuel.isPresent()) { tooltip.add(Component.translatable("mymod.fuel", fuel.get())); } } @Override public ResourceLocation getUid() { return ExamplePlugin.FURNACE_FUEL; } } ``` -------------------------------- ### Registering Secondary Options Source: https://jademc.readthedocs.io/en/latest/plugins22/plugin-config This snippet shows how to register a sub-option under a parent configuration option. ```java var parentId = ResourceLocation.fromNamespaceAndPath("examplemod", "parent"); registration.addConfig(ResourceLocation.fromNamespaceAndPath("examplemod", "parent.suboption"), true); ``` -------------------------------- ### Implement Server Data Provider in Java Source: https://jademc.readthedocs.io/en/latest/plugins22/getting-started Implement `StreamServerDataProvider` to sync data like furnace burn time from the server to the client. Uses `StreamCodec` for encoding/decoding. Requires access to protected fields via Access Transformers or Wideners. ```java package snownee.jade.test; import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.network.codec.ByteBufCodecs; import net.minecraft.network.codec.StreamCodec; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.level.block.entity.AbstractFurnaceBlockEntity; import org.jetbrains.annotations.Nullable; import snownee.jade.api.BlockAccessor; import snownee.jade.api.StreamServerDataProvider; public class ExampleDataProvider implements StreamServerDataProvider<BlockAccessor, Integer> { public static final ExampleDataProvider INSTANCE = new ExampleDataProvider(); @Override public @Nullable Integer streamData(BlockAccessor accessor) { return ((AbstractFurnaceBlockEntity) accessor.getBlockEntity()).litTimeRemaining; } @Override public StreamCodec<RegistryFriendlyByteBuf, Integer> streamCodec() { return ByteBufCodecs.VAR_INT.cast(); } @Override public ResourceLocation getUid() { return ExamplePlugin.FURNACE_FUEL; } } ``` -------------------------------- ### Background Image Theme Configuration Source: https://jademc.readthedocs.io/en/latest/themes/v3 Defines a theme using a background image sprite for tooltips. Specify the sprite name for the main background and optionally for when an icon is present. ```json { "version": 100, "tooltipStyle": { // the main background nine-slice image "sprite": "jade_stardew:stardew_valley", // optional, when there is icon present, use this sprite instead. "withIconSprite": "jade_stardew:stardew_valley" } } ``` -------------------------------- ### Marking Option as Client Feature Source: https://jademc.readthedocs.io/en/latest/plugins22/plugin-config Use this method to designate a configuration option as a client feature, meaning it can operate independently of server data. ```java registration.markAsClientFeature(optionId); ``` -------------------------------- ### Gradient Border Theme Configuration Source: https://jademc.readthedocs.io/en/latest/themes/v3 Defines a theme with gradient borders for tooltips. Use this to customize the appearance of tooltips with colored borders. Colors can be specified in hex or RGBA format. ```json { "version": 100, "tooltipStyle": { // optional, transparent by default "backgroundColor": "#131313", "borderColor": [ // top-left "#383838", // top-right "#383838", // bottom-right "#242424FF", // bottom-left "#242424FF" ], // optional "borderWidth": 1, // optional "roundCorner": true } } ``` -------------------------------- ### Registering Boolean and String Options Source: https://jademc.readthedocs.io/en/latest/plugins22/plugin-config Use this to register boolean and string configuration options for your plugin. For string options, a validation function can be provided to ensure valid resource locations. ```java registration.addConfig(optionId, true); // IWailaConfig.get().getPlugin().get(optionId); optionId = ResourceLocation.fromNamespaceAndPath("examplemod", "string_option"); registration.addConfig(optionId, "minecraft:apple", ResourceLocation::isValidResourceLocation); registration.addConfigListener(optionId, id -> System.out.println("Changed to: " + IWailaConfig.get().getPlugin().getString(id))); ``` -------------------------------- ### Register Server Data Provider in Java Source: https://jademc.readthedocs.io/en/latest/plugins22/getting-started Register your custom `IServerDataProvider` instance with Jade using `registration.registerBlockDataProvider`. ```java @Override public void register(IWailaCommonRegistration registration) { registration.registerBlockDataProvider(ExampleDataProvider.INSTANCE, AbstractFurnaceBlockEntity.class); } ``` -------------------------------- ### Register a Block Component Provider Source: https://jademc.readthedocs.io/en/latest/plugins22/getting-started Register your custom block component provider within the `registerClient` method of your `IWailaPlugin`. This associates the provider with specific block classes. ```java @Override public void registerClient(IWailaClientRegistration registration) { registration.registerBlockComponent(ExampleComponentProvider.INSTANCE, AbstractFurnaceBlock.class); } ``` -------------------------------- ### Add Item Stack as Tooltip Icon Source: https://jademc.readthedocs.io/en/latest/changes/117 Use IElementHelper to add an item stack as an icon in the tooltip. Ensure itemStack is a valid ItemStack object. ```java IElementHelper helper = tooltip.getElementHelper(); tooltip.add(helper.item(itemStack)); ``` -------------------------------- ### Fabric Mod JSON Entrypoint Source: https://jademc.readthedocs.io/en/latest/plugins22/getting-started For Fabric users, specify the entrypoint for your Jade plugin in the fabric.mod.json file. This allows Fabric to discover and load your plugin. ```json { "entrypoints": { "jade": [ "full.class.path.to.ExamplePlugin" ] } } ``` -------------------------------- ### Basic Jade Plugin Structure Source: https://jademc.readthedocs.io/en/latest/plugins22/getting-started Implement the IWailaPlugin interface to register common and client-side elements for your Jade plugin. This includes registering data providers and component providers. ```java package snownee.jade.test; import snownee.jade.api.IWailaClientRegistration; import snownee.jade.api.IWailaCommonRegistration; import snownee.jade.api.IWailaPlugin; import snownee.jade.api.WailaPlugin; @WailaPlugin public class ExamplePlugin implements IWailaPlugin { @Override public void register(IWailaCommonRegistration registration) { //TODO register data providers and hiding things here } @Override public void registerClient(IWailaClientRegistration registration) { //TODO register component providers, icon providers, callbacks, and config options here } } ``` -------------------------------- ### Add Jade Dependency for NeoForge Source: https://jademc.readthedocs.io/en/latest/plugins22/getting-started Configure your build.gradle file to include the Jade library for NeoForge mod development. Ensure you use the correct version from Modrinth. ```gradle repositories { maven { url = "https://api.modrinth.com/maven" } } dependencies { // jade_version example: 15.10.0+neoforge // Visit https://modrinth.com/mod/jade/versions?l=neoforge to get the latest version implementation "maven.modrinth:jade:${project.jade_version}" } ``` -------------------------------- ### Use Pick Result as Target Name, Icon, and Mod Name Source: https://jademc.readthedocs.io/en/latest/plugins22/hiding-target Configure Waila to use the 'pick' result for the target's name, icon, and mod name. This is commonly used for blocks like player heads. ```java @Override public void register(IWailaCommonRegistration registration) { registration.blockOperations().pick(Blocks.PLAYER_HEAD); } ``` -------------------------------- ### Theme Naming for Localization Source: https://jademc.readthedocs.io/en/latest/themes/v3 Provides the translation key for a theme name, used for displaying the theme's name in the game's UI. This JSON snippet maps an internal identifier to a user-facing string. ```json { "jade.theme.jade_stardew.stardew_valley": "Stardew Valley" } ``` -------------------------------- ### Checking if Option is Client Feature Source: https://jademc.readthedocs.io/en/latest/plugins22/plugin-config This code checks whether a given configuration option has been marked as a client feature. ```java registration.isClientFeature(optionId); // true ``` -------------------------------- ### Add Text Element with Identifier Source: https://jademc.readthedocs.io/en/latest/changes/117 A simplified shorthand to add a text element with an identifier to the tooltip. Ensure text is a String and identifier is a Identifier object. ```java tooltip.add(text, identifier); ``` -------------------------------- ### Tag Text Element in Tooltip Source: https://jademc.readthedocs.io/en/latest/changes/117 Tag a text element with a specific identifier using IElementHelper. Ensure text is a String and identifier is a Identifier object. ```java IElementHelper helper = tooltip.getElementHelper(); tooltip.add(helper.text(text).tag(identifier)); ``` -------------------------------- ### Add Jade Dependency for Fabric Source: https://jademc.readthedocs.io/en/latest/plugins22/getting-started Configure your build.gradle file to include the Jade library for Fabric mod development. Ensure you use the correct version from Modrinth. ```gradle repositories { maven { url = "https://api.modrinth.com/maven" } } dependencies { // jade_version example: 15.10.0+fabric // Visit https://modrinth.com/mod/jade/versions?l=fabric to get the latest version modImplementation "maven.modrinth:jade:${project.jade_version}" } ``` -------------------------------- ### Box Style Properties Source: https://jademc.readthedocs.io/en/latest/themes/v3 Defines common properties for box styling, including padding, offset for box progress bars, and colors for the progress bar. Use this to customize the visual layout and appearance of boxes within the theme. ```json { "padding": [ 6, 7, 6, 6 ], // a box progress is a progress bar that attached to the box, similar to the block breaking progress bar "boxProgressOffset": [ -1, -2, -1, 2 ], "boxProgressColors": { "normal": "#FFFFFF", "failure": "#FF4444" // ... } } ``` -------------------------------- ### Override Grass Block to TNT Block Source: https://jademc.readthedocs.io/en/latest/plugins22/overrides This callback replaces the grass block with a TNT block during ray tracing. It requires the `IWailaClientRegistration` interface. ```java @Override public void registerClient(IWailaClientRegistration registration) { registration.addRayTraceCallback((hitResult, accessor, originalAccessor) -> { if (accessor instanceof BlockAccessor blockAccessor && blockAccessor.getBlock() == Blocks.GRASS_BLOCK) { return registration.blockAccessor() .from(blockAccessor) .blockState(Blocks.TNT.defaultBlockState()) .build(); } return accessor; }); } ``` -------------------------------- ### Add Mod Name Translation Source: https://jademc.readthedocs.io/en/latest/datapacks/block22 Provide translations for your mod's name in the en_us.json file. This ensures Jade displays your mod name correctly. ```json { "jade.modName.mymod": "My Mod", "itemGroup.mymod": "My Mod (alternative)" } ``` -------------------------------- ### Adjusting Line Spacing in Tooltips Source: https://jademc.readthedocs.io/en/latest/changes/121 Use `tooltip.setLineMargin` to modify the spacing between lines in a tooltip. Negative values reduce or remove existing spacing. This is useful for fine-tuning the visual appearance of tooltips. ```java tooltip.setLineMargin(-1, ScreenDirection.UP, -2); ``` -------------------------------- ### Add Custom Element to Tooltip Source: https://jademc.readthedocs.io/en/latest/changes/117 Add a custom IElement to the tooltip. Ensure MyElement implements the IElement interface. ```java tooltip.add(new MyElement()); ``` -------------------------------- ### Assign Block ID with $jade:stack Tag Source: https://jademc.readthedocs.io/en/latest/datapacks/block22 Add this tag to your item's custom data to assign a unique ID for Jade to recognize. This ID is used for displaying the correct mod name and looking up recipes. ```json { "$jade:stack": { "id": "mymod:my_block" } } ``` -------------------------------- ### Hide Blocks and Entity Types Source: https://jademc.readthedocs.io/en/latest/plugins22/hiding-target Use this method to prevent Waila from displaying specific blocks or entity types. This is useful for elements that do not require Waila's detailed information. ```java @Override public void register(IWailaCommonRegistration registration) { registration.blockOperations().hide(Blocks.BARRIER); registration.entityTypeOperations().hide(EntityType.AREA_EFFECT_CLOUD); } ```