mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-18 03:25:18 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
397ceac0b6 | ||
|
|
1b7665cdaa | ||
|
|
70f96ef64e | ||
|
|
0cf4446352 | ||
|
|
b8270cd9ff |
No files matched your search
+2
-2
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
MinecraftForge
|
MinecraftForge
|
||||||
=============
|
=============
|
||||||
[][Download]
|
[][Download]
|
||||||
[][Download] [][Discord] [][Patreon]
|
)][Download] [][Discord] [][Patreon]
|
||||||
|
|
||||||
Forge is a free, open-source modding API all of your favourite mods use!
|
Forge is a free, open-source modding API all of your favourite mods use!
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ public class FMLConfig
|
|||||||
EARLY_WINDOW_SQUIR("earlyWindowSquir", Boolean.FALSE, "Squir?"),
|
EARLY_WINDOW_SQUIR("earlyWindowSquir", Boolean.FALSE, "Squir?"),
|
||||||
EARLY_WINDOW_SHOW_CPU("earlyWindowShowCPU", Boolean.FALSE, "Whether to show CPU usage stats in early window"),
|
EARLY_WINDOW_SHOW_CPU("earlyWindowShowCPU", Boolean.FALSE, "Whether to show CPU usage stats in early window"),
|
||||||
EARLY_WINDOW_LOG_HELP_MSG("earlyWindowLogHelpMessage", Boolean.TRUE, "Whether to log a help message on first attempt, to aid troubleshooting. This setting should automatically disable itself after a successful launch"),
|
EARLY_WINDOW_LOG_HELP_MSG("earlyWindowLogHelpMessage", Boolean.TRUE, "Whether to log a help message on first attempt, to aid troubleshooting. This setting should automatically disable itself after a successful launch"),
|
||||||
|
DETECT_NON_FORGE_MODS_TOML("detectNonForgeModsToml", Boolean.TRUE, "Attempt to detect non-Forge mods from their mods.toml to show a friendlier error message. This is a best-effort feature - disable if it causes issues."),
|
||||||
;
|
;
|
||||||
|
|
||||||
private final String entry;
|
private final String entry;
|
||||||
|
|||||||
+14
@@ -10,6 +10,8 @@ import cpw.mods.jarhandling.SecureJar;
|
|||||||
import cpw.mods.modlauncher.api.LamdbaExceptionUtils;
|
import cpw.mods.modlauncher.api.LamdbaExceptionUtils;
|
||||||
import cpw.mods.modlauncher.api.NamedPath;
|
import cpw.mods.modlauncher.api.NamedPath;
|
||||||
import cpw.mods.modlauncher.serviceapi.ITransformerDiscoveryService;
|
import cpw.mods.modlauncher.serviceapi.ITransformerDiscoveryService;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.ApiStatus;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -20,6 +22,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
@ApiStatus.Internal
|
||||||
public class ModDirTransformerDiscoverer implements ITransformerDiscoveryService {
|
public class ModDirTransformerDiscoverer implements ITransformerDiscoveryService {
|
||||||
private static final Logger LOGGER = LogUtils.getLogger();
|
private static final Logger LOGGER = LogUtils.getLogger();
|
||||||
private static final Set<String> SERVICES = Set.of(
|
private static final Set<String> SERVICES = Set.of(
|
||||||
@@ -76,4 +79,15 @@ public class ModDirTransformerDiscoverer implements ITransformerDiscoveryService
|
|||||||
.filter(SERVICES::contains)
|
.filter(SERVICES::contains)
|
||||||
.forEach(s -> found.add(new NamedPath(s, path)));
|
.forEach(s -> found.add(new NamedPath(s, path)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isServiceProvider(Path path) {
|
||||||
|
var jar = SecureJar.from(path);
|
||||||
|
|
||||||
|
for (var providers : jar.moduleDataProvider().descriptor().provides()) {
|
||||||
|
if (SERVICES.contains(providers.service()))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+1
-2
@@ -8,7 +8,6 @@ package net.minecraftforge.fml.loading.moddiscovery;
|
|||||||
import com.mojang.logging.LogUtils;
|
import com.mojang.logging.LogUtils;
|
||||||
import cpw.mods.jarhandling.JarMetadata;
|
import cpw.mods.jarhandling.JarMetadata;
|
||||||
import cpw.mods.jarhandling.SecureJar;
|
import cpw.mods.jarhandling.SecureJar;
|
||||||
import net.minecraftforge.fml.loading.EarlyLoadingException;
|
|
||||||
import net.minecraftforge.fml.loading.LogMarkers;
|
import net.minecraftforge.fml.loading.LogMarkers;
|
||||||
import net.minecraftforge.forgespi.language.IConfigurable;
|
import net.minecraftforge.forgespi.language.IConfigurable;
|
||||||
import net.minecraftforge.forgespi.language.IModFileInfo;
|
import net.minecraftforge.forgespi.language.IModFileInfo;
|
||||||
@@ -51,7 +50,7 @@ public abstract class AbstractModProvider implements IModProvider {
|
|||||||
if (sj.moduleDataProvider().findFile(MODS_TOML).isPresent()) {
|
if (sj.moduleDataProvider().findFile(MODS_TOML).isPresent()) {
|
||||||
LOGGER.debug(LogMarkers.SCAN, "Found {} mod of type {}: {}", MODS_TOML, type, path);
|
LOGGER.debug(LogMarkers.SCAN, "Found {} mod of type {}: {}", MODS_TOML, type, path);
|
||||||
mod = new ModFile(sj, this, ModFileParser::modsTomlParser);
|
mod = new ModFile(sj, this, ModFileParser::modsTomlParser);
|
||||||
if (mod.getModFileInfo().getFileProperties().containsKey(ModFileInfo.NOT_A_FORGE_MOD_PROP)) {
|
if (ModFileInfo.DETECT_NON_FORGE_MODS_TOML && mod.getModFileInfo().getFileProperties().containsKey(ModFileInfo.NOT_A_FORGE_MOD_PROP)) {
|
||||||
LOGGER.error(LogMarkers.SCAN, "Unable to load file \"{}\" because its mods.toml is requesting an invalid javafml loaderVersion (use \"*\" if you want to allow all versions) and is missing a forge modId dependency declaration (see the sample mods.toml in the MDK).", path);
|
LOGGER.error(LogMarkers.SCAN, "Unable to load file \"{}\" because its mods.toml is requesting an invalid javafml loaderVersion (use \"*\" if you want to allow all versions) and is missing a forge modId dependency declaration (see the sample mods.toml in the MDK).", path);
|
||||||
return new IModLocator.ModFileOrException(null, new ModFileLoadingException("File \"%s\" is not a Forge mod and cannot be loaded. Look for a Forge version of this mod or consider alternative mods.".formatted(mod.getFileName())));
|
return new IModLocator.ModFileOrException(null, new ModFileLoadingException("File \"%s\" is not a Forge mod and cannot be loaded. Look for a Forge version of this mod or consider alternative mods.".formatted(mod.getFileName())));
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-2
@@ -8,6 +8,7 @@ package net.minecraftforge.fml.loading.moddiscovery;
|
|||||||
import com.mojang.logging.LogUtils;
|
import com.mojang.logging.LogUtils;
|
||||||
|
|
||||||
import net.minecraftforge.fml.loading.LogMarkers;
|
import net.minecraftforge.fml.loading.LogMarkers;
|
||||||
|
import net.minecraftforge.fml.loading.ModDirTransformerDiscoverer;
|
||||||
import net.minecraftforge.forgespi.locating.IModLocator;
|
import net.minecraftforge.forgespi.locating.IModLocator;
|
||||||
|
|
||||||
import org.jetbrains.annotations.ApiStatus;
|
import org.jetbrains.annotations.ApiStatus;
|
||||||
@@ -71,8 +72,11 @@ public class ClasspathLocator extends AbstractModProvider implements IModLocator
|
|||||||
}
|
}
|
||||||
|
|
||||||
var ret = new ArrayList<ModFileOrException>();
|
var ret = new ArrayList<ModFileOrException>();
|
||||||
for (var path : claimed)
|
for (var path : claimed) {
|
||||||
ret.add(createMod(path));
|
// Filter out anything found by the ServiceLoader
|
||||||
|
if (!ModDirTransformerDiscoverer.isServiceProvider(path))
|
||||||
|
ret.add(createMod(path));
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+6
-1
@@ -8,6 +8,7 @@ package net.minecraftforge.fml.loading.moddiscovery;
|
|||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
import com.mojang.logging.LogUtils;
|
import com.mojang.logging.LogUtils;
|
||||||
import cpw.mods.modlauncher.api.LamdbaExceptionUtils;
|
import cpw.mods.modlauncher.api.LamdbaExceptionUtils;
|
||||||
|
import net.minecraftforge.fml.loading.FMLConfig;
|
||||||
import net.minecraftforge.fml.loading.LogMarkers;
|
import net.minecraftforge.fml.loading.LogMarkers;
|
||||||
import net.minecraftforge.fml.loading.StringUtils;
|
import net.minecraftforge.fml.loading.StringUtils;
|
||||||
import net.minecraftforge.forgespi.language.IConfigurable;
|
import net.minecraftforge.forgespi.language.IConfigurable;
|
||||||
@@ -48,6 +49,9 @@ public class ModFileInfo implements IModFileInfo, IConfigurable
|
|||||||
@ApiStatus.Internal
|
@ApiStatus.Internal
|
||||||
public static final String NOT_A_FORGE_MOD_PROP = "__FORGE__not_a_forge_mod";
|
public static final String NOT_A_FORGE_MOD_PROP = "__FORGE__not_a_forge_mod";
|
||||||
|
|
||||||
|
@ApiStatus.Internal
|
||||||
|
public static final boolean DETECT_NON_FORGE_MODS_TOML = FMLConfig.getBoolConfigValue(FMLConfig.ConfigValue.DETECT_NON_FORGE_MODS_TOML);
|
||||||
|
|
||||||
private final IConfigurable config;
|
private final IConfigurable config;
|
||||||
private final ModFile modFile;
|
private final ModFile modFile;
|
||||||
private final URL issueURL;
|
private final URL issueURL;
|
||||||
@@ -75,7 +79,8 @@ public class ModFileInfo implements IModFileInfo, IConfigurable
|
|||||||
this.languageSpecs = new ArrayList<>(List.of(new LanguageSpec(modLoader, modLoaderVersion)));
|
this.languageSpecs = new ArrayList<>(List.of(new LanguageSpec(modLoader, modLoaderVersion)));
|
||||||
|
|
||||||
// if true, this might not be a Forge mod
|
// if true, this might not be a Forge mod
|
||||||
boolean maybeNotAForgeMod = modLoader.equals(JAVAFML)
|
boolean maybeNotAForgeMod = DETECT_NON_FORGE_MODS_TOML
|
||||||
|
&& modLoader.equals(JAVAFML)
|
||||||
&& modLoaderVersion.hasRestrictions() // if loaderVersion is not "*"
|
&& modLoaderVersion.hasRestrictions() // if loaderVersion is not "*"
|
||||||
&& modLoaderVerStr.equals(MAYBE_NOT_JAVAFML_VER); // if loaderVersion is exactly "[2,)"
|
&& modLoaderVerStr.equals(MAYBE_NOT_JAVAFML_VER); // if loaderVersion is exactly "[2,)"
|
||||||
|
|
||||||
|
|||||||
@@ -214,7 +214,7 @@ public class ModInfo implements IModInfo, IConfigurable {
|
|||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
this.modId = config.<String>getConfigElement("modId")
|
this.modId = config.<String>getConfigElement("modId")
|
||||||
.orElseThrow(()->new InvalidModFileException("Missing required field modid in dependency", getOwningFile()));
|
.orElseThrow(()->new InvalidModFileException("Missing required field modid in dependency", getOwningFile()));
|
||||||
if (this.modId.equals("forge")) {
|
if (ModFileInfo.DETECT_NON_FORGE_MODS_TOML && this.modId.equals("forge")) {
|
||||||
var fileProps = owner.getOwningFile().getFileProperties();
|
var fileProps = owner.getOwningFile().getFileProperties();
|
||||||
// Checking containsKey to avoid a possible exception if the property is not present (due to Collections.emptyMap())
|
// Checking containsKey to avoid a possible exception if the property is not present (due to Collections.emptyMap())
|
||||||
if (!fileProps.isEmpty() && fileProps.containsKey(ModFileInfo.NOT_A_FORGE_MOD_PROP)) {
|
if (!fileProps.isEmpty() && fileProps.containsKey(ModFileInfo.NOT_A_FORGE_MOD_PROP)) {
|
||||||
@@ -226,7 +226,7 @@ public class ModInfo implements IModInfo, IConfigurable {
|
|||||||
var mandatory = config.<Boolean>getConfigElement("mandatory");
|
var mandatory = config.<Boolean>getConfigElement("mandatory");
|
||||||
if (mandatory.isPresent()) {
|
if (mandatory.isPresent()) {
|
||||||
this.mandatory = mandatory.get();
|
this.mandatory = mandatory.get();
|
||||||
} else if (owner.getOwningFile().getFileProperties().containsKey(ModFileInfo.NOT_A_FORGE_MOD_PROP)) {
|
} else if (ModFileInfo.DETECT_NON_FORGE_MODS_TOML && owner.getOwningFile().getFileProperties().containsKey(ModFileInfo.NOT_A_FORGE_MOD_PROP)) {
|
||||||
this.mandatory = true;
|
this.mandatory = true;
|
||||||
} else {
|
} else {
|
||||||
throw new InvalidModFileException("Missing required field mandatory in dependency", getOwningFile());
|
throw new InvalidModFileException("Missing required field mandatory in dependency", getOwningFile());
|
||||||
|
|||||||
@@ -45,7 +45,7 @@
|
|||||||
|
|
||||||
public LevelSettings withDataConfiguration(WorldDataConfiguration p_250867_) {
|
public LevelSettings withDataConfiguration(WorldDataConfiguration p_250867_) {
|
||||||
- return new LevelSettings(this.levelName, this.gameType, this.hardcore, this.difficulty, this.allowCommands, this.gameRules, p_250867_);
|
- return new LevelSettings(this.levelName, this.gameType, this.hardcore, this.difficulty, this.allowCommands, this.gameRules, p_250867_);
|
||||||
+ return new LevelSettings(this.levelName, this.gameType, this.hardcore, this.difficulty, this.allowCommands, this.gameRules, dataConfiguration, this.lifecycle);
|
+ return new LevelSettings(this.levelName, this.gameType, this.hardcore, this.difficulty, this.allowCommands, this.gameRules, p_250867_, this.lifecycle);
|
||||||
}
|
}
|
||||||
|
|
||||||
public LevelSettings copy() {
|
public LevelSettings copy() {
|
||||||
|
|||||||
@@ -16,11 +16,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,14 +_,14 @@
|
@@ -139,7 +_,7 @@
|
||||||
p_221161_.scheduleTick(p_221162_, this, getFireTickDelay(p_221161_.random));
|
|
||||||
if (p_221161_.getGameRules().getBoolean(GameRules.RULE_DOFIRETICK)) {
|
|
||||||
if (!p_221160_.canSurvive(p_221161_, p_221162_)) {
|
|
||||||
- p_221161_.removeBlock(p_221162_, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockState blockstate = p_221161_.getBlockState(p_221162_.below());
|
BlockState blockstate = p_221161_.getBlockState(p_221162_.below());
|
||||||
@@ -29,10 +25,6 @@
|
|||||||
int i = p_221160_.getValue(AGE);
|
int i = p_221160_.getValue(AGE);
|
||||||
if (!flag && p_221161_.isRaining() && this.isNearRain(p_221161_, p_221162_) && p_221163_.nextFloat() < 0.2F + (float)i * 0.03F) {
|
if (!flag && p_221161_.isRaining() && this.isNearRain(p_221161_, p_221162_) && p_221163_.nextFloat() < 0.2F + (float)i * 0.03F) {
|
||||||
p_221161_.removeBlock(p_221162_, false);
|
p_221161_.removeBlock(p_221162_, false);
|
||||||
+ p_221161_.removeBlock(p_221162_, false);
|
|
||||||
} else {
|
|
||||||
int j = Math.min(15, i + p_221163_.nextInt(3) / 2);
|
|
||||||
if (i != j) {
|
|
||||||
@@ -160,7 +_,7 @@
|
@@ -160,7 +_,7 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
import org.gradle.internal.os.OperatingSystem
|
|
||||||
|
|
||||||
pluginManagement {
|
pluginManagement {
|
||||||
repositories {
|
repositories {
|
||||||
gradlePluginPortal()
|
gradlePluginPortal()
|
||||||
|
|||||||
Reference in new issue
Block a user