MinecraftScripterAI
Discord ↗
Link Copied to Clipboard
×
"Create a armor"
/* To create a custom armor in Minecraft Forge, you'll need to create a new class for the armor that extends ArmorItem and define its properties. */ public class CustomArmor extends ArmorItem { public CustomArmor(IArmorMaterial material, EquipmentSlotType slot, Properties properties) { super(material, slot, properties); } } /* Next, you'll need to register your custom armor in your mod's item registry. */ public static final RegistryObject<Item> CUSTOM_HELMET = ITEMS.register("custom_helmet", () -> new CustomArmor(ModArmorMaterials.CUSTOM_MATERIAL, EquipmentSlotType.HEAD, new Item.Properties().tab(ItemGroup.TAB_COMBAT))); public static final RegistryObject<Item> CUSTOM_CHESTPLATE = ITEMS.register("custom_chestplate", () -> new CustomArmor(ModArmorMaterials.CUSTOM_MATERIAL, EquipmentSlotType.CHEST, new Item.Properties().tab(ItemGroup.TAB_COMBAT))); public static final RegistryObject<Item> CUSTOM_LEGGINGS = ITEMS.register("custom_leggings", () -> new CustomArmor(ModArmorMaterials.CUSTOM_MATERIAL, EquipmentSlotType.LEGS, new Item.Properties().tab(ItemGroup.TAB_COMBAT))); public static final RegistryObject<Item> CUSTOM_BOOTS = ITEMS.register("custom_boots", () -> new CustomArmor(ModArmorMaterials.CUSTOM_MATERIAL, EquipmentSlotType.FEET, new Item.Properties().tab(ItemGroup.TAB_COMBAT))); /* Finally, create a new class for your custom armor material that implements IArmorMaterial. */ public enum ModArmorMaterials implements IArmorMaterial { CUSTOM_MATERIAL("custom_material", 35, new int[]{3, 6, 8, 3}, 15, SoundEvents.ARMOR_EQUIP_DIAMOND, 2.0F, 0.0F, () -> { return Ingredient.of(Items.DIAMOND); }); private static final int[] HEALTH_PER_SLOT = new int[]{13, 15, 16, 11}; private final String name; private final int maxDamageFactor; private final int[] damageReductionAmountArray; private final int enchantability; private final SoundEvent soundEvent; private final float toughness; private final float knockbackResistance; private final LazyValue<Ingredient> repairMaterial; ModArmorMaterials(String name, int maxDamageFactor, int[] damageReductionAmountArray, int enchantability, SoundEvent soundEvent, float toughness, float knockbackResistance, Supplier<Ingredient> repairMaterial) { this.name = name; this.maxDamageFactor = maxDamageFactor; this.damageReductionAmountArray = damageReductionAmountArray; this.enchantability = enchantability; this.soundEvent = soundEvent; this.toughness = toughness; this.knockbackResistance = knockbackResistance; this.repairMaterial = new LazyValue<>(repairMaterial); } @Override public int getDurabilityForSlot(EquipmentSlotType slotIn) { return HEALTH_PER_SLOT[slotIn.getIndex()] * this.maxDamageFactor; } @Override public int getDefenseForSlot(EquipmentSlotType slotIn) { return this.damageReductionAmountArray[slotIn.getIndex()]; } @Override public int getEnchantmentValue() { return this.enchantability; } @Override public SoundEvent getEquipSound() { return this.soundEvent; } @Override public Ingredient getRepairIngredient() { return this.repairMaterial.get(); } @OnlyIn(Dist.CLIENT) @Override public String getName() { return this.name; } @Override public float getToughness() { return this.toughness; } @Override public float getKnockbackResistance() { return this.knockbackResistance; } }