User Tools

Site Tools


tutorial:blocks

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
tutorial:blocks [2021/05/24 18:52] – [Creating a Custom Block Class] Replace Block.Settings by FabricBlockSettings technici4ntutorial:blocks [2021/10/09 01:27] – [Registering your Block] solidblock
Line 30: Line 30:
 ==== Registering your Block ==== ==== Registering your Block ====
  
-Blocks should be registered under the ''Registry.BLOCK'' registry. Call //Registry.register// and pass in the appropriate arguments.+Blocks should be registered under the ''Registry.BLOCK'' registry. Call ''Registry.//register//'' and pass in the appropriate arguments. You can register the block in ''onInitialize'' method or directly when creating the block instance in the static context.
  
 <code java [enable_line_numbers="true",highlight_lines_extra="11"]> <code java [enable_line_numbers="true",highlight_lines_extra="11"]>
Line 131: Line 131:
       ]       ]
     }     }
 +  ]
 +}
 +</code>
 +
 +In minecraft 1.17, there has been a change for breaking blocks. Now, to define harvest tools and harvest levels, we need to use tags. Read about tags at: [[tutorial:tags|Tags Tutorial]]. The tags that we need to add the block to are:
 +
 +  Harvest tool: src/main/resources/data/minecraft/tags/blocks/mineable/<tooltype>.json, Where 'tooltype' can be any of: 'axe', 'pickaxe', 'shovel' ore 'hoe'
 +  Harvest level: src/main/resources/data/minecraft/tags/blocks/needs_<tier>_tool.json, Where 'tier' can be any of: 'stone', 'iron' or 'diamond'
 +
 +<code JavaScript src/main/resources/data/minecraft/tags/blocks/mineable/pickaxe.json>
 +{
 +  "replace": false,
 +  "values": [
 +    "example:example_block"
 +  ]
 +}
 +</code>
 +
 +<code JavaScript src/main/resources/data/minecraft/tags/blocks/needs_stone_tool.json>
 +{
 +  "replace": false,
 +  "values": [
 +    "example:example_block"
   ]   ]
 } }
Line 137: Line 160:
 ===== Creating a Custom Block Class ===== ===== Creating a Custom Block Class =====
  
-The above approach works well for simple items but falls short when you want a block with //unique// mechanics. We'll create a //separate// class that extends ''Block'' to do this. The class needs a constructor that takes in an ''AbstractBlock.Settings'' argument:+The above approach works well for simple blocks but falls short when you want a block with //unique// mechanics. We'll create a //separate// class that extends ''Block'' to do this. The class needs a constructor that takes in an ''AbstractBlock.Settings'' argument:
  
 <code java [enable_line_numbers="true"]> <code java [enable_line_numbers="true"]>
tutorial/blocks.txt · Last modified: 2024/04/15 01:52 by solidblock