mirror of
https://github.com/lukasabbe/bookshelf-inspector.git
synced 2026-04-30 10:40:53 +00:00
1.21.10
This commit is contained in:
+1
-1
@@ -2,5 +2,5 @@ plugins {
|
||||
// see https://fabricmc.net/develop/ for new versions
|
||||
id 'fabric-loom' version '1.11-SNAPSHOT' apply false
|
||||
// see https://projects.neoforged.net/neoforged/moddevgradle for new versions
|
||||
id 'net.neoforged.moddev' version '2.0.107' apply false
|
||||
id 'net.neoforged.moddev' version '2.0.112' apply false
|
||||
}
|
||||
@@ -19,7 +19,7 @@ public class Config {
|
||||
|
||||
public void loadConfig(){
|
||||
Path configPath = Services.PLATFORM.getConfigPath("bookshelfinspector-config.yml");
|
||||
if(!Files.exists(configPath))createConfig(configPath);
|
||||
if(!Files.exists(configPath)) createConfig(configPath);
|
||||
Yaml yaml = new Yaml();
|
||||
try{
|
||||
Map<String, Object> configMap = yaml.load(new FileReader(configPath.toFile()));
|
||||
@@ -39,7 +39,8 @@ public class Config {
|
||||
}
|
||||
|
||||
private void createConfig(Path configPath){
|
||||
Path defaultConfigPath = Services.PLATFORM.getFileInModContainer("bookshelfinspector", "bookshelfinspector-config.yml");
|
||||
Path defaultConfigPath = Services.PLATFORM.getFileOrCopyInModContainer("bookshelfinspector", "bookshelfinspector-config.yml");
|
||||
if(defaultConfigPath == null) return;
|
||||
try {
|
||||
Files.copy(defaultConfigPath, configPath);
|
||||
} catch (IOException e) {
|
||||
|
||||
+1
-1
@@ -9,5 +9,5 @@ public interface IPlatformHelper {
|
||||
|
||||
Path getConfigPath(String file);
|
||||
|
||||
Path getFileInModContainer(String mod, String fileName);
|
||||
Path getFileOrCopyInModContainer(String mod, String fileName);
|
||||
}
|
||||
+1
-2
@@ -15,7 +15,6 @@ public class FabricPlatformHelper implements IPlatformHelper {
|
||||
|
||||
@Override
|
||||
public boolean isModLoaded(String modId) {
|
||||
|
||||
return FabricLoader.getInstance().isModLoaded(modId);
|
||||
}
|
||||
|
||||
@@ -25,7 +24,7 @@ public class FabricPlatformHelper implements IPlatformHelper {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path getFileInModContainer(String mod, String fileName) {
|
||||
public Path getFileOrCopyInModContainer(String mod, String fileName) {
|
||||
if(FabricLoader.getInstance().getModContainer(mod).isEmpty()) return null;
|
||||
ModContainer modContainer = FabricLoader.getInstance().getModContainer(mod).get();
|
||||
return modContainer.findPath(fileName).orElseThrow();
|
||||
|
||||
+9
-9
@@ -1,32 +1,32 @@
|
||||
version=2.1+1.21.10-rc1
|
||||
version=2.1+1.21.10
|
||||
|
||||
# release, beta & alpha
|
||||
versionType=beta
|
||||
versionType=release
|
||||
group=com.lukasabbe.bookshelfinspector
|
||||
java_version=21
|
||||
|
||||
# Common
|
||||
minecraft_version=1.21.10-rc1
|
||||
minecraft_version=1.21.10
|
||||
mod_name=BookshelfInspector
|
||||
mod_author=Lukasabbe
|
||||
mod_id=bookshelfinspector
|
||||
license=MIT
|
||||
credits=
|
||||
description=Inspect any book in a chiseled bookshelf.
|
||||
minecraft_version_range=[1.21.10-rc1, 1.22)
|
||||
minecraft_version_range=[1.21.10, 1.22)
|
||||
|
||||
# https://projects.neoforged.net/neoforged/neoform
|
||||
neo_form_version=1.21.10-rc1-20251002.143406
|
||||
neo_form_version=1.21.10-20251007.142004
|
||||
# The version of ParchmentMC that is used, see https://parchmentmc.org/docs/getting-started#choose-a-version for new versions
|
||||
parchment_minecraft=1.21.8
|
||||
parchment_version=2025.07.20
|
||||
parchment_minecraft=1.21.9
|
||||
parchment_version=2025.10.05
|
||||
|
||||
# Fabric
|
||||
fabric_version=0.134.1+1.21.10
|
||||
fabric_loader_version=0.17.2
|
||||
|
||||
# NeoForge
|
||||
neoforge_version=21.9.9-beta
|
||||
neoforge_version=21.10.1-beta
|
||||
neoforge_loader_version_range=[4,)
|
||||
|
||||
# Gradle
|
||||
@@ -35,5 +35,5 @@ org.gradle.daemon=false
|
||||
|
||||
# Global dep
|
||||
YAML_snake=2.5
|
||||
cloth_config=19.0.147
|
||||
cloth_config=20.0.148
|
||||
mod_menu=16.0.0-rc.1
|
||||
@@ -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' }
|
||||
|
||||
+4
-1
@@ -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
-3
@@ -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();
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
+14
-2
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user