mirror of
https://github.com/TechnoVisionDev/Forge-Modding-Tutorial-1.16
synced 2024-10-27 20:34:04 +00:00
Custom Armor
This commit is contained in:
parent
e34e51e48c
commit
f8cb68375a
@ -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<Ingredient> repairMaterial;
|
||||||
|
|
||||||
|
ModArmorMaterial(String name, int maxDamageFactor, int[] damageReductionAmount, int enchantability,
|
||||||
|
SoundEvent soundEvent, float toughness, Supplier<Ingredient> 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;
|
||||||
|
}
|
||||||
|
}
|
@ -8,7 +8,7 @@ import java.util.function.Supplier;
|
|||||||
|
|
||||||
public enum ModItemTier implements IItemTier {
|
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());
|
return Ingredient.fromItems(RegistryHandler.RUBY_SWORD.get());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
package com.technovision.tutorial.util;
|
package com.technovision.tutorial.util;
|
||||||
|
|
||||||
import com.technovision.tutorial.Tutorial;
|
import com.technovision.tutorial.Tutorial;
|
||||||
|
import com.technovision.tutorial.armor.ModArmorMaterial;
|
||||||
import com.technovision.tutorial.blocks.BlockItemBase;
|
import com.technovision.tutorial.blocks.BlockItemBase;
|
||||||
import com.technovision.tutorial.blocks.RubyBlock;
|
import com.technovision.tutorial.blocks.RubyBlock;
|
||||||
import com.technovision.tutorial.items.ItemBase;
|
import com.technovision.tutorial.items.ItemBase;
|
||||||
import com.technovision.tutorial.tools.ModItemTier;
|
import com.technovision.tutorial.tools.ModItemTier;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.inventory.EquipmentSlotType;
|
||||||
import net.minecraft.item.*;
|
import net.minecraft.item.*;
|
||||||
import net.minecraftforge.fml.RegistryObject;
|
import net.minecraftforge.fml.RegistryObject;
|
||||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||||
@ -26,20 +28,21 @@ public class RegistryHandler {
|
|||||||
public static final RegistryObject<Item> RUBY = ITEMS.register("ruby", ItemBase::new);
|
public static final RegistryObject<Item> RUBY = ITEMS.register("ruby", ItemBase::new);
|
||||||
|
|
||||||
// Tools
|
// Tools
|
||||||
public static final RegistryObject<SwordItem> RUBY_SWORD = ITEMS.register("ruby_sword", () ->
|
public static final RegistryObject<SwordItem> RUBY_SWORD = ITEMS.register("ruby_sword", () -> new SwordItem(ModItemTier.RUBY, 2, -2.4F, new Item.Properties().group(Tutorial.TAB)));
|
||||||
new SwordItem(ModItemTier.RUBY, 2, -2.4F, new Item.Properties().group(Tutorial.TAB)));
|
public static final RegistryObject<PickaxeItem> RUBY_PICKAXE = ITEMS.register("ruby_pickaxe", () -> new PickaxeItem(ModItemTier.RUBY, 0, -2.8F, new Item.Properties().group(Tutorial.TAB)));
|
||||||
|
public static final RegistryObject<ShovelItem> RUBY_SHOVEL = ITEMS.register("ruby_shovel", () -> new ShovelItem(ModItemTier.RUBY, 0.5F, -3.0F, new Item.Properties().group(Tutorial.TAB)));
|
||||||
|
public static final RegistryObject<AxeItem> RUBY_AXE = ITEMS.register("ruby_axe", () -> new AxeItem(ModItemTier.RUBY, 5, -3.1F, new Item.Properties().group(Tutorial.TAB)));
|
||||||
|
public static final RegistryObject<HoeItem> RUBY_HOE = ITEMS.register("ruby_hoe", () -> new HoeItem(ModItemTier.RUBY,-1.0F, new Item.Properties().group(Tutorial.TAB)));
|
||||||
|
|
||||||
public static final RegistryObject<PickaxeItem> RUBY_PICKAXE = ITEMS.register("ruby_pickaxe", () ->
|
// Armor
|
||||||
new PickaxeItem(ModItemTier.RUBY, 0, -2.8F, new Item.Properties().group(Tutorial.TAB)));
|
public static final RegistryObject<ArmorItem> RUBY_HELMET = ITEMS.register("ruby_helmet", () ->
|
||||||
|
new ArmorItem(ModArmorMaterial.RUBY, EquipmentSlotType.HEAD, new Item.Properties().group(Tutorial.TAB)));
|
||||||
public static final RegistryObject<ShovelItem> RUBY_SHOVEL = ITEMS.register("ruby_shovel", () ->
|
public static final RegistryObject<ArmorItem> RUBY_CHESTPLATE = ITEMS.register("ruby_chestplate", () ->
|
||||||
new ShovelItem(ModItemTier.RUBY,0.5F, -3.0F, new Item.Properties().group(Tutorial.TAB)));
|
new ArmorItem(ModArmorMaterial.RUBY, EquipmentSlotType.CHEST, new Item.Properties().group(Tutorial.TAB)));
|
||||||
|
public static final RegistryObject<ArmorItem> RUBY_LEGGINGS = ITEMS.register("ruby_leggings", () ->
|
||||||
public static final RegistryObject<AxeItem> RUBY_AXE = ITEMS.register("ruby_axe", () ->
|
new ArmorItem(ModArmorMaterial.RUBY, EquipmentSlotType.LEGS, new Item.Properties().group(Tutorial.TAB)));
|
||||||
new AxeItem(ModItemTier.RUBY, 5, -3.1F, new Item.Properties().group(Tutorial.TAB)));
|
public static final RegistryObject<ArmorItem> RUBY_BOOTS = ITEMS.register("ruby_boots", () ->
|
||||||
|
new ArmorItem(ModArmorMaterial.RUBY, EquipmentSlotType.FEET, new Item.Properties().group(Tutorial.TAB)));
|
||||||
public static final RegistryObject<HoeItem> RUBY_HOE = ITEMS.register("ruby_hoe", () ->
|
|
||||||
new HoeItem(ModItemTier.RUBY, -1.0F, new Item.Properties().group(Tutorial.TAB)));
|
|
||||||
|
|
||||||
// Blocks
|
// Blocks
|
||||||
public static final RegistryObject<Block> RUBY_BLOCK = BLOCKS.register("ruby_block", RubyBlock::new);
|
public static final RegistryObject<Block> RUBY_BLOCK = BLOCKS.register("ruby_block", RubyBlock::new);
|
||||||
|
@ -6,5 +6,9 @@
|
|||||||
"item.tutorial.ruby_pickaxe": "Ruby Pickaxe",
|
"item.tutorial.ruby_pickaxe": "Ruby Pickaxe",
|
||||||
"item.tutorial.ruby_shovel": "Ruby Shovel",
|
"item.tutorial.ruby_shovel": "Ruby Shovel",
|
||||||
"item.tutorial.ruby_axe": "Ruby Axe",
|
"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"
|
||||||
}
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"parent": "item/generated",
|
||||||
|
"textures": {
|
||||||
|
"layer0": "tutorial:items/ruby_boots"
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"parent": "item/generated",
|
||||||
|
"textures": {
|
||||||
|
"layer0": "tutorial:items/ruby_chestplate"
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"parent": "item/generated",
|
||||||
|
"textures": {
|
||||||
|
"layer0": "tutorial:items/ruby_helmet"
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"parent": "item/generated",
|
||||||
|
"textures": {
|
||||||
|
"layer0": "tutorial:items/ruby_leggings"
|
||||||
|
}
|
||||||
|
}
|
BIN
src/main/resources/assets/tutorial/textures/items/ruby_boots.png
Normal file
BIN
src/main/resources/assets/tutorial/textures/items/ruby_boots.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 221 B |
Binary file not shown.
After Width: | Height: | Size: 294 B |
Binary file not shown.
After Width: | Height: | Size: 209 B |
Binary file not shown.
After Width: | Height: | Size: 195 B |
Binary file not shown.
After Width: | Height: | Size: 582 B |
Binary file not shown.
After Width: | Height: | Size: 295 B |
Loading…
Reference in New Issue
Block a user