tutorial:armor
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:armor [2022/04/13 09:39] – map2fabricyarn daomephsta | tutorial:armor [2022/06/24 07:17] – Remove [Adding Knockback Protection] as FAPI 0.55.1 obsoletes it daomephsta | ||
---|---|---|---|
Line 18: | Line 18: | ||
private static final int[] PROTECTION_VALUES = new int[] {A, B, C, D}; | private static final int[] PROTECTION_VALUES = new int[] {A, B, C, D}; | ||
- | // In which A is helmet, B chestplate, C leggings | + | // In which A is boots, B leggings, C chestplate, |
// For reference, Leather uses {1, 2, 3, 1}, and Diamond/ | // For reference, Leather uses {1, 2, 3, 1}, and Diamond/ | ||
} | } | ||
Line 165: | Line 165: | ||
Repeat with all armor items. | Repeat with all armor items. | ||
- | To give your on-body armor a texture, | + | Generally, mod textures go under resources/ |
+ | To give your on-body armor a texture, place X_layer_1.png and X_layer_2.png (where X is the <yarn method_7694> | ||
If you followed everything, you should now be able to have a full armor set! | If you followed everything, you should now be able to have a full armor set! | ||
- | |||
- | ====Adding Knockback Protection==== | ||
- | |||
- | And here comes the so very cursed! | ||
- | |||
- | Mojang decided that they were not only going to hardcode <yarn method_24355>, | ||
- | |||
- | To get around this, we're gonna make a mixin that goes into <yarn class_1738> | ||
- | |||
- | We'll make a class called ArmorItemMixin, | ||
- | |||
- | < | ||
- | @Mixin (class_1738.class) | ||
- | public abstract class ArmorItemMixin { | ||
- | |||
- | } | ||
- | </ | ||
- | |||
- | Now we have to make a @Shadow to modify knockbackResistance, | ||
- | |||
- | < | ||
- | @Mixin (class_1738.class) | ||
- | public abstract class ArmorItemMixin { | ||
- | @Shadow @Final private static UUID[] MODIFIERS; | ||
- | @Shadow @Final @Mutable private Multimap< | ||
- | @Shadow @Final protected float knockbackResistance; | ||
- | } | ||
- | </ | ||
- | |||
- | Next we @Inject our <yarn field_23718> | ||
- | |||
- | < | ||
- | @Mixin (class_1738.class) | ||
- | public abstract class ArmorItemMixin { | ||
- | |||
- | @Shadow @Final private static UUID[] MODIFIERS; | ||
- | @Shadow @Final @Mutable private Multimap< | ||
- | @Shadow @Final protected float knockbackResistance; | ||
- | |||
- | @Inject(method = "< | ||
- | private void constructor(class_1741 material, class_1304 slot, class_1792.class_1793 settings, CallbackInfo ci) { | ||
- | UUID uUID = MODIFIERS[slot.method_5927()]; | ||
- | |||
- | if (material == RegisterItems.CUSTOM_ARMOR_MATERIAL) { | ||
- | ImmutableMultimap.Builder< | ||
- | |||
- | this.attributeModifiers.forEach(builder:: | ||
- | |||
- | builder.put( | ||
- | class_5134.field_23718, | ||
- | new class_1322(uUID, | ||
- | "Armor knockback resistance", | ||
- | this.knockbackResistance, | ||
- | class_1322.class_1323.field_6328 | ||
- | ) | ||
- | ); | ||
- | |||
- | this.attributeModifiers = builder.build(); | ||
- | } | ||
- | } | ||
- | |||
- | } | ||
- | </ | ||
- | |||
- | Now your armor has the knockback resistance value you assigned to it back on CustomArmorMaterial. |
tutorial/armor.txt · Last modified: 2023/08/20 10:19 by wjz_p