User Tools

Site Tools


tutorial:blockstate

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Last revisionBoth sides next revision
tutorial:blockstate [2022/12/16 01:52] solidblocktutorial:blockstate [2023/06/04 10:38] – [A note about performance] fixed typos terra
Line 117: Line 117:
  
 ==== A note about performance ==== ==== A note about performance ====
-Every possible block states for a block is registered when the ''Block'' object is initialized. This means that if you have 14 boolean properties, the block has 2^14 = 16384 different states and 2^14 states are registered. For this reason blocks should not contain too many blockstate properties. Rather, blockstates should be mostly reserved for visuals, and [[tutorial:blockentity|Block Entities]] should be used for more advanced state.+Every possible blockstate for a block is registered when the ''Block'' object is initialized. This means that if you have 14 boolean properties, the block has 2^14 = 16384 different states and 2^14 states are registered. For this reasonblocks should not contain too many blockstate properties. Rather, blockstates should be mostly reserved for visuals, and [[tutorial:blockentity|Block Entities]] should be used for more advanced state.
  
-As all possible states have been built, an equal state for a block is a same object, and the ''with'' method returns an existing object, instead of creating a new object - which means, for example, ''CHARGEABLE_BLOCK.getDefaultState().with(CHARGED, true) == CHARGEABLE_BLOCK.getDefaultState().with(CHARGED, true)'' returne ''true''.+As all possible states have been built, an equal state for a block is a same object, and the ''with'' method returns an existing object, instead of creating a new object - which means, for example, ''CHARGEABLE_BLOCK.getDefaultState().with(CHARGED, true) == CHARGEABLE_BLOCK.getDefaultState().with(CHARGED, true)'' returns ''true''.
tutorial/blockstate.txt · Last modified: 2023/11/18 08:13 by solidblock