Skip to content

Commit 969e865

Browse files
committed
port 90% done for 1.21.11
1 parent 1b38759 commit 969e865

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+272
-196
lines changed

build.gradle.kts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,17 @@ stonecutter {
141141
dependencies {
142142
put("fapi", (findProperty("deps.fabricApi")?.toString() ?: "0.0.0"))
143143
}
144+
145+
replacements {
146+
string {
147+
direction = eval(current.version, ">=1.21.11")
148+
replace("ResourceLocation", "Identifier")
149+
}
150+
string {
151+
direction = eval(current.version, ">=1.21.11")
152+
replace("import net.minecraft.Util;", "import net.minecraft.util.Util;")
153+
}
154+
}
144155
}
145156

146157
dependencies {

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ curseforgeSlug=yacl
88
curseforgeId=667299
99
githubProject=isXander/YetAnotherConfigLib
1010

11-
deps.fabricLoader=0.17.0
11+
deps.fabricLoader=0.17.3
1212
deps.imageio=3.12.0
1313
deps.quiltParsers=0.2.1
1414
deps.fabricLangKotlin=1.12.3+kotlin.2.0.21

settings.gradle.kts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ pluginManagement {
99
}
1010

1111
plugins {
12-
id("dev.kikugie.stonecutter") version "0.7.6"
12+
id("dev.kikugie.stonecutter") version "0.7.11"
1313
}
1414

1515
stonecutter {
@@ -19,11 +19,12 @@ stonecutter {
1919
create(rootProject) {
2020
fun mc(mcVersion: String, name: String = mcVersion, loaders: Iterable<String>) {
2121
for (loader in loaders) {
22-
vers("$name-$loader", mcVersion)
22+
version("$name-$loader", mcVersion)
2323
}
2424
}
2525

26-
mc("1.21.9", loaders = listOf("fabric", "neoforge"))
26+
mc("1.21.11", loaders = listOf("fabric"))
27+
mc("1.21.10", loaders = listOf("fabric", "neoforge"))
2728
mc("1.21.6", loaders = listOf("fabric", "neoforge"))
2829
mc("1.21.5", loaders = listOf("fabric", "neoforge"))
2930
mc("1.21.4", loaders = listOf("fabric", "neoforge"))

src/main/java/dev/isxander/yacl3/api/OptionDescription.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import dev.isxander.yacl3.impl.OptionDescriptionImpl;
55
import net.minecraft.network.chat.CommonComponents;
66
import net.minecraft.network.chat.Component;
7-
import net.minecraft.resources.ResourceLocation;
7+
import net.minecraft.resources.Identifier;
88

99
import java.nio.file.Path;
1010
import java.util.Collection;
@@ -29,7 +29,7 @@ public interface OptionDescription {
2929
* Usually, the image renderers are constructed asynchronously, so this method returns a {@link CompletableFuture}.
3030
* <p>
3131
* Image renderers are cached throughout the whole lifecycle of the game, and should not be generated more than once
32-
* per image. See {@link ImageRenderer#getOrMakeAsync(ResourceLocation, Supplier)} for implementation details.
32+
* per image. See {@link ImageRenderer#getOrMakeAsync(Identifier, Supplier)} for implementation details.
3333
*/
3434
CompletableFuture<Optional<ImageRenderer>> image();
3535

@@ -76,7 +76,7 @@ interface Builder {
7676
* @param height the height of the texture
7777
* @return this builder
7878
*/
79-
Builder image(ResourceLocation image, int width, int height);
79+
Builder image(Identifier image, int width, int height);
8080

8181
/**
8282
* Sets a static image to display with the description. This is backed by a regular minecraft resource
@@ -91,7 +91,7 @@ interface Builder {
9191
* @param textureHeight the height of whole texture file
9292
* @return this builder
9393
*/
94-
Builder image(ResourceLocation image, float u, float v, int width, int height, int textureWidth, int textureHeight);
94+
Builder image(Identifier image, float u, float v, int width, int height, int textureWidth, int textureHeight);
9595

9696
/**
9797
* Sets a static image to display with the description. This is backed by a file on disk.
@@ -101,7 +101,7 @@ interface Builder {
101101
* @param uniqueLocation the unique identifier for the image, used for caching and resource manager registrar
102102
* @return this builder
103103
*/
104-
Builder image(Path path, ResourceLocation uniqueLocation);
104+
Builder image(Path path, Identifier uniqueLocation);
105105

106106
/**
107107
* Sets a static OR ANIMATED webP image to display with the description. This is backed by a regular minecraft resource
@@ -110,7 +110,7 @@ interface Builder {
110110
* @param image the location of the image to display from the resource manager
111111
* @return this builder
112112
*/
113-
Builder webpImage(ResourceLocation image);
113+
Builder webpImage(Identifier image);
114114

115115
/**
116116
* Sets a static OR ANIMATED webP image to display with the description. This is backed by a file on disk.
@@ -120,15 +120,15 @@ interface Builder {
120120
* @param uniqueLocation the unique identifier for the image, used for caching and resource manager registrar
121121
* @return this builder
122122
*/
123-
Builder webpImage(Path path, ResourceLocation uniqueLocation);
123+
Builder webpImage(Path path, Identifier uniqueLocation);
124124

125125
/**
126126
* Sets a custom image renderer to display with the description.
127127
* This is useful for rendering other abstract things relevant to your mod.
128128
* <p>
129129
* However, <strong>THIS IS NOT API SAFE!</strong> As part of the gui package, things
130130
* may change that could break compatibility with future versions of YACL.
131-
* A helpful utility (that is also not API safe) is {@link dev.isxander.yacl3.gui.image.ImageRendererManager#registerOrGetImage(ResourceLocation, Supplier)}
131+
* A helpful utility (that is also not API safe) is {@link dev.isxander.yacl3.gui.image.ImageRendererManager#registerOrGetImage(Identifier, Supplier)}
132132
* which will cache the image renderer for the whole game lifecycle and construct it asynchronously to the render thread.
133133
* @param image the image renderer to display
134134
* @return this builder
@@ -141,7 +141,7 @@ interface Builder {
141141
* <p>
142142
* However, <strong>THIS IS NOT API SAFE!</strong> As part of the gui package, things
143143
* may change that could break compatibility with future versions of YACL.
144-
* A helpful utility (that is also not API safe) is {@link dev.isxander.yacl3.gui.image.ImageRendererManager#registerOrGetImage(ResourceLocation, Supplier)}
144+
* A helpful utility (that is also not API safe) is {@link dev.isxander.yacl3.gui.image.ImageRendererManager#registerOrGetImage(Identifier, Supplier)}
145145
* which will cache the image renderer for the whole game lifecycle and construct it asynchronously to the render thread.
146146
* @param image the image renderer to display
147147
* @return this builder
@@ -158,7 +158,7 @@ default Builder customImage(ImageRenderer image) {
158158
* @return this builder
159159
*/
160160
@Deprecated
161-
Builder gifImage(ResourceLocation image);
161+
Builder gifImage(Identifier image);
162162

163163
/**
164164
* Sets an animated GIF image to display with the description. This is backed by a file on disk.
@@ -169,7 +169,7 @@ default Builder customImage(ImageRenderer image) {
169169
* @return this builder
170170
*/
171171
@Deprecated
172-
Builder gifImage(Path path, ResourceLocation uniqueLocation);
172+
Builder gifImage(Path path, Identifier uniqueLocation);
173173

174174
OptionDescription build();
175175
}

src/main/java/dev/isxander/yacl3/config/GsonConfigInstance.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
* {@code
3434
* public class MyConfig {
3535
* public static ConfigClassHandler<MyConfig> HANDLER = ConfigClassHandler.createBuilder(MyConfig.class)
36-
* .id(new ResourceLocation("modid", "config"))
36+
* .id(new Identifier("modid", "config"))
3737
* .serializer(config -> GsonConfigSerializerBuilder.create(config)
3838
* .setPath(FabricLoader.getInstance().getConfigDir().resolve("my_mod.json")
3939
* .build())

src/main/java/dev/isxander/yacl3/config/v2/api/ConfigClassHandler.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import dev.isxander.yacl3.api.YetAnotherConfigLib;
44
import dev.isxander.yacl3.config.v2.impl.ConfigClassHandlerImpl;
5-
import net.minecraft.resources.ResourceLocation;
5+
import net.minecraft.resources.Identifier;
66

77
import java.util.function.Function;
88

@@ -40,7 +40,7 @@ public interface ConfigClassHandler<T> {
4040
/**
4141
* The unique identifier of this config handler.
4242
*/
43-
ResourceLocation id();
43+
Identifier id();
4444

4545
/**
4646
* Auto-generates a GUI for this config class.
@@ -93,7 +93,7 @@ interface Builder<T> {
9393
*
9494
* @return this builder
9595
*/
96-
Builder<T> id(ResourceLocation id);
96+
Builder<T> id(Identifier id);
9797

9898
/**
9999
* The function to create the serializer for this config class.

src/main/java/dev/isxander/yacl3/config/v2/api/autogen/CustomImage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
@Target(ElementType.FIELD)
2323
public @interface CustomImage {
2424
/**
25-
* The resource path to the image, a {@link net.minecraft.resources.ResourceLocation}
25+
* The resource path to the image, a {@link net.minecraft.resources.Identifier}
2626
* is constructed with the namespace being the modid of the config, and the path being
2727
* this value.
2828
* <p>

src/main/java/dev/isxander/yacl3/config/v2/api/autogen/SimpleOptionFactory.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import net.minecraft.locale.Language;
1515
import net.minecraft.network.chat.Component;
1616
import net.minecraft.network.chat.MutableComponent;
17-
import net.minecraft.resources.ResourceLocation;
17+
import net.minecraft.resources.Identifier;
1818
import org.jetbrains.annotations.Nullable;
1919

2020
import java.lang.annotation.Annotation;
@@ -91,7 +91,7 @@ protected OptionDescription.Builder description(T value, A annotation, ConfigFie
9191
builder.customImage(imageFactory.createImage(value, field, storage).thenApply(Optional::of));
9292
} else if (!imageOverride.value().isEmpty()) {
9393
String path = imageOverride.value();
94-
ResourceLocation imageLocation = YACLPlatform.rl(field.parent().id().getNamespace(), path);
94+
Identifier imageLocation = YACLPlatform.rl(field.parent().id().getNamespace(), path);
9595
String extension = path.substring(path.lastIndexOf('.') + 1);
9696

9797
switch (extension) {
@@ -106,7 +106,7 @@ protected OptionDescription.Builder description(T value, A annotation, ConfigFie
106106
} else {
107107
String imagePath = "textures/yacl3/" + field.parent().id().getPath() + "/" + field.access().name() + ".webp";
108108
imagePath = imagePath.toLowerCase().replaceAll("[^a-z0-9/._:-]", "_");
109-
ResourceLocation imageLocation = YACLPlatform.rl(field.parent().id().getNamespace(), imagePath);
109+
Identifier imageLocation = YACLPlatform.rl(field.parent().id().getNamespace(), imagePath);
110110
if (Minecraft.getInstance().getResourceManager().getResource(imageLocation).isPresent()) {
111111
builder.webpImage(imageLocation);
112112
}

src/main/java/dev/isxander/yacl3/config/v2/impl/ConfigClassHandlerImpl.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import dev.isxander.yacl3.impl.utils.YACLConstants;
1212
import dev.isxander.yacl3.platform.YACLPlatform;
1313
import net.minecraft.network.chat.Component;
14-
import net.minecraft.resources.ResourceLocation;
14+
import net.minecraft.resources.Identifier;
1515
import org.apache.commons.lang3.Validate;
1616

1717
import java.lang.reflect.Constructor;
@@ -25,7 +25,7 @@
2525

2626
public class ConfigClassHandlerImpl<T> implements ConfigClassHandler<T> {
2727
private final Class<T> configClass;
28-
private final ResourceLocation id;
28+
private final Identifier id;
2929
private final boolean supportsAutoGen;
3030
private final ConfigSerializer<T> serializer;
3131
private final ConfigFieldImpl<?>[] fields;
@@ -34,7 +34,7 @@ public class ConfigClassHandlerImpl<T> implements ConfigClassHandler<T> {
3434
private final T defaults;
3535
private final Constructor<T> noArgsConstructor;
3636

37-
public ConfigClassHandlerImpl(Class<T> configClass, ResourceLocation id, Function<ConfigClassHandler<T>, ConfigSerializer<T>> serializerFactory) {
37+
public ConfigClassHandlerImpl(Class<T> configClass, Identifier id, Function<ConfigClassHandler<T>, ConfigSerializer<T>> serializerFactory) {
3838
this.configClass = configClass;
3939
this.id = id;
4040
this.supportsAutoGen = id != null && YACLPlatform.getEnvironment().isClient();
@@ -98,7 +98,7 @@ public ConfigFieldImpl<?>[] fields() {
9898
}
9999

100100
@Override
101-
public ResourceLocation id() {
101+
public Identifier id() {
102102
return this.id;
103103
}
104104

@@ -244,15 +244,15 @@ private void detectOldAnnotation(Field[] fields) {
244244

245245
public static class BuilderImpl<T> implements Builder<T> {
246246
private final Class<T> configClass;
247-
private ResourceLocation id;
247+
private Identifier id;
248248
private Function<ConfigClassHandler<T>, ConfigSerializer<T>> serializerFactory;
249249

250250
public BuilderImpl(Class<T> configClass) {
251251
this.configClass = configClass;
252252
}
253253

254254
@Override
255-
public Builder<T> id(ResourceLocation id) {
255+
public Builder<T> id(Identifier id) {
256256
this.id = id;
257257
return this;
258258
}

src/main/java/dev/isxander/yacl3/config/v2/impl/autogen/ListGroupImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import net.minecraft.client.Minecraft;
1313
import net.minecraft.locale.Language;
1414
import net.minecraft.network.chat.Component;
15-
import net.minecraft.resources.ResourceLocation;
15+
import net.minecraft.resources.Identifier;
1616
import org.jetbrains.annotations.Nullable;
1717

1818
import java.lang.reflect.Constructor;
@@ -57,7 +57,7 @@ private OptionDescription description(ConfigField<List<T>> field) {
5757

5858
String imagePath = "textures/yacl3/" + field.parent().id().getPath() + "/" + field.access().name() + ".webp";
5959
imagePath = imagePath.toLowerCase().replaceAll("[^a-z0-9/._:-]", "_");
60-
ResourceLocation imageLocation = YACLPlatform.rl(field.parent().id().getNamespace(), imagePath);
60+
Identifier imageLocation = YACLPlatform.rl(field.parent().id().getNamespace(), imagePath);
6161
if (Minecraft.getInstance().getResourceManager().getResource(imageLocation).isPresent()) {
6262
builder.webpImage(imageLocation);
6363
}

0 commit comments

Comments
 (0)