mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-18 03:25:18 +00:00
1 parent
2ab2ced589
commit
f1702495ef
5 files changed
+47
-27
No files matched your search
@@ -69,7 +69,7 @@ public class FMLConfig
|
||||
LOGGER.trace(CORE, "Version check is {}", FMLConfig.runVersionCheck());
|
||||
LOGGER.trace(CORE, "Default config paths at {}", FMLConfig.defaultConfigPath());
|
||||
}
|
||||
FMLPaths.getOrCreateGameRelativePath(Paths.get(FMLConfig.defaultConfigPath()), "default config directory");
|
||||
FMLPaths.getOrCreateGameRelativePath(Paths.get(FMLConfig.defaultConfigPath()));
|
||||
}
|
||||
|
||||
public static boolean splashScreenEnabled() {
|
||||
|
||||
@@ -9,6 +9,8 @@ import com.mojang.logging.LogUtils;
|
||||
import cpw.mods.modlauncher.api.IEnvironment;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Arrays;
|
||||
@@ -57,9 +59,13 @@ public enum FMLPaths
|
||||
for (FMLPaths path : FMLPaths.values())
|
||||
{
|
||||
path.absolutePath = rootPath.resolve(path.relativePath).toAbsolutePath().normalize();
|
||||
if (path.isDirectory)
|
||||
if (path.isDirectory && !Files.isDirectory(path.absolutePath))
|
||||
{
|
||||
FileUtils.getOrCreateDirectory(path.absolutePath, path.name());
|
||||
try {
|
||||
Files.createDirectories(path.absolutePath);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
if (LOGGER.isDebugEnabled(CORE))
|
||||
{
|
||||
@@ -68,8 +74,26 @@ public enum FMLPaths
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #getOrCreateGameRelativePath(Path)} instead.
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "1.19.4")
|
||||
public static Path getOrCreateGameRelativePath(Path path, String name) {
|
||||
return FileUtils.getOrCreateDirectory(FMLPaths.GAMEDIR.get().resolve(path), name);
|
||||
return getOrCreateGameRelativePath(path);
|
||||
}
|
||||
|
||||
public static Path getOrCreateGameRelativePath(Path path) {
|
||||
Path gameFolderPath = FMLPaths.GAMEDIR.get().resolve(path);
|
||||
|
||||
if (!Files.isDirectory(gameFolderPath)) {
|
||||
try {
|
||||
Files.createDirectories(gameFolderPath);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
return gameFolderPath;
|
||||
}
|
||||
|
||||
public Path relative() {
|
||||
|
||||
@@ -10,37 +10,27 @@ import org.slf4j.Logger;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.FileAlreadyExistsException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import static net.minecraftforge.fml.loading.LogMarkers.CORE;
|
||||
|
||||
public class FileUtils
|
||||
{
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
|
||||
/**
|
||||
* @deprecated Use normal Java NIO methods instead
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "1.19.4")
|
||||
public static Path getOrCreateDirectory(Path dirPath, String dirLabel) {
|
||||
if (!Files.isDirectory(dirPath.getParent())) {
|
||||
getOrCreateDirectory(dirPath.getParent(), "parent of "+dirLabel);
|
||||
}
|
||||
if (!Files.isDirectory(dirPath))
|
||||
{
|
||||
LOGGER.debug(CORE, "Making {} directory : {}", dirLabel, dirPath);
|
||||
try {
|
||||
Files.createDirectory(dirPath);
|
||||
Files.createDirectories(dirPath);
|
||||
} catch (IOException e) {
|
||||
if (e instanceof FileAlreadyExistsException) {
|
||||
LOGGER.error(CORE, "Failed to create {} directory - there is a file in the way", dirLabel);
|
||||
} else {
|
||||
LOGGER.error(CORE, "Problem with creating {} directory (Permissions?)", dirLabel, e);
|
||||
}
|
||||
throw new RuntimeException("Problem creating directory", e);
|
||||
}
|
||||
LOGGER.debug(CORE, "Created {} directory : {}", dirLabel, dirPath);
|
||||
} else {
|
||||
LOGGER.debug(CORE, "Found existing {} directory : {}", dirLabel, dirPath);
|
||||
}
|
||||
|
||||
return dirPath;
|
||||
}
|
||||
|
||||
@@ -54,7 +44,7 @@ public class FileUtils
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static boolean matchFileName(String path, String... matches) {
|
||||
// Extract file name from path
|
||||
String name = path.substring(Math.min(path.lastIndexOf(File.separatorChar) + 1, path.length()));
|
||||
|
||||
@@ -7,6 +7,8 @@ package net.minecraftforge.server;
|
||||
|
||||
import static net.minecraftforge.fml.Logging.CORE;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -35,7 +37,6 @@ import net.minecraftforge.fml.ModLoadingStage;
|
||||
import net.minecraftforge.fml.ModLoadingWarning;
|
||||
import net.minecraftforge.network.ConnectionType;
|
||||
import net.minecraftforge.network.NetworkConstants;
|
||||
import net.minecraftforge.network.ServerStatusPing;
|
||||
import net.minecraftforge.network.NetworkHooks;
|
||||
import net.minecraftforge.network.NetworkRegistry;
|
||||
import net.minecraftforge.forgespi.locating.IModFile;
|
||||
@@ -62,7 +63,6 @@ import net.minecraftforge.event.server.ServerStartedEvent;
|
||||
import net.minecraftforge.event.server.ServerStartingEvent;
|
||||
import net.minecraftforge.event.server.ServerStoppedEvent;
|
||||
import net.minecraftforge.event.server.ServerStoppingEvent;
|
||||
import net.minecraftforge.fml.loading.FileUtils;
|
||||
import net.minecraftforge.forgespi.language.IModInfo;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.GameData;
|
||||
@@ -79,7 +79,13 @@ public class ServerLifecycleHooks
|
||||
private static Path getServerConfigPath(final MinecraftServer server)
|
||||
{
|
||||
final Path serverConfig = server.getWorldPath(SERVERCONFIG);
|
||||
FileUtils.getOrCreateDirectory(serverConfig, "serverconfig");
|
||||
if (!Files.isDirectory(serverConfig)) {
|
||||
try {
|
||||
Files.createDirectories(serverConfig);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
return serverConfig;
|
||||
}
|
||||
|
||||
|
||||
@@ -49,10 +49,10 @@ import org.joml.Quaternionf;
|
||||
/**
|
||||
* This mod is testing the use of {@link RenderLevelStageEvent} and is a modifaction of a pre-existing test mod that used the old
|
||||
* {@link RenderLevelLastEvent}. To restore the old behavior, set {@link #USE_LEVEL_RENDERER_STAGE} to false.
|
||||
*
|
||||
*
|
||||
* When you enter a world, there should be 6 sugar gliders rendering at (0, 120, 0) that test the various stages in {@link RenderLevelStageEvent}.
|
||||
* From left to right (with the sugar gliders facing you) they represent {@link Stage#AFTER_SKY}, {@link Stage#AFTER_SOLID_BLOCKS},
|
||||
* {@link Stage#AFTER_TRANSLUCENT_BLOCKS}, {@link Stage#AFTER_TRIPWIRE_BLOCKS}, {@link Stage#AFTER_PARTICLES}, and {@link Stage#AFTER_WEATHER}.
|
||||
* {@link Stage#AFTER_TRANSLUCENT_BLOCKS}, {@link Stage#AFTER_TRIPWIRE_BLOCKS}, {@link Stage#AFTER_PARTICLES}, and {@link Stage#AFTER_WEATHER}.
|
||||
* Due to how weather modifies the projection matrix, it's sugar glider will be positioned weirdly. Below each sugar gliders is a render of
|
||||
* blue stained glass to test translucency with fabulous graphics. {@link Stage#AFTER_PARTICLES} will render the stained glass using
|
||||
* {@link ForgeRenderTypes#TRANSLUCENT_ON_PARTICLES_TARGET}.
|
||||
@@ -63,7 +63,7 @@ public class RenderableTest
|
||||
public static final String MODID = "renderable_test";
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
public static final boolean ENABLED = true; // Renders at (0, 120, 0)
|
||||
public static final boolean ENABLED = false; // Renders at (0, 120, 0)
|
||||
public static final boolean USE_LEVEL_RENDERER_STAGE = true; // True when using RenderLevelStageEvent. False when using RenderLevelLastEvent
|
||||
|
||||
public RenderableTest()
|
||||
|
||||
Reference in new issue
Block a user