Skip to content

Plugin API (Experimental)

ResourcesTrees provides a Java plugin API that allows other mods to register custom resource types and tree types programmatically.

Experimental

The Plugin API is experimental and may change in future versions. For stability, prefer using config files instead.

Adding the Dependency

ResourcesTrees is published on a Maven repository.

build.gradle (Groovy DSL)

groovy
repositories {
    maven {
        name = "CoolerProMC Maven"
        url = "https://maven.coolerpromc.com/releases"
    }
}

dependencies {
    // Pick the artifact matching your loader:

    // Common (multiloader projects)
    compileOnly "com.coolerpromc.resourcestrees:resourcestrees-common-${minecraft_version}:${resourcestrees_version}"

    // Fabric
    compileOnly "com.coolerpromc.resourcestrees:resourcestrees-fabric-${minecraft_version}:${resourcestrees_version}"

    // NeoForge
    compileOnly "com.coolerpromc.resourcestrees:resourcestrees-neoforge-${minecraft_version}:${resourcestrees_version}"
}

gradle.properties

properties
minecraft_version=26.3
resourcestrees_version=26.3.0.0

Replace 26.3.0.0 with the actual latest version.

Implementing the Plugin

1. Implement IResourcesTreesPlugin

java
public class MyPlugin implements IResourcesTreesPlugin {

    @Override
    public void registerResourcesType(IResourcesTypeRegistry registry) {
        // Register using a specific item
        registry.register(new ResourcesType.Builder("ruby", Items.REDSTONE, 0xFFCC0000)
                .saplingDropChance(0.1f)
                .leafDropChance(0.2f)
                .treeSimulatorTicks(1400));

        // Register using an item tag
        registry.register(new ResourcesType.Builder("logs", ItemTags.LOGS, 0xFF8D6E63));
    }

    @Override
    public void registerTreeType(ITreeTypeRegistry registry) {
        registry.register(new TreeType(
                "oak",                                           // unique name
                "oak",                                           // treeGrowerName
                ResourceLocation.withDefaultNamespace("block/oak_sapling"),  // saplingTexture
                ResourceLocation.withDefaultNamespace("block/oak_leaves"),   // leavesTexture
                "minecraft:oak_sapling",                         // originalSapling
                "minecraft:oak_leaves",                          // originalLeaves
                "minecraft:oak_log",                             // log
                0.01f,                                           // particle chance
                AmbientLeavesBlockSoundPlayer.noAmbientSound()   // leavesBlockSoundPlayer
        ));
    }

    @Override
    public void registerGrowerType(IGrowerTypeRegistry registry) {
        // Reference vanilla tree features directly via TreeFeatures
        registry.register(new GrowerType(
                "oak",                                           // name (matches TreeType#treeGrowerName)
                List.of(                                         // trees
                        new Weighted<>(TreeFeatures.OAK, 9),
                        new Weighted<>(TreeFeatures.FANCY_OAK, 1)),
                List.of(),                                       // megaTrees (may be empty)
                List.of(new Weighted<>(TreeFeatures.OAK_BEES_005, 1)),  // flowerTrees (may be empty)
                Optional.of(TreeFeatures.OAK)                    // shortestTreeType
        ));
    }
}

TIP

You can reference vanilla tree features directly through net.minecraft.data.worldgen.features.TreeFeatures (e.g. TreeFeatures.OAK, TreeFeatures.FANCY_OAK, TreeFeatures.SPRUCE) instead of building a ResourceKey by hand.

2. Register to EntryPoint

NeoForge

Use @ResourcesTreesPlugin annotation.

java
@ResourcesTreesPlugin
public class MyPlugin implements IResourcesTreesPlugin {
}

Fabric

Add resources_trees_plugin entrypoint to fabric.mod.json

json
"entrypoints": {
  "resources_trees_plugin": [
    "com.coolerpromc.resourcestrees.api.internal.InternalResourcesTreesPlugin"
  ]
}

ResourcesType.Builder Parameters

ParameterRequiredDefaultDescription
nameUnique identifier used in block/item registry names
materialItemLike, TagKey<Item>, or RegistryHandler<Item>
colorARGB tint color applied to leaves, sapling, and leaf fragment
saplingDropChance0.125Chance a sapling drops when leaves decay or are broken
leafDropChance0.25Chance a leaf fragment drops from a leaves block
treeSimulatorTicks1200Ticks per Tree Simulator growth cycle
weight5Deprecated — no longer used

TreeType Parameters

ParameterRequiredDefaultDescription
nameUnique identifier (e.g. "oak", "birch")
treeGrowerNameName of the GrowerType used to grow this tree (e.g. "oak", "spruce")
saplingTextureIdentifier of the sapling texture
leavesTextureIdentifier of the leaves texture
originalSaplingRegistry name of the vanilla sapling to copy properties from
originalLeavesRegistry name of the vanilla leaves to copy properties from
logRegistry name of the log block used as the trunk
particle0.01fPer-tick chance (0.01.0) for the leaves block to spawn falling tinted leaf particles
leavesBlockSoundPlayerAmbientLeavesBlockSoundPlayer.noAmbientSound()Controls the ambient rustling sound emitted by the leaves block

TIP

particle and leavesBlockSoundPlayer are new in 26.1.2.111. They are optional when defining a tree type from a config file, but the Java record's canonical constructor requires all parameters — pass 0.01f and AmbientLeavesBlockSoundPlayer.noAmbientSound() to keep the defaults.

GrowerType Parameters

A GrowerType defines which world-gen tree features a sapling can grow into. Its name is referenced by TreeType#treeGrowerName.

ParameterRequiredDefaultDescription
nameUnique identifier, referenced by TreeType#treeGrowerName
treesList<Weighted<ResourceKey<Feature>>> of features used for normal single-sapling trees (must not be empty)
megaTreesList<Weighted<ResourceKey<Feature>>> of features used for 2×2 mega trees (may be empty)
flowerTreesList<Weighted<ResourceKey<Feature>>> of flowering variants, e.g. bee-nest trees (may be empty)
shortestTreeTypeOptional<ResourceKey<Feature>> fallback feature used when there is not enough space for a full tree

Weighted is Minecraft's net.minecraft.util.random.Weighted — wrap each feature key with a weight (new Weighted<>(featureKey, weight)); higher weights are chosen more often.

The GrowerType for a TreeType can also be supplied from a config file without writing code.

Texture for TreeType

Please see tree type textures for more information.

Released under the All Rights Reserved License.