Skip to content
superfluke edited this page Feb 13, 2019 · 13 revisions

Welcome to the treetweaker wiki!

Basic Script Structure

#loader preinit
import mods.treetweaker.TreeFactory;

var newtree = TreeFactory.createTree("fluke_tree"); //create a new tree named 'fluke_tree'
newtree.setTreeType("SPRUCE"); //set which type of tree shape to generate as
newtree.setLog("minecraft:wool:3"); //set optional fields such as what log and leaf blocks to use
newtree.setLeaf("minecraft:melon_block"); //blocks are passed in as a string with optional metadata
newtree.register(); //register tree to add to worldgen

Fields

Field Type Required Default Value Notes
createTree("name") String Yes Name used to identify tree in error logs and sapling naming. Should be all lowercase
setTreeType("OAK") String Yes OAK Tree shape to use. Valid types: OAK, LARGE_OAK, JUNGLE, CANOPY, LARGE_CANOPY, PINE, LARGE_PINE, SPRUCE, LARGE_SPRUCE, ACACIA, RED_MUSHROOM, BROWN_MUSHROOM, BRAIDED, PALM, WILLOW
setLog("minecraft:log") String No minecraft:log The block the trunk of the tree is made of
setLeaf("minecraft:leaves") String No minecraft:leaves The block the tree leaves are made of
setMinHeight(5) int No 5 The minimum height of the tree
setExtraHeight(3) int No 3 Extra height randomly added when tree generates
setGenFrequency(5) int No 5 Used to control how often a tree generates, successfully spawning at a rate of 1 in N attempts
setGenAttempts(1) int No 1 How many trees should try to spawn during a successful generation attempt. Can be used to make clusters of trees
extraThick=false boolean No false Makes tree trunk generate as 2x2 thick. Only valid on LARGE_OAK, PINE, CANOPY, and SPRUCE trees
setGenBiome("minecraft:plains") String No null Specific biome to generate in, ignoring typical biome tree rules. If not set, tree will generate in all biomes that normally contain trees
setGenBiomeByTag("HOT") String No null Biome tag tree can generate in (HOT, SWAMP, SNOWY...), ignoring typical biome tree rules . Will not function unless spawnBiome is null.
setBaseBlock("minecraft:dirt") String No null What block the tree should generate on top of. If not set, will default to blocks valid for vanilla trees (grass, dirt, farmland)
setDimWhitelist(0) int or int[] No null Either single int or array of ints listing dimension IDs the tree may generate in. If null, may generate in any dimension
addSapling() No null Calling this function will add a sapling with the same name provided to createTree. Users must provide their own texture. More Info

Examples

Remember to import

The first lines of your tree script should contain the loader and import lines

#loader preinit
import mods.treetweaker.TreeFactory;

var oak = TreeFactory.createTree("oak");
oak.setTreeType("OAK");
oak.setLog("minecraft:wool:6");
oak.setLeaf("minecraft:stained_glass:2");
oak.setMinHeight(2);
oak.setExtraHeight(8); //add more variation to tree height
oak.setGenFrequency(6); //make tree less frequent
oak.register();


var jungle = TreeFactory.createTree("jungle");
jungle.setTreeType("JUNGLE");
jungle.setLog("minecraft:bone_block");
jungle.setLeaf("minecraft:brown_mushroom_block");
jungle.setGenFrequency(7);
jungle.setMinHeight(10); //make minimum tree size larger
jungle.register();


var deserttree = TreeFactory.createTree("hawt");
deserttree.setTreeType("SPRUCE");
deserttree.setLeaf("minecraft:black_glazed_terracotta");
deserttree.setLog("minecraft:red_sandstone");
deserttree.setGenFrequency(4);
deserttree.setMinHeight(9);
deserttree.setExtraHeight(9);
deserttree.extraThick = true; //will turn this into LARGE_SPRUCE
deserttree.setGenBiome("minecraft:desert"); //only generates in the desert
deserttree.setBaseBlock("minecraft:sand"); //will only generate on sand blocks
deserttree.register();


var largeoak = TreeFactory.createTree("largeoak");
largeoak.setTreeType("LARGE_OAK");
largeoak.setLog("minecraft:wool:3");
largeoak.setLeaf("minecraft:melon_block");
largeoak.extraTreeHeight = 6;
largeoak.minTreeHeight = 15;
largeoak.generationFrequency = 8;
largeoak.extraThick = true; //will make trunk 2x2
largeoak.register();


var rocktree = TreeFactory.createTree("rocktree"); 
rocktree.setLog("minecraft:purpur_block"); 
rocktree.setLeaf("minecraft:packed_ice"); 
rocktree.setTreeType("ACACIA"); 
rocktree.setMinHeight(3); 
rocktree.setGenBiomeByTag("MOUNTAIN"); 
rocktree.setBaseBlock("minecraft:stone"); 
rocktree.register(); 


var redmush = TreeFactory.createTree("redmushroom");
redmush.setTreeType("RED_MUSHROOM");
redmush.setLeaf("minecraft:glowstone");
redmush.setLog("minecraft:stained_hardened_clay:4");
redmush.setGenFrequency(4);
redmush.setMinHeight(9);
redmush.setExtraHeight(9);
redmush.setDimWhitelist([0,1,2,3,4,5,6,7,8,9]); //list of dim IDs ok to generate in, still follows biome rules and needs dirt
redmush.register();


var nethertree = TreeFactory.createTree("quartzmushroom");
nethertree.setTreeType("RED_MUSHROOM");
nethertree.setLeaf("minecraft:quartz_block");
nethertree.setLog("minecraft:obsidian");
nethertree.setMinHeight(6);
nethertree.setExtraHeight(5);
nethertree.setBaseBlock("minecraft:netherrack");
nethertree.setGenBiome("minecraft:hell");
nethertree.setDimWhitelist(-1);
nethertree.register();


var clustertree = TreeFactory.createTree("slimy");
clustertree.setTreeType("ACACIA");
clustertree.setLog("minecraft:sponge");
clustertree.setLeaf("minecraft:slime");
clustertree.setMinHeight(5);
clustertree.setExtraHeight(7);
clustertree.setGenFrequency(8); //spawns less frequently than normal
clustertree.setGenAttempts(5); //tries creating tree 5 times, making clusters of trees
clustertree.register();


//Due to the sheer size of this lad, it can be slow to generate
//Don't over use very tall versions of this
var helix = TreeFactory.createTree("swirlytree");
helix.setTreeType("BRAIDED");
helix.setLog("minecraft:log:1");
helix.setLeaf("minecraft:leaves:3");
helix.setMinHeight(17); //this tree is meant to be tall
helix.setExtraHeight(17);
helix.setGenFrequency(8); //make it not so frequent 
helix.register();


var palmy = TreeFactory.createTree("palmy");
palmy.setTreeType("PALM");
palmy.setLog("minecraft:planks:3");
palmy.setLeaf("minecraft:leaves:3");
palmy.setBaseBlock("minecraft:sand"); 
palmy.setGenBiome("minecraft:beaches");
palmy.register();


var tallcanopy = TreeFactory.createTree("bigcanopyboi");
tallcanopy.setTreeType("LARGE_CANOPY");
tallcanopy.setLog("minecraft:stained_hardened_clay:12");
tallcanopy.setLeaf("minecraft:stained_hardened_clay:5");
tallcanopy.setMinHeight(9);
tallcanopy.setExtraHeight(6);
tallcanopy.register();


var willo = TreeFactory.createTree("willo");
willo.setTreeType("WILLOW");
willo.setLog("minecraft:log2:1");
willo.setLeaf("minecraft:leaves2:1");
willo.setMinHeight(4);
willo.addSapling();
willo.register();

Clone this wiki locally