Краш игры при создании своей брони...

Версия Minecraft
1.12.2
API
Forge
38
0
Делал броню, создал ее, зарегал. В игре броня появилась, но я хотел дать ей свою модель и текстуру, начал делать как в учебнике, но что-то не вышло... игра крашит....
SpartaArmor:
public class SpartaArmor extends ItemArmor {
    public SpartaArmor(String name, ArmorMaterial armorMaterial, int renderIndIn, EntityEquipmentSlot entityEquipmentSlot) {
        super(armorMaterial,renderIndIn,entityEquipmentSlot);
        this.setRegistryName(name);
        this.setUnlocalizedName(name);
    }
    public static final ItemArmor.ArmorMaterial ARMOR_MATERIAL = EnumHelper.addArmorMaterial("li:spartaarmor", "li:spartaarmor", 9, new int[]{2, 4, 6, 3}, 10, SoundEvents.ITEM_ARMOR_EQUIP_IRON, 5.0F);
    public String getArmorTexture(ItemStack stack, Entity entity, EntityEquipmentSlot slot, String type) {
        return "li:textures/armor/sparta_armor.png";
    }

    @Override
    @SideOnly(Side.CLIENT)
    public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, EntityEquipmentSlot armorSlot, ModelBiped model) {
        final ModelBiped armorModel = ItemsRegistry.armorModels.get(this);

        if (armorModel != null) {
            armorModel.bipedHead.showModel = armorSlot == EntityEquipmentSlot.HEAD;
            armorModel.bipedHeadwear.showModel = false;
            armorModel.bipedBody.showModel = armorSlot == EntityEquipmentSlot.CHEST || armorSlot == EntityEquipmentSlot.LEGS;
            armorModel.bipedRightArm.showModel = armorSlot == EntityEquipmentSlot.CHEST;
            armorModel.bipedLeftArm.showModel = armorSlot == EntityEquipmentSlot.CHEST;
            armorModel.bipedRightLeg.showModel = armorSlot == EntityEquipmentSlot.LEGS || armorSlot == EntityEquipmentSlot.FEET;
            armorModel.bipedLeftLeg.showModel = armorSlot == EntityEquipmentSlot.LEGS || armorSlot == EntityEquipmentSlot.FEET;

            armorModel.isSneak = entityLiving.isSneaking();
            armorModel.isRiding = entityLiving.isRiding();
            armorModel.isChild = entityLiving.isChild();
        }
        return armorModel;
    }
}

ItemsRegistry:
public static final Item
            BOOTS = new SpartaArmor("boots", SpartaArmor.ARMOR_MATERIAL, 1, EntityEquipmentSlot.FEET),
            LEGGS = new SpartaArmor("leggs", SpartaArmor.ARMOR_MATERIAL, 2, EntityEquipmentSlot.LEGS),
            CHESTPLATE = new SpartaArmor("chestplate", SpartaArmor.ARMOR_MATERIAL, 1, EntityEquipmentSlot.CHEST),
            HEAD = new SpartaArmor("head", SpartaArmor.ARMOR_MATERIAL, 1, EntityEquipmentSlot.HEAD);


    @SubscribeEvent
    public static void onRegistryItem(RegistryEvent.Register<Item> e) {
        e.getRegistry().register(BOOTS);
        e.getRegistry().register(LEGGS);
        e.getRegistry().register(CHESTPLATE);
        e.getRegistry().register(HEAD);
    }

public static void register()
    {
        SpartaArmorModel
                HeadModel = new SpartaArmorModel(0),
                ArmorModel = new SpartaArmorModel(1),
                LeggsModel = new SpartaArmorModel(2),
                BootsModel = new SpartaArmorModel(3);
        ItemsRegistry.armorModels.put(ItemsRegistry.HEAD, HeadModel);
        ItemsRegistry.armorModels.put(ItemsRegistry.CHESTPLATE, ArmorModel);
        ItemsRegistry.armorModels.put(ItemsRegistry.LEGGS, LeggsModel);
        ItemsRegistry.armorModels.put(ItemsRegistry.BOOTS, BootsModel);
    }
 
Краш-лог
[15:03:07] [Client thread/WARN] [FML]: Zip file asm-analysis-6.2.jar failed to read properly, it will be ignored
net.minecraftforge.fml.common.LoaderException: java.lang.IllegalArgumentException

at net.minecraftforge.fml.common.discovery.asm.ASMModParser.<init>(ASMModParser.java:63) ~[ASMModParser.class:?]
at net.minecraftforge.fml.common.discovery.JarDiscoverer.findClassesASM(JarDiscoverer.java:102) ~[JarDiscoverer.class:?]
at net.minecraftforge.fml.common.discovery.JarDiscoverer.discover(JarDiscoverer.java:77) [JarDiscoverer.class:?]
at net.minecraftforge.fml.common.discovery.ContainerType.findMods(ContainerType.java:47) [ContainerType.class:?]
at net.minecraftforge.fml.common.discovery.ModCandidate.explore(ModCandidate.java:74) [ModCandidate.class:?]
at net.minecraftforge.fml.common.discovery.ModDiscoverer.identifyMods(ModDiscoverer.java:93) [ModDiscoverer.class:?]
at net.minecraftforge.fml.common.Loader.identifyMods(Loader.java:427) [Loader.class:?]
at net.minecraftforge.fml.common.Loader.loadMods(Loader.java:568) [Loader.class:?]
at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:232) [FMLClientHandler.class:?]
at net.minecraft.client.Minecraft.init(Minecraft.java:467) [Minecraft.class:?]
at net.minecraft.client.Minecraft.run(Minecraft.java:378) [Minecraft.class:?]
at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_302]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_302]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_302]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_302]
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]
at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_302]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_302]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_302]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_302]
at net.minecraftforge.legacydev.Main.start(Main.java:86) [legacydev-0.2.3.1-fatjar.jar:0.2.3.1+4+372be23]
at net.minecraftforge.legacydev.MainClient.main(MainClient.java:29) [legacydev-0.2.3.1-fatjar.jar:0.2.3.1+4+372be23]
Caused by: java.lang.IllegalArgumentException
at org.objectweb.asm.ClassReader.<init>(ClassReader.java:185) ~[asm-debug-all-5.2.jar:5.2]
at org.objectweb.asm.ClassReader.<init>(ClassReader.java:168) ~[asm-debug-all-5.2.jar:5.2]
at org.objectweb.asm.ClassReader.<init>(ClassReader.java:439) ~[asm-debug-all-5.2.jar:5.2]
at net.minecraftforge.fml.common.discovery.asm.ASMModParser.<init>(ASMModParser.java:57) ~[ASMModParser.class:?]
... 23 more
[15:03:07] [Client thread/INFO] [FML]: Forge Mod Loader has identified 9 mods to load
[15:03:07] [Client thread/INFO] [FML]: Attempting connection with missing mods [minecraft, mcp, FML, forge, li, epicfight, itemzoom, testdummy, torohud] at CLIENT
[15:03:07] [Client thread/INFO] [FML]: Attempting connection with missing mods [minecraft, mcp, FML, forge, li, epicfight, itemzoom, testdummy, torohud] at SERVER
[15:03:08] [Thread-3/INFO] [FML]: Using sync timing. 200 frames of Display.update took 171211600 nanos
[15:03:08] [Client thread/INFO] [testdummy]: Please don't hurt me. :S
[15:03:08] [Client thread/INFO] [net.minecraft.client.resources.SimpleReloadableResourceManager]: Reloading ResourceManager: Default, FMLFileResourcePack:Forge Mod Loader, FMLFileResourcePack:Minecraft Forge, FMLFileResourcePack:Legacy Items, FMLFileResourcePack:Epic Fight Mod, FMLFileResourcePack:Item Zoom, FMLFileResourcePack:MmmMmmMmmMmm, FMLFileResourcePack:ToroHUD Damage Indicators
[15:03:08] [Client thread/INFO] [FML]: Processing ObjectHolder annotations
[15:03:08] [Client thread/INFO] [STDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:553]: ---- Minecraft Crash Report ----
// Who set us up the TNT?

Time: 1/17/22 3:03 PM
Description: Initializing game

java.lang.IllegalStateException: The ObjectHolder annotation cannot apply to a field that does not map to a registry. Ensure the registry was created during the RegistryEvent.NewRegistry event. (found : java.util.Map at com.we1nar.li.init.ItemsRegistry.armorModels)
at net.minecraftforge.registries.ObjectHolderRef.<init>(ObjectHolderRef.java:85)
at net.minecraftforge.registries.ObjectHolderRegistry.scanClassForFields(ObjectHolderRegistry.java:153)
at net.minecraftforge.registries.ObjectHolderRegistry.scanTarget(ObjectHolderRegistry.java:115)
at net.minecraftforge.registries.ObjectHolderRegistry.findObjectHolders(ObjectHolderRegistry.java:68)
at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:626)
at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:252)
at net.minecraft.client.Minecraft.init(Minecraft.java:467)
at net.minecraft.client.Minecraft.run(Minecraft.java:378)
at net.minecraft.client.main.Main.main(Main.java:118)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at net.minecraftforge.legacydev.Main.start(Main.java:86)
at net.minecraftforge.legacydev.MainClient.main(MainClient.java:29)


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Thread: Client thread
Stacktrace:
at net.minecraftforge.registries.ObjectHolderRef.<init>(ObjectHolderRef.java:85)
at net.minecraftforge.registries.ObjectHolderRegistry.scanClassForFields(ObjectHolderRegistry.java:153)
at net.minecraftforge.registries.ObjectHolderRegistry.scanTarget(ObjectHolderRegistry.java:115)
at net.minecraftforge.registries.ObjectHolderRegistry.findObjectHolders(ObjectHolderRegistry.java:68)
at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:626)
at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:252)
at net.minecraft.client.Minecraft.init(Minecraft.java:467)

-- Initialization --
Details:
Stacktrace:
at net.minecraft.client.Minecraft.run(Minecraft.java:378)
at net.minecraft.client.main.Main.main(Main.java:118)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at net.minecraftforge.legacydev.Main.start(Main.java:86)
at net.minecraftforge.legacydev.MainClient.main(MainClient.java:29)
Краш-лог:
[15:03:07] [Client thread/WARN] [FML]: Zip file asm-analysis-6.2.jar failed to read properly, it will be ignored
net.minecraftforge.fml.common.LoaderException: java.lang.IllegalArgumentException

	at net.minecraftforge.fml.common.discovery.asm.ASMModParser.<init>(ASMModParser.java:63) ~[ASMModParser.class:?]
	at net.minecraftforge.fml.common.discovery.JarDiscoverer.findClassesASM(JarDiscoverer.java:102) ~[JarDiscoverer.class:?]
	at net.minecraftforge.fml.common.discovery.JarDiscoverer.discover(JarDiscoverer.java:77) [JarDiscoverer.class:?]
	at net.minecraftforge.fml.common.discovery.ContainerType.findMods(ContainerType.java:47) [ContainerType.class:?]
	at net.minecraftforge.fml.common.discovery.ModCandidate.explore(ModCandidate.java:74) [ModCandidate.class:?]
	at net.minecraftforge.fml.common.discovery.ModDiscoverer.identifyMods(ModDiscoverer.java:93) [ModDiscoverer.class:?]
	at net.minecraftforge.fml.common.Loader.identifyMods(Loader.java:427) [Loader.class:?]
	at net.minecraftforge.fml.common.Loader.loadMods(Loader.java:568) [Loader.class:?]
	at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:232) [FMLClientHandler.class:?]
	at net.minecraft.client.Minecraft.init(Minecraft.java:467) [Minecraft.class:?]
	at net.minecraft.client.Minecraft.run(Minecraft.java:378) [Minecraft.class:?]
	at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_302]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_302]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_302]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_302]
	at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]
	at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_302]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_302]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_302]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_302]
	at net.minecraftforge.legacydev.Main.start(Main.java:86) [legacydev-0.2.3.1-fatjar.jar:0.2.3.1+4+372be23]
	at net.minecraftforge.legacydev.MainClient.main(MainClient.java:29) [legacydev-0.2.3.1-fatjar.jar:0.2.3.1+4+372be23]
Caused by: java.lang.IllegalArgumentException
	at org.objectweb.asm.ClassReader.<init>(ClassReader.java:185) ~[asm-debug-all-5.2.jar:5.2]
	at org.objectweb.asm.ClassReader.<init>(ClassReader.java:168) ~[asm-debug-all-5.2.jar:5.2]
	at org.objectweb.asm.ClassReader.<init>(ClassReader.java:439) ~[asm-debug-all-5.2.jar:5.2]
	at net.minecraftforge.fml.common.discovery.asm.ASMModParser.<init>(ASMModParser.java:57) ~[ASMModParser.class:?]
	... 23 more
[15:03:07] [Client thread/INFO] [FML]: Forge Mod Loader has identified 9 mods to load
[15:03:07] [Client thread/INFO] [FML]: Attempting connection with missing mods [minecraft, mcp, FML, forge, li, epicfight, itemzoom, testdummy, torohud] at CLIENT
[15:03:07] [Client thread/INFO] [FML]: Attempting connection with missing mods [minecraft, mcp, FML, forge, li, epicfight, itemzoom, testdummy, torohud] at SERVER
[15:03:08] [Thread-3/INFO] [FML]: Using sync timing. 200 frames of Display.update took 171211600 nanos
[15:03:08] [Client thread/INFO] [testdummy]: Please don't hurt me. :S
[15:03:08] [Client thread/INFO] [net.minecraft.client.resources.SimpleReloadableResourceManager]: Reloading ResourceManager: Default, FMLFileResourcePack:Forge Mod Loader, FMLFileResourcePack:Minecraft Forge, FMLFileResourcePack:Legacy Items, FMLFileResourcePack:Epic Fight Mod, FMLFileResourcePack:Item Zoom, FMLFileResourcePack:MmmMmmMmmMmm, FMLFileResourcePack:ToroHUD Damage Indicators
[15:03:08] [Client thread/INFO] [FML]: Processing ObjectHolder annotations
[15:03:08] [Client thread/INFO] [STDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:553]: ---- Minecraft Crash Report ----
// Who set us up the TNT?

Time: 1/17/22 3:03 PM
Description: Initializing game

java.lang.IllegalStateException: The ObjectHolder annotation cannot apply to a field that does not map to a registry. Ensure the registry was created during the RegistryEvent.NewRegistry event. (found : java.util.Map at com.we1nar.li.init.ItemsRegistry.armorModels)
	at net.minecraftforge.registries.ObjectHolderRef.<init>(ObjectHolderRef.java:85)
	at net.minecraftforge.registries.ObjectHolderRegistry.scanClassForFields(ObjectHolderRegistry.java:153)
	at net.minecraftforge.registries.ObjectHolderRegistry.scanTarget(ObjectHolderRegistry.java:115)
	at net.minecraftforge.registries.ObjectHolderRegistry.findObjectHolders(ObjectHolderRegistry.java:68)
	at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:626)
	at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:252)
	at net.minecraft.client.Minecraft.init(Minecraft.java:467)
	at net.minecraft.client.Minecraft.run(Minecraft.java:378)
	at net.minecraft.client.main.Main.main(Main.java:118)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
	at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at net.minecraftforge.legacydev.Main.start(Main.java:86)
	at net.minecraftforge.legacydev.MainClient.main(MainClient.java:29)


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Thread: Client thread
Stacktrace:
	at net.minecraftforge.registries.ObjectHolderRef.<init>(ObjectHolderRef.java:85)
	at net.minecraftforge.registries.ObjectHolderRegistry.scanClassForFields(ObjectHolderRegistry.java:153)
	at net.minecraftforge.registries.ObjectHolderRegistry.scanTarget(ObjectHolderRegistry.java:115)
	at net.minecraftforge.registries.ObjectHolderRegistry.findObjectHolders(ObjectHolderRegistry.java:68)
	at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:626)
	at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:252)
	at net.minecraft.client.Minecraft.init(Minecraft.java:467)

-- Initialization --
Details:
Stacktrace:
	at net.minecraft.client.Minecraft.run(Minecraft.java:378)
	at net.minecraft.client.main.Main.main(Main.java:118)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
	at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at net.minecraftforge.legacydev.Main.start(Main.java:86)
	at net.minecraftforge.legacydev.MainClient.main(MainClient.java:29)
Последнее редактирование:
Решение
ObjectHolder не крепится на класс. это аннотация поля
Он крепится и на класс и на поле.
Просто когда он крепится на класс, в классе не должно быть никаких полей кроме тех, которые ты хотел бы заинжектить.
К примеру
Java:
@ObjectHolder("minecraft")
public class ItemsThatINeed {

    public static final Block STONE = null;

    @ObjectHolder("grass_block")
    public static final Block GRASS_BUT_FIELD_NAME_IS_WRONG = null;

    @ObjectHolder("subpocket:key")
    public static final Item ITEM_FROM_OTHER_MOD = null;
}

И, собственно, реестра с типом объектов Map<Item, ModelBiped> игра не нашла, и не смогла заинжектить в это твоё поле armorModels, как в логе и написано.

За каким ... эту аннотацию навешал на тот класс -...
38
0
Не весь. Лог говорит, что в классе ItemsRegistry есть поле armorModels и на нём висит аннотация ObjectHolder
Все, я понял о чем ты, вот весь код:

ItemsRegistry:
@GameRegistry.ObjectHolder("li")
@Mod.EventBusSubscriber
public class ItemsRegistry {
public static final Item
            BOOTS = new SpartaArmor("boots", SpartaArmor.ARMOR_MATERIAL, 1, EntityEquipmentSlot.FEET),
            LEGGS = new SpartaArmor("leggs", SpartaArmor.ARMOR_MATERIAL, 2, EntityEquipmentSlot.LEGS),
            CHESTPLATE = new SpartaArmor("chestplate", SpartaArmor.ARMOR_MATERIAL, 1, EntityEquipmentSlot.CHEST),
            HEAD = new SpartaArmor("head", SpartaArmor.ARMOR_MATERIAL, 1, EntityEquipmentSlot.HEAD);


    @SubscribeEvent
    public static void onRegistryItem(RegistryEvent.Register<Item> e) {
    e.getRegistry().register(BOOTS);
        e.getRegistry().register(LEGGS);
        e.getRegistry().register(CHESTPLATE);
        e.getRegistry().register(HEAD);
    }

    public static void register()
    {
        SpartaArmorModel
                HeadModel = new SpartaArmorModel(0),
                ArmorModel = new SpartaArmorModel(1),
                LeggsModel = new SpartaArmorModel(2),
                BootsModel = new SpartaArmorModel(3);
        ItemsRegistry.armorModels.put(ItemsRegistry.HEAD, HeadModel);
        ItemsRegistry.armorModels.put(ItemsRegistry.CHESTPLATE, ArmorModel);
        ItemsRegistry.armorModels.put(ItemsRegistry.LEGGS, LeggsModel);
        ItemsRegistry.armorModels.put(ItemsRegistry.BOOTS, BootsModel);
    }
    @SideOnly(Side.CLIENT)
    private static void registryModel(Item item) {
        final ResourceLocation regName = item.getRegistryName();// Не забываем, что getRegistryName может вернуть Null!
        final ModelResourceLocation mrl = new ModelResourceLocation(regName, "inventory");
        ModelBakery.registerItemVariants(item, mrl);// Регистрация вариантов предмета. Это нужно если мы хотим использовать подтипы предметов/блоков(см. статью подтипы)
        ModelLoader.setCustomModelResourceLocation(item, 0, mrl);// Устанавливаем вариант модели для нашего предмета. Без регистрации варианта модели, сама модель не будет установлена для предмета/блока(см. статью подтипы)
    }

    public static final Map<Item, ModelBiped> armorModels = new HashMap<>();
}
 
177
4
42
Собственно, тебе всё в логе сказали:
The ObjectHolder annotation cannot apply to a field that does not map to a registry. Ensure the registry was created during the RegistryEvent.NewRegistry event. (found : java.util.Map at com.we1nar.li.init.ItemsRegistry.armorModels).
ObjectHolder не крепится на класс. это аннотация поля. Простой пример использования. Технически, фордж в поле, помеченное аннотацией, где-то в пост-инициализации положит указанный объект, если он зарегистрирован в соответствующей регистрации. А у тебя тут класс помечен, даже не понимаю, как это интерпретировать... И даже если ты пометишь свою мапу, то это тоже не катит, так как нет в фордже регистрации для такого типа объектов.
 

necauqua

когда-то был anti344
Администратор
1,151
22
152
ObjectHolder не крепится на класс. это аннотация поля
Он крепится и на класс и на поле.
Просто когда он крепится на класс, в классе не должно быть никаких полей кроме тех, которые ты хотел бы заинжектить.
К примеру
Java:
@ObjectHolder("minecraft")
public class ItemsThatINeed {

    public static final Block STONE = null;

    @ObjectHolder("grass_block")
    public static final Block GRASS_BUT_FIELD_NAME_IS_WRONG = null;

    @ObjectHolder("subpocket:key")
    public static final Item ITEM_FROM_OTHER_MOD = null;
}

И, собственно, реестра с типом объектов Map<Item, ModelBiped> игра не нашла, и не смогла заинжектить в это твоё поле armorModels, как в логе и написано.

За каким ... эту аннотацию навешал на тот класс - непонятно, там-то ты свои итемы объявляешь, а не реквестишь у игры чужие, короче просто убери её, лол
 
Сверху