User Tools

Site Tools


tutorial:shield

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:shield [2024/07/03 07:08] solidblocktutorial:shield [2024/09/29 19:35] (current) – updated with 1.21 guide and past guides cringestar_boi
Line 1: Line 1:
-====== Making a Custom Shield in Minecraft [1.19-1.20] ======+====== Making a Custom Shield in Minecraft [1.19-1.21.1] ======
 :!: The tutorial depends on third-party libraries. :!: The tutorial depends on third-party libraries.
  
Line 16: Line 16:
 **gradle.properties** **gradle.properties**
 <file properties gradle.properties> <file properties gradle.properties>
-fabric_shield_lib_version=1.7.2-1.20.4 +fabric_shield_lib_version=1.7.2-1.21.1 
-midnightlib_version=1.5.2-fabric +midnightlib_version=1.5.8-fabric 
-mod_menu_version=9.0.0-pre.1+mod_menu_version=11.0.1
 fabricasm_version=2.3 fabricasm_version=2.3
 </file> </file>
Line 31: Line 31:
  
 At the time of writing, the latest project.fabric_shield_lib_version should be 1.7.2, which supports versions: At the time of writing, the latest project.fabric_shield_lib_version should be 1.7.2, which supports versions:
 +  * **1.21** - **1.21.1** (''1.7.2-1.21.1'')
 +  * **1.20.5** - **1.20.6** (''1.7.2-1.20.6'')
   * **1.20.2** - **1.20.4** (''1.7.2-1.20.4'')   * **1.20.2** - **1.20.4** (''1.7.2-1.20.4'')
   * **1.20** - **1.20.1** (''1.7.2-1.20.1'')   * **1.20** - **1.20.1** (''1.7.2-1.20.1'')
Line 57: Line 59:
 public final class TutorialItems { public final class TutorialItems {
     // ...     // ...
-    public static final Item NETHERITE_SHIELD = register(new FabricShieldItem(new FabricItemSettings().maxDamage(2500), 10, 13, Items.NETHERITE_INGOT), "netherite_shield");+    public static final Item NETHERITE_SHIELD = register(new FabricShieldItem(new FabricItemSettings().maxDamage(2500), 10, 13, Items.NETHERITE_INGOT), "netherite_shield");  
 +    //The constructor for the item takes in the following values: FabricBannerShieldItem(settings.maxDamage(durability), cooldownTicks, enchantability, repairItems
     // ...     // ...
 } }
Line 112: Line 115:
 </file> </file>
  
-Lastly, as a [[tags|conventional tag]], create a ''shields.json'' file in ''resources/data/c/tags/item/shields.json'' (since 1.21) or ''resources/data/c/tags/items/shields.json'' (befire 1.21) and add your shield to it:+Then, as a [[tags|conventional tag]], create a ''shield.json'' file in ''resources/data/c/tags/item/tools/shield.json'' and add your shield to it:
 <code javascript resources/data/c/tags/items/shields.json> <code javascript resources/data/c/tags/items/shields.json>
 +{
 +  "replace": false,
 +  "values": [
 +    "tutorial:netherite_shield"
 +  ]
 +}
 +</code>
 +
 +Lastly, to make it enchantable, create a ''durability.json'' file in ''resources/data/minecraft/tags/item/enchantable/durability.json'' and add your shield to it:
 +<code javascript resources/data/minecraft/tags/item/enchantable/durability.json>
 { {
   "replace": false,   "replace": false,
Line 137: Line 150:
     public static final Item NETHERITE_BANNER_SHIELD = register(new FabricBannerShieldItem(new FabricItemSettings().maxDamage(2500), 10, 13, Items.NETHERITE_INGOT), "netherite_banner_shield");     public static final Item NETHERITE_BANNER_SHIELD = register(new FabricBannerShieldItem(new FabricItemSettings().maxDamage(2500), 10, 13, Items.NETHERITE_INGOT), "netherite_banner_shield");
 </code> </code>
- +If you want to add your shield to a [[itemgroup|item groups]], for example, the "Combat" group, use:   
-If you want to add your shield to a [[itemgroup|item groups]], for example, the "Combat" group, use: +  
- +<yarncode java ExampleMod>   
-<yarncode java ExampleMod> +public class ExampleMod implements ModInitializer {   
-public class ExampleMod implements ModInitializer { +    @Override   
-    @Override +    public void onInitialize() {   
-    public void onInitialize() { +        ItemGroupEvents.modifyEntriesEvent(ItemGroups.COMBAT).register(entries -> {   
-        ItemGroupEvents.modifyEntriesEvent(ItemGroups.COMBAT).register(entries -> { +            // ...   
-            // ... +            entries.add(NETHERITE_BANNER_SHIELD);   
-            entries.add(NETHERITE_BANNER_SHIELD); +        });   
-        }); +    }   
-    } +}  
-}+
 </yarncode> </yarncode>
  
Line 158: Line 170:
 @Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
 public class ExampleModClient implements ClientModInitializer { public class ExampleModClient implements ClientModInitializer {
-    public static final EntityModelLayer NETHERITE_BANNER_SHIELD_MODEL_LAYER = new EntityModelLayer(new Identifier("tutorial", "netherite_banner_shield"),"main");+    public static final EntityModelLayer NETHERITE_BANNER_SHIELD_MODEL_LAYER = new EntityModelLayer(Identifier.of("tutorial", "netherite_banner_shield"),"main");
  
     @Override     @Override
Line 173: Line 185:
 public class ExampleModClient implements ClientModInitializer { public class ExampleModClient implements ClientModInitializer {
  
-    public static final EntityModelLayer NETHERITE_SHIELD_MODEL_LAYER = new EntityModelLayer(new Identifier("tutorial", "netherite_shield"),"main");+    public static final EntityModelLayer NETHERITE_SHIELD_MODEL_LAYER = new EntityModelLayer(Identifier.of("tutorial", "netherite_shield"),"main");
  
     @Override     @Override
Line 187: Line 199:
 @Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
 public class ExampleModClient implements ClientModInitializer { public class ExampleModClient implements ClientModInitializer {
-    public static final EntityModelLayer NETHERITE_SHIELD_MODEL_LAYER = new EntityModelLayer(new Identifier("tutorial", "netherite_shield"), "main");+    public static final EntityModelLayer NETHERITE_SHIELD_MODEL_LAYER = new EntityModelLayer(Identifier.of("tutorial", "netherite_shield"), "main");
          
     public static ShieldEntityModel modelNetheriteShield;     public static ShieldEntityModel modelNetheriteShield;
Line 203: Line 215:
 @Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
 public class ExampleModClient implements ClientModInitializer { public class ExampleModClient implements ClientModInitializer {
-    public static final EntityModelLayer NETHERITE_SHIELD_MODEL_LAYER = new EntityModelLayer(new Identifier("tutorial", "netherite_shield"),"main");+    public static final EntityModelLayer NETHERITE_SHIELD_MODEL_LAYER = new EntityModelLayer(Identifier.of("tutorial", "netherite_shield"),"main");
          
     public static ShieldEntityModel modelNetheriteShield;     public static ShieldEntityModel modelNetheriteShield;
Line 224: Line 236:
 public class ExampleModClient implements ClientModInitializer { public class ExampleModClient implements ClientModInitializer {
  
- public static final EntityModelLayer netherite_banner_shield_model_layer = new EntityModelLayer(new Identifier("tutorial", "netherite_banner_shield"), "main");+ public static final EntityModelLayer netherite_banner_shield_model_layer = new EntityModelLayer(Identifier.of("tutorial", "netherite_banner_shield"), "main");
  
  public static ShieldEntityModel modelNetheriteShield;  public static ShieldEntityModel modelNetheriteShield;
  
- public static final SpriteIdentifier NETHERITE_BANNER_SHIELD_BASE = new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEXTURE, new Identifier("tutorial", "entity/netherite_banner_shield_base")); + public static final SpriteIdentifier NETHERITE_BANNER_SHIELD_BASE = new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEXTURE, Identifier.of("tutorial", "entity/netherite_banner_shield_base")); 
- public static final SpriteIdentifier NETHERITE_BANNER_SHIELD_BASE_NO_PATTERN = new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEXTURE, new Identifier("tutorial", "entity/netherite_banner_shield_base_nopattern"));+ public static final SpriteIdentifier NETHERITE_BANNER_SHIELD_BASE_NO_PATTERN = new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEXTURE, Identifier.of("tutorial", "entity/netherite_banner_shield_base_nopattern"));
  
  @Override  @Override
Line 247: Line 259:
 @Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
 public class ExampleModClient implements ClientModInitializer { public class ExampleModClient implements ClientModInitializer {
- public static final EntityModelLayer netherite_banner_shield_model_layer = new EntityModelLayer(new Identifier("tutorial", "netherite_banner_shield"),"main");+ public static final EntityModelLayer netherite_banner_shield_model_layer = new EntityModelLayer(Identifier.of("tutorial", "netherite_banner_shield"),"main");
  
  public static ShieldEntityModel modelNetheriteShield;  public static ShieldEntityModel modelNetheriteShield;
  
- public static final SpriteIdentifier NETHERITE_BANNER_SHIELD_BASE = new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEXTURE, new Identifier("tutorial", "entity/netherite_banner_shield_base")); + public static final SpriteIdentifier NETHERITE_BANNER_SHIELD_BASE = new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEXTURE, Identifier.of("tutorial", "entity/netherite_banner_shield_base")); 
- public static final SpriteIdentifier NETHERITE_BANNER_SHIELD_BASE_NO_PATTERN = new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEXTURE, new Identifier("tutorial", "entity/netherite_banner_shield_base_nopattern"));+ public static final SpriteIdentifier NETHERITE_BANNER_SHIELD_BASE_NO_PATTERN = new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEXTURE, Identifier.of("tutorial", "entity/netherite_banner_shield_base_nopattern"));
  
  @Override  @Override
Line 289: Line 301:
 </code> </code>
  
-Next, inside ''resources/assets/tutorial/models/item/'', create a ''netherite_banner_shield.json'' file and put this inside it:+Next, inside ''resources/assets/tutorial/models/item/'', create a ''netherite_banner_shield.json'' file and put this inside it:
 <code javascript resources/assets/tutorial/models/item/etherite_banner_shield.json> <code javascript resources/assets/tutorial/models/item/etherite_banner_shield.json>
 { {
Line 310: Line 321:
   "parent":"fabricshieldlib:item/fabric_banner_shield_blocking",   "parent":"fabricshieldlib:item/fabric_banner_shield_blocking",
   "textures":{   "textures":{
-    "shield":"tutorial:item/netherite_shield"+    "shield":"tutorial:item/netherite_banner_shield"
   }   }
 } }
Line 319: Line 330:
 Then, you will move both of these textures into ''resources/assets/<modid>/textures/entity''. Then, you will move both of these textures into ''resources/assets/<modid>/textures/entity''.
  
-Lastly, create a ''shields.json'' file in ''resources/data/c/tags/items/shields.json'' and add your shield to it:+Next, create a ''shields.json'' file in ''resources/data/c/tags/items/shields.json'' and add your shield to it:
 <code javascript resources/data/c/tags/items/shields.json> <code javascript resources/data/c/tags/items/shields.json>
 +{
 +  "replace": false,
 +  "values": [
 +    "tutorial:netherite_banner_shield"
 +  ]
 +}
 +</code>
 +
 +Finally create a ''durability.json'' file in ''resources/data/minecraft/tags/item/enchantable/durability.json'' and add your shield to it:
 +<code javascript resources/data/minecraft/tags/item/enchantable/durability.json>
 { {
   "replace": false,   "replace": false,
Line 354: Line 375:
  
 And now your shield is fully completed and supports banner decoration! And now your shield is fully completed and supports banner decoration!
 +
 +===== Changes for 1.20.6 =====
 +If you are working in 1.20.6, first change the FabricShieldLib and FAPI versions accordingly and change your other dependencies to these versions:\\
 +
 +<file properties gradle.properties>
 +mod_menu_version=10.0.0-beta.1
 +midnightlib_version=1.5.5-fabric
 +</file>
 +
 +Next, change all instances of ''Identifier.of'' to ''new Identifier''; these are when you are registering your item, creating your ''EntityModelLayer'', and creating your ''SpriteIdentifiers''.
 +
 +Then, change your ''shield.json'' in ''resources/data/c/tags/item/tools/shield.json'' to ''shields.json'' file in ''resources/data/c/tags/items/shields.json'' 
 +
 +Finally, move your ''durability.json'' from ''resources/data/minecraft/tags/items/enchantable/durability.json'' to ''resources/data/minecraft/tags/item/enchantable/durability.json''
 +
 +===== Changes for 1.20.4 =====
 +If you are working in 1.20.4, **follow the changes for 1.20.6 first**, then change the FabricShieldLib and FAPI versions accordingly and change your other dependencies to these versions:\\
 +
 +**gradle.properties**
 +<file properties gradle.properties>
 +midnightlib_version=1.5.2-fabric
 +mod_menu_version=9.0.0-pre.1
 +</file>
 +
 +Additionally, **remove the** ''durability.json'' **file** completely.
  
 ===== Changes for 1.19 ===== ===== Changes for 1.19 =====
-If you are working in 1.19, make sure to change the FabricShieldLib and FAPI versions accordingly as well as changing your Midnight Lib and Mod Menu dependencies to these versions:\\+If you are working in 1.19, **follow the changes for 1.20.6 and 1.20.4 first**, then change the FabricShieldLib and FAPI versions accordingly and change your other dependencies to these versions:\\ 
 **gradle.properties** **gradle.properties**
-<code java>+<file properties gradle.properties>
 midnightlib_version=1.0.0-fabric midnightlib_version=1.0.0-fabric
 mod_menu_version=4.2.0-beta.2 mod_menu_version=4.2.0-beta.2
-</code>+</file>
tutorial/shield.1719990499.txt.gz · Last modified: 2024/07/03 07:08 by solidblock