tutorial:shield
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | Next revisionBoth sides next revision | ||
tutorial:shield [2022/01/01 00:37] – old revision restored (2021/12/27 20:29) cringestar_boi | tutorial:shield [2022/01/01 01:04] – added 1.14 section for banner support again cringestar_boi | ||
---|---|---|---|
Line 577: | Line 577: | ||
//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