-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Multiversion and too much other stuff
- Loading branch information
1 parent
a2a178f
commit 57cdd2d
Showing
74 changed files
with
1,242 additions
and
463 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package wtf.cheeze.sbt.config; | ||
|
||
public class VersionedObject { | ||
public int configVersion; | ||
} |
56 changes: 56 additions & 0 deletions
56
src/main/java/wtf/cheeze/sbt/config/migration/BarColorTransformation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package wtf.cheeze.sbt.config.migration; | ||
|
||
import net.minecraft.util.Identifier; | ||
import wtf.cheeze.sbt.config.ConfigImpl; | ||
import wtf.cheeze.sbt.utils.render.Colors; | ||
|
||
import java.util.function.Function; | ||
|
||
|
||
/** | ||
* In mod versions prior to 0.1.0-Alpha.8, bar colors (all colors actually), defaulted to RGB ints. | ||
* This was fine pre 1.21.2 since the shader system was used, which was fine with RGB ints | ||
* However, in 1.21.2, the shader system was tweaked, and we moved to the color parameter in {@link net.minecraft.client.gui.DrawContext#drawTexture(Function, Identifier, int, int, float, float, int, int, int, int, int)} | ||
* This method interprets ints as ARGB, not RGB, which resulted in the bars not rendering with default settings due to the alpha value being 0 | ||
* YACL always treated the color as ARGB, so this issue only affects users who never modified the settings | ||
* This transformation checks for the old defaults and updates them to the new defaults | ||
*/ | ||
public class BarColorTransformation implements ConfigTransformation<ConfigImpl> { | ||
|
||
private static final int OLD_HEALTH = 16733525; | ||
private static final int OLD_HEALTH_ABSORB = 16755200; | ||
private static final int OLD_MANA = 5592575; | ||
private static final int OLD_SKILL = 43690; | ||
private static final int OLD_DRILL = 43520; | ||
|
||
private BarColorTransformation() {} | ||
|
||
public static final BarColorTransformation INSTANCE = new BarColorTransformation(); | ||
|
||
@Override | ||
public ConfigImpl tranform(ConfigImpl config) { | ||
if (config.huds.healthBar.color == OLD_HEALTH) config.huds.healthBar.color = Colors.RED; | ||
if (config.huds.healthBar.colorAbsorption == OLD_HEALTH_ABSORB) config.huds.healthBar.colorAbsorption = Colors.ORANGE; | ||
if (config.huds.manaBar.color == OLD_MANA) config.huds.manaBar.color = Colors.BLUE; | ||
if (config.huds.skillBar.color == OLD_SKILL) config.huds.skillBar.color = Colors.CYAN; | ||
if (config.huds.drillFuelBar.color == OLD_DRILL) config.huds.drillFuelBar.color = Colors.GREEN; | ||
|
||
return config; | ||
} | ||
|
||
@Override | ||
public boolean isApplicable(ConfigImpl config) { | ||
return config.huds.healthBar.color == OLD_HEALTH | ||
|| config.huds.healthBar.colorAbsorption == OLD_HEALTH_ABSORB | ||
|| config.huds.manaBar.color == OLD_MANA | ||
|| config.huds.skillBar.color == OLD_SKILL | ||
|| config.huds.drillFuelBar.color == OLD_DRILL; | ||
} | ||
|
||
@Override | ||
public boolean isApplicable(int configVersion) { | ||
return configVersion == 1; | ||
} | ||
|
||
|
||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/wtf/cheeze/sbt/config/migration/ConfigMigration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package wtf.cheeze.sbt.config.migration; | ||
|
||
|
||
/** | ||
* A ConfigMigration migrates a config object from one version to another. | ||
* These should be used instead of Transformations when the actual structure | ||
* of the config changes, as opposed to simply needing to modify certain values. | ||
* A ConfigMigration will always be accompanied by an increase in the config version | ||
*/ | ||
public interface ConfigMigration<Source, Target> { | ||
|
||
|
||
Source migrate(Target config); | ||
|
||
boolean isApplicable(int aVersion); | ||
|
||
int getTargetVersion(); | ||
int getSourceVersion(); | ||
|
||
Class<Source> getSourceClass(); | ||
Class<Target> getTargetClass(); | ||
|
||
} |
13 changes: 13 additions & 0 deletions
13
src/main/java/wtf/cheeze/sbt/config/migration/ConfigTransformation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package wtf.cheeze.sbt.config.migration; | ||
|
||
/** | ||
* A ConfigTransformation transforms a single version of a config, rather than migrating from one version to another. | ||
*/ | ||
public interface ConfigTransformation<T>{ | ||
|
||
T tranform(T config); | ||
|
||
boolean isApplicable(T config); | ||
|
||
boolean isApplicable(int configVersion); | ||
} |
Oops, something went wrong.