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 [2022/01/30 02:45] – [Registering your Block] solidblocktutorial:blocks [2022/07/18 16:25] – [Configuring Block Drops] correcting 'ore' to 'or' rodriguezrrp
Line 137: Line 137:
 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: 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 tool: src/main/resources/data/minecraft/tags/blocks/mineable/<tooltype>.json, Where 'tooltype' can be any of: 'axe', 'pickaxe', 'shovel' or 'hoe'
   Harvest level: src/main/resources/data/minecraft/tags/blocks/needs_<tier>_tool.json, Where 'tier' can be any of: 'stone', 'iron' or 'diamond'   Harvest level: src/main/resources/data/minecraft/tags/blocks/needs_<tier>_tool.json, Where 'tier' can be any of: 'stone', 'iron' or 'diamond'
  
Line 144: Line 144:
   "replace": false,   "replace": false,
   "values": [   "values": [
-    "example:example_block"+    "tutorial:example_block"
   ]   ]
 } }
Line 153: Line 153:
   "replace": false,   "replace": false,
   "values": [   "values": [
-    "example:example_block"+    "tutorial:example_block"
   ]   ]
 } }
Line 190: Line 190:
     public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {     public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
         if (!world.isClient) {         if (!world.isClient) {
-            player.sendMessage(new LiteralText("Hello, world!"), false);+            player.sendMessage(Text.of("Hello, world!"), false);
         }         }
  
Line 221: Line 221:
 To fix this, we have to define the ''VoxelShape'' of the new block: To fix this, we have to define the ''VoxelShape'' of the new block:
  
-<code> +<code java
- @Override +public class ExambleBlock extends Block { 
- public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext context) { +    [...] 
-     return VoxelShapes.cuboid(0f, 0f, 0f, 1f, 1.0f, 0.5f); +    @Override 
- }+    public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext context) { 
 +        return VoxelShapes.cuboid(0f, 0f, 0f, 1f, 1.0f, 0.5f); 
 +    } 
 +}
 </code> </code>
  
Line 236: Line 239:
  
 [[tutorial:blockentity|Giving blocks a block entity so they can have advanced state like inventories]]. Also needed for many things like GUI and custom block rendering. [[tutorial:blockentity|Giving blocks a block entity so they can have advanced state like inventories]]. Also needed for many things like GUI and custom block rendering.
 +
 +To make your block flammable (that is, can be burned in fire), you may use ''FlammableBlockRegistry''.
tutorial/blocks.txt · Last modified: 2024/04/15 01:52 by solidblock