Fix parsing of render queue with chroma key (fixes #564)

By simply replacing the private field with a concrete type, so we do not need to
manually register one when constructing the gson instance (which is evidently
too easy to forget about).
This commit is contained in:
Jonas Herzig
2021-08-15 11:39:10 +02:00
parent 3db8c28505
commit 9626a4c442
2 changed files with 3 additions and 4 deletions

View File

@@ -4,6 +4,7 @@ import com.google.gson.annotations.JsonAdapter;
import com.google.gson.annotations.SerializedName;
import com.replaymod.core.utils.FileTypeAdapter;
import com.replaymod.core.versions.MCVer;
import de.johni0702.minecraft.gui.utils.lwjgl.Color;
import de.johni0702.minecraft.gui.utils.lwjgl.ReadableColor;
import net.minecraft.client.resource.language.I18n;
import net.minecraft.util.Util;
@@ -153,7 +154,7 @@ public class RenderSettings {
private final boolean stabilizeYaw;
private final boolean stabilizePitch;
private final boolean stabilizeRoll;
private final ReadableColor chromaKeyingColor;
private final Color chromaKeyingColor;
private final int sphericalFovX;
private final int sphericalFovY;
private final boolean injectSphericalMetadata;
@@ -207,7 +208,7 @@ public class RenderSettings {
this.stabilizeYaw = stabilizeYaw;
this.stabilizePitch = stabilizePitch;
this.stabilizeRoll = stabilizeRoll;
this.chromaKeyingColor = chromaKeyingColor;
this.chromaKeyingColor = chromaKeyingColor == null ? null : new Color(chromaKeyingColor);
this.sphericalFovX = sphericalFovX;
this.sphericalFovY = sphericalFovY;
this.injectSphericalMetadata = injectSphericalMetadata;

View File

@@ -31,7 +31,6 @@ 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.screen.NoticeScreen;
import net.minecraft.client.resource.language.I18n;
@@ -333,7 +332,6 @@ public class GuiRenderSettings extends AbstractGuiPopup<GuiRenderSettings> {
try {
settings = new GsonBuilder()
.registerTypeAdapter(RenderSettings.class, (InstanceCreator<RenderSettings>) type -> getDefaultRenderSettings())
.registerTypeAdapter(ReadableColor.class, new Gson().getAdapter(Color.class))
.create().fromJson(json, RenderSettings.class);
} catch (JsonSyntaxException e) {
LOGGER.error("Parsing render settings:", e);