<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://forge.gemwire.uk/index.php?action=history&amp;feed=atom&amp;title=BlockStates%2F1.16</id>
	<title>BlockStates/1.16 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://forge.gemwire.uk/index.php?action=history&amp;feed=atom&amp;title=BlockStates%2F1.16"/>
	<link rel="alternate" type="text/html" href="https://forge.gemwire.uk/index.php?title=BlockStates/1.16&amp;action=history"/>
	<updated>2026-05-01T18:23:44Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.0</generator>
	<entry>
		<id>https://forge.gemwire.uk/index.php?title=BlockStates/1.16&amp;diff=2683&amp;oldid=prev</id>
		<title>ShrimpBot: Copy BlockStates to MC1.16 archive</title>
		<link rel="alternate" type="text/html" href="https://forge.gemwire.uk/index.php?title=BlockStates/1.16&amp;diff=2683&amp;oldid=prev"/>
		<updated>2021-07-27T03:58:00Z</updated>

		<summary type="html">&lt;p&gt;Copy &lt;a href=&quot;/wiki/BlockStates&quot; title=&quot;BlockStates&quot;&gt;BlockStates&lt;/a&gt; to MC1.16 archive&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Introduction of States ==&lt;br /&gt;
&lt;br /&gt;
The block state system abstracts out the details of the block's properties from the other behaviors of the block.&lt;br /&gt;
&lt;br /&gt;
Each &amp;lt;code&amp;gt;property&amp;lt;/code&amp;gt; of a block is described by an instance of &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;Property&amp;lt;?&amp;gt;&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;. Examples of block properties include instruments (&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;Property&amp;lt;NoteBlockInstrument&amp;gt;&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;), direction (&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;Property&amp;lt;Direction&amp;gt;&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;), poweredness (&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;Property&amp;lt;Boolean&amp;gt;&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;), etc. Each property has the value of the type &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;T&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; parametrized by &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;Property&amp;lt;T&amp;gt;&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
A unique triple can be constructed from the &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;Block&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;, the set of &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;Property&amp;lt;?&amp;gt;&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;, and the set of values for those properties. This unique triple is called a &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;BlockState&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;. For example, a stone button which is facing east and is powered or held down is represented by &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;minecraft:stone_button[facing=east,powered=true]&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Proper Usage of Block States ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;BlockState&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; is a flexible and powerful system, but it also has limitations. &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;BlockState&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;s are immutable, and all combinations of their properties are generated on startup of the game. This means that having a &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;BlockState&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; with many properties and possible values will slow down the loading of the game, and befuddle anyone trying to make sense of your block logic.&lt;br /&gt;
&lt;br /&gt;
Not all blocks and situations require the usage of &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;BlockState&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;; only the most basic properties of a block should be put into one, and any other situation is better off with having a &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;TileEntity&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; or being a separate &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;Block&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;. Always consider if you actually need to use a state for your purposes.&lt;br /&gt;
&lt;br /&gt;
{{Colored box|title=Tip|content=A good rule of thumb is: '''if it has a different name, it should be a separate block'''.}}&lt;br /&gt;
&lt;br /&gt;
An example is making chair blocks: the ''direction'' of the chair should be a ''property'', while the different ''types of wood'' should be separated into different blocks.&lt;br /&gt;
An &amp;quot;Oak Chair&amp;quot; facing east (&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;oak_chair[facing=east]&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;) is different from a &amp;quot;Spruce Chair&amp;quot; facing west (&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;spruce_chair[facing=west]&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
== Implementing Block States ==&lt;br /&gt;
&lt;br /&gt;
In your Block class, create or reference &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;static final&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;Property&amp;lt;?&amp;gt;&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; objects for every property that your Block has. You are free to make your own &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;Property&amp;lt;?&amp;gt;&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; implementations, but the means to do that are left as an exercise to the reader. The vanilla code provides several convenience implementations:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;IntegerProperty&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Implements &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;Property&amp;lt;Integer&amp;gt;&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;. Defines a property that holds an integer value.&lt;br /&gt;
** Created by calling &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;IntegerProperty.create(String propertyName, int minimum, int maximum)&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;.&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;BooleanProperty&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Implements &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;Property&amp;lt;Boolean&amp;gt;&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;. Defines a property that holds a &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;true&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;false&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; value.&lt;br /&gt;
** Created by calling &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;BooleanProperty.create(String propertyName)&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;.&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;EnumProperty&amp;lt;E extends Enum&amp;lt;E&amp;gt;&amp;gt;&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Implements &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;Property&amp;lt;E&amp;gt;&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;. Defines a property that can take on the values of an Enum class.&lt;br /&gt;
** Created by calling &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;EnumProperty.create(String propertyName, Class&amp;lt;E&amp;gt; enumClass)&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;.&lt;br /&gt;
** It is also possible to use only a subset of the Enum values (e.g. &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;RailShape&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;s that can only ascend and not turn). See the overloads of &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;EnumProperty.create&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;.&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;DirectionProperty&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
** This is a convenience implementation of &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;EnumProperty&amp;lt;Direction&amp;gt;&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
** Several convenience predicates are also provided. For example, to get a property that represents the cardinal directions, call &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;DirectionProperty.create(&amp;quot;&amp;lt;name&amp;gt;&amp;quot;, Direction.Plane.HORIZONTAL)&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;; to get the X directions, &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;DirectionProperty.create(&amp;quot;&amp;lt;name&amp;gt;&amp;quot;, Direction.Axis.X)&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The class &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;BlockStateProperties&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; contains shared vanilla properties which should be used or referenced whenever possible, in place of creating your own properties.&lt;br /&gt;
&lt;br /&gt;
When you have your desired &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;Property&amp;lt;&amp;gt;&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; objects, override &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;Block#fillStateContainer(StateContainer$Builder)&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; in your ''Block'' class. In that method, call &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;StateContainer$Builder#add(...);&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;  with the parameters as every &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;Property&amp;lt;?&amp;gt;&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; you wish the block to have.&lt;br /&gt;
&lt;br /&gt;
Every block will also have a &amp;quot;default&amp;quot; state that is automatically chosen for you. You can change this &amp;quot;default&amp;quot; state by calling the &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;Block#setDefaultState(BlockState)&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; method from your constructor. When your block is placed it will become this &amp;quot;default&amp;quot; state. An example from &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;DoorBlock&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
this.setDefaultState(&lt;br /&gt;
    this.stateContainer.getBaseState()&lt;br /&gt;
        .with(FACING, Direction.NORTH)&lt;br /&gt;
        .with(OPEN, false)&lt;br /&gt;
        .with(HINGE, DoorHingeSide.LEFT)&lt;br /&gt;
        .with(POWERED, false)&lt;br /&gt;
        .with(HALF, DoubleBlockHalf.LOWER)&lt;br /&gt;
);&lt;br /&gt;
&amp;lt;/syntaxhighlight &amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you wish to change what &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;BlockState&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; is used when placing your block, you can overwrite &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;Block#getStateForPlacement(BlockItemUseContext)&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;. This can be used to, for example, set the direction of your block depending on where the player is standing when they place it.&lt;br /&gt;
&lt;br /&gt;
Because &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;BlockState&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;s are immutable, and all combinations of their properties are generated on startup of the game, calling &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;BlockState#with(IProperty&amp;lt;T&amp;gt;, T)&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; will simply go to the &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;Block&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;'s &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;StateContainer&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; and request the &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;BlockState&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; with the set of values you want.&lt;br /&gt;
&lt;br /&gt;
Because all possible &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;BlockState&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;s are generated at startup, you are free and encouraged to use the reference equality operator (&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;==&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;) to check if two &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;BlockState&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;s are equal.&lt;br /&gt;
&lt;br /&gt;
== Using &amp;lt;tt&amp;gt;BlockState&amp;lt;/tt&amp;gt;s ==&lt;br /&gt;
&lt;br /&gt;
You can get the value of a property by calling &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;BlockState#get(IProperty&amp;lt;?&amp;gt;)&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;, passing it the property you want to get the value of.&lt;br /&gt;
If you want to get a &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;BlockState&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; with a different set of values, simply call &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;BlockState#with(IProperty&amp;lt;T&amp;gt;, T)&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; with the property and its value.&lt;br /&gt;
&lt;br /&gt;
You can get and place &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;BlockState&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;s in the world using &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;World#setBlockState(BlockPos, BlockState)&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;World#getBlockState(BlockState)&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;. If you are placing a &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;Block&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;, call &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;Block#getDefaultState()&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; to get the &amp;quot;default&amp;quot; state, and use subsequent calls to &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;BlockState#with(IProperty&amp;lt;T&amp;gt;, T)&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; as stated above to achieve the desired state.&lt;/div&gt;</summary>
		<author><name>ShrimpBot</name></author>
	</entry>
</feed>