<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://forge.gemwire.uk/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Senox13</id>
	<title>Forge Community Wiki - User contributions [en-gb]</title>
	<link rel="self" type="application/atom+xml" href="https://forge.gemwire.uk/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Senox13"/>
	<link rel="alternate" type="text/html" href="https://forge.gemwire.uk/wiki/Special:Contributions/Senox13"/>
	<updated>2026-05-01T17:55:51Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.35.0</generator>
	<entry>
		<id>https://forge.gemwire.uk/index.php?title=Talk:Mods.toml&amp;diff=3412</id>
		<title>Talk:Mods.toml</title>
		<link rel="alternate" type="text/html" href="https://forge.gemwire.uk/index.php?title=Talk:Mods.toml&amp;diff=3412"/>
		<updated>2023-10-07T16:47:47Z</updated>

		<summary type="html">&lt;p&gt;Senox13: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;it doesn't make sense that modId is a string yet the curseforge API defines it as an integer. Why are there two modId's??? https://docs.curseforge.com/?python#get-mod&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I believe you're confusing MinecraftForge and CurseForge - while they are both have Forge in their name, they are separate things made by separate people - kind of like carpet and car&lt;/div&gt;</summary>
		<author><name>Senox13</name></author>
	</entry>
	<entry>
		<id>https://forge.gemwire.uk/index.php?title=BlockStates&amp;diff=3408</id>
		<title>BlockStates</title>
		<link rel="alternate" type="text/html" href="https://forge.gemwire.uk/index.php?title=BlockStates&amp;diff=3408"/>
		<updated>2023-07-15T19:31:24Z</updated>

		<summary type="html">&lt;p&gt;Senox13: overwrite -&amp;gt; override&lt;/p&gt;
&lt;hr /&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;BlockEntity&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#createBlockStateDefinition(StateDefinition$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;StateDefinition$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#registerDefaultState(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.registerDefaultState(&lt;br /&gt;
    this.stateDefinition.any()&lt;br /&gt;
        .setValue(FACING, Direction.NORTH)&lt;br /&gt;
        .setValue(OPEN, false)&lt;br /&gt;
        .setValue(HINGE, DoorHingeSide.LEFT)&lt;br /&gt;
        .setValue(POWERED, false)&lt;br /&gt;
        .setValue(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 override &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;Block#getStateForPlacement(BlockPlaceContext)&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#setValue(Property&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;StateHolder&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#getValue(Property&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#setValue(Property&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 level using &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;Level#setBlockAndUpdate(BlockPos, BlockState)&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;Level#getBlockState(BlockPos)&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#defaultBlockState()&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#setValue(Property&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>Senox13</name></author>
	</entry>
	<entry>
		<id>https://forge.gemwire.uk/index.php?title=BlockStates&amp;diff=2480</id>
		<title>BlockStates</title>
		<link rel="alternate" type="text/html" href="https://forge.gemwire.uk/index.php?title=BlockStates&amp;diff=2480"/>
		<updated>2021-03-05T22:21:26Z</updated>

		<summary type="html">&lt;p&gt;Senox13: Removed misused apostrophe&lt;/p&gt;
&lt;hr /&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>Senox13</name></author>
	</entry>
	<entry>
		<id>https://forge.gemwire.uk/index.php?title=BlockStates&amp;diff=2479</id>
		<title>BlockStates</title>
		<link rel="alternate" type="text/html" href="https://forge.gemwire.uk/index.php?title=BlockStates&amp;diff=2479"/>
		<updated>2021-03-05T22:20:14Z</updated>

		<summary type="html">&lt;p&gt;Senox13: Removed misused apostrophe&lt;/p&gt;
&lt;hr /&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>Senox13</name></author>
	</entry>
	<entry>
		<id>https://forge.gemwire.uk/index.php?title=BlockStates&amp;diff=2478</id>
		<title>BlockStates</title>
		<link rel="alternate" type="text/html" href="https://forge.gemwire.uk/index.php?title=BlockStates&amp;diff=2478"/>
		<updated>2021-03-05T22:19:19Z</updated>

		<summary type="html">&lt;p&gt;Senox13: Removed misused apostrophe&lt;/p&gt;
&lt;hr /&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>Senox13</name></author>
	</entry>
	<entry>
		<id>https://forge.gemwire.uk/index.php?title=BlockStates&amp;diff=2477</id>
		<title>BlockStates</title>
		<link rel="alternate" type="text/html" href="https://forge.gemwire.uk/index.php?title=BlockStates&amp;diff=2477"/>
		<updated>2021-03-05T22:18:27Z</updated>

		<summary type="html">&lt;p&gt;Senox13: Removed misused apostrophe&lt;/p&gt;
&lt;hr /&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>Senox13</name></author>
	</entry>
</feed>