Fix replay mod not showing LODs

This commit is contained in:
James Seibel
2024-07-21 20:05:36 -05:00
parent c9b650fb7f
commit d38711ca4b
5 changed files with 53 additions and 8 deletions
@@ -23,6 +23,7 @@ import com.seibel.distanthorizons.api.DhApi;
import com.seibel.distanthorizons.api.enums.rendering.EDhApiRenderPass;
import com.seibel.distanthorizons.api.methods.events.abstractEvents.*;
import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiRenderParam;
import com.seibel.distanthorizons.core.file.structure.ClientOnlySaveStructure;
import com.seibel.distanthorizons.core.level.IKeyedClientLevelManager;
import com.seibel.distanthorizons.core.pos.DhChunkPos;
import com.seibel.distanthorizons.core.render.DhApiRenderProxy;
@@ -53,6 +54,7 @@ import org.apache.logging.log4j.Logger;
import org.jetbrains.annotations.Nullable;
import org.lwjgl.glfw.GLFW;
import java.io.File;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Queue;
@@ -125,9 +127,28 @@ public class ClientApi
public synchronized void onClientOnlyConnected()
{
// only continue if the client is connected to a different server
if (MC.clientConnectedToDedicatedServer())
boolean connectedToServer = MC.clientConnectedToDedicatedServer();
boolean connectedToReplay = MC.connectedToReplay();
if (connectedToServer || connectedToReplay)
{
LOGGER.info("Client on ClientOnly mode connecting.");
if (connectedToServer)
{
LOGGER.info("Client on ClientOnly mode connecting.");
}
else
{
LOGGER.info("Replay on ClientServer mode connecting.");
if (Config.Client.Advanced.Logging.showReplayWarningOnStartup.get())
{
MC.sendChatMessage("\u00A76" + "Distant Horizons: Replay detected." + "\u00A7r"); // gold color
MC.sendChatMessage("DH may behave strangely or have missing functionality.");
MC.sendChatMessage("In order to use pre-generated LODs, put your DH database(s) in:");
MC.sendChatMessage("\u00A77"+".Minecraft" + File.separator + ClientOnlySaveStructure.SERVER_DATA_FOLDER_NAME + File.separator + ClientOnlySaveStructure.REPLAY_SERVER_FOLDER_NAME + File.separator + "DIMENSION_NAME"+"\u00A7r"); // light gray color
MC.sendChatMessage("This can be disabled in DH's config under Advanced -> Logging.");
MC.sendChatMessage("");
}
}
// firing after clientLevelLoadEvent
// TODO if level has prepped to load it should fire level load event
@@ -616,6 +616,7 @@ public class Config
@Deprecated
public static ConfigEntry<Integer> caveCullingHeight = new ConfigEntry.Builder<Integer>()
.setMinDefaultMax(-4096, 40, 4096)
.setAppearance(EConfigEntryAppearance.ONLY_IN_API)
.comment(""
+ "At what Y value should cave culling start?")
.build();
@@ -1209,6 +1210,13 @@ public class Config
+ "memory allocated to run DH well.")
.build();
public static ConfigEntry<Boolean> showReplayWarningOnStartup = new ConfigEntry.Builder<Boolean>()
.set(true)
.comment(""
+ "If enabled, a chat message will be displayed when a replay is started \n"
+ "giving some basic information about how DH will function.")
.build();
}
public static class Debugging
@@ -41,13 +41,17 @@ import java.util.*;
*/
public class ClientOnlySaveStructure extends AbstractSaveStructure
{
final File folder;
private static final IMinecraftClientWrapper MC_CLIENT = SingletonInjector.INSTANCE.get(IMinecraftClientWrapper.class);
private static final IMinecraftSharedWrapper MC_SHARED = SingletonInjector.INSTANCE.get(IMinecraftSharedWrapper.class);
public static final String SERVER_DATA_FOLDER_NAME = "Distant_Horizons_server_data";
public static final String REPLAY_SERVER_FOLDER_NAME = "REPLAY";
public static final String INVALID_FILE_CHARACTERS_REGEX = "[\\\\/:*?\"<>|]";
SubDimensionLevelMatcher subDimMatcher = null;
final HashMap<ILevelWrapper, File> levelWrapperToFileMap = new HashMap<>();
private static final IMinecraftClientWrapper MC_CLIENT = SingletonInjector.INSTANCE.get(IMinecraftClientWrapper.class);
private static final IMinecraftSharedWrapper MC_SHARED = SingletonInjector.INSTANCE.get(IMinecraftSharedWrapper.class);
private SubDimensionLevelMatcher subDimMatcher = null;
private final File folder;
private final HashMap<ILevelWrapper, File> levelWrapperToFileMap = new HashMap<>();
@@ -237,7 +241,7 @@ public class ClientOnlySaveStructure extends AbstractSaveStructure
private static String getSaveStructureFolderPath()
{
String path = MC_SHARED.getInstallationDirectory().getPath() + File.separatorChar
+ "Distant_Horizons_server_data" + File.separatorChar
+ SERVER_DATA_FOLDER_NAME + File.separatorChar
+ getServerFolderName();
return path;
}
@@ -245,6 +249,14 @@ public class ClientOnlySaveStructure extends AbstractSaveStructure
/** Generated from the server the client is currently connected to. */
private static String getServerFolderName()
{
// if connected to a replay we won't have any server info
// use the dedicated replay server folder
if (MC_CLIENT.connectedToReplay())
{
return REPLAY_SERVER_FOLDER_NAME;
}
// parse the current server's IP
ParsedIp parsedIp = new ParsedIp(MC_CLIENT.getCurrentServerIp());
String serverIpCleaned = parsedIp.ip.replaceAll(INVALID_FILE_CHARACTERS_REGEX, "");
@@ -62,6 +62,8 @@ public interface IMinecraftClientWrapper extends IBindable
boolean hasSinglePlayerServer();
boolean clientConnectedToDedicatedServer();
/** for use with the Replay mod */
boolean connectedToReplay();
String getCurrentServerName();
String getCurrentServerIp();
@@ -558,6 +558,8 @@
"Network Events",
"distanthorizons.config.client.advanced.logging.showLowMemoryWarningOnStartup":
"Show Low Memory Warning",
"distanthorizons.config.client.advanced.logging.showReplayWarningOnStartup":
"Show Replay Warning",