mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-19 11:59:25 +00:00
Clean up CraftingHelper constants loading API
This commit is contained in:
1 parent
5ef199f6d7
commit
f1d1e8853b
6 files changed
+50
-35
No files matched your search
@@ -797,14 +797,33 @@ public class GameData
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #checkPrefix(String, boolean)}.
|
||||
*/
|
||||
@Deprecated
|
||||
public static ResourceLocation checkPrefix(String name)
|
||||
{
|
||||
return checkPrefix(name, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check a name for a domain prefix, and if not present infer it from the
|
||||
* current active mod container.
|
||||
*
|
||||
* @param name The name or resource location
|
||||
* @param warnOverrides If true, logs a warning if domain differs from that of
|
||||
* the currently currently active mod container
|
||||
*
|
||||
* @return The {@link ResourceLocation} with given or inferred domain
|
||||
*/
|
||||
public static ResourceLocation checkPrefix(String name, boolean warnOverrides)
|
||||
{
|
||||
int index = name.lastIndexOf(':');
|
||||
String oldPrefix = index == -1 ? "" : name.substring(0, index).toLowerCase(Locale.ROOT);
|
||||
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(Locale.ROOT);
|
||||
if (!oldPrefix.equals(prefix) && oldPrefix.length() > 0)
|
||||
if (warnOverrides && !oldPrefix.equals(prefix) && oldPrefix.length() > 0)
|
||||
{
|
||||
FMLLog.log.warn("Potentially Dangerous alternative prefix `{}` for name `{}`, expected `{}`. This could be a intended override, but in most cases indicates a broken mod.", oldPrefix, name, prefix);
|
||||
prefix = oldPrefix;
|
||||
|
||||
Reference in new issue
Block a user