Iron's Spells 'n Spellbooks

Iron's Spells 'n Spellbooks

18M Downloads

[Bug] Can't use whitelist option in serverconfig for modifying which weapons can be imbued.

Razor235T opened this issue · 4 comments

commented

Observed behaviour

Adding weapons, for example a bow or shield, to the imbueWhitelist doesn't do anything. After adding imbueWhitelist = ["minecraft:bow"], I place a bow into the Arcane Anvil, but it flashes for a moment and then still can't be imbued.
Disabling all the ModernFix options doesn't do anything, issue still persists. Only uninstalling ModernFix fixes it. Also, on an integrated server issue sometimes fixes itself, but on a dedicated server it never does.

Expected behaviour

Imbuing bow by modifying config that should make it possible

Steps to reproduce

  1. Install Iron's Spells 'n Spellbooks and dependencies on a server and a client
  2. Install ModernFix on the server and the client
  3. Try modifying imbueWhitelist in serverconfig, adding to it some item like a bow
  4. Start and join dedicated server
  5. Try imbuing the item in the game

Server Type

Dedicated Server

Crashlog

No response

Iron's Spells N Spellbooks version

irons_spellbooks-1.20.1-3.1.7

Forge version

Minecraft 1.20.1, Forge 47.2.32

Other mods

Iron's Spells 'n Spellbooks, Caelus, Curios, Player Animation Lib, Geckolib, Modernfix

commented

its modernfix breaks forge config, that's an issue with them. we do no special config handling

commented

@iron431 I believe the issue is that you only reload your configs in response to ModConfigEvent.Reloading (which is intended to fire when the config file is changed after load) and not in ModConfigEvent.Loading (which always fires once on server/client startup).

In base Forge, due to a variety of thread safety/concurrency flaws in the config system, most mod configs tend to get the Reloading event fired at startup as well, because Forge saves the config file to disk after loading it (the file being changed on disk triggers a reload event). This usually causes random CME crashes, as well as the config file randomly becoming corrupted on disk, since most modders do not code with that in mind.

There was no way to properly patch the concurrency issues from ModernFix's side alone. For this reason, ModernFix disables the file watcher that automatically reloads the configs and only reloads configs in response to a special command being run. This means the Reloading event will not fire on startup, only Loading. However, that is not really a breaking change, because there is no guarantee the Reloading event would ever have run anyway (e.g. on systems on which file watching is not supported, and thus there is no way to detect reloads).

For reliability, you should reload your stuff in both Loading and Reloading. Additionally, due to the aforementioned Forge bugs, you should be prepared for both of these events to fire at the same time, potentially on different threads. (Yes. -_-)

@SubscribeEvent
public static void onModConfigLoadingEvent(ModConfigEvent.Loading event) {
IronsSpellbooks.LOGGER.debug("onModConfigLoadingEvent");
if (event.getConfig().getType() == ModConfig.Type.SERVER) {
}
}
@SubscribeEvent
public static void onModConfigReloadingEvent(ModConfigEvent.Reloading event) {
IronsSpellbooks.LOGGER.debug("onModConfigReloadingEvent");
if (event.getConfig().getType() == ModConfig.Type.SERVER) {
SpellRegistry.onConfigReload();
ServerConfigs.onConfigReload();
}
}

commented

@embeddedt Good to know, in all my testing the reload event always fires on load, I thought that was just how the system worked. In that case, it will be an easy fix.

commented

Is this likely to be fixed soon? As this issue is bothering me as well