added armor

This commit is contained in:
IM23a-loritzg
2025-05-28 09:59:16 +02:00
parent 46cc28c4a1
commit 1837116013
7 changed files with 78 additions and 6 deletions
@@ -35,5 +35,6 @@ public class DataGenerators {
generator.addProvider(event.includeClient(), new ModBlockStateProvider(packOutput, existingFileHelper)); generator.addProvider(event.includeClient(), new ModBlockStateProvider(packOutput, existingFileHelper));
generator.addProvider(event.includeClient(), new ModItemModelProvider(packOutput, existingFileHelper)); generator.addProvider(event.includeClient(), new ModItemModelProvider(packOutput, existingFileHelper));
generator.addProvider(event.includeServer(), new ModDatapackProvider(packOutput, lookupProvider)); generator.addProvider(event.includeServer(), new ModDatapackProvider(packOutput, lookupProvider));
} }
} }
@@ -20,6 +20,5 @@ public class ModItemModelProvider extends ItemModelProvider {
handheldItem(ModItems.STALINIUM_AXE.get()); handheldItem(ModItems.STALINIUM_AXE.get());
handheldItem(ModItems.STALINIUM_SHOVEL.get()); handheldItem(ModItems.STALINIUM_SHOVEL.get());
handheldItem(ModItems.STALINIUM_HOE.get()); handheldItem(ModItems.STALINIUM_HOE.get());
handheldItem(ModItems.STALINIUM_PICKAXE.get());
} }
} }
@@ -34,5 +34,10 @@ public class ModItemTagProvider extends ItemTagsProvider {
.add(ModItems.STALINIUM_SHOVEL.get()); .add(ModItems.STALINIUM_SHOVEL.get());
this.tag(ItemTags.HOES) this.tag(ItemTags.HOES)
.add(ModItems.STALINIUM_HOE.get()); .add(ModItems.STALINIUM_HOE.get());
this.tag(ItemTags.TRIMMABLE_ARMOR)
.add(ModItems.STALINIUM_HELMET.get())
.add(ModItems.STALINIUM_CHESTPLATE.get())
.add(ModItems.STALINIUM_LEGGINGS.get())
.add(ModItems.STALINIUM_BOOTS.get());
} }
} }
@@ -0,0 +1,47 @@
package net.krituximon.stalinium.item;
import net.krituximon.stalinium.Stalinium;
import net.minecraft.Util;
import net.minecraft.core.Holder;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.item.ArmorItem;
import net.minecraft.world.item.ArmorMaterial;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.crafting.Ingredient;
import java.util.EnumMap;
import java.util.List;
import java.util.function.Supplier;
public class ModArmorMaterials {
public static final Holder<ArmorMaterial> STALINIUM_ARMOR_MATERIAL = register("stalinium",
Util.make(new EnumMap<>(ArmorItem.Type.class), attribute -> {
attribute.put(ArmorItem.Type.BOOTS, 5);
attribute.put(ArmorItem.Type.LEGGINGS, 7);
attribute.put(ArmorItem.Type.CHESTPLATE, 9);
attribute.put(ArmorItem.Type.HELMET, 5);
attribute.put(ArmorItem.Type.BODY, 11);
}), 16, 2f, 0.1f, () -> ModItems.STALINIUM_INGOT.get());
private static Holder<ArmorMaterial> register(String name, EnumMap<ArmorItem.Type, Integer> typeProtection,
int enchantability, float toughness, float knockbackResistance,
Supplier<Item> ingredientItem) {
ResourceLocation location = ResourceLocation.fromNamespaceAndPath(Stalinium.MODID, name);
Holder<SoundEvent> equipSound = SoundEvents.ARMOR_EQUIP_NETHERITE;
Supplier<Ingredient> ingredient = () -> Ingredient.of(ingredientItem.get());
List<ArmorMaterial.Layer> layers = List.of(new ArmorMaterial.Layer(location));
EnumMap<ArmorItem.Type, Integer> typeMap = new EnumMap<>(ArmorItem.Type.class);
for (ArmorItem.Type type : ArmorItem.Type.values()) {
typeMap.put(type, typeProtection.get(type));
}
return Registry.registerForHolder(BuiltInRegistries.ARMOR_MATERIAL, location,
new ArmorMaterial(typeProtection, enchantability, equipSound, ingredient, layers, toughness, knockbackResistance));
}
}
@@ -30,7 +30,6 @@ public class ModCreativeModeTabs {
output.accept(ModItems.STALINIUM_AXE.get()); output.accept(ModItems.STALINIUM_AXE.get());
output.accept(ModItems.STALINIUM_SHOVEL.get()); output.accept(ModItems.STALINIUM_SHOVEL.get());
output.accept(ModItems.STALINIUM_HOE.get()); output.accept(ModItems.STALINIUM_HOE.get());
output.accept(ModItems.STALINIUM_PICKAXE.get());
}).build()); }).build());
public static void register(IEventBus eventBus) { public static void register(IEventBus eventBus) {
@@ -4,7 +4,6 @@ import net.krituximon.stalinium.Stalinium;
import net.krituximon.stalinium.sound.ModSounds; import net.krituximon.stalinium.sound.ModSounds;
import net.minecraft.world.item.*; import net.minecraft.world.item.*;
import net.neoforged.bus.api.IEventBus; import net.neoforged.bus.api.IEventBus;
import net.neoforged.neoforge.registries.DeferredHolder;
import net.neoforged.neoforge.registries.DeferredItem; import net.neoforged.neoforge.registries.DeferredItem;
import net.neoforged.neoforge.registries.DeferredRegister; import net.neoforged.neoforge.registries.DeferredRegister;
@@ -28,6 +27,10 @@ public class ModItems {
() -> new StaliniumAxeItem(ModTiers.STALINIUM, new Item.Properties() () -> new StaliniumAxeItem(ModTiers.STALINIUM, new Item.Properties()
.attributes(AxeItem.createAttributes(ModTiers.STALINIUM, 5f, -3.0f)))); .attributes(AxeItem.createAttributes(ModTiers.STALINIUM, 5f, -3.0f))));
public static final DeferredItem<PickaxeItem> STALINIUM_PICKAXE = ITEMS.register("stalinium_pickaxe",
() -> new StaliniumPickaxeItem(ModTiers.STALINIUM, new Item.Properties()
.attributes(PickaxeItem.createAttributes(ModTiers.STALINIUM, 1.0f, -2.8f))));
public static final DeferredItem<ShovelItem> STALINIUM_SHOVEL = ITEMS.register("stalinium_shovel", public static final DeferredItem<ShovelItem> STALINIUM_SHOVEL = ITEMS.register("stalinium_shovel",
() -> new StaliniumShovelItem(ModTiers.STALINIUM, new Item.Properties() () -> new StaliniumShovelItem(ModTiers.STALINIUM, new Item.Properties()
.attributes(ShovelItem.createAttributes(ModTiers.STALINIUM, 1.5f, -3.0f)))); .attributes(ShovelItem.createAttributes(ModTiers.STALINIUM, 1.5f, -3.0f))));
@@ -36,9 +39,22 @@ public class ModItems {
() -> new StaliniumHoeItem(ModTiers.STALINIUM, new Item.Properties() () -> new StaliniumHoeItem(ModTiers.STALINIUM, new Item.Properties()
.attributes(HoeItem.createAttributes(ModTiers.STALINIUM, 1.0f, -3.0f)))); .attributes(HoeItem.createAttributes(ModTiers.STALINIUM, 1.0f, -3.0f))));
public static final DeferredItem<PickaxeItem> STALINIUM_PICKAXE = ITEMS.register("stalinium_pickaxe", public static final DeferredItem<ArmorItem> STALINIUM_HELMET = ITEMS.register("stalinium_helmet",
() -> new StaliniumPickaxeItem(ModTiers.STALINIUM, new Item.Properties() () -> new ArmorItem(ModArmorMaterials.STALINIUM_ARMOR_MATERIAL, ArmorItem.Type.HELMET,
.attributes(PickaxeItem.createAttributes(ModTiers.STALINIUM, 1.0f, -2.8f)))); new Item.Properties().durability(ArmorItem.Type.HELMET.getDurability(19))));
public static final DeferredItem<ArmorItem> STALINIUM_CHESTPLATE = ITEMS.register("stalinium_chestplate",
() -> new ArmorItem(ModArmorMaterials.STALINIUM_ARMOR_MATERIAL, ArmorItem.Type.CHESTPLATE,
new Item.Properties().durability(ArmorItem.Type.CHESTPLATE.getDurability(19))));
public static final DeferredItem<ArmorItem> STALINIUM_LEGGINGS = ITEMS.register("stalinium_leggings",
() -> new ArmorItem(ModArmorMaterials.STALINIUM_ARMOR_MATERIAL, ArmorItem.Type.LEGGINGS,
new Item.Properties().durability(ArmorItem.Type.LEGGINGS.getDurability(19))));
public static final DeferredItem<ArmorItem> STALINIUM_BOOTS = ITEMS.register("stalinium_boots",
() -> new ArmorItem(ModArmorMaterials.STALINIUM_ARMOR_MATERIAL, ArmorItem.Type.BOOTS,
new Item.Properties().durability(ArmorItem.Type.BOOTS.getDurability(19))));
public static void register(IEventBus eventBus) { public static void register(IEventBus eventBus) {
ITEMS.register(eventBus); ITEMS.register(eventBus);
} }
@@ -7,6 +7,11 @@
"item.stalinium.stalinium_hoe": "Stalinium Hoe", "item.stalinium.stalinium_hoe": "Stalinium Hoe",
"item.stalinium.stalinium_pickaxe": "Stalinium Pickaxe", "item.stalinium.stalinium_pickaxe": "Stalinium Pickaxe",
"item.stalinium.stalinium_helmet": "Stalinium Helmet",
"item.stalinium.stalinium_chestplate": "Stalinium Chestplate",
"item.stalinium.stalinium_leggings": "Stalinium Leggings",
"item.stalinium.stalinium_boots": "Stalinium Boots",
"item.stalinium.soviet_anthem_music_disc": "Soviet Anthem Music Disc", "item.stalinium.soviet_anthem_music_disc": "Soviet Anthem Music Disc",
"item.stalinium.soviet_anthem_music_disc.desc": "Ministry of Defense of the USSR - Soviet Union national anthem", "item.stalinium.soviet_anthem_music_disc.desc": "Ministry of Defense of the USSR - Soviet Union national anthem",