tutorial:armor
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revisionNext revisionBoth sides next revision | ||
tutorial:armor [2019/07/19 05:33] – created (Feel free to edit if I missed anything, this was all done by looking at the vanilla code so it's pretty likely I missed something :P) ggtylerr | tutorial:armor [2020/08/01 00:59] – Add in Knockback Resistance ggtylerr | ||
---|---|---|---|
Line 25: | Line 25: | ||
- Armor values, or " | - Armor values, or " | ||
- Enchantability. This will be how likely the armor can get high level or multiple enchantments in an enchantment book. | - Enchantability. This will be how likely the armor can get high level or multiple enchantments in an enchantment book. | ||
- | - A sound event. The standard used by vanilla armor is '' | + | - A sound event. The standard used by vanilla armor is '' |
- 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 36: | ||
<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 52: | ||
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 62: | ||
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 81: | ||
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 122: | ||
public float getToughness() { | public float getToughness() { | ||
return this.toughness; | return this.toughness; | ||
+ | } | ||
+ | | ||
+ | public float getKnockbackResistance() { | ||
+ | return this.knockbackResistance; | ||
} | } | ||
} | } | ||
Line 124: | Line 134: | ||
<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); | ||
}); | }); | ||
Line 167: | Line 177: | ||
{ | { | ||
" | " | ||
- | " | + | " |
- | " | + | " |
} | } | ||
} | } |
tutorial/armor.txt · Last modified: 2023/08/20 10:19 by wjz_p