From a6d0afa9cf28ae3a42aceca1b2a8ddc8f9a78efe Mon Sep 17 00:00:00 2001 From: Astoria Date: Sat, 18 Mar 2023 10:29:45 -0500 Subject: [PATCH] Actually work this time --- build.gradle | 20 +++++++++++++++- .../afloydironchest/IronChestMain.java | 24 ++++--------------- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/build.gradle b/build.gradle index 3b3e6e9..b6be34d 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,6 @@ plugins { id 'babric-loom' version '0.12-SNAPSHOT' + id 'com.github.johnrengelman.shadow' version '7.1.2' id 'java' } @@ -7,6 +8,23 @@ group = project.mod_group archivesBaseName = project.mod_name version = project.mod_version +//Begin shadowing weirdness +configurations { + shade +} + +shadowJar { + archiveClassifier.set('shadow') + configurations = [project.configurations.shade] +} +tasks.assemble.dependsOn tasks.shadowJar + +remapJar { + dependsOn(shadowJar) + inputFile.set(shadowJar.archiveFile) +} +//End shadowing weirdness + loom { gluedMinecraftJar() noIntermediateMappings() @@ -63,7 +81,7 @@ dependencies { modImplementation "org.apache.logging.log4j:log4j-slf4j18-impl:2.16.0" //TOML - implementation 'com.moandjiezana.toml:toml4j:0.7.2' + modImplementation include(shadow('com.moandjiezana.toml:toml4j:0.7.2')) } diff --git a/src/main/java/net/brokenmoon/afloydironchest/IronChestMain.java b/src/main/java/net/brokenmoon/afloydironchest/IronChestMain.java index eaaa607..1b025dc 100644 --- a/src/main/java/net/brokenmoon/afloydironchest/IronChestMain.java +++ b/src/main/java/net/brokenmoon/afloydironchest/IronChestMain.java @@ -15,8 +15,6 @@ import turniplabs.halplibe.helper.BlockHelper; import turniplabs.halplibe.helper.RecipeHelper; import java.io.*; -import java.net.URISyntaxException; -import java.net.URL; public class IronChestMain implements ModInitializer { @@ -97,18 +95,18 @@ public class IronChestMain implements ModInitializer { }); } - public File getConfig(){ + public File getConfig() { File config = new File("config/AstoriaIronChest.toml"); if (!config.exists()) { LOGGER.warn("Config For afloydironchest Not Found! Creating new config based upon default :)"); InputStream in; OutputStream out; try { - in = new FileInputStream(getDefaultConfig()); + in = getClass().getClassLoader().getResourceAsStream("assets/ironchest/config.toml"); out = new FileOutputStream(config); byte[] buffer = new byte[1024]; int length; - while((length = in.read(buffer)) > 0){ + while ((length = in.read(buffer)) > 0) { out.write(buffer, 0, length); } return getConfig(); @@ -120,18 +118,4 @@ public class IronChestMain implements ModInitializer { return config; } } - - public File getDefaultConfig() { - URL defaultConfig = getClass().getClassLoader().getResource("assets/ironchest/config.toml"); - if (defaultConfig == null) { - LOGGER.warn("Default Config For afloydironchest Not Found! REAL BAD."); - } else { - try { - return new File(defaultConfig.toURI()); - } catch (URISyntaxException e) { - throw new RuntimeException(e); - } - } - return null; - } -} +} \ No newline at end of file