User Tools

Site Tools


tutorial:datagen_model

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:datagen_model [2022/10/02 21:05] nexus-dinotutorial:datagen_model [2023/06/05 17:43] (current) – Change to FabricDataOutput mcrafterzz
Line 8: Line 8:
 <code java> <code java>
 private static class MyModelGenerator extends FabricModelProvider { private static class MyModelGenerator extends FabricModelProvider {
- private MyModelGenerator(FabricDataGenerator generator) {+ private MyModelGenerator(FabricDataOutput generator) {
  super(generator);  super(generator);
  }  }
Line 38: Line 38:
  
 <code java> <code java>
-public static Block SIMPLE_BLOCK = Registry.register(Registry.BLOCK, new Identifier("mymod", "simple_block"), new Block(...)); +public static Block SIMPLE_BLOCK = Registry.register(Registries.BLOCK, new Identifier("tutorial", "simple_block"), new Block(...)); 
-public static BlockItem SIMPLE_BLOCK_ITEM = Registry.register(Registry.ITEM, ..., new BlockItem(SIMPLE_BLOCK, ...));+public static BlockItem SIMPLE_BLOCK_ITEM = Registry.register(Registries.ITEM, ..., new BlockItem(SIMPLE_BLOCK, ...));
 // ... // ...
  
Line 49: Line 49:
  
 Since a ''BlockItem'' for ''SIMPLE_BLOCK'' exists and has been registered, an item model will also be automatically generated that parents the block model. This can be overridden in the ''generateItemModels'' method. Since a ''BlockItem'' for ''SIMPLE_BLOCK'' exists and has been registered, an item model will also be automatically generated that parents the block model. This can be overridden in the ''generateItemModels'' method.
 +
 +==== Strict Validation ====
 +By default, data generation will throw an exception if the run did not generate blockstates for all blocks belonging to the processed mods. 
 +Fabric API allows disabling this. To do so, edit your ''build.gradle'' to remove the ''-Dfabric-api.datagen.strict-validation'' VM arg from the ''loom {}'' block.
  
 ===== Adding Item Models ===== ===== Adding Item Models =====
Line 57: Line 61:
  
 <code java> <code java>
-public static Block SIMPLE_BLOCK = Registry.register(Registry.BLOCK, new Identifier("mymod", "simple_block"), new Block(...)); +public static Block SIMPLE_BLOCK = Registry.register(Registries.BLOCK, new Identifier("tutorial", "simple_block"), new Block(...)); 
-public static BlockItem SIMPLE_BLOCK_ITEM = Registry.register(Registry.ITEM, ..., new BlockItem(SIMPLE_BLOCK, ...));+public static BlockItem SIMPLE_BLOCK_ITEM = Registry.register(Registries.ITEM, ..., new BlockItem(SIMPLE_BLOCK, ...));
 // ... // ...
  
Line 79: Line 83:
  
 @Override @Override
-public void onInitialize() +public void onInitialize() { 
-+    Registry.register(Registries.BLOCK, new Identifier("tutorial", "machine"), MACHINE_BLOCK);
-    Registry.register(Registry.BLOCK, new Identifier("tutorial", "machine"), MACHINE_BLOCK);+
 } }
 </code> </code>
Line 89: Line 92:
 <code java> <code java>
 private static class MyModelGenerator extends FabricModelProvider { private static class MyModelGenerator extends FabricModelProvider {
- private MyModelGenerator(FabricDataGenerator generator) {+ private MyModelGenerator(FabricDataOutput generator) {
  super(generator);  super(generator);
  }  }
tutorial/datagen_model.1664744728.txt.gz · Last modified: 2022/10/02 21:05 by nexus-dino