Get render module compiling on 1.13

This commit is contained in:
Jonas Herzig
2019-03-01 15:16:59 +01:00
parent 641014b0d1
commit 344a550dc1
38 changed files with 632 additions and 327 deletions

View File

@@ -28,18 +28,21 @@ import de.johni0702.minecraft.gui.popup.GuiFileChooserPopup;
import de.johni0702.minecraft.gui.utils.Colors;
import de.johni0702.minecraft.gui.utils.Consumer;
import de.johni0702.minecraft.gui.utils.Utils;
import de.johni0702.minecraft.gui.utils.lwjgl.Color;
import de.johni0702.minecraft.gui.utils.lwjgl.Dimension;
import de.johni0702.minecraft.gui.utils.lwjgl.ReadableColor;
import de.johni0702.minecraft.gui.utils.lwjgl.ReadableDimension;
import net.minecraft.client.gui.GuiErrorScreen;
import net.minecraft.client.resources.I18n;
import net.minecraft.crash.CrashReport;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.common.config.Property;
import org.lwjgl.util.Color;
import org.lwjgl.util.Dimension;
import org.lwjgl.util.ReadableColor;
import org.lwjgl.util.ReadableDimension;
import javax.annotation.Nullable;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;
@@ -294,7 +297,14 @@ public class GuiRenderSettings extends GuiScreen implements Closeable {
this.replayHandler = replayHandler;
this.timeline = timeline;
String json = getConfigProperty(ReplayModRender.instance.getConfiguration()).getString();
Path path = ReplayModRender.instance.getRenderSettingsPath();
String json = "{}";
try {
json = new String(Files.readAllBytes(path), StandardCharsets.UTF_8);
} catch (FileNotFoundException ignored) {
} catch (IOException e) {
LOGGER.error("Reading render settings:", e);
}
RenderSettings settings = new GsonBuilder()
.registerTypeAdapter(RenderSettings.class, (InstanceCreator<RenderSettings>) type -> getDefaultRenderSettings())
.registerTypeAdapter(ReadableColor.class, new Gson().getAdapter(Color.class))
@@ -506,14 +516,12 @@ public class GuiRenderSettings extends GuiScreen implements Closeable {
public void close() {
RenderSettings settings = save(true);
String json = new Gson().toJson(settings);
Configuration config = ReplayModRender.instance.getConfiguration();
getConfigProperty(config).set(json);
config.save();
}
protected Property getConfigProperty(Configuration configuration) {
return configuration.get("rendersettings", "settings", "{}",
"Last state of the render settings GUI. Internal use only.");
Path path = ReplayModRender.instance.getRenderSettingsPath();
try {
Files.write(path, json.getBytes(StandardCharsets.UTF_8));
} catch (IOException e) {
LOGGER.error("Saving render settings:", e);
}
}
public ReplayHandler getReplayHandler() {