From 328630fc9ce40771d859e87de495a4c82c125d81 Mon Sep 17 00:00:00 2001 From: Justin Aquadro Date: Fri, 27 Feb 2015 23:17:37 -0500 Subject: [PATCH] Add limited debug logging option --- build.gradle | 4 ++-- resources/assets/storagedrawers/lang/en_US.lang | 4 ++++ .../storagedrawers/block/BlockDrawers.java | 16 ++++++++++++++++ .../storagedrawers/config/ConfigManager.java | 9 +++++++-- 4 files changed, 29 insertions(+), 4 deletions(-) diff --git a/build.gradle b/build.gradle index 91993f9..ebbae48 100644 --- a/build.gradle +++ b/build.gradle @@ -17,12 +17,12 @@ buildscript { apply plugin: 'forge' -version = "1.7.10-1.2.3" +version = "1.7.10-1.2.4" group= "com.jaquadro.minecraft.storagedrawers" // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = "StorageDrawers" minecraft { - version = "1.7.10-10.13.2.1291" + version = "1.7.10-10.13.2.1307-1.7.10" assetDir = "runtime/assets" replace '@VERSION@', project.version diff --git a/resources/assets/storagedrawers/lang/en_US.lang b/resources/assets/storagedrawers/lang/en_US.lang index b5b18d1..80035a9 100644 --- a/resources/assets/storagedrawers/lang/en_US.lang +++ b/resources/assets/storagedrawers/lang/en_US.lang @@ -98,6 +98,10 @@ storageDrawers.config.prop.enableSidedInput=Enable Sided Input storageDrawers.config.prop.enableSidedInput.tooltip=Other blocks can insert items into drawers. storageDrawers.config.prop.enableSidedOutput=Enable Sided Output storageDrawers.config.prop.enableSidedOutput.tooltip=Other blocks can extract items from drawers. +storageDrawers.config.prop.invertShift=Invert Shift +storageDrawers.config.prop.invertShift.tooltip=Inverts click and shift+click behavior. +storageDrawers.config.prop.enableDebugLogging=Enable Debug Logging +storageDrawers.config.prop.enableDebugLogging.tooltip=Prints extra information to the logs. storageDrawers.config.integration=Integration storageDrawers.config.integration.tooltip=Configure integration with other mods. diff --git a/src/com/jaquadro/minecraft/storagedrawers/block/BlockDrawers.java b/src/com/jaquadro/minecraft/storagedrawers/block/BlockDrawers.java index b0cdf2e..3cdd943 100644 --- a/src/com/jaquadro/minecraft/storagedrawers/block/BlockDrawers.java +++ b/src/com/jaquadro/minecraft/storagedrawers/block/BlockDrawers.java @@ -9,6 +9,7 @@ import com.jaquadro.minecraft.storagedrawers.core.ModCreativeTabs; import com.jaquadro.minecraft.storagedrawers.core.ModItems; import com.jaquadro.minecraft.storagedrawers.network.BlockClickMessage; +import cpw.mods.fml.common.FMLLog; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; @@ -34,6 +35,7 @@ import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; +import org.apache.logging.log4j.Level; import java.util.List; import java.util.Random; @@ -178,6 +180,11 @@ public class BlockDrawers extends BlockContainer implements IExtendedBlockClickH TileEntityDrawers tileDrawers = getTileEntitySafe(world, x, y, z); ItemStack item = player.inventory.getCurrentItem(); + if (StorageDrawers.config.cache.debugTrace) { + FMLLog.log(StorageDrawers.MOD_ID, Level.INFO, "BlockDrawers.onBlockActivated"); + FMLLog.log(StorageDrawers.MOD_ID, Level.INFO, (item == null) ? " null item" : " " + item.toString()); + } + if (item != null && item.getItem() != null) { if (item.getItem() == ModItems.upgrade && item.getItemDamage() != tileDrawers.getStorageLevel()) { tileDrawers.setStorageLevel(item.getItemDamage()); @@ -274,11 +281,17 @@ public class BlockDrawers extends BlockContainer implements IExtendedBlockClickH float hitZ = (float)(posn.hitVec.zCoord - posn.blockZ); StorageDrawers.network.sendToServer(new BlockClickMessage(x, y, z, posn.sideHit, hitX, hitY, hitZ)); + + if (StorageDrawers.config.cache.debugTrace) + FMLLog.log(StorageDrawers.MOD_ID, Level.INFO, "BlockDrawers.onBlockClicked with " + posn.toString()); } } @Override public void onBlockClicked (World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { + if (StorageDrawers.config.cache.debugTrace) + FMLLog.log(StorageDrawers.MOD_ID, Level.INFO, "IExtendedBlockClickHandler.onBlockClicked"); + TileEntityDrawers tileDrawers = getTileEntitySafe(world, x, y, z); if (tileDrawers.getDirection() != side) return; @@ -293,6 +306,9 @@ public class BlockDrawers extends BlockContainer implements IExtendedBlockClickH else item = tileDrawers.takeItemsFromSlot(slot, 1); + if (StorageDrawers.config.cache.debugTrace) + FMLLog.log(StorageDrawers.MOD_ID, Level.INFO, (item == null) ? " null item" : " " + item.toString()); + if (item != null && item.stackSize > 0) { dropItemStack(world, x, y, z, player, item); world.markBlockForUpdate(x, y, z); diff --git a/src/com/jaquadro/minecraft/storagedrawers/config/ConfigManager.java b/src/com/jaquadro/minecraft/storagedrawers/config/ConfigManager.java index c25b84e..7fafe9e 100644 --- a/src/com/jaquadro/minecraft/storagedrawers/config/ConfigManager.java +++ b/src/com/jaquadro/minecraft/storagedrawers/config/ConfigManager.java @@ -62,6 +62,7 @@ public class ConfigManager public boolean enableWailaIntegration; public boolean enableAE2Integration; public boolean invertShift; + public boolean debugTrace; public int level2Mult; public int level3Mult; @@ -119,8 +120,12 @@ public class ConfigManager cache.enableSidedInput = config.get(Configuration.CATEGORY_GENERAL, "enableSidedInput", true).setLanguageKey(LANG_PREFIX + "prop.enableSidedInput").getBoolean(); cache.enableSidedOutput = config.get(Configuration.CATEGORY_GENERAL, "enableSidedOutput", true).setLanguageKey(LANG_PREFIX + "prop.enableSidedOutput").getBoolean(); cache.invertShift = config.get(Configuration.CATEGORY_GENERAL, "invertShift", false, - "Inverts how shift works with drawers. If this is true, shifting will only give one item, where regular clicks will give a full stack. Leave false for default behavior.").getBoolean(); - + "Inverts how shift works with drawers. If this is true, shifting will only give one item, where regular clicks will give a full stack. Leave false for default behavior.") + .setLanguageKey(LANG_PREFIX + "prop.invertShift").getBoolean(); + cache.debugTrace = config.get(Configuration.CATEGORY_GENERAL, "enableDebugLogging", false, + "Writes additional log messages while using the mod. Mainly for debug purposes. Should be kept disabled unless instructed otherwise.") + .setLanguageKey(LANG_PREFIX + "prop.enableDebugLogging").getBoolean(); + cache.enableAE2Integration = config.get(sectionIntegration.getQualifiedName(), "enableAE2", true).setLanguageKey(LANG_PREFIX + "integration.enableAE2").setRequiresMcRestart(true).getBoolean(); cache.enableWailaIntegration = config.get(sectionIntegration.getQualifiedName(), "enableWaila", true).setLanguageKey(LANG_PREFIX + "integration.enableWaila").setRequiresMcRestart(true).getBoolean();