feat(dependencies): Backwards Compatibility until 1.21.3
All checks were successful
Build AirClient Jar / build (push) Successful in 2m46s
All checks were successful
Build AirClient Jar / build (push) Successful in 2m46s
This commit is contained in:
parent
3741bd5145
commit
3923673d2a
2 changed files with 21 additions and 5 deletions
|
@ -13,6 +13,7 @@ import net.minecraft.client.texture.NativeImageBackedTexture;
|
|||
import net.minecraft.util.Identifier;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.net.URI;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
|
@ -20,6 +21,7 @@ import java.net.http.HttpResponse;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
|
@ -148,9 +150,23 @@ public class WebCapeLoader {
|
|||
private NativeImageBackedTexture createNativeTexture(String name, byte[] bytes) {
|
||||
if (bytes == null) return null;
|
||||
try {
|
||||
return new NativeImageBackedTexture(() -> name, NativeImage.read(bytes));
|
||||
// Try 1.21.5 constructor first (2 parameters)
|
||||
Constructor<NativeImageBackedTexture> constructor =
|
||||
NativeImageBackedTexture.class.getConstructor(Supplier.class, NativeImage.class);
|
||||
|
||||
Supplier<String> nameSupplier = () -> name;
|
||||
return constructor.newInstance(nameSupplier, NativeImage.read(bytes));
|
||||
} catch (NoSuchMethodException e) {
|
||||
try {
|
||||
// Fall back to >=1.21.4 constructor (1 parameter)
|
||||
Constructor<NativeImageBackedTexture> constructor =
|
||||
NativeImageBackedTexture.class.getConstructor(NativeImage.class);
|
||||
return constructor.newInstance(NativeImage.read(bytes));
|
||||
} catch (Exception ex) {
|
||||
throw new RuntimeException("Failed to create NativeImageBackedTexture", ex);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
throw new RuntimeException("Failed to create NativeImageBackedTexture", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
"description": "The AirClient",
|
||||
"authors": [ "pauljako" ],
|
||||
"contact": {
|
||||
"issues": "https://gitlab.com/pauljako/airclient/-/issues",
|
||||
"sources": "https://gitlab.com/pauljako/airclient"
|
||||
"issues": "https://git.pauljako.de/AirClient/AirClient/issues",
|
||||
"sources": "https://git.pauljako.de/AirClient/AirClient"
|
||||
},
|
||||
"license": " LGPL-3.0-or-later",
|
||||
"icon": "assets/airclient/icon.png",
|
||||
|
@ -27,6 +27,6 @@
|
|||
"fabricloader": ">=${loader_version}",
|
||||
"fabric-language-kotlin": "*",
|
||||
"fabric": "*",
|
||||
"minecraft": "${minecraft_version}"
|
||||
"minecraft": "~1.21.3"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue