tutorial:shield
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
tutorial:shield [2022/01/01 00:37] – old revision restored (2021/12/27 20:29) cringestar_boi | tutorial:shield [2022/03/26 19:43] – fix double </code> furnygo | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Making a Custom Shield in Minecraft [1.17] ====== | + | ====== Making a Custom Shield in Minecraft [1.18-1.14] ====== |
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.\\ | 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.\\ | ||
Line 13: | Line 13: | ||
**gradle.properties**\\ | **gradle.properties**\\ | ||
<code java> | <code java> | ||
- | fabric_shield_lib_version=1.4.5-1.18 | + | fabric_shield_lib_version=1.5.3-1.18 |
</ | </ | ||
**build.gradle** (under dependencies)\\ | **build.gradle** (under dependencies)\\ | ||
Line 19: | Line 19: | ||
modImplementation " | modImplementation " | ||
</ | </ | ||
- | At the time of writing, latest project.fabric_shield_lib_version should be 1.4.5-1.18. This page will be updated whenever a new update comes out.\\ \\ | + | At the time of writing, latest project.fabric_shield_lib_version should be 1.5.3-1.18. This page will be updated whenever a new update comes out.\\ \\ |
**build.gradle** (under repositories)\\ | **build.gradle** (under repositories)\\ | ||
<code java> | <code java> | ||
Line 396: | Line 396: | ||
private static final SpriteIdentifier NETHERITE_SHIELD_BASE_NO_PATTERN = new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEXTURE, | private static final SpriteIdentifier NETHERITE_SHIELD_BASE_NO_PATTERN = new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEXTURE, | ||
} | } | ||
- | </ | ||
</ | </ | ||
Line 559: | Line 558: | ||
private static final SpriteIdentifier NETHERITE_SHIELD_BASE_NO_PATTERN = new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEX, | private static final SpriteIdentifier NETHERITE_SHIELD_BASE_NO_PATTERN = new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEX, | ||
} | } | ||
- | </ | ||
</ | </ | ||
Line 577: | Line 575: | ||
//The first five parameters are taken from the method, while the last 3 you provide yourself. You will provide the model, and then your 2 sprite identifiers in the order of ''// | //The first five parameters are taken from the method, while the last 3 you provide yourself. You will provide the model, and then your 2 sprite identifiers in the order of ''// | ||
'' | '' | ||
+ | } | ||
+ | } | ||
+ | |||
+ | | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | That is now all of the complicated things done! We now only need to change our existing model, add a '' | ||
+ | |||
+ | In your shield model, '' | ||
+ | <code javascript> | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | } | ||
+ | ] | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | You also have to change your blocking model for your shield, '' | ||
+ | |||
+ | <code javascript> | ||
+ | { | ||
+ | " | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | For this next step, you will add '' | ||
+ | Then, you will need to make a '' | ||
+ | |||
+ | Then, you will move both of these textures into '' | ||
+ | |||
+ | For one last thing, you will need to add names for each of your shield color variants in '' | ||
+ | <code javascript> | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | </ | ||
+ | ===== Adding banner support to your shield (1.14) ===== | ||
+ | |||
+ | This is where mixins get involved. | ||
+ | |||
+ | First, change the fabric_shield_lib in **gradle.properties** | ||
+ | \\ | ||
+ | <code java> | ||
+ | fabric_shield_lib_version=1.4.5-1.14 | ||
+ | </ | ||
+ | \\ | ||
+ | |||
+ | Next thing you will want to do is to change // | ||
+ | |||
+ | <code java> | ||
+ | public static final Item NETHERITE_SHIELD = new FabricBannerShieldItem(new FabricItemSettings().maxDamage(2500).group(ItemGroup.COMBAT), | ||
+ | </ | ||
+ | |||
+ | The only thing we will need to do now is to add a simple mixin. | ||
+ | |||
+ | If this is your first time, [[tutorial: | ||
+ | |||
+ | We will make a class called '' | ||
+ | <code java> | ||
+ | @Mixin (BuiltinModelItemRenderer.class) | ||
+ | public class RendererMixin { | ||
+ | |||
+ | } | ||
+ | </ | ||
+ | |||
+ | Then we will make the necessary '' | ||
+ | <code java> | ||
+ | @Mixin (BuiltinModelItemRenderer.class) | ||
+ | public class RendererMixin { | ||
+ | private static final Identifier NETHERITE_SHIELD_BASE = new Identifier(" | ||
+ | private static final Identifier NETHERITE_SHIELD_BASE_NO_PATTERN = new Identifier(" | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | Now we get to the most important part of the mixin. We will inject a method to render a banner on our shield. **Do not forget to mark the inject with // | ||
+ | | ||
+ | <code java> | ||
+ | @Mixin (BuiltinModelItemRenderer.class) | ||
+ | public class RendererMixin { | ||
+ | private static final Identifier NETHERITE_SHIELD_BASE = new Identifier(" | ||
+ | private static final Identifier NETHERITE_SHIELD_BASE_NO_PATTERN = new Identifier(" | ||
+ | | ||
+ | @Inject(method = " | ||
+ | private void mainRender(ItemStack stack, CallbackInfo callbackInfo) { | ||
+ | if (stack.getItem() == ExampleMod.NETHERITE_SHIELD)) { | ||
+ | //The first parameter is taken from the method, while you will provide your 2 identifiers in the order of ''// | ||
+ | FabricShieldBannerRendering.render(stack, | ||
+ | callbackInfo.cancel(); | ||
} | } | ||
} | } |
tutorial/shield.txt · Last modified: 2024/01/14 18:05 by cringestar_boi