Skip to content

Commit

Permalink
Removed Log4J dependency, 0.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Arminias committed May 25, 2024
1 parent 7671c52 commit 7228a94
Show file tree
Hide file tree
Showing 12 changed files with 54 additions and 39 deletions.
13 changes: 10 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ dependencies {

implementation 'net.fabricmc:fabric-loom:1.4-SNAPSHOT'

implementation 'org.apache.logging.log4j:log4j-core:2.19.0'
implementation 'org.apache.logging.log4j:log4j-api:2.19.0'
//implementation 'org.apache.logging.log4j:log4j-core:2.19.0'
//implementation 'org.apache.logging.log4j:log4j-api:2.19.0'

implementation "org.lwjgl.lwjgl:lwjgl_util:${lwjglVersion}"
implementation "org.lwjgl.lwjgl:lwjgl:${lwjglVersion}"
Expand Down Expand Up @@ -144,7 +144,14 @@ class BTWJarReplacer implements MinecraftJarProcessor<Spec> {
void processJar(java.nio.file.Path jar, Spec spec, ProcessorContext context) throws IOException {
// Replace the Minecraft jar with the custom one from BTW_dev.
// This is just a straight up file replacement, no remapping or anything.
Files.copy(Paths.get(path, "BTW_dev/BTW_dev.zip"), jar, StandardCopyOption.REPLACE_EXISTING)
if (!Files.exists(Paths.get(path, "build/BTW_dev/BTW_dev.zip"))) {
// Print a warning if the BTW_dev zip doesn't exist.
System.err.println("BTW_dev zip not found, skipping BTWJarReplacer")
} else {
Files.copy(Paths.get(path, "build/BTW_dev/BTW_dev.zip"), jar, StandardCopyOption.REPLACE_EXISTING)
// Add Javadocs
Files.copy(Paths.get(path, "build/BTW_dev/BTW_dev-javadoc.jar"), jar.resolveSibling(jar.getFileName().toString().replace(".jar", "-javadoc.jar")), StandardCopyOption.REPLACE_EXISTING)
}
}

@Override
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ minecraft_version = 1.6.4
yarn_mappings = 1.6.4+build.420
loader_version = 0.14.19

mod_version = 0.3.0
mod_version = 0.3.1
maven_group = net.fabricmc
archives_base_name = neodymium-btw

org.gradle.jvmargs=-Xmx4g
org.gradle.jvmargs=-Xmx4g
24 changes: 17 additions & 7 deletions install.bat
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
set MAPPINGS_VERSION=1.0.3
cd "%~dp0"
rd /s /q "./BTW_dev"
rd /s /q "build\BTW_dev"
rd /s /q "build\tmp\BTW_dev"
call gradlew.bat --no-daemon downloadAssets
mkdir BTW_dev
mkdir build\BTW_dev
mkdir custom_mappings
mkdir build\tmp\BTW_dev
tar.exe -xf mavenRepo/btw/community/mappings/%MAPPINGS_VERSION%/mappings-%MAPPINGS_VERSION%.jar -C custom_mappings
java -jar libs/tiny-remapper-0.8.6+local-fat.jar %~f1 "BTW_dev/%~nx1" custom_mappings/mappings/mappings.tiny intermediary named %userprofile%/.gradle/caches/fabric-loom/1.6.4/minecraft-merged-intermediary.jar"
tar.exe -xf %userprofile%/.gradle/caches/fabric-loom/minecraftMaven/net/minecraft/minecraft-merged/1.6.4-btw.community.mappings.1_6_4.%MAPPINGS_VERSION%-v2/minecraft-merged-1.6.4-btw.community.mappings.1_6_4.%MAPPINGS_VERSION%-v2.jar -C BTW_dev
tar.exe -xf "BTW_dev/%~nx1" -C BTW_dev
del BTW_dev\%~nx1
cd BTW_dev
del "%userprofile%\.gradle\caches\fabric-loom\1.6.4\minecraft-merged-intermediary.jar"
java -jar libs/tiny-remapper-0.8.6+local-fat.jar "%userprofile%/.gradle/caches/fabric-loom/1.6.4/minecraft-merged.jar" "%userprofile%/.gradle/caches/fabric-loom/1.6.4/minecraft-merged-intermediary.jar" "%userprofile%/.gradle/caches/fabric-loom/1.6.4/intermediary-v2.tiny" official intermediary
tar.exe -xf "%~f1" -C build/tmp/BTW_dev
java -jar libs/tiny-remapper-0.8.6+local-fat.jar "build/tmp/BTW_dev/BTW-CE-Intermediary.zip" "build/BTW_dev/BTW-CE-Intermediary.zip" custom_mappings/mappings/mappings.tiny intermediary named "%userprofile%/.gradle/caches/fabric-loom/1.6.4/minecraft-merged-intermediary.jar"
tar.exe -xf %userprofile%/.gradle/caches/fabric-loom/minecraftMaven/net/minecraft/minecraft-merged/1.6.4-btw.community.mappings.1_6_4.%MAPPINGS_VERSION%-v2/minecraft-merged-1.6.4-btw.community.mappings.1_6_4.%MAPPINGS_VERSION%-v2.jar -C build/BTW_dev
tar.exe -xf "build/BTW_dev/BTW-CE-Intermediary.zip" -C build/BTW_dev
del build\BTW_dev\BTW-CE-Intermediary.zip
cd build\BTW_dev
tar.exe -a -cf ../BTW_dev.zip *
cd ..
rd /s /q "BTW_dev"
mkdir "BTW_dev"
move BTW_dev.zip BTW_dev\BTW_dev.zip
cd ..
move build\tmp\BTW_dev\BTW-CE-Intermediary-javadoc.jar build\BTW_dev\BTW_dev-javadoc.jar
rd /s /q "build\tmp\BTW_dev"
echo Done!
PAUSE
10 changes: 5 additions & 5 deletions src/main/java/makamys/neodymium/Compat.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class Compat {

public static void init() {
isGL33Supported = GLContext.getCapabilities().OpenGL33;
if (!MinecraftServer.getIsServer() && !FabricLauncherBase.getLauncher().isDevelopment() && System.getProperty("os.name") != null && System.getProperty("os.name").contains("Windows")) {
if (!MinecraftServer.getIsServer() && !FabricLauncherBase.getLauncher().isDevelopment() && System.getProperty("os.name") != null && System.getProperty("os.name").toLowerCase().contains("windows")) {
boolean found = false;
Minecraft.getMinecraft().getPlayerUsageSnooper().startSnooper();
Map map = ((PlayerUsageSnooperAccessor)Minecraft.getMinecraft().getPlayerUsageSnooper()).getDataMap();
Expand All @@ -47,7 +47,7 @@ public static void init() {
}
}
if (!found) {
FabricGuiEntry.displayCriticalError(new RuntimeException("Neodymium requires the JVM argument -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump to be set. Please add it to your JVM arguments."), true);
//FabricGuiEntry.displayCriticalError(new RuntimeException("Neodymium requires the JVM argument -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump to be set. Please add it to your JVM arguments."), true);
}
}
/*if (Loader.isModLoaded("triangulator")) {
Expand All @@ -72,7 +72,7 @@ public static void getCompatibilityWarnings(List<Warning> warns, List<Warning> c
criticalWarns.add(new Warning("A shader pack is enabled, this is not supported."));
}
} catch(Exception e) {
LOGGER.warn("Failed to get shader pack name");
LOGGER.log(System.Logger.Level.WARNING, "Failed to get shader pack name");
e.printStackTrace();
}
} catch (ClassNotFoundException e) {
Expand Down Expand Up @@ -114,7 +114,7 @@ private static boolean detectedNotEnoughVRAM() {
public static void forceEnableOptiFineDetectionOfFastCraft() {
if(Compat.class.getResource("/fastcraft/Tweaker.class") != null) {
// If OptiFine is present, it's already on the class path at this point, so our virtual jar won't override it.
LOGGER.info("FastCraft is present, applying hack to forcingly enable FastCraft's OptiFine compat");
LOGGER.log(System.Logger.Level.INFO, "FastCraft is present, applying hack to forcingly enable FastCraft's OptiFine compat");
VirtualJar.add(new OptiFineStubVirtualJar());
}
}
Expand All @@ -141,7 +141,7 @@ public String getName() {
public InputStream getInputStream(String path) {
if(path.equals("/optifine/OptiFineForgeTweaker.class")) {
// Dummy file to make FastCraft think OptiFine is present.
LOGGER.debug("Returning a dummy /optifine/OptiFineForgeTweaker.class to force FastCraft compat.");
LOGGER.log(System.Logger.Level.DEBUG, "Returning a dummy /optifine/OptiFineForgeTweaker.class to force FastCraft compat.");
return new ByteArrayInputStream(new byte[0]);
} else {
return null;
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/makamys/neodymium/Constants.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package makamys.neodymium;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

public class Constants {

public static final String MODID = "neodymium";
public static final String VERSION = "0.3.0";
public static final Logger LOGGER = LogManager.getLogger(MODID);
public static final String VERSION = "0.3.1";
public static final System.Logger LOGGER = System.getLogger(MODID);

public static final String PROTOCOL = "neodymiumvirtualjar";

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/makamys/neodymium/Neodymium.java
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,10 @@ public static Pair<List<Warning>, List<Warning>> showCompatStatus(boolean status
}

for(Warning warn : warns) {
LOGGER.warn(warn.text);
LOGGER.log(System.Logger.Level.WARNING, warn.text);
}
for(Warning criticalWarn : criticalWarns) {
LOGGER.warn("Critical: " + criticalWarn.text);
LOGGER.log(System.Logger.Level.WARNING, "Critical: " + criticalWarn.text);
}

return new Pair(warns, criticalWarns);
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/makamys/neodymium/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public void handleConfigProperties(Map<String, String> propertyValues) {
try {
registerWatchService();
} catch(IOException e) {
LOGGER.warn("Failed to register watch service: " + e + " (" + e.getMessage() + "). Changes to the config file will not be reflected");
LOGGER.log(System.Logger.Level.WARNING, "Failed to register watch service: " + e + " (" + e.getMessage() + "). Changes to the config file will not be reflected");
}
}
}*/
Expand Down Expand Up @@ -193,7 +193,7 @@ public static void reloadConfig() {
try {
currentValue = field.get(null);
} catch (Exception e) {
LOGGER.error("Failed to get value of field " + field.getName());
LOGGER.log(System.Logger.Level.ERROR, "Failed to get value of field " + field.getName());
e.printStackTrace();
continue;
}
Expand Down Expand Up @@ -245,7 +245,7 @@ public static void reloadConfig() {
try {
field.set(null, newValue);
} catch (Exception e) {
LOGGER.error("Failed to set value of field " + field.getName());
LOGGER.log(System.Logger.Level.ERROR, "Failed to set value of field " + field.getName());
e.printStackTrace();
}
}
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/makamys/neodymium/renderer/ChunkMesh.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public ChunkMesh(WorldRenderer wr, int pass) {
instances++;

if(!quadBuf.getAsList().isEmpty()) {
LOGGER.error("Invalid state: tried to construct a chunk mesh before the previous one has finished constructing!");
LOGGER.log(System.Logger.Level.ERROR, "Invalid state: tried to construct a chunk mesh before the previous one has finished constructing!");
}
}

Expand Down Expand Up @@ -119,22 +119,22 @@ private void addTessellatorData(Tessellator t) {
if(!Config.silenceErrors) {
String dimId = wr.worldObj != null && wr.worldObj.provider != null ? "" + wr.worldObj.provider.dimensionId : "UNKNOWN";
if(!errors.isEmpty()) {
LOGGER.error("Errors in chunk ({}, {}, {}) in dimension {}:", x, y, z, dimId);
LOGGER.log(System.Logger.Level.ERROR, "Errors in chunk ({}, {}, {}) in dimension {}:", x, y, z, dimId);
for(String error : errors) {
LOGGER.error("Error: " + error);
LOGGER.log(System.Logger.Level.ERROR, "Error: " + error);
}
for(String warning : warnings) {
LOGGER.error("Warning: " + warning);
LOGGER.log(System.Logger.Level.ERROR, "Warning: " + warning);
}
LOGGER.error("(World renderer pos: ({}, {}, {}), Tessellator pos: ({}, {}, {}), Tessellation count: {}", wr.posX, wr.posY, wr.posZ, ((TessellatorAccessor) t).getXOffset(), ((TessellatorAccessor) t).getYOffset(), ((TessellatorAccessor) t).getZOffset(), tesselatorDataCount);
LOGGER.error("Stack trace:");
LOGGER.log(System.Logger.Level.ERROR, "(World renderer pos: ({}, {}, {}), Tessellator pos: ({}, {}, {}), Tessellation count: {}", wr.posX, wr.posY, wr.posZ, ((TessellatorAccessor) t).getXOffset(), ((TessellatorAccessor) t).getYOffset(), ((TessellatorAccessor) t).getZOffset(), tesselatorDataCount);
LOGGER.log(System.Logger.Level.ERROR, "Stack trace:");
try {
// Generate a stack trace
throw new IllegalArgumentException();
} catch(IllegalArgumentException e) {
e.printStackTrace();
}
LOGGER.error("Skipping chunk due to errors.");
LOGGER.log(System.Logger.Level.ERROR, "Skipping chunk due to errors.");
quadBuf.reset();
} else {
WarningHelper.showDebugMessageOnce(String.format("Warnings in chunk (%d, %d, %d) in dimension %s: %s", x, y, z, dimId, String.join(", ", warnings)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public void sendMeshToGPU(Mesh mesh) {
ChatUtil.showNeoChatMessage("VRAM keeps getting full! Reverting to vanilla renderer. Try increasing the VRAM buffer size in the config, if possible.", ChatUtil.MessageVerbosity.ERROR, false);
Compat.onNotEnoughVRAM(Config.VRAMSize);
} else {
LOGGER.debug("Reloading renderer because VRAM is full.");
LOGGER.log(System.Logger.Level.DEBUG, "Reloading renderer because VRAM is full.");
// TODO restart renderer with more VRAM allocated when this happens.
}
lastVRAMFullness = t;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/makamys/neodymium/util/ChatUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public static void showChatMessage(String text) {
if(player != null) {
player.addChatMessage(text);
} else {
LOGGER.info(text);
LOGGER.log(System.Logger.Level.INFO, text);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/makamys/neodymium/util/WarningHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class WarningHelper {
public static void showDebugMessageOnce(String warning) {
int hash = warning.hashCode();
if(!shownWarnings.contains(hash)) {
LOGGER.debug(warning);
LOGGER.log(System.Logger.Level.DEBUG, warning);
shownWarnings.add(hash);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class VirtualJar {
public static void registerHandler() {
if(registered) return;

LOGGER.debug("Registering URL protocol handler: " + PROTOCOL);
LOGGER.log(System.Logger.Level.DEBUG, "Registering URL protocol handler: " + PROTOCOL);

// We want the Handler to always be loaded by the same class loader.
//Launch.classLoader.addClassLoaderExclusion("makamys." + MODID + ".util.virtualjar.protocol." + PROTOCOL);
Expand All @@ -45,7 +45,7 @@ public static void registerHandler() {
public static void add(IVirtualJar jar) {
registerHandler();

LOGGER.trace("Adding virtual jar to class path: " + PROTOCOL + ":" + jar.getName() + ".jar");
LOGGER.log(System.Logger.Level.TRACE, "Adding virtual jar to class path: " + PROTOCOL + ":" + jar.getName() + ".jar");

String urlStr = PROTOCOL + ":" + jar.getName() + ".jar!/";

Expand All @@ -58,7 +58,7 @@ public static void add(IVirtualJar jar) {

jars.put(jar.getName(), jar);
} catch(MalformedURLException e) {
LOGGER.fatal("Failed to add virtual jar to class path");
LOGGER.log(System.Logger.Level.ERROR, "Failed to add virtual jar to class path");
e.printStackTrace();
}
}
Expand Down

0 comments on commit 7228a94

Please sign in to comment.