From f8cb68375a2bbff38210ce9a9fdd8049cfa70369 Mon Sep 17 00:00:00 2001 From: TechnoVisionDev Date: Thu, 9 Jul 2020 00:21:51 -0700 Subject: [PATCH] Custom Armor --- .../tutorial/armor/ModArmorMaterial.java | 76 ++++++++++++++++++ .../tutorial/tools/ModItemTier.java | 2 +- .../tutorial/util/RegistryHandler.java | 29 ++++--- .../resources/assets/tutorial/lang/en_us.json | 6 +- .../tutorial/models/item/ruby_boots.json | 6 ++ .../tutorial/models/item/ruby_chestplate.json | 6 ++ .../tutorial/models/item/ruby_helmet.json | 6 ++ .../tutorial/models/item/ruby_leggings.json | 6 ++ .../tutorial/textures/items/ruby_boots.png | Bin 0 -> 221 bytes .../textures/items/ruby_chestplate.png | Bin 0 -> 294 bytes .../tutorial/textures/items/ruby_helmet.png | Bin 0 -> 209 bytes .../tutorial/textures/items/ruby_leggings.png | Bin 0 -> 195 bytes .../textures/models/armor/ruby_layer_1.png | Bin 0 -> 582 bytes .../textures/models/armor/ruby_layer_2.png | Bin 0 -> 295 bytes 14 files changed, 122 insertions(+), 15 deletions(-) create mode 100644 src/main/java/com/technovision/tutorial/armor/ModArmorMaterial.java create mode 100644 src/main/resources/assets/tutorial/models/item/ruby_boots.json create mode 100644 src/main/resources/assets/tutorial/models/item/ruby_chestplate.json create mode 100644 src/main/resources/assets/tutorial/models/item/ruby_helmet.json create mode 100644 src/main/resources/assets/tutorial/models/item/ruby_leggings.json create mode 100644 src/main/resources/assets/tutorial/textures/items/ruby_boots.png create mode 100644 src/main/resources/assets/tutorial/textures/items/ruby_chestplate.png create mode 100644 src/main/resources/assets/tutorial/textures/items/ruby_helmet.png create mode 100644 src/main/resources/assets/tutorial/textures/items/ruby_leggings.png create mode 100644 src/main/resources/assets/tutorial/textures/models/armor/ruby_layer_1.png create mode 100644 src/main/resources/assets/tutorial/textures/models/armor/ruby_layer_2.png diff --git a/src/main/java/com/technovision/tutorial/armor/ModArmorMaterial.java b/src/main/java/com/technovision/tutorial/armor/ModArmorMaterial.java new file mode 100644 index 0000000..4439cd8 --- /dev/null +++ b/src/main/java/com/technovision/tutorial/armor/ModArmorMaterial.java @@ -0,0 +1,76 @@ +package com.technovision.tutorial.armor; + +import com.technovision.tutorial.Tutorial; +import com.technovision.tutorial.util.RegistryHandler; +import net.minecraft.inventory.EquipmentSlotType; +import net.minecraft.item.IArmorMaterial; +import net.minecraft.item.crafting.Ingredient; +import net.minecraft.util.LazyValue; +import net.minecraft.util.SoundEvent; +import net.minecraft.util.SoundEvents; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; + +import java.util.function.Supplier; + +public enum ModArmorMaterial implements IArmorMaterial { + + RUBY(Tutorial.MOD_ID + ":ruby", 5, new int[] { 7, 9, 11, 7 }, 18, + SoundEvents.ITEM_ARMOR_EQUIP_GENERIC, 6.9F, () -> { return Ingredient.fromItems(RegistryHandler.RUBY_HELMET.get()); }); + + private static final int[] MAX_DAMAGE_ARRAY = new int[] { 16, 16, 16, 16 }; + 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 LazyValue repairMaterial; + + ModArmorMaterial(String name, int maxDamageFactor, int[] damageReductionAmount, int enchantability, + SoundEvent soundEvent, float toughness, Supplier repairMaterial) { + this.name = name; + this.maxDamageFactor = maxDamageFactor; + this.damageReductionAmountArray = damageReductionAmount; + this.enchantability = enchantability; + this.soundEvent = soundEvent; + this.toughness = toughness; + this.repairMaterial = new LazyValue<>(repairMaterial); + } + + @Override + public int getDurability(EquipmentSlotType slotIn) { + return MAX_DAMAGE_ARRAY[slotIn.getIndex()] * this.maxDamageFactor; + } + + @Override + public int getDamageReductionAmount(EquipmentSlotType slotIn) { + return this.damageReductionAmountArray[slotIn.getIndex()]; + } + + @Override + public int getEnchantability() { + return this.enchantability; + } + + @Override + public SoundEvent getSoundEvent() { + return this.soundEvent; + } + + @Override + public Ingredient getRepairMaterial() { + return this.repairMaterial.getValue(); + } + + @OnlyIn(Dist.CLIENT) + @Override + public String getName() { + return this.name; + } + + @Override + public float getToughness() { + return this.toughness; + } +} diff --git a/src/main/java/com/technovision/tutorial/tools/ModItemTier.java b/src/main/java/com/technovision/tutorial/tools/ModItemTier.java index f1aad72..9d991ce 100644 --- a/src/main/java/com/technovision/tutorial/tools/ModItemTier.java +++ b/src/main/java/com/technovision/tutorial/tools/ModItemTier.java @@ -8,7 +8,7 @@ import java.util.function.Supplier; public enum ModItemTier implements IItemTier { - RUBY(2, 800, 7.0F, 3.0F, 12, () -> { + RUBY(3, 800, 7.0F, 3.0F, 12, () -> { return Ingredient.fromItems(RegistryHandler.RUBY_SWORD.get()); }); diff --git a/src/main/java/com/technovision/tutorial/util/RegistryHandler.java b/src/main/java/com/technovision/tutorial/util/RegistryHandler.java index 726e6fa..e262d88 100644 --- a/src/main/java/com/technovision/tutorial/util/RegistryHandler.java +++ b/src/main/java/com/technovision/tutorial/util/RegistryHandler.java @@ -1,11 +1,13 @@ package com.technovision.tutorial.util; import com.technovision.tutorial.Tutorial; +import com.technovision.tutorial.armor.ModArmorMaterial; import com.technovision.tutorial.blocks.BlockItemBase; import com.technovision.tutorial.blocks.RubyBlock; import com.technovision.tutorial.items.ItemBase; import com.technovision.tutorial.tools.ModItemTier; import net.minecraft.block.Block; +import net.minecraft.inventory.EquipmentSlotType; import net.minecraft.item.*; import net.minecraftforge.fml.RegistryObject; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; @@ -26,20 +28,21 @@ public class RegistryHandler { public static final RegistryObject RUBY = ITEMS.register("ruby", ItemBase::new); // Tools - public static final RegistryObject RUBY_SWORD = ITEMS.register("ruby_sword", () -> - new SwordItem(ModItemTier.RUBY, 2, -2.4F, new Item.Properties().group(Tutorial.TAB))); + public static final RegistryObject RUBY_SWORD = ITEMS.register("ruby_sword", () -> new SwordItem(ModItemTier.RUBY, 2, -2.4F, new Item.Properties().group(Tutorial.TAB))); + public static final RegistryObject RUBY_PICKAXE = ITEMS.register("ruby_pickaxe", () -> new PickaxeItem(ModItemTier.RUBY, 0, -2.8F, new Item.Properties().group(Tutorial.TAB))); + public static final RegistryObject RUBY_SHOVEL = ITEMS.register("ruby_shovel", () -> new ShovelItem(ModItemTier.RUBY, 0.5F, -3.0F, new Item.Properties().group(Tutorial.TAB))); + public static final RegistryObject RUBY_AXE = ITEMS.register("ruby_axe", () -> new AxeItem(ModItemTier.RUBY, 5, -3.1F, new Item.Properties().group(Tutorial.TAB))); + public static final RegistryObject RUBY_HOE = ITEMS.register("ruby_hoe", () -> new HoeItem(ModItemTier.RUBY,-1.0F, new Item.Properties().group(Tutorial.TAB))); - public static final RegistryObject RUBY_PICKAXE = ITEMS.register("ruby_pickaxe", () -> - new PickaxeItem(ModItemTier.RUBY, 0, -2.8F, new Item.Properties().group(Tutorial.TAB))); - - public static final RegistryObject RUBY_SHOVEL = ITEMS.register("ruby_shovel", () -> - new ShovelItem(ModItemTier.RUBY,0.5F, -3.0F, new Item.Properties().group(Tutorial.TAB))); - - public static final RegistryObject RUBY_AXE = ITEMS.register("ruby_axe", () -> - new AxeItem(ModItemTier.RUBY, 5, -3.1F, new Item.Properties().group(Tutorial.TAB))); - - public static final RegistryObject RUBY_HOE = ITEMS.register("ruby_hoe", () -> - new HoeItem(ModItemTier.RUBY, -1.0F, new Item.Properties().group(Tutorial.TAB))); + // Armor + public static final RegistryObject RUBY_HELMET = ITEMS.register("ruby_helmet", () -> + new ArmorItem(ModArmorMaterial.RUBY, EquipmentSlotType.HEAD, new Item.Properties().group(Tutorial.TAB))); + public static final RegistryObject RUBY_CHESTPLATE = ITEMS.register("ruby_chestplate", () -> + new ArmorItem(ModArmorMaterial.RUBY, EquipmentSlotType.CHEST, new Item.Properties().group(Tutorial.TAB))); + public static final RegistryObject RUBY_LEGGINGS = ITEMS.register("ruby_leggings", () -> + new ArmorItem(ModArmorMaterial.RUBY, EquipmentSlotType.LEGS, new Item.Properties().group(Tutorial.TAB))); + public static final RegistryObject RUBY_BOOTS = ITEMS.register("ruby_boots", () -> + new ArmorItem(ModArmorMaterial.RUBY, EquipmentSlotType.FEET, new Item.Properties().group(Tutorial.TAB))); // Blocks public static final RegistryObject RUBY_BLOCK = BLOCKS.register("ruby_block", RubyBlock::new); diff --git a/src/main/resources/assets/tutorial/lang/en_us.json b/src/main/resources/assets/tutorial/lang/en_us.json index f485499..13528da 100644 --- a/src/main/resources/assets/tutorial/lang/en_us.json +++ b/src/main/resources/assets/tutorial/lang/en_us.json @@ -6,5 +6,9 @@ "item.tutorial.ruby_pickaxe": "Ruby Pickaxe", "item.tutorial.ruby_shovel": "Ruby Shovel", "item.tutorial.ruby_axe": "Ruby Axe", - "item.tutorial.ruby_hoe": "Ruby Hoe" + "item.tutorial.ruby_hoe": "Ruby Hoe", + "item.tutorial.ruby_helmet": "Ruby Helmet", + "item.tutorial.ruby_chestplate": "Ruby Chestplate", + "item.tutorial.ruby_leggings": "Ruby Leggings", + "item.tutorial.ruby_boots": "Ruby Boots" } \ No newline at end of file diff --git a/src/main/resources/assets/tutorial/models/item/ruby_boots.json b/src/main/resources/assets/tutorial/models/item/ruby_boots.json new file mode 100644 index 0000000..9ac0eb3 --- /dev/null +++ b/src/main/resources/assets/tutorial/models/item/ruby_boots.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "tutorial:items/ruby_boots" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/tutorial/models/item/ruby_chestplate.json b/src/main/resources/assets/tutorial/models/item/ruby_chestplate.json new file mode 100644 index 0000000..593a3fa --- /dev/null +++ b/src/main/resources/assets/tutorial/models/item/ruby_chestplate.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "tutorial:items/ruby_chestplate" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/tutorial/models/item/ruby_helmet.json b/src/main/resources/assets/tutorial/models/item/ruby_helmet.json new file mode 100644 index 0000000..6c8fe8f --- /dev/null +++ b/src/main/resources/assets/tutorial/models/item/ruby_helmet.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "tutorial:items/ruby_helmet" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/tutorial/models/item/ruby_leggings.json b/src/main/resources/assets/tutorial/models/item/ruby_leggings.json new file mode 100644 index 0000000..b209236 --- /dev/null +++ b/src/main/resources/assets/tutorial/models/item/ruby_leggings.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "tutorial:items/ruby_leggings" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/tutorial/textures/items/ruby_boots.png b/src/main/resources/assets/tutorial/textures/items/ruby_boots.png new file mode 100644 index 0000000000000000000000000000000000000000..60ff03e950046de89494351cecc3476e8523306d GIT binary patch literal 221 zcmV<303!d1P))p+Aq*A`-pBO-X3pM~ zs_qZ;H1`}jFr%nqA;N2(5o0WXo^Fs9AcAF@T0lqd1BN^J8(<%x2tf38h(7rnGd!Wg zl+9oXSe;Y2uPdJUlW?6<0hqz7zU*2EAwRaQ@f1KxsT_L#=QTG-t(ouoRsQvJ4R`Pc XIvbJ^-ndQd00000NkvXXu0mjfN#9st literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/tutorial/textures/items/ruby_chestplate.png b/src/main/resources/assets/tutorial/textures/items/ruby_chestplate.png new file mode 100644 index 0000000000000000000000000000000000000000..a3bdeb528c4e580ee6b04f2c4dbee00aa327cc5a GIT binary patch literal 294 zcmV+>0oneEP)o!J$9DgXZ`ewW5zL5h82|tP07*qoM6N<$f<4K3oB#j- literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/tutorial/textures/items/ruby_helmet.png b/src/main/resources/assets/tutorial/textures/items/ruby_helmet.png new file mode 100644 index 0000000000000000000000000000000000000000..d26c0a6b8ac1aaac2b2346302826244cf9f834bf GIT binary patch literal 209 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Gdx`!LoEE0Qx*sq1g)6gXvX&9 z)vJHUpKUrlT|YUZLy_T9&C5@zJb!I{e0XXfJ>oe(-`@RV^P$G*uj zn{G4c%<436Xl!)!4;O#eYo344KxA)?=N@i{S@w2&dWHD*?_@pLCh(NCi+94LDJcnm zf6XfqZzyRz9DJj@Uq zd-wkjp1n0cjk@GS_&h!@Jw3hf)%&EBlo<+&2S5DzS-ivU4cnh~t0uv#jVh8Cjvi@w zG-=cS|B@YM3`+!99L}*eHi_#?c$hKVT)$z1;z`!UYzx#RCNUX4J0)5nawtgV1Vhdv ug;oj8k7s9_e_(0JVK6J?VLowkCWFL@wSsFqG#r7hV(@hJb6Mw<&;$T&Zb_5? literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/tutorial/textures/models/armor/ruby_layer_1.png b/src/main/resources/assets/tutorial/textures/models/armor/ruby_layer_1.png new file mode 100644 index 0000000000000000000000000000000000000000..2315c0742c36bb7849c99fc7cffae9b99f20d94f GIT binary patch literal 582 zcmV-M0=fN(P)OTOj5x+Qu7LWYHEJLQ&K>c%ugs0w%qOarFKTn>#Fet!0m3=`0%kL|(4pgO=MgIK3e-~V0f*#O{kkS9R`1@jny za;+l_1EhnJ_IOM6*LbU{ruwsmkL|3SRm1?m9rjTYdqei{GqVPu>m&!zBnSwfg z0C0W`)B3WBo}+eyeHxSESt&oxWFIly zdkAPwJyg|?I^w?mp2|?sdXCurnq64eLRMvf_8-v%qZitA|HUI|40ACjMQ5FDjmXHi;07zCP4}re` zVAEN7%LD~*X|gK}H4WFoGi2R*CB`Z4x-LUu6Y5kS&V)ED_x!pNi#;S)$3p%11cuQe UKX-hc-v9sr07*qoM6N<$g4ak1VE_OC literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/tutorial/textures/models/armor/ruby_layer_2.png b/src/main/resources/assets/tutorial/textures/models/armor/ruby_layer_2.png new file mode 100644 index 0000000000000000000000000000000000000000..8354da7d46c33bc581e62d6d8f3fda8e8f2d1d90 GIT binary patch literal 295 zcmeAS@N?(olHy`uVBq!ia0vp^4nVBH!3HE3&8=$zQtv!n978gk-%dB=Yc>#Zp6spg z?n2|rz5nm*O=l=bP0l+XkKXA6Ex literal 0 HcmV?d00001