Jump to content

Elucent

Members
  • Posts

    2
  • Joined

  • Last visited

Converted

  • Gender
    Undisclosed
  • Personal Text
    I am new!

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Elucent's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. If that's really it, then is there any (sane, no ASM ofc) way I can circumvent this if in my case it's fully-intended behavior? I'm guessing no, but no harm in asking.
  2. I've recently been working on a lib mod to make tedious modding tasks less, well, tedious. Among the first features I added was a simple registry system that keeps a list of every item and block I wish to register, posts an event that is received by dependent mods wherein they can add their content to the list, then handles registry of the items/blocks and their respective models in the relevant Forge events. This works fine, but I've run into a somewhat annoying issue: since I dispatch my RegisterContentEvent from my lib mod, I instantiate my blocks and items while the lib mod is currently the active mod container. So, as I call setRegistryName, the following code from the IForgeRegistry Impl is executed and a big warning is printed: public final T setRegistryName(String name) { if (getRegistryName() != null) throw new IllegalStateException("Attempted to set registry name with existing registry name! New: " + name + " Old: " + getRegistryName()); int index = name.lastIndexOf(':'); String oldPrefix = index == -1 ? "" : name.substring(0, index); name = index == -1 ? name : name.substring(index + 1); ModContainer mc = Loader.instance().activeModContainer(); String prefix = mc == null || (mc instanceof InjectedModContainer && ((InjectedModContainer)mc).wrappedContainer instanceof FMLContainer) ? "minecraft" : mc.getModId().toLowerCase(); if (!oldPrefix.equals(prefix) && oldPrefix.length() > 0) { FMLLog.bigWarning("Dangerous alternative prefix `{}` for name `{}`, expected `{}` invalid registry invocation/invalid name?", oldPrefix, name, prefix); prefix = oldPrefix; } this.registryName = new ResourceLocation(prefix, name); return (T)this; } I can adapt my setup so that I'm not relying on this event, but I was wondering if I was missing any reasons why this warning was fired. Obviously it's best to keep content from a given mod using the modid of that mod, but in this case content from respective mods will be using the modids of those respective mods -- I'm just trying to avoid having to recode a registry for every mod. And yeah, of course, I can work around this no problem. But for future reference, are there any consequences for registering a registry entry with a modid not matching the currently-active mod container, other than potential confusion and not obeying the standard? I would personally rather rely on the event than sticking all of my content instantiation in a preinit somewhere, to try and be more in-line with Forge's registry changes, which as I understand are working towards the goal of the potential for mods to be loaded somewhat dynamically. Obviously this isn't the case now, and it wouldn't impact my mods at the moment to rely on the old initialization events, but I feel as if moving forward relying on a freely-postable event will be more of a positive than a negative -- unless, of course, this mismatched modid issue has some dire consequences I'm not aware of. My apologies if this is the wrong subforum, since it's more of a general Forge clarification question than a direct issue with my code. Thank you!
×
×
  • Create New...

Important Information

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