User Tools

Site Tools


tutorial:armor

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
tutorial:armor [2019/09/27 20:42] – SoundEvents.ITEM_ARMOR_EQUIP_X, as SoundEvents.ITEM.EQUIP.ARMOR.X doesn't exist descuddlebattutorial:armor [2020/08/01 00:59] – Add in Knockback Resistance ggtylerr
Line 28: Line 28:
   - 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 ''Supplier<Ingredient>'' instance instead of an ''Item'', which will go over in a bit.   - A repair ingredient. This will be a ''Supplier<Ingredient>'' instance instead of an ''Item'', which will go over in a bit.
 +
 +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="true"]> <code java [enable_line_numbers="true"]>
 public enum CustomArmorMaterial implements ArmorMaterial { public enum CustomArmorMaterial implements ArmorMaterial {
-    CustomArmorMaterial(String name, int durabilityMultiplier, int[] armorValueArr, int enchantability, SoundEvent soundEvent, float toughness, Supplier<Ingredient> repairIngredient) {+    CustomArmorMaterial(String name, int durabilityMultiplier, int[] armorValueArr, int enchantability, SoundEvent soundEvent, float toughness, float knockbackResistance, Supplier<Ingredient> repairIngredient) {
                  
     }     }
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<Ingredient> repairIngredient;     private final Lazy<Ingredient> repairIngredient;
          
-    CustomArmorMaterial(String name, int durabilityMultiplier, int[] armorValueArr, int enchantability, SoundEvent soundEvent, float toughness, Supplier<Ingredient> repairIngredient) {+    CustomArmorMaterial(String name, int durabilityMultiplier, int[] armorValueArr, int enchantability, SoundEvent soundEvent, float toughness, float knockbackResistance, Supplier<Ingredient> repairIngredient) {
         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); // We'll need this to be a Lazy type for later.         this.repairIngredient = new Lazy(repairIngredient); // We'll need this to be a Lazy type for later.
     }     }
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<Ingredient> repairIngredient;     private final Lazy<Ingredient> repairIngredient;
          
-    CustomArmorMaterial(String name, int durabilityMultiplier, int[] armorValueArr, int enchantability, SoundEvent soundEvent, float toughness, Supplier<Ingredient> repairIngredient) {+    CustomArmorMaterial(String name, int durabilityMultiplier, int[] armorValueArr, int enchantability, SoundEvent soundEvent, float toughness, float knockbackResistance, Supplier<Ingredient> repairIngredient) {
         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="true"]> <code java [enable_line_numbers="true"]>
 public enum CustomArmorMaterial implements ArmorMaterial { public enum CustomArmorMaterial implements ArmorMaterial {
-    WOOL("wool", 5, new int[]{1,3,2,1}, 15, SoundEvents.BLOCK_WOOL_PLACE, 0.0F, () -> {+    WOOL("wool", 5, new int[]{1,3,2,1}, 15, SoundEvents.BLOCK_WOOL_PLACE, 0.0F, 0.0F, () -> {
         return Ingredient.ofItems(Items.WHITE_WOOL);         return Ingredient.ofItems(Items.WHITE_WOOL);
     });     });
Line 167: Line 177:
 { {
     "pack":{     "pack":{
-        "pack_format":4+        "pack_format": 5
-        "description":"Tutorial Mod"+        "description": "Tutorial Mod"
     }     }
 } }
tutorial/armor.txt · Last modified: 2023/08/20 10:19 by wjz_p