Skip to content
This repository was archived by the owner on Aug 6, 2023. It is now read-only.

Commit 90f6355

Browse files
committed
Improved log output, includes block id and registry name
1 parent 40112f4 commit 90f6355

2 files changed

Lines changed: 21 additions & 9 deletions

File tree

build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ buildscript {
1010
apply plugin: 'net.minecraftforge.gradle.forge'
1111
//Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
1212

13-
1413
version = "1.0"
1514
group = "com.yourname.modid" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
1615
archivesBaseName = "modid"

src/main/java/com/mcmoddev/mmdlogger/MMDLogger.java

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
package com.mcmoddev.mmdlogger;
22

33
import net.minecraftforge.oredict.OreDictionary;
4+
45
import java.util.List;
56

67
import org.apache.logging.log4j.LogManager;
78
import org.apache.logging.log4j.Logger;
9+
import org.apache.logging.log4j.core.LoggerContext;
10+
import org.apache.logging.log4j.core.config.Configurator;
811

12+
import net.minecraft.block.Block;
913
import net.minecraft.client.resources.I18n;
14+
import net.minecraft.item.Item;
1015
import net.minecraft.item.ItemStack;
1116
import net.minecraftforge.common.config.Configuration;
1217
import net.minecraftforge.fml.common.Mod;
@@ -22,21 +27,26 @@ public class MMDLogger
2227
public static final String MODID = "mmdlogger";
2328
public static final String VERSION = "1.0";
2429

25-
public static final Logger logger = LogManager.getFormatterLogger(MMDLogger.MODID);
30+
private Logger logger;
31+
private LoggerContext loggerContext;
2632
private boolean loggingOn = false;
2733

2834
@EventHandler
2935
public void preInit(FMLPreInitializationEvent event)
3036
{
31-
Configuration config = new Configuration(event.getSuggestedConfigurationFile());
32-
config.load();
37+
Configuration modConfig = new Configuration(event.getSuggestedConfigurationFile());
38+
modConfig.load();
3339

3440
final String OPTIONS = "options";
3541

36-
loggingOn = config.getBoolean("OREDICT_LOGGING", OPTIONS, loggingOn,
42+
loggingOn = modConfig.getBoolean("OREDICT_LOGGING", OPTIONS, loggingOn,
3743
"If true, then ore dict names and corresponding id's are logged");
3844

39-
config.save();
45+
modConfig.save();
46+
47+
if (loggingOn) {
48+
logger = LogManager.getFormatterLogger(MMDLogger.MODID);
49+
}
4050
}
4151

4252
@EventHandler
@@ -48,13 +58,16 @@ public void postInit(FMLPostInitializationEvent event)
4858

4959
for (String oreName : OreDictionary.getOreNames()) {
5060
oreID = OreDictionary.getOreID(oreName);
51-
5261
items = OreDictionary.getOres(oreName);
5362

5463
for (ItemStack itemStack : items) {
55-
logger.info("Ore Dictionary Entry: Ore Name: %s, Ore ID: %s, Unlocalised Name: %s", oreName, oreID, itemStack.getItem().getUnlocalizedName());
64+
Item item = itemStack.getItem();
65+
66+
logger.info("Ore Dictionary Entry: Ore Name: %s, Ore ID: %s, Unlocalised Name: %s, Block ID: %s, Registry Name: %s", oreName, oreID, item.getUnlocalizedName(), Item.getIdFromItem(item), item.getRegistryName());
5667
}
57-
}
68+
}
69+
70+
Configurator.shutdown(loggerContext);
5871
}
5972
}
6073

0 commit comments

Comments
 (0)