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
Next revision
Previous revision
tutorial:blockstate [2024/08/24 14:13] solidblocktutorial:blockstate [2024/10/27 14:57] (current) solidblock
Line 9: Line 9:
  
 In fact, you can also use existing properties defined in vanilla, which can be found in ''Properties'' (''net.minecraft.state.property.Properties''). If you intend to define other types of properties, you may use ''IntProperty'' or ''EnumProperty''. In fact, you can also use existing properties defined in vanilla, which can be found in ''Properties'' (''net.minecraft.state.property.Properties''). If you intend to define other types of properties, you may use ''IntProperty'' or ''EnumProperty''.
 +
 +Create the class first:
 <code java> <code java>
 public class ChargeableBlock extends Block { public class ChargeableBlock extends Block {
Line 16: Line 18:
       super(settings);       super(settings);
     }     }
-   
-    // The block instance. You can place it anywhere. Make the class is initialized. 
-    public static final ChargeableBlock CHARGEABLE_BLOCK = new ChargeableBlock(FabricBlockSettings.copyOf(Blocks.STONE)); 
 } }
 </code> </code>
Line 25: Line 24:
 <code java> <code java>
 public final class TutorialBlocks { public final class TutorialBlocks {
-    public static final Chargeable CHARGEABLE_BLOCK = register(new ChargeableBlock(Block.Settings.copy(Blocks.STONE))"chargeable_block");+    // For versions below 1.21.2: 
 +    public static final Chargeable CHARGEABLE_BLOCK = register("chargeable_block", new ChargeableBlock(Block.Settings.copy(Blocks.STONE))); 
 +    // For versions since 1.21.2: 
 +    public static final Chargeable CHARGEABLE_BLOCK = register("chargeable_block", ChargeableBlock::new, Block.Settings.copy(Blocks.STONE));
          
     // [...]     // [...]
tutorial/blockstate.1724508802.txt.gz · Last modified: 2024/08/24 14:13 by solidblock