Posted July 4, 20223 yr Hello, I'm currently working on a mod and I'm using a configuration field to determine the durability of an item. But I don't understand why when I change the config in the .toml file, the durability of the item stay at the default value. Here is how I set the durability (MOB_SHARD_DURABILITY) : /** * Manager for the mod items */ public class ItemManager { public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, PerfectMobFarm.MODID); // Use of CommonConfig public static final RegistryObject<Item> MOB_SHARD = ITEMS.register("mob_shard", () -> new MobShard(new Item.Properties().tab(PerfectMobFarm.PERFECT_MOB_FARM_TAB), CommonConfigs.MOB_SHARD_DURABILITY.get())); public static void register(IEventBus eventBus) { ITEMS.register(eventBus); } } ///////////////// // Item class // //////////////// public MobShard(Properties pProperties, int pDurability) { this(pProperties.durability(pDurability)); } Of course I have others config fields and they work properly.
July 4, 20223 yr Those item registrations only happen at startup. Your durability is fixed then. If you want something more dynamic you would need to do something like this in your item class: Quote @Override public int getMaxDamage(ItemStack stack) { return fromTheConfiguration(); } Boilerplate: If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one. If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install Large files should be posted to a file sharing site like https://gist.github.com You should also read the support forum sticky post.
July 5, 20223 yr Author Thanks for your answers. I managed to use a server config and to override the function @Override public int getMaxDamage(ItemStack stack) { return ServerConfigs.MOB_SHARD_DURABILITY.get(); } But now, the durability bar seems to be hidden since I removed the .durability(int) in the properties. How can I show it again ? EDIT : I found the solution to display it again. I just had to use the .durability(int) function on the properties, and the value taken for the durability is the one that come from the configs. Edited July 5, 20223 yr by Sweetmimike
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.