Changes

46 bytes removed ,  22:02, 30 July 2021
Fix broken sound link
Line 1: Line 1:  
Blocks are, obviously, essential to the Minecraft world. They make up all of the terrain, structures, and machines. Chances are if you are interested in making a mod, then you will want to add some blocks. This page will guide you through the creation of blocks, and some of the things you can do with them.
 
Blocks are, obviously, essential to the Minecraft world. They make up all of the terrain, structures, and machines. Chances are if you are interested in making a mod, then you will want to add some blocks. This page will guide you through the creation of blocks, and some of the things you can do with them.
 
+
==Creating a Block==
== Creating a Block ==
+
===Basic Blocks===
 
  −
=== Basic Blocks ===
  −
 
   
For simple blocks, which need no special functionality (think cobblestone, wooden planks, etc.), a custom class is not necessary. You can create a block by instantiating the <code><nowiki>Block</nowiki></code> class with a <code><nowiki>BlockBehaviour$Properties</nowiki></code> object. This <code><nowiki>BlockBehaviour$Properties</nowiki></code> object can be made using <code><nowiki>BlockBehaviour$Properties::of</nowiki></code> and it can be customised by calling its methods. For instance:
 
For simple blocks, which need no special functionality (think cobblestone, wooden planks, etc.), a custom class is not necessary. You can create a block by instantiating the <code><nowiki>Block</nowiki></code> class with a <code><nowiki>BlockBehaviour$Properties</nowiki></code> object. This <code><nowiki>BlockBehaviour$Properties</nowiki></code> object can be made using <code><nowiki>BlockBehaviour$Properties::of</nowiki></code> and it can be customised by calling its methods. For instance:
   
* <code><nowiki>strength</nowiki></code> - The hardness controls the time it takes to break the block. It is an arbitrary value. For reference, stone has a hardness of 1.5, and dirt 0.5. If the block should be unbreakable a hardness of -1.0 should be used, see the definition of <code><nowiki>Blocks#BEDROCK</nowiki></code> as an example. The resistance controls the explosion resistance of the block. For reference, stone has a resistance of 6.0, and dirt 0.5.
 
* <code><nowiki>strength</nowiki></code> - The hardness controls the time it takes to break the block. It is an arbitrary value. For reference, stone has a hardness of 1.5, and dirt 0.5. If the block should be unbreakable a hardness of -1.0 should be used, see the definition of <code><nowiki>Blocks#BEDROCK</nowiki></code> as an example. The resistance controls the explosion resistance of the block. For reference, stone has a resistance of 6.0, and dirt 0.5.
* <code><nowiki>sound</nowiki></code> - Controls the sound the block makes when it is punched, broken, or placed. Requires a <code><nowiki>SoundType</nowiki></code> argument, see the [[latest:advanced:effects:sounds|sounds]] page for more details.
+
* <code><nowiki>sound</nowiki></code> - Controls the sound the block makes when it is punched, broken, or placed. Requires a <code><nowiki>SoundType</nowiki></code> argument, see the [[Sounds|sounds]] page for more details.
 
* <code><nowiki>lightLevel</nowiki></code> - Controls the light emission of the block. Takes a function with a ''BlockState'' parameter that returns an integer value from zero to fifteen.
 
* <code><nowiki>lightLevel</nowiki></code> - Controls the light emission of the block. Takes a function with a ''BlockState'' parameter that returns an integer value from zero to fifteen.
 
* <code><nowiki>friction</nowiki></code> - Controls how slippery the block is. For reference, ice has a slipperiness of 0.98.
 
* <code><nowiki>friction</nowiki></code> - Controls how slippery the block is. For reference, ice has a slipperiness of 0.98.
Line 16: Line 12:  
{{Colored box|title=Tip|content=Blocks have no setter for their <code><nowiki>CreativeModeTab</nowiki></code>. This has been moved to the <code><nowiki>BlockItem</nowiki></code> and is now its responsibility.}}
 
{{Colored box|title=Tip|content=Blocks have no setter for their <code><nowiki>CreativeModeTab</nowiki></code>. This has been moved to the <code><nowiki>BlockItem</nowiki></code> and is now its responsibility.}}
   −
=== Advanced Blocks ===
+
===Advanced Blocks===
 
   
Of course, the above only allows for extremely basic blocks. If you want to add functionality, like player interaction, a custom class is required. However, the <code><nowiki>Block</nowiki></code> class has many methods and unfortunately not every single one can be documented here. See the rest of the pages in this section for things you can do with blocks.
 
Of course, the above only allows for extremely basic blocks. If you want to add functionality, like player interaction, a custom class is required. However, the <code><nowiki>Block</nowiki></code> class has many methods and unfortunately not every single one can be documented here. See the rest of the pages in this section for things you can do with blocks.
 
+
==Registering a Block==
== Registering a Block ==
  −
 
   
Blocks must be [[Registration|registered]] to function.
 
Blocks must be [[Registration|registered]] to function.
   Line 29: Line 22:       −
==== Optionally Registering Blocks ====
+
====Optionally Registering Blocks====
 
   
Since there is no limit on the amount of blocks that can be register, register all blocks in your mod! If you want a block to be disabled through a configuration file, you should disable the crafting recipe and/or remove the block from the creative menu (<code><nowiki>CreativeModeTab</nowiki></code>).
 
Since there is no limit on the amount of blocks that can be register, register all blocks in your mod! If you want a block to be disabled through a configuration file, you should disable the crafting recipe and/or remove the block from the creative menu (<code><nowiki>CreativeModeTab</nowiki></code>).
 
+
==Further Reading==
== Further Reading ==
  −
 
   
For information about block properties, such as those used for vanilla blocks like fences, walls, and many more, see the section on [[Understanding Blockstates|blockstates]].
 
For information about block properties, such as those used for vanilla blocks like fences, walls, and many more, see the section on [[Understanding Blockstates|blockstates]].
       
[[Category:Blocks]]
 
[[Category:Blocks]]