Skip to content

Commit

Permalink
actually fix migration
Browse files Browse the repository at this point in the history
fix old config options showing in config
add new icons
  • Loading branch information
Wyvest committed Jun 18, 2024
1 parent 6f61c7b commit 4fb0cc5
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 71 deletions.
5 changes: 5 additions & 0 deletions src/main/java/club/sk1er/patcher/PolyPatcher.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package club.sk1er.patcher;

// Being nice and giving developers a head start in detecting if the mod is PolyPatcher and not the original Patcher
public class PolyPatcher {
}
71 changes: 37 additions & 34 deletions src/main/java/club/sk1er/patcher/config/PatcherConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,6 @@ public class PatcherConfig extends Config {
)
public static boolean fixedAlexArms = true;

@Switch(
name = "Fix Actionbar Overlap",
description = "Prevents the actionbar text from rendering above the armor/health bar.",
category = "Bug Fixes", subcategory = "Rendering"
)
public static boolean fixActionbarOverlap;

@Dropdown(
name = "Keyboard Layout",
description = "The layout of your keyboard, used to fix input bugs accordingly.",
Expand Down Expand Up @@ -1572,6 +1565,14 @@ public static int getInventoryScale() {
// HIDDEN OPTION!!!!!!! DO NOT REMOVE OR TOUCH
public static int tabHeightOld = 10;

@Switch(
name = "Fix Actionbar Overlap",
description = "Prevents the actionbar text from rendering above the armor/health bar.",
category = "Bug Fixes", subcategory = "Rendering"
)
// HIDDEN OPTION!!!!!!! DO NOT REMOVE OR TOUCH
public static boolean fixActionbarOverlapOld;

@Exclude public static boolean nauseaEffect = false;
@Exclude public static float fireOverlayOpacity = 1F;
@Exclude public static boolean disableTitles = false;
Expand All @@ -1598,6 +1599,7 @@ public static int getInventoryScale() {
@Exclude public static int tabPlayerCount = 80;
@Exclude public static boolean tabHeightAllow = false;
@Exclude public static int tabHeight = 0;
@Exclude public static boolean fixActionbarOverlap = false;


public static boolean labyModMoment = true;
Expand All @@ -1606,7 +1608,7 @@ public static int getInventoryScale() {
public static PatcherConfig INSTANCE = new PatcherConfig(); // Needs to be at the bottom or the default values take priority

public PatcherConfig() {
super(new Mod("PolyPatcher", ModType.UTIL_QOL, "/patcher.png", new VigilanceMigrator("./config/patcher.toml")), "patcher.json");
super(new Mod("PolyPatcher", ModType.UTIL_QOL, "/patcher.svg", new VigilanceMigrator("./config/patcher.toml")), "patcher.json");
initialize();

boolean modified = false;
Expand Down Expand Up @@ -1640,32 +1642,33 @@ public PatcherConfig() {
addListener("removeGroundFoliage", reloadWorld);
addListener("vanillaGlassPanes", reloadWorld);

hideIf("showOwnNametag", () -> true);
hideIf("shadowedNametagText", () -> true);
hideIf("shadowedActionbarText", () -> true);
hideIf("disableTitles", () -> true);
hideIf("titleScale", () -> true);
hideIf("titleOpacity", () -> true);
hideIf("actionbarBackground", () -> true);
hideIf("removeContainerBackground", () -> true);
hideIf("disableNametagBoxes", () -> true);
hideIf("toggleTab", () -> true);
hideIf("numberPing", () -> true);
hideIf("tabOpacity", () -> true);
hideIf("tabPlayerCount", () -> true);
hideIf("tabHeightAllow", () -> true);
hideIf("tabHeight", () -> true);
hideIf("removeVerticalViewBobbing", () -> true);
hideIf("cleanView", () -> true);
hideIf("disableBlockBreakParticles", () -> true);
hideIf("staticParticleColor", () -> true);
hideIf("maxParticleLimit", () -> true);
hideIf("crosshairPerspective", () -> true);
hideIf("removeInvertFromCrosshair", () -> true);
hideIf("guiCrosshair", () -> true);
hideIf("nauseaEffect", () -> true);
hideIf("riddenHorseOpacity", () -> true);
hideIf("fireOverlayOpacity", () -> true);
hideIf("nauseaEffectOld", () -> true);
hideIf("fireOverlayOpacityOld", () -> true);
hideIf("disableTitlesOld", () -> true);
hideIf("titleScaleOld", () -> true);
hideIf("titleOpacityOld", () -> true);
hideIf("toggleTabOld", () -> true);
hideIf("crosshairPerspectiveOld", () -> true);
hideIf("showOwnNametagOld", () -> true);
hideIf("riddenHorseOpacityOld", () -> true);
hideIf("numberPingOld", () -> true);
hideIf("cleanViewOld", () -> true);
hideIf("disableBlockBreakParticlesOld", () -> true);
hideIf("removeInvertFromCrosshairOld", () -> true);
hideIf("shadowedNametagTextOld", () -> true);
hideIf("shadowedActionbarTextOld", () -> true);
hideIf("actionbarBackgroundOld", () -> true);
hideIf("removeVerticalViewBobbingOld", () -> true);
hideIf("staticParticleColorOld", () -> true);
hideIf("maxParticleLimitOld", () -> true);
hideIf("disableNametagBoxesOld", () -> true);
hideIf("removeContainerBackgroundOld", () -> true);
hideIf("guiCrosshairOld", () -> true);
hideIf("tabOpacityOld", () -> true);
hideIf("tabPlayerCountOld", () -> true);
hideIf("tabHeightAllowOld", () -> true);
hideIf("tabHeightOld", () -> true);
hideIf("fixActionbarOverlapOld", () -> true);

try {
addDependency("smartFullbright", "fullbright");
Expand Down
28 changes: 19 additions & 9 deletions src/main/java/club/sk1er/patcher/config/PatcherSoundConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import cc.polyfrost.oneconfig.config.elements.OptionSubcategory;
import cc.polyfrost.oneconfig.config.migration.VigilanceMigrator;
import cc.polyfrost.oneconfig.gui.elements.config.ConfigSlider;
import club.sk1er.patcher.Patcher;
import com.google.gson.JsonObject;
import net.minecraft.client.audio.SoundEventAccessorComposite;
import net.minecraft.util.ResourceLocation;
Expand All @@ -27,9 +28,11 @@ public class PatcherSoundConfig extends Config {
//#else
//$$ "patcher_sounds-112.json";
//#endif
public transient static final Mod soundModImpl = new Mod("Patcher Sounds", ModType.UTIL_QOL, "/patcher.png", new VigilanceMigrator("./config/" + CONFIG_NAME.replace(".json", ".toml")));
public transient static final Mod soundModImpl = new Mod("Patcher Sounds", ModType.UTIL_QOL, "/patcher.svg", new VigilanceMigrator("./config/" + CONFIG_NAME.replace(".json", ".toml")));
public transient final Map<ResourceLocation, BasicOption> data;

public static boolean dummyBooleanForMigratorDONTTOUCH = false; // this is used by vigilance migrator, but only to check if an annotation exists. so we can just pass it a random field

public PatcherSoundConfig(Map<ResourceLocation, BasicOption> data, Map<ResourceLocation, SoundEventAccessorComposite> soundRegistry) {
super(soundModImpl, CONFIG_NAME);
mod.config = this;
Expand All @@ -39,8 +42,17 @@ public PatcherSoundConfig(Map<ResourceLocation, BasicOption> data, Map<ResourceL
}

public void initialize(Map<ResourceLocation, BasicOption> data, Map<ResourceLocation, SoundEventAccessorComposite> soundRegistry) {
File profileFile = ConfigUtils.getProfileFile(configFile);
Field dummyField = null;
try {
dummyField = getClass().getDeclaredField("dummyBooleanForMigratorDONTTOUCH");
} catch (Exception e) {
e.printStackTrace();
Patcher.instance.getLogger().error("Failed to get dummy field for migrator, this is a bug!");
}
try {
for (Map.Entry<ResourceLocation, SoundEventAccessorComposite> entry : soundRegistry.entrySet()) {
Field finalDummyField = dummyField;
data.computeIfAbsent(entry.getKey(), location -> {
String name = getName(location);
//#if MC==11202
Expand All @@ -61,23 +73,21 @@ public void initialize(Map<ResourceLocation, BasicOption> data, Map<ResourceLoca
OptionSubcategory subCategory = ConfigUtils.getSubCategory(mod.defaultPage, category, subcategory);
DummySlider slider = new DummySlider(name, category, subcategory);
subCategory.options.add(slider);
if (!profileFile.exists() && mod.migrator != null && finalDummyField != null) {
Object value = mod.migrator.getValue(finalDummyField, name, category, subcategory);
if (value != null) slider.value = (int) value;
}
return slider;
});
}
} catch (Exception e) {
e.printStackTrace();
}

boolean migrate = false;
File profileFile = ConfigUtils.getProfileFile(configFile);
if (profileFile.exists()) load();
if (!profileFile.exists()) {
if (mod.migrator != null) migrate = true;
else save();
}
else save();
mod.config = this;
generateOptionList(this, mod.defaultPage, mod, migrate);
if (migrate) save();
generateOptionList(this, mod.defaultPage, mod, false);
Config.register(mod);
}

Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion src/main/resources/mcmod.info
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"description": "A Forge mod full of Vanilla bug fixes, Quality of Life improvements, and performance enhancements.",
"version": "${version}",
"mcversion": "${mcVersionStr}",
"url": "https://sk1er.club/mods/patcher",
"url": "https://modrinth.com/mod/patcher",
"updateUrl": "",
"authorList": [
"Sk1er LLC",
Expand Down
1 change: 0 additions & 1 deletion src/main/resources/mixins.patcher.json
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@
"features.GuiChatMixin_SafeChatClicksHistory",
"features.GuiContainerMixin_ClickOutOfContainers",
"features.GuiContainerMixin_DropModifierKey",
"features.GuiIngameForgeMixin_ActionbarText",
"features.GuiIngameForgeMixin_TitleRendering",
"features.GuiIngameMixin_PumpkinBlurRendering",
"features.GuiMultiplayerMixin_FastServerJoin",
Expand Down
Binary file modified src/main/resources/patcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions src/main/resources/patcher.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 4fb0cc5

Please sign in to comment.