User Tools

Site Tools


Sidebar

Setup

Basics

Advanced

Items

Blocks and Block Entities

Fluids

Entities

World Generation

Recipe Types

Miscellaneous

Events

Mixins

Dynamic Data Generation

Tutorials for Minecraft 1.15

Tutorials for Minecraft 1.14

Documentation

tutorial:shield

Making a Custom Shield in Minecraft

Congrats! You just learned how to create your custom sword in the last tutorial! Now imagine you want to shield yourself from that sword if your friend got it. If you made it too op, a regular shield won't do. So we will see how to make a custom shield.
Luckily, CrimsonDawn45 has already made a library to help with this! If he didn't, you probably would be sitting here for the next hour to follow this tutorial, so thanks CrimsonDawn45!

Library source is available at https://github.com/CrimsonDawn45/Fabric-Shield-Lib

Adding the library to your project

Add the following code to the files mentioned:

gradle.properties

fabric_shield_lib_version=1.3.7


build.gradle (under dependencies)

modImplementation "com.github.hackcoder1000:Fabric-Shield-Lib:v${project.fabric_shield_lib_version}-${project.minecraft_version}"


At the time of writing, latest project.fabric_shield_lib_version should be 1.3.7, and latest project.minecraft_version should be 1.17.1. This page will be updated whenever a new update comes out.

build.gradle (under repositories)

allprojects { repositories { maven { url 'https://jitpack.io' } } }


Adding a custom shield

On to the non-boring steps! We will now make a custom shield!

If you have followed the above steps correctly and refreshed the project, then you will have the fabric shield api installed.
If so, the first step to do is create a new instance of an Item like:

public static final Item NETHERITE_SHIELD = new FabricShield(new FabricItemSettings().group(ItemGroup.COMBAT), 10, 2500, 13, Items.NETHERITE_INGOT); // FabricShield(settings, cooldownTicks, durability, enchantability, repairItem)


Then, we have to register it, like so:

Registry.register(Registry.ITEM, new Identifier("moreshields", "netherite_shield"), NETHERITE_SHIELD)


And our shield is done!
Now, we have to create the textures and models of the shield.
For the texture, you can use anything. A good place to start is looking at mojang's shield image and changing it. Put it in resources/textures/item/<filename>.png
Now, for the models, we have to write a few .json files.
For the model file without blocking, we use:

{
    "parent":"fabricshieldlib:item/template_shield",
    "textures":{
        "shield":"moreshields:item/netherite_shield"
    },
    "overrides": [
        {
            "predicate": {
                "blocking": 1
            },
            "model": "moreshields:item/netherite_shield_blocking"
        }
    ]
}


Put it in resources/models/item/netherite_shield.json
For the blocking model, use this:

{
    "parent":"fabricshieldlib:item/template_shield_blocking",
    "textures":{
        "shield":"moreshields:item/netherite_shield"
    }
}


Plop it in resources/models/item/netherite_shield_blocking.json

Don't forget to add it to en_us.json

{
  "item.moreshields.netherite_shield": "Netherite Shield"
}


And with that, your shield is done!

tutorial/shield.txt · Last modified: 2021/09/14 15:10 by redgrapefruit