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 [2020/06/17 20:19] – Some corrections in spacing and pack format (5 for 1.15 & 1.16) terantai | tutorial:armor [2020/10/09 19:04] – Knockback warning sakira | ||
---|---|---|---|
Line 3: | Line 3: | ||
==== Introduction ==== | ==== Introduction ==== | ||
- | While Armor is a bit more complicated to add then a normal block/item, once you can understand it, it becomes simple to make. To add Armor, we'll first make a custom material | + | While Armor is a bit more complicated to add then a normal block/item, once you can understand it, it becomes simple to make. |
+ | To add Armor, we'll first make a CustomArmorMaterial | ||
+ | There' | ||
==== Creating an Armor Material class ==== | ==== Creating an Armor Material class ==== | ||
Line 28: | Line 30: | ||
- Toughness. This is a second protection value where the armor is more durable against high value attacks. | - Toughness. This is a second protection value where the armor is more durable against high value attacks. | ||
- A repair ingredient. This will be a '' | - A repair ingredient. This will be a '' | ||
+ | |||
+ | If you're on 1.16+, they also have a new argument: | ||
+ | - Knockback Resistance. This is the scale of the amount of knockback resisted from attacks, explosions, and projectiles. 1.0 is 100%. | ||
With those arguments, it should now look something like this: | With those arguments, it should now look something like this: | ||
Line 33: | Line 38: | ||
<code java [enable_line_numbers=" | <code java [enable_line_numbers=" | ||
public enum CustomArmorMaterial implements ArmorMaterial { | public enum CustomArmorMaterial implements ArmorMaterial { | ||
- | CustomArmorMaterial(String name, int durabilityMultiplier, | + | CustomArmorMaterial(String name, int durabilityMultiplier, |
| | ||
} | } | ||
Line 49: | Line 54: | ||
private final SoundEvent equipSound; | private final SoundEvent equipSound; | ||
private final float toughness; | private final float toughness; | ||
+ | private final float knockbackResistance; | ||
private final Lazy< | private final Lazy< | ||
| | ||
- | CustomArmorMaterial(String name, int durabilityMultiplier, | + | CustomArmorMaterial(String name, int durabilityMultiplier, |
this.name = name; | this.name = name; | ||
this.durabilityMultiplier = durabilityMultiplier; | this.durabilityMultiplier = durabilityMultiplier; | ||
Line 58: | Line 64: | ||
this.equipSound = soundEvent; | this.equipSound = soundEvent; | ||
this.toughness = toughness; | this.toughness = toughness; | ||
+ | this.knockbackResistance = knockbackResistance; | ||
this.repairIngredient = new Lazy(repairIngredient); | this.repairIngredient = new Lazy(repairIngredient); | ||
} | } | ||
Line 76: | Line 83: | ||
private final SoundEvent equipSound; | private final SoundEvent equipSound; | ||
private final float toughness; | private final float toughness; | ||
+ | private final float knockbackResistance; | ||
private final Lazy< | private final Lazy< | ||
| | ||
- | CustomArmorMaterial(String name, int durabilityMultiplier, | + | CustomArmorMaterial(String name, int durabilityMultiplier, |
this.name = name; | this.name = name; | ||
this.durabilityMultiplier = durabilityMultiplier; | this.durabilityMultiplier = durabilityMultiplier; | ||
Line 116: | Line 124: | ||
public float getToughness() { | public float getToughness() { | ||
return this.toughness; | return this.toughness; | ||
+ | } | ||
+ | | ||
+ | public float getKnockbackResistance() { | ||
+ | return this.knockbackResistance; | ||
} | } | ||
} | } | ||
Line 124: | Line 136: | ||
<code java [enable_line_numbers=" | <code java [enable_line_numbers=" | ||
public enum CustomArmorMaterial implements ArmorMaterial { | public enum CustomArmorMaterial implements ArmorMaterial { | ||
- | WOOL(" | + | WOOL(" |
return Ingredient.ofItems(Items.WHITE_WOOL); | return Ingredient.ofItems(Items.WHITE_WOOL); | ||
}); | }); |
tutorial/armor.txt · Last modified: 2023/08/20 10:19 by wjz_p