Skip to content

Commit

Permalink
YACL 3.2.0 (+1.20.2 Support)
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron committed Sep 24, 2023
1 parent 7a990e6 commit 7ff0192
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 6 deletions.
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ repositories {
}
maven { url "https://repo.codemc.io/repository/maven-public/" } // For Occlusion Culling library
maven { url "https://repo.nea.moe/releases" } // For neu repoparser
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots" } //For YACL
maven { url "https://maven.quiltmc.org/repository/release" } //For YACL
maven {url "https://jitpack.io"}
}

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fabric_api_version=0.89.1+1.20.2

# Dependencies
## YACL (https://github.com/isXander/YetAnotherConfigLib)
yacl_version=3.1.1+1.20
yacl_version=3.2.0+1.20.2
## Mod Menu (https://modrinth.com/mod/modmenu/versions)
mod_menu_version=8.0.0-beta.2
## REI (https://modrinth.com/mod/rei/versions?l=fabric)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;

@SuppressWarnings("deprecation")
public class ConfigModel {
@ConfigEntry
public int version = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,23 @@
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

import dev.isxander.yacl3.config.GsonConfigInstance.ColorTypeAdapter;
import dev.isxander.yacl3.config.v2.impl.serializer.GsonConfigSerializer;
import net.minecraft.item.Item;
import net.minecraft.text.Style;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;

/**
* Note: The type hierarchy adapters are copied from YACL's code
*/
class ConfigSerializer {
static final Gson INSTANCE = new GsonBuilder()
.setFieldNamingPolicy(FieldNamingPolicy.IDENTITY)
.registerTypeHierarchyAdapter(Text.class, new Text.Serializer())
.registerTypeHierarchyAdapter(Style.class, new Style.Serializer())
.registerTypeHierarchyAdapter(Identifier.class, new Identifier.Serializer())
.registerTypeHierarchyAdapter(Color.class, new ColorTypeAdapter())
.registerTypeHierarchyAdapter(Color.class, new GsonConfigSerializer.ColorTypeAdapter())
.registerTypeHierarchyAdapter(Item.class, new GsonConfigSerializer.ItemTypeAdapter())
.serializeNulls()
.setPrettyPrinting()
.create();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ public class ConfigUtils {
public static <E extends Enum<?>> CyclingListControllerBuilder<E> createCyclingListController4Enum(Option<E> opt) {
E[] constants = (E[]) opt.binding().defaultValue().getClass().getEnumConstants();

return CyclingListControllerBuilder.create(opt).values(constants).valueFormatter(c -> Text.of(c.toString()));
return CyclingListControllerBuilder.create(opt).values(constants).formatValue(formatter -> Text.of(formatter.toString()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,20 @@
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.text.Text;

@SuppressWarnings("deprecation")
public class SkyblockerConfig {
private static final Path PATH = FabricLoader.getInstance().getConfigDir().resolve("skyblocker.json");
private static final GsonConfigInstance<ConfigModel> INSTANCE = GsonConfigInstance.createBuilder(ConfigModel.class)
.setPath(PATH)
.overrideGsonBuilder(ConfigSerializer.INSTANCE)
.build();
/*private static final ConfigClassHandler<ConfigModel> HANDLER = ConfigClassHandler.createBuilder(ConfigModel.class)
.serializer(config -> GsonConfigSerializerBuilder.create(config)
.setPath(PATH)
.setJson5(false)
.overrideGsonBuilder(ConfigSerializer.INSTANCE)
.build())
.build();*/

public static ConfigModel get() {
return INSTANCE.getConfig();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ private static int customizeTrim(FabricClientCommandSource source, Identifier ma
return Command.SINGLE_SUCCESS;
}

@SuppressWarnings("deprecation")
public record ArmorTrimId(@ConfigEntry Identifier material, @ConfigEntry Identifier pattern) implements Pair<Identifier, Identifier> {
@Override
public Identifier left() {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"depends": {
"fabricloader": ">=0.14.22",
"fabric-api": ">=0.89.1+1.20.2",
"yet_another_config_lib_v3": ">=3.1.0+1.20",
"yet_another_config_lib_v3": ">=3.2.0+1.20.2",
"minecraft": "~1.20.2"
},
"conflicts": {
Expand Down

0 comments on commit 7ff0192

Please sign in to comment.