User Tools

Site Tools


tutorial:custom_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
Next revisionBoth sides next revision
tutorial:custom_model [2020/12/15 15:10] – [Custom Model] BLOCK_ATLAS_TEX to BLOCK_ATLAS_TEXTURE technici4ntutorial:custom_model [2022/03/21 04:12] – [Registering the model] solidblock
Line 71: Line 71:
     }     }
 </code> </code>
 +
 +Note that the type parameter "''Pair''" in ''getTextureDependencies'' method is ''com.mojang.datafixers.util.Pair'' instead of ''net.minecraft.util.Pair''.
  
 ==== BakedModel methods ==== ==== BakedModel methods ====
 Not all the methods here are used by the Fabric Renderer, so we don't really care about the implementation. Not all the methods here are used by the Fabric Renderer, so we don't really care about the implementation.
 <code java> <code java>
-@Override+    @Override
     public List<BakedQuad> getQuads(BlockState state, Direction face, Random random) {     public List<BakedQuad> getQuads(BlockState state, Direction face, Random random) {
-        return null; // Don't need because we use FabricBakedModel instead+        // Don't need because we use FabricBakedModel instead. However, it's better to not return null in case some mod decides to call this function. 
 +        return Collections.emptyList();
     }     }
  
Line 101: Line 104:
  
     @Override     @Override
-    public Sprite getSprite() {+    public Sprite getParticleSprite() {
         return SPRITES[1]; // Block break particle, let's use furnace_top         return SPRITES[1]; // Block break particle, let's use furnace_top
     }     }
Line 143: Line 146:
 Let's register the model under the name ''tutorial:block/four_sided_furnace''. Let's register the model under the name ''tutorial:block/four_sided_furnace''.
 <code java> <code java>
 +@Environment(EnvType.CLIENT)
 public class TutorialModelProvider implements ModelResourceProvider { public class TutorialModelProvider implements ModelResourceProvider {
     public static final Identifier FOUR_SIDED_FURNACE_MODEL = new Identifier("tutorial:block/four_sided_furnace");     public static final Identifier FOUR_SIDED_FURNACE_MODEL = new Identifier("tutorial:block/four_sided_furnace");
Line 158: Line 162:
 Now we have to register this class in the client initializer, the entry point for client-specific code. Now we have to register this class in the client initializer, the entry point for client-specific code.
 <code java> <code java>
 +@Environment(EntType.CLIENT)
 public class ExampleModClient implements ClientModInitializer { public class ExampleModClient implements ClientModInitializer {
     @Override     @Override
Line 174: Line 179:
     /* ... */     /* ... */
     "client": [     "client": [
-      "tutorial.path.to.ExampleModClient"+      "net.fabricmc.example.ExampleModClient"
     ]     ]
   },   },
tutorial/custom_model.txt · Last modified: 2024/04/27 08:58 by florens