Skip to content

Using BlockStates

Chris edited this page Dec 19, 2020 · 2 revisions

BiomeTweaker 3.1 has changed the way you should handle blocks in scripts. Previously, all commands accepted a string for the block's resource location and, optionally, a metadata value. Script commands will still accept resource locations for blocks, but if you wish to specify metadata, you must do it through the property system.

Block Objects

Suppose we wanted to use andesite in one of our scripts. To get started, we must first create a block object. To do this, all you need is the resource location of the base block. Andesite is a variant of stone, so we use "minecraft:stone":

myBlock = forBlock("minecraft:stone")

That's it! We're now ready to modify our block object. Below I will detail the numerous amount of commands available to you.

setProperty

This command is used to set a property of a block object. Properties are inherent to blockstates and are the preferred way to specify blockstates. Each property has a string key and a value. To use this command, you will need both.

Example:

blockStGlass.setProperty("color", "BLUE")

Whew! That was a lot of commands, huh? Back to our andesite example, the property we're looking for is "variant" and the value is "andesite". There are several ways to look this up. The Minecraft wiki will have most of them for vanilla blocks. Otherwise you can find this information in the in-game debug overlay. You'll be looking for this section on the minecraft wiki:

So, to set the property, we need to simply write:

myBlock.setProperty("variant", "andesite")

That's it! We can now use this object whenever we want to use andesite in scripts. Here's a full example:

allB = forAllBiomes()
myBlock = forBlock("minecraft:stone")
myBlock.setProperty("variant", "andesite")
allB.registerGenBlockRep("minecraft:stone", myBlock)

BiomeTweaker has been updated to 1.18. Please see the links below. Pages for previous versions can be found above.


BiomeTweaker 1.18

Features and Carvers

Custom Mob Effects

Example Scripts

Clone this wiki locally