This commit is contained in:
lukasabbe
2025-10-08 10:32:40 +02:00
parent 8750d28667
commit 47b10cfe05
9 changed files with 36 additions and 23 deletions
+2 -2
View File
@@ -19,7 +19,7 @@ neoForge {
mappingsVersion = parchment_version
}
dependencies {
//api "me.shedaniel.cloth:cloth-config-neoforge:${cloth_config}"
api "me.shedaniel.cloth:cloth-config-neoforge:${cloth_config}"
}
runs {
@@ -46,7 +46,7 @@ neoForge {
dependencies {
jarJar(implementation("org.yaml:snakeyaml:2.4")){}
additionalRuntimeClasspath "org.yaml:snakeyaml:2.4"
runtimeOnly "org.yaml:snakeyaml:2.4"
}
sourceSets.main.resources { srcDir 'src/generated/resources' }
@@ -1,15 +1,18 @@
package com.lukasabbe.bookshelfinspector;
import com.lukasabbe.bookshelfinspector.config.ClothConfigGenerator;
import com.lukasabbe.bookshelfinspector.util.EventHandler;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.fml.ModLoadingContext;
import net.neoforged.fml.common.Mod;
import net.neoforged.neoforge.client.gui.IConfigScreenFactory;
@Mod(value = Constants.MOD_ID, dist = Dist.CLIENT)
public class BookshelfInspectorNeoForgeClient {
public BookshelfInspectorNeoForgeClient(IEventBus bus) {
EventHandler.initClient();
BookshelfInspectorClient.clientInit();
//ModLoadingContext.get().registerExtensionPoint(IConfigScreenFactory.class, () -> (client, parent) -> ClothConfigGenerator.createConfig(parent));
ModLoadingContext.get().registerExtensionPoint(IConfigScreenFactory.class, () -> (client, parent) -> ClothConfigGenerator.createConfig(parent));
}
}
@@ -1,4 +1,3 @@
/*
package com.lukasabbe.bookshelfinspector.config;
import com.lukasabbe.bookshelfinspector.BookshelfInspectorClient;
@@ -37,5 +36,4 @@ public class ClothConfigGenerator {
builder.setSavingRunnable(BookshelfInspectorClient.config::saveConfig);
return builder.build();
}
}
*/
}
@@ -7,6 +7,7 @@ import net.neoforged.fml.config.ModConfig;
import net.neoforged.fml.loading.FMLLoader;
import net.neoforged.fml.loading.FMLPaths;
import java.io.*;
import java.nio.file.Path;
import java.nio.file.Paths;
@@ -29,9 +30,20 @@ public class NeoForgePlatformHelper implements IPlatformHelper {
}
@Override
public Path getFileInModContainer(String mod, String fileName) {
public Path getFileOrCopyInModContainer(String mod, String fileName) {
if(ModList.get().getModContainerById(mod).isEmpty()) return null;
ModContainer container = ModList.get().getModContainerById(mod).get();
return Paths.get(container.getModInfo().getOwningFile().getFile().getContents().findFile(fileName).get());
try {
InputStream inputStream = container.getModInfo().getOwningFile().getFile().getContents().get(fileName).open();
File targetFile = new File(getConfigPath("bookshelfinspector-config.yml").toUri());
try(OutputStream outputStream = new FileOutputStream(targetFile)){
byte[] buffer = new byte[8192];
int bytesRead;
while((bytesRead = inputStream.read(buffer)) != -1){
outputStream.write(buffer, 0, bytesRead);
}
}catch (IOException ignore){}
}catch (IOException ignore){}
return null;
}
}