Jump to content

Registry Object not present: forge:entity_gravity after updating forge version. [1.19]


Bailym

Recommended Posts

I have been getting this error since updating my forge version in build.gradle.

The client crashes when loading into a world.

The full crash report is below:

Spoiler

---- Minecraft Crash Report ----
// Hey, that tickles! Hehehe!

Time: 08/08/2022, 16:19
Description: Ticking entity

java.lang.NullPointerException: Registry Object not present: forge:entity_gravity
    at java.util.Objects.requireNonNull(Objects.java:334) ~[?:?] {}
    at net.minecraftforge.registries.RegistryObject.get(RegistryObject.java:204) ~[forge-1.19-41.1.0_mapped_official_1.19-recomp.jar%23179%23186!/:?] {re:classloading}
    at net.minecraft.world.entity.LivingEntity.travel(LivingEntity.java:2033) ~[forge-1.19-41.1.0_mapped_official_1.19-recomp.jar%23180!/:?] {re:classloading}
    at net.minecraft.world.entity.LivingEntity.aiStep(LivingEntity.java:2585) ~[forge-1.19-41.1.0_mapped_official_1.19-recomp.jar%23180!/:?] {re:classloading}
    at net.minecraft.world.entity.Mob.aiStep(Mob.java:501) ~[forge-1.19-41.1.0_mapped_official_1.19-recomp.jar%23180!/:?] {re:classloading,pl:accesstransformer:B}
    at net.minecraft.world.entity.AgeableMob.aiStep(AgeableMob.java:117) ~[forge-1.19-41.1.0_mapped_official_1.19-recomp.jar%23180!/:?] {re:classloading}
    at net.minecraft.world.entity.animal.Animal.aiStep(Animal.java:53) ~[forge-1.19-41.1.0_mapped_official_1.19-recomp.jar%23180!/:?] {re:classloading}
    at net.minecraft.world.entity.animal.Sheep.aiStep(Sheep.java:131) ~[forge-1.19-41.1.0_mapped_official_1.19-recomp.jar%23180!/:?] {re:classloading}
    at net.minecraft.world.entity.LivingEntity.tick(LivingEntity.java:2290) ~[forge-1.19-41.1.0_mapped_official_1.19-recomp.jar%23180!/:?] {re:classloading}
    at net.minecraft.world.entity.Mob.tick(Mob.java:313) ~[forge-1.19-41.1.0_mapped_official_1.19-recomp.jar%23180!/:?] {re:classloading,pl:accesstransformer:B}
    at net.minecraft.server.level.ServerLevel.tickNonPassenger(ServerLevel.java:657) ~[forge-1.19-41.1.0_mapped_official_1.19-recomp.jar%23180!/:?] {re:classloading,pl:accesstransformer:B}
    at net.minecraft.world.level.Level.guardEntityTick(Level.java:457) ~[forge-1.19-41.1.0_mapped_official_1.19-recomp.jar%23180!/:?] {re:classloading,pl:accesstransformer:B}
    at net.minecraft.server.level.ServerLevel.lambda$tick$3(ServerLevel.java:322) ~[forge-1.19-41.1.0_mapped_official_1.19-recomp.jar%23180!/:?] {re:classloading,pl:accesstransformer:B}
    at net.minecraft.world.level.entity.EntityTickList.forEach(EntityTickList.java:53) ~[forge-1.19-41.1.0_mapped_official_1.19-recomp.jar%23180!/:?] {re:classloading}
    at net.minecraft.server.level.ServerLevel.tick(ServerLevel.java:302) ~[forge-1.19-41.1.0_mapped_official_1.19-recomp.jar%23180!/:?] {re:classloading,pl:accesstransformer:B}
    at net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:866) ~[forge-1.19-41.1.0_mapped_official_1.19-recomp.jar%23180!/:?] {re:classloading,pl:accesstransformer:B}
    at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:806) ~[forge-1.19-41.1.0_mapped_official_1.19-recomp.jar%23180!/:?] {re:classloading,pl:accesstransformer:B}
    at net.minecraft.client.server.IntegratedServer.tickServer(IntegratedServer.java:84) ~[forge-1.19-41.1.0_mapped_official_1.19-recomp.jar%23180!/:?] {re:classloading,pl:runtimedistcleaner:A}
    at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:654) ~[forge-1.19-41.1.0_mapped_official_1.19-recomp.jar%23180!/:?] {re:classloading,pl:accesstransformer:B}
    at net.minecraft.server.MinecraftServer.lambda$spin$2(MinecraftServer.java:245) ~[forge-1.19-41.1.0_mapped_official_1.19-recomp.jar%23180!/:?] {re:classloading,pl:accesstransformer:B}
    at java.lang.Thread.run(Thread.java:833) [?:?] {}


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

-- Head --
Thread: Server thread
Stacktrace:
    at java.util.Objects.requireNonNull(Objects.java:334) ~[?:?] {}
    at net.minecraftforge.registries.RegistryObject.get(RegistryObject.java:204) ~[forge-1.19-41.1.0_mapped_official_1.19-recomp.jar%23179%23186!/:?] {re:classloading}
    at net.minecraft.world.entity.LivingEntity.travel(LivingEntity.java:2033) ~[forge-1.19-41.1.0_mapped_official_1.19-recomp.jar%23180!/:?] {re:classloading}
    at net.minecraft.world.entity.LivingEntity.aiStep(LivingEntity.java:2585) ~[forge-1.19-41.1.0_mapped_official_1.19-recomp.jar%23180!/:?] {re:classloading}
    at net.minecraft.world.entity.Mob.aiStep(Mob.java:501) ~[forge-1.19-41.1.0_mapped_official_1.19-recomp.jar%23180!/:?] {re:classloading,pl:accesstransformer:B}
    at net.minecraft.world.entity.AgeableMob.aiStep(AgeableMob.java:117) ~[forge-1.19-41.1.0_mapped_official_1.19-recomp.jar%23180!/:?] {re:classloading}
    at net.minecraft.world.entity.animal.Animal.aiStep(Animal.java:53) ~[forge-1.19-41.1.0_mapped_official_1.19-recomp.jar%23180!/:?] {re:classloading}
    at net.minecraft.world.entity.animal.Sheep.aiStep(Sheep.java:131) ~[forge-1.19-41.1.0_mapped_official_1.19-recomp.jar%23180!/:?] {re:classloading}
    at net.minecraft.world.entity.LivingEntity.tick(LivingEntity.java:2290) ~[forge-1.19-41.1.0_mapped_official_1.19-recomp.jar%23180!/:?] {re:classloading}
    at net.minecraft.world.entity.Mob.tick(Mob.java:313) ~[forge-1.19-41.1.0_mapped_official_1.19-recomp.jar%23180!/:?] {re:classloading,pl:accesstransformer:B}
    at net.minecraft.server.level.ServerLevel.tickNonPassenger(ServerLevel.java:657) ~[forge-1.19-41.1.0_mapped_official_1.19-recomp.jar%23180!/:?] {re:classloading,pl:accesstransformer:B}
    at net.minecraft.world.level.Level.guardEntityTick(Level.java:457) ~[forge-1.19-41.1.0_mapped_official_1.19-recomp.jar%23180!/:?] {re:classloading,pl:accesstransformer:B}
    at net.minecraft.server.level.ServerLevel.lambda$tick$3(ServerLevel.java:322) ~[forge-1.19-41.1.0_mapped_official_1.19-recomp.jar%23180!/:?] {re:classloading,pl:accesstransformer:B}
    at net.minecraft.world.level.entity.EntityTickList.forEach(EntityTickList.java:53) ~[forge-1.19-41.1.0_mapped_official_1.19-recomp.jar%23180!/:?] {re:classloading}
    at net.minecraft.server.level.ServerLevel.tick(ServerLevel.java:302) ~[forge-1.19-41.1.0_mapped_official_1.19-recomp.jar%23180!/:?] {re:classloading,pl:accesstransformer:B}
-- Entity being ticked --
Details:
    Entity Type: minecraft:sheep (net.minecraft.world.entity.animal.Sheep)
    Entity ID: 1
    Entity Name: Sheep
    Entity's Exact location: -44.48, -60.00, 48.53
    Entity's Block location: World: (-45,-60,48), Section: (at 3,4,0 in -3,-4,3; chunk contains blocks -48,-64,48 to -33,319,63), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,-64,0 to -1,319,511)
    Entity's Momentum: 0.00, -0.08, 0.00
    Entity's Passengers: []
    Entity's Vehicle: null
Stacktrace:
    at net.minecraft.world.level.Level.guardEntityTick(Level.java:457) ~[forge-1.19-41.1.0_mapped_official_1.19-recomp.jar%23180!/:?] {re:classloading,pl:accesstransformer:B}
    at net.minecraft.server.level.ServerLevel.lambda$tick$3(ServerLevel.java:322) ~[forge-1.19-41.1.0_mapped_official_1.19-recomp.jar%23180!/:?] {re:classloading,pl:accesstransformer:B}
    at net.minecraft.world.level.entity.EntityTickList.forEach(EntityTickList.java:53) ~[forge-1.19-41.1.0_mapped_official_1.19-recomp.jar%23180!/:?] {re:classloading}
    at net.minecraft.server.level.ServerLevel.tick(ServerLevel.java:302) ~[forge-1.19-41.1.0_mapped_official_1.19-recomp.jar%23180!/:?] {re:classloading,pl:accesstransformer:B}
    at net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:866) ~[forge-1.19-41.1.0_mapped_official_1.19-recomp.jar%23180!/:?] {re:classloading,pl:accesstransformer:B}
    at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:806) ~[forge-1.19-41.1.0_mapped_official_1.19-recomp.jar%23180!/:?] {re:classloading,pl:accesstransformer:B}
    at net.minecraft.client.server.IntegratedServer.tickServer(IntegratedServer.java:84) ~[forge-1.19-41.1.0_mapped_official_1.19-recomp.jar%23180!/:?] {re:classloading,pl:runtimedistcleaner:A}
    at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:654) ~[forge-1.19-41.1.0_mapped_official_1.19-recomp.jar%23180!/:?] {re:classloading,pl:accesstransformer:B}
    at net.minecraft.server.MinecraftServer.lambda$spin$2(MinecraftServer.java:245) ~[forge-1.19-41.1.0_mapped_official_1.19-recomp.jar%23180!/:?] {re:classloading,pl:accesstransformer:B}
    at java.lang.Thread.run(Thread.java:833) [?:?] {}


-- Affected level --
Details:
    All players: 0 total; []
    Chunk stats: 2209
    Level dimension: minecraft:overworld
    Level spawn location: World: (0,-60,0), Section: (at 0,4,0 in 0,-4,0; chunk contains blocks 0,-64,0 to 15,319,15), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,-64,0 to 511,319,511)
    Level time: 7176 game time, 7176 day time
    Level name: New World
    Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: true
    Level weather: Rain time: 5065 (now: false), thunder time: 102830 (now: false)
    Known server brands: forge
    Level was modded: true
    Level storage version: 0x04ABD - Anvil
Stacktrace:
    at net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:866) ~[forge-1.19-41.1.0_mapped_official_1.19-recomp.jar%23180!/:?] {re:classloading,pl:accesstransformer:B}
    at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:806) ~[forge-1.19-41.1.0_mapped_official_1.19-recomp.jar%23180!/:?] {re:classloading,pl:accesstransformer:B}
    at net.minecraft.client.server.IntegratedServer.tickServer(IntegratedServer.java:84) ~[forge-1.19-41.1.0_mapped_official_1.19-recomp.jar%23180!/:?] {re:classloading,pl:runtimedistcleaner:A}
    at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:654) ~[forge-1.19-41.1.0_mapped_official_1.19-recomp.jar%23180!/:?] {re:classloading,pl:accesstransformer:B}
    at net.minecraft.server.MinecraftServer.lambda$spin$2(MinecraftServer.java:245) ~[forge-1.19-41.1.0_mapped_official_1.19-recomp.jar%23180!/:?] {re:classloading,pl:accesstransformer:B}
    at java.lang.Thread.run(Thread.java:833) [?:?] {}


-- System Details --
Details:
    Minecraft Version: 1.19
    Minecraft Version ID: 1.19
    Operating System: Windows 10 (amd64) version 10.0
    Java Version: 17.0.1, Oracle Corporation
    Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode, sharing), Oracle Corporation
    Memory: 636289464 bytes (606 MiB) / 1509949440 bytes (1440 MiB) up to 6425673728 bytes (6128 MiB)
    CPUs: 8
    Processor Vendor: GenuineIntel
    Processor Name: Intel(R) Core(TM) i7-9700K CPU @ 3.60GHz
    Identifier: Intel64 Family 6 Model 158 Stepping 12
    Microarchitecture: Coffee Lake
    Frequency (GHz): 3.60
    Number of physical packages: 1
    Number of physical CPUs: 8
    Number of logical CPUs: 8
    Graphics card #0 name: NVIDIA GeForce RTX 2060 SUPER
    Graphics card #0 vendor: NVIDIA (0x10de)
    Graphics card #0 VRAM (MB): 4095.00
    Graphics card #0 deviceId: 0x1f06
    Graphics card #0 versionInfo: DriverVersion=30.0.15.1179
    Graphics card #1 name: Virtual Desktop Monitor
    Graphics card #1 vendor: Virtual Desktop, Inc.
    Graphics card #1 VRAM (MB): 0.00
    Graphics card #1 deviceId: unknown
    Graphics card #1 versionInfo: DriverVersion=15.39.56.845
    Memory slot #0 capacity (MB): 8192.00
    Memory slot #0 clockSpeed (GHz): 2.13
    Memory slot #0 type: DDR4
    Memory slot #1 capacity (MB): 8192.00
    Memory slot #1 clockSpeed (GHz): 2.13
    Memory slot #1 type: DDR4
    Memory slot #2 capacity (MB): 8192.00
    Memory slot #2 clockSpeed (GHz): 2.13
    Memory slot #2 type: DDR4
    Virtual memory max (MB): 28091.35
    Virtual memory used (MB): 23215.91
    Swap memory total (MB): 3584.00
    Swap memory used (MB): 102.76
    JVM Flags: 1 total; -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump
    Server Running: true
    Player Count: 0 / 8; []
    Data Packs: vanilla, mod:extraarmor, mod:forge
    World Generation: Stable
    Type: Integrated Server (map_client.txt)
    Is Modded: Definitely; Client brand changed to 'forge'; Server brand changed to 'forge'
    Launched Version: MOD_DEV
    ModLauncher: 10.0.8+10.0.8+main.0ef7e830
    ModLauncher launch target: forgeclientuserdev
    ModLauncher naming: mcp
    ModLauncher services: 
        mixin-0.8.5.jar mixin PLUGINSERVICE 
        eventbus-6.0.0.jar eventbus PLUGINSERVICE 
        fmlloader-1.19-41.1.0.jar slf4jfixer PLUGINSERVICE 
        fmlloader-1.19-41.1.0.jar object_holder_definalize PLUGINSERVICE 
        fmlloader-1.19-41.1.0.jar runtime_enum_extender PLUGINSERVICE 
        fmlloader-1.19-41.1.0.jar capability_token_subclass PLUGINSERVICE 
        accesstransformers-8.0.4.jar accesstransformer PLUGINSERVICE 
        fmlloader-1.19-41.1.0.jar runtimedistcleaner PLUGINSERVICE 
        modlauncher-10.0.8.jar mixin TRANSFORMATIONSERVICE 
        modlauncher-10.0.8.jar fml TRANSFORMATIONSERVICE 
    FML Language Providers: 
        [email protected]
        lowcodefml@null
        javafml@null
    Mod List: 
        forge-1.19-41.1.0_mapped_official_1.19-recomp.jar |Minecraft                     |minecraft                     |1.19                |DONE      |Manifest: a1:d4:5e:04:4f:d3:d6:e0:7b:37:97:cf:77:b0:de:ad:4a:47:ce:8c:96:49:5f:0a:cf:8c:ae:b2:6d:4b:8a:3f
        main                                              |Extra Armor                   |extraarmor                    |1.15.1              |DONE      |Manifest: NOSIGNATURE
                                                          |Forge                         |forge                         |41.1.0              |DONE      |Manifest: NOSIGNATURE
    Crash Report UUID: 5f6f2f4f-2eaf-4f27-b347-7d64b611a1a0
    FML: 41.1
    Forge: net.minecraftforge:41.1.0

 

The crash report seems to be from the server, could there be an issue with my Forge environment?

I have tried creating a new world which would load in but crash after a few seconds.

Any help is appreciated.

Link to comment
Share on other sites

Yes I tried that many times. It seems that after a certain forge version I get this error. 

I have worked out it's something to do with values in my mods config file being referenced before the value is assigned. 

This is strange as I haven't changed the config at all. Has forge changed the stage at which it loads the config in a recent version? 

Link to comment
Share on other sites

Heres my main class where I register the config. 

Spoiler
public ExtraArmor() {

        IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus();

        //REGISTER CONFIG
        ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, ArmorConfig.COMMON_SPEC);

        ModRegistry.ITEMS.register(bus);

    }

 

Here's the config file.

Spoiler
package com.bailym.extraarmor.config;

import com.bailym.extraarmor.ExtraArmor;
import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.common.ForgeConfigSpec.BooleanValue;
import net.minecraftforge.common.ForgeConfigSpec.IntValue;
import net.minecraftforge.fml.config.ModConfig;
import org.apache.commons.lang3.tuple.Pair;

public class ArmorConfig {

    public static class Common {

        //on/off
        public final BooleanValue enableCactus;
        public final BooleanValue enableObsidian;
        public final BooleanValue enableMolten;
        public final BooleanValue enablePhantom;
        public final BooleanValue enableGhost;
        public final BooleanValue enableCryingObsidian;
        public final BooleanValue enableIce;
        public final BooleanValue enableGlowstone;
        public final BooleanValue enablePrismarineShard;
        public final BooleanValue enablePrismarineCrystal;
        public final BooleanValue enableEmerald;
        public final BooleanValue enableEnder;
        public final BooleanValue enableFeather;
        public final BooleanValue enableSlime;
        public final BooleanValue enableLapis;
        public final BooleanValue enableCrimsonWood;
        public final BooleanValue enableWarpedWood;
        public final BooleanValue enableReinforcedIron;
        public final BooleanValue enableGlowingObsidian;
        public final BooleanValue enableEnderghost;
        public final BooleanValue enableEchoShard;


        //enchant/effect levels
        public final IntValue cactusLevel;  //enchant
        public final IntValue cryingObsidianLevel;  //enchant
        public final IntValue emeraldLevel; //effect
        public final IntValue enderLevel;   //effect
        public final IntValue featherLevel; //effect
        public final IntValue ghostLevel;   //enchant
        public final IntValue iceLevel;     //enchant
        public final IntValue obsidianLevel;    //enchant
        public final IntValue prismarineCrystalLevel;   //effect
        public final IntValue slimeLevel;   //enchant
        public final IntValue echoShardLevel;   //enchant

        //durability
        public final IntValue oakWoodDurability;
        public final IntValue birchWoodDurability;



        Common(ForgeConfigSpec.Builder builder){
            builder.comment("Extra Armor Config - Requires Client Restart!")
                    .push("Enable or Disable Set Bonuses (true = enabled, false = disabled)");

            enableCactus = builder
                    .comment("Enable or Disable Cactus Armor Effects")
                    .worldRestart()
                    .define("enableCactus", true);
            enableObsidian = builder
                    .comment("Enable or Disable Obsidian Armor Effects")
                    .worldRestart()
                    .define("enableObsidian", true);
            enableMolten = builder
                    .comment("Enable or Disable Molten Armor Effects")
                    .worldRestart()
                    .define("enableMolten", true);
            enablePhantom = builder
                    .comment("Enable or Disable Phantom Armor Effects")
                    .worldRestart()
                    .define("enablePhantom", true);
            enableGhost = builder
                    .comment("Enable or Disable Ghost Armor Effects")
                    .worldRestart()
                    .define("enableGhost", true);
            enableCryingObsidian = builder
                    .comment("Enable or Disable Crying Obsidian Armor Effects")
                    .worldRestart()
                    .define("enableCryingObsidian", true);
            enableIce = builder
                    .comment("Enable or Disable Ice Armor Effects")
                    .worldRestart()
                    .define("enableIce", true);
            enableGlowstone = builder
                    .comment("Enable or Disable Glowstone Armor Effects")
                    .worldRestart()
                    .define("enableGlowstone", true);
            enablePrismarineShard = builder
                    .comment("Enable or Disable Prismarine Shard Armor Effects")
                    .worldRestart()
                    .define("enablePrismarineShard", true);
            enablePrismarineCrystal = builder
                    .comment("Enable or Disable Prismarine Crystal Armor Effects")
                    .worldRestart()
                    .define("enablePrismarineCrystal", true);
            enableEmerald = builder
                    .comment("Enable or Disable Emerald Armor Effects")
                    .worldRestart()
                    .define("enableEmerald", true);
            enableEnder = builder
                    .comment("Enable or Disable Ender Armor Effects")
                    .worldRestart()
                    .define("enableEnder", true);
            enableFeather = builder
                    .comment("Enable or Disable Feather Armor Effects")
                    .worldRestart()
                    .define("enableFeather", true);
            enableSlime = builder
                    .comment("Enable or Disable Slime Armor Effects")
                    .worldRestart()
                    .define("enableSlime", true);
            enableLapis = builder
                    .comment("Enable or Disable Lapis Armor Effects")
                    .worldRestart()
                    .define("enableLapis", true);
            enableCrimsonWood = builder
                    .comment("Enable or Disable Crimson Wood Armor Effects")
                    .worldRestart()
                    .define("enableCrimsonWood", true);
            enableWarpedWood = builder
                    .comment("Enable or Disable Warped Wood Armor Effects")
                    .worldRestart()
                    .define("enableWarpedWood", true);
            enableReinforcedIron = builder
                    .comment("Enable or Disable Reinforced Iron Armor Effects")
                    .worldRestart()
                    .define("enableReinforcedIron", true);
            enableGlowingObsidian = builder
                    .comment("Enable or Disable Glowing Obsidian Armor Effects")
                    .worldRestart()
                    .define("enableGlowingObsidian", true);
            enableEnderghost = builder
                    .comment("Enable or Disable Glowing Obsidian Armor Effects")
                    .worldRestart()
                    .define("enableGlowingObsidian", true);
            enableEchoShard = builder
                    .comment("Enable or Disable Echo Shard Armor Effects")
                    .worldRestart()
                    .define("enableEchoShard", true);

            builder.pop();

            builder.push("Set Effect/Enchantment Levels");
            cactusLevel = builder
                    .comment("The Level of Thorns Given by the Cactus Set (Default: 1)")
                    .worldRestart()
                    .defineInRange("cactusLevel", 1,1, 4 );
            cryingObsidianLevel = builder
                    .comment("The Level of Blast Protection Given by the Crying Obsidian Set (Default: 4)")
                    .worldRestart()
                    .defineInRange("cryingObsidianLevel", 4,1, 4 );
            emeraldLevel = builder
                    .comment("The Level of Luck Given by the Emerald Set (Default: 2)")
                    .worldRestart()
                    .defineInRange("emeraldLevel", 2,1, 5 );
            enderLevel = builder
                    .comment("The Level of Speed Given by the Ender Set (Default: 2) NOTE: Also affects combined armors")
                    .worldRestart()
                    .defineInRange("enderLevel", 2,1, 5 );
            featherLevel = builder
                    .comment("The Level of Jump Boost Given by the Feather Set (Default: 2)")
                    .worldRestart()
                    .defineInRange("featherLevel", 2,1, 5 );
            ghostLevel = builder
                    .comment("The Level of Soul Speed Given by the Ghost Set (Default: 2) NOTE: Also affects combined armors")
                    .worldRestart()
                    .defineInRange("ghostLevel", 2,1, 3 );
            iceLevel = builder
                    .comment("The Level of Frost Walker Given by the Ice Set (Default: 2)")
                    .worldRestart()
                    .defineInRange("iceLevel", 2,1, 2 );
            obsidianLevel = builder
                    .comment("The Level of Blast Protection Given by the Obsidian Set (Default: 4). NOTE: Also affects combined armors")
                    .worldRestart()
                    .defineInRange("obsidianLevel", 4,1, 4 );
            prismarineCrystalLevel = builder
                    .comment("The Level of Dolphins Grace Given by the Prismarine Crystal Set (Default: 2)")
                    .worldRestart()
                    .defineInRange("prismarineCrystalLevel", 2,1, 5 );
            slimeLevel = builder
                    .comment("The Level of Projectile Protection Given by the Slime Set (Default: 2)")
                    .worldRestart()
                    .defineInRange("slimeLevel", 2,1, 4 );
            echoShardLevel = builder
                    .comment("The Level of Swift Sneak Given by the Slime Set (Default: 2)")
                    .worldRestart()
                    .defineInRange("slimeLevel", 2,1, 4 );

            builder.pop();

            builder.push("Set Durability Levels (1 to 2147483647) Netherite = 37, Diamond = 33, Iron = 15, Gold = 7, Leather = 5");

            oakWoodDurability = builder
                    .comment("The Durability Level for Oak Wood Armor (Default: 2)")
                    .worldRestart()
                    .defineInRange("oakWoodDurability", 2,1, Integer.MAX_VALUE );
            birchWoodDurability = builder
                    .comment("The Durability Level for Birch Wood Armor (Default: 2)")
                    .worldRestart()
                    .defineInRange("birchWoodDurability", 2,1, Integer.MAX_VALUE );

            //TODO: Complete for the rest of the sets

        }
    }

    public static final ForgeConfigSpec COMMON_SPEC;
    public static final Common COMMON;
            static{
                final Pair<Common, ForgeConfigSpec> specPair = new ForgeConfigSpec.Builder().configure(Common::new);
                COMMON_SPEC = specPair.getRight();
                COMMON = specPair.getLeft();
            }

}

 

 

Here is where I'm trying to reference the config values. CustomArmorMaterial is essentially a copy of Minecrafts ArmorMaterials which implements ArmorMaterial.

I'm guessing the materials in here are initialised before the config is loaded which is causing the issue. If i remove ArmorConfig.COMMON.birchWoodDurability.get() everything works fine.

 

Spoiler
public enum CustomArmorMaterial implements ArmorMaterial {
    OAK_WOOD(ExtraArmor.MOD_ID + ":oak_wood", 2, new int[]{1, 2, 3, 1}, 9, SoundEvents.ARMOR_EQUIP_GENERIC, 0.0F, 0.0F, () -> {
        return Ingredient.of(Items.OAK_PLANKS);
    }),
    BIRCH_WOOD(ExtraArmor.MOD_ID + ":birch_wood",ArmorConfig.COMMON.birchWoodDurability.get(), new int[]{1, 2, 3, 1}, 9, SoundEvents.ARMOR_EQUIP_GENERIC, 0.0F, 0.0F, () -> {
        return Ingredient.of(Items.BIRCH_PLANKS);
    }),
    JUNGLE_WOOD(ExtraArmor.MOD_ID + ":jungle_wood", 2, new int[]{1, 2, 3, 1}, 9, SoundEvents.ARMOR_EQUIP_GENERIC, 0.0F, 0.0F, () -> {
        return Ingredient.of(Items.JUNGLE_PLANKS);
    }),
    SPRUCE_WOOD(ExtraArmor.MOD_ID + ":spruce_wood", 2, new int[]{1, 2, 3, 1}, 9, SoundEvents.ARMOR_EQUIP_GENERIC, 0.0F, 0.0F, () -> {
        return Ingredient.of(Items.SPRUCE_PLANKS);
    }),
    DARK_OAK_WOOD(ExtraArmor.MOD_ID + ":dark_oak_wood", 2, new int[]{1, 2, 3, 1}, 9, SoundEvents.ARMOR_EQUIP_GENERIC, 0.0F, 0.0F, () -> {
        return Ingredient.of(Items.DARK_OAK_PLANKS);
    }),
    ACACIA_WOOD(ExtraArmor.MOD_ID + ":acacia_wood", 2, new int[]{1, 2, 3, 1}, 9, SoundEvents.ARMOR_EQUIP_GENERIC, 0.0F, 0.0F, () -> {
        return Ingredient.of(Items.ACACIA_PLANKS);
    }),
    CACTUS(ExtraArmor.MOD_ID + ":cactus", 3, new int[]{2, 2, 3, 2}, 9, SoundEvents.ARMOR_EQUIP_GENERIC, 0.0F, 0.0F, () -> {
        return Ingredient.of(Items.CACTUS);
    }),
    OBSIDIAN(ExtraArmor.MOD_ID + ":obsidian", 28, new int[]{2, 5, 6, 3}, 9, SoundEvents.ARMOR_EQUIP_GENERIC, 1.0F, 0.1F, () -> {
        return Ingredient.of(Items.OBSIDIAN);
    }),
    MAGMA(ExtraArmor.MOD_ID + ":magma", 6, new int[]{2, 3, 4, 2}, 20, SoundEvents.ARMOR_EQUIP_GENERIC, 0.0F, 0.0F, () -> {
        return Ingredient.of(Items.MAGMA_BLOCK);
    }),
    MELON(ExtraArmor.MOD_ID + ":melon", 3, new int[]{2, 2, 3, 2}, 9, SoundEvents.ARMOR_EQUIP_GENERIC, 0.0F, 0.0F, () -> {
        return Ingredient.of(Items.MELON);
    }),
    QUARTZ(ExtraArmor.MOD_ID + ":quartz", 5, new int[]{2, 3, 5, 2}, 9, SoundEvents.ARMOR_EQUIP_GENERIC, 0.0F, 0.0F, () -> {
        return Ingredient.of(Items.QUARTZ);
    }),
    BONE(ExtraArmor.MOD_ID + ":bone", 15, new int[]{2, 5, 6, 2}, 18, SoundEvents.ARMOR_EQUIP_GENERIC, 0.0F, 0.0F, () -> {
        return Ingredient.of(Items.BONE);
    }),
    MOLTEN(ExtraArmor.MOD_ID + ":molten", 15, new int[]{2, 5, 7, 3}, 9, SoundEvents.ARMOR_EQUIP_GENERIC, 0.0F, 0.0F, () -> {
        return Ingredient.of(Items.LAVA_BUCKET);
    }),
    PUMPKIN(ExtraArmor.MOD_ID + ":pumpkin", 3, new int[]{2, 2, 3, 2}, 9, SoundEvents.ARMOR_EQUIP_GENERIC, 0.0F, 0.0F, () -> {
        return Ingredient.of(Items.PUMPKIN);
    }),
    PHANTOM(ExtraArmor.MOD_ID + ":phantom", 15, new int[]{2, 4, 5, 2}, 9, SoundEvents.ARMOR_EQUIP_GENERIC, 0.0F, 0.0F, () -> {
        return Ingredient.of(Items.PHANTOM_MEMBRANE);
    }),
    GHOST(ExtraArmor.MOD_ID + ":ghost", 28, new int[]{3, 6, 8, 3}, 20, SoundEvents.ARMOR_EQUIP_GENERIC, 0.0F, 0.0F, () -> {
        return Ingredient.of(Items.GHAST_TEAR);
    }),
    CRYING_OBSIDIAN(ExtraArmor.MOD_ID + ":crying_obsidian", 28, new int[]{2, 5, 6, 3}, 9, SoundEvents.ARMOR_EQUIP_GENERIC, 1.0F, 0.1F, () -> {
        return Ingredient.of(Items.CRYING_OBSIDIAN);
    }),
    ICE(ExtraArmor.MOD_ID + ":ice", 4, new int[]{1, 3, 4, 2}, 20, SoundEvents.ARMOR_EQUIP_GENERIC, 0.0F, 0.0F, () -> {
        return Ingredient.of(Items.ICE);
    }),
    SNOW(ExtraArmor.MOD_ID + ":snow", 2, new int[]{1, 2, 3, 1}, 9, SoundEvents.ARMOR_EQUIP_GENERIC, 0.0F, 0.0F, () -> {
        return Ingredient.of(Items.SNOWBALL);
    }),
    GLOWSTONE(ExtraArmor.MOD_ID + ":glowstone", 18, new int[]{2, 5, 7, 3}, 15, SoundEvents.ARMOR_EQUIP_GENERIC, 0.0F, 0.0F, () -> {
        return Ingredient.of(Items.GLOWSTONE);
    }),
    PRISMARINE_SHARD(ExtraArmor.MOD_ID + ":prismarine_shard", 25, new int[]{3, 5, 6, 3}, 10, SoundEvents.ARMOR_EQUIP_GENERIC, 0.0F, 0.0F, () -> {
        return Ingredient.of(Items.PRISMARINE_SHARD);
    }),
    PRISMARINE_CRYSTAL(ExtraArmor.MOD_ID + ":prismarine_crystal", 25, new int[]{3, 5, 6, 3}, 10, SoundEvents.ARMOR_EQUIP_GENERIC, 0.0F, 0.0F, () -> {
        return Ingredient.of(Items.PRISMARINE_CRYSTALS);
    }),
    HONEYCOMB(ExtraArmor.MOD_ID + ":honeycomb", 4, new int[]{1, 3, 4, 2}, 9, SoundEvents.ARMOR_EQUIP_GENERIC, 0.0F, 0.0F, () -> {
        return Ingredient.of(Items.HONEYCOMB);
    }),
    EMERALD(ExtraArmor.MOD_ID + ":emerald", 15, new int[]{3, 5, 6, 3}, 20, SoundEvents.ARMOR_EQUIP_GENERIC, 0.0F, 0.0F, () -> {
        return Ingredient.of(Items.EMERALD);
    }),
    ENDER(ExtraArmor.MOD_ID + ":ender", 12, new int[]{2, 4, 5, 2}, 20, SoundEvents.ARMOR_EQUIP_GENERIC, 0.0F, 0.0F, () -> {
        return Ingredient.of(Items.ENDER_PEARL);
    }),
    FEATHER(ExtraArmor.MOD_ID + ":feather", 6, new int[]{2, 3, 4, 2}, 9, SoundEvents.ARMOR_EQUIP_GENERIC, 0.0F, 0.0F, () -> {
        return Ingredient.of(Items.FEATHER);
    }),
    SLIME(ExtraArmor.MOD_ID + ":slime", 8, new int[]{2, 4, 4, 2}, 9, SoundEvents.ARMOR_EQUIP_GENERIC, 0.0F, 0.0F, () -> {
        return Ingredient.of(Items.SLIME_BALL);
    }),
    LAPIS(ExtraArmor.MOD_ID + ":lapis", 6, new int[]{2, 3, 4, 2}, 25, SoundEvents.ARMOR_EQUIP_GENERIC, 0.0F, 0.0F, () -> {
        return Ingredient.of(Items.LAPIS_LAZULI);
    }),
    COPPER(ExtraArmor.MOD_ID + ":copper", 10, new int[]{2, 2, 3, 2}, 9, SoundEvents.ARMOR_EQUIP_GENERIC, 0.0F, 0.0F, () -> {
        return Ingredient.of(Items.COPPER_INGOT);
    }),
    AMETHYST(ExtraArmor.MOD_ID + ":amethyst", 20, new int[]{4, 5, 6, 4}, 20, SoundEvents.ARMOR_EQUIP_GENERIC, 0.0F, 0.0F, () -> {
        return Ingredient.of(Items.AMETHYST_SHARD);
    }),
    CRIMSON_WOOD(ExtraArmor.MOD_ID + ":crimson_wood", 2, new int[]{1, 2, 3, 1}, 9, SoundEvents.ARMOR_EQUIP_GENERIC, 0.0F, 0.0F, () -> {
        return Ingredient.of(Items.CRIMSON_PLANKS);
    }),
    WARPED_WOOD(ExtraArmor.MOD_ID + ":warped_wood", 2, new int[]{1, 2, 3, 1}, 9, SoundEvents.ARMOR_EQUIP_GENERIC, 0.0F, 0.0F, () -> {
        return Ingredient.of(Items.WARPED_PLANKS);
    }),
    REINFORCED_IRON(ExtraArmor.MOD_ID + ":reinforced_iron", 15, new int[]{2, 5, 6, 2}, 9, SoundEvents.ARMOR_EQUIP_IRON, 2.0F, 0.0F, () -> {
        return Ingredient.of(Items.IRON_INGOT);
    }),
    GLOWING_OBSIDIAN(ExtraArmor.MOD_ID + ":glowing_obsidian", 20, new int[]{2, 5, 6, 3}, 12, SoundEvents.ARMOR_EQUIP_IRON, 1.0F, 0.1F, () -> {
        return Ingredient.of(Items.OBSIDIAN);
    }),
    ENDERGHOST(ExtraArmor.MOD_ID + ":enderghost", 20, new int[]{3, 5, 6, 3}, 20, SoundEvents.ARMOR_EQUIP_IRON, 0.0F, 0.0F, () -> {
        return Ingredient.of(Items.ENDER_PEARL);
    }),
    ECHO_SHARD(ExtraArmor.MOD_ID + ":echo_shard", 22, new int[]{3, 5, 6, 3}, 5, SoundEvents.ARMOR_EQUIP_GENERIC, 0.0F, 0.0F, () -> {
        return Ingredient.of(Items.ECHO_SHARD);
    }),
    MANGROVE_WOOD(ExtraArmor.MOD_ID + ":mangrove_wood", 2, new int[]{1, 2, 3, 1}, 9, SoundEvents.ARMOR_EQUIP_GENERIC, 0.0F, 0.0F, () -> {
        return Ingredient.of(Items.MANGROVE_PLANKS);
    });

    private static final int[] HEALTH_PER_SLOT = new int[]{13, 15, 16, 11};
    private final String name;
    private final int durabilityMultiplier;
    private final int[] slotProtections;
    private final int enchantmentValue;
    private final SoundEvent sound;
    private final float toughness;
    private final float knockbackResistance;
    private final LazyLoadedValue<Ingredient> repairIngredient;

    private CustomArmorMaterial(String p_40474_, int p_40475_, int[] p_40476_, int p_40477_, SoundEvent p_40478_, float p_40479_, float p_40480_, Supplier<Ingredient> p_40481_) {
        this.name = p_40474_;
        this.durabilityMultiplier = p_40475_;
        this.slotProtections = p_40476_;
        this.enchantmentValue = p_40477_;
        this.sound = p_40478_;
        this.toughness = p_40479_;
        this.knockbackResistance = p_40480_;
        this.repairIngredient = new LazyLoadedValue<>(p_40481_);
    }

    public int getDurabilityForSlot(EquipmentSlot p_40484_) {
        return HEALTH_PER_SLOT[p_40484_.getIndex()] * this.durabilityMultiplier;
    }

    public int getDefenseForSlot(EquipmentSlot p_40487_) {
        return this.slotProtections[p_40487_.getIndex()];
    }

    public int getEnchantmentValue() {
        return this.enchantmentValue;
    }

    public SoundEvent getEquipSound() {
        return this.sound;
    }

    public Ingredient getRepairIngredient() {
        return this.repairIngredient.get();
    }

    public String getName() {
        return this.name;
    }

    public float getToughness() {
        return this.toughness;
    }

    public float getKnockbackResistance() {
        return this.knockbackResistance;
    }
}

 

 

Link to comment
Share on other sites

9 minutes ago, Bailym said:

I'm guessing the materials in here are initialised before the config is loaded which is causing the issue. If i remove ArmorConfig.COMMON.birchWoodDurability.get() everything works fine.

That's correct, if you want that your Armor is modifiable via the config you need to lazy load/get the values.
Means you need to get the config value in the getter of the value (e.g. #getDurabilityForSlot).

You also should use a server config file, to make sure the values of server and client match.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.