Follow along with the video below to see how to install our site as a web app on your home screen.
Примечание: This feature may not be available in some browsers.
public void loadIcon() {
String iconPathStr = ...
Path externalPath = Paths.get(iconPathStr);
ResourceLocation icon;
if (Files.exists(externalPath)) {
try {
icon = Minecraft.getMinecraft().getTextureManager().getDynamicTextureLocation("dynamic_icon", new DynamicTexture(ImageIO.read(new File(iconPathStr))));
} catch (IOException exception) {
exception.printStackTrace();
}
}
}
System.getProperty("user.dir");, использовать новые пути джавы, вычитать текстуру. public void loadIcon() {
String iconPathStr = ...
Path externalPath = Paths.get(iconPathStr);
ResourceLocation icon;
if (Files.exists(externalPath)) {
try {
icon = Minecraft.getMinecraft().getTextureManager().getDynamicTextureLocation("dynamic_icon", new DynamicTexture(ImageIO.read(new File(iconPathStr))));
} catch (IOException exception) {
exception.printStackTrace();
}
}
}
val cl = javaClass.classLoader as LaunchClassLoader
val file = File(resourceDir).toDir().absoluteFile
cl.addURL(file.toURI().toURL())
А где я его возьму? У меня только есть ResourceLocation своей текстурыВ нем уже регаешь свой TextureAtlasSprite
LaunchClassLoader cl = (LaunchClassLoader) любойВащеJavaClass.classLoader
File file = File(resourceDir).toDir().absoluteFile
cl.addURL(file.toURI().toURL())
Да, он добавляет новые ресурсы к основному класслоадеру. После этого их можно будет через getResourceAsStream загрузить уже стандартными средствами.Это чтобы можно было доставать через getClass().getResourceAsStream?
String configPath = event.getSuggestedConfigurationFile().getParent();
LaunchClassLoader cl = (LaunchClassLoader) event.getClass().getClassLoader();
try {
cl.addURL(new File(configPath + "/textures").toURI().toURL());
} catch (MalformedURLException e) {
e.printStackTrace();
}
if (e.map.getTextureType() == 0){
TextureAtlas atl = new TextureAtlas("asd");
try {
atl.loadSprite(new BufferedImage[]{ ImageIO.read(e.getClass().getClassLoader().getResourceAsStream("asd.png")) }, null, false);
} catch (IOException e1) {
e1.printStackTrace();
}
e.map.setTextureEntry("asd", atl);
test = atl;
}
