From 0b4c21d49891da01826f2ae0e5a7d6588459fc43 Mon Sep 17 00:00:00 2001 From: boubou19 Date: Sun, 9 Apr 2023 00:00:03 +0200 Subject: Misc (#1844) * add debug code in ItemList * added debug code in getModItem --- src/main/java/gregtech/api/util/GT_ModHandler.java | 30 ++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) (limited to 'src/main/java/gregtech/api/util') diff --git a/src/main/java/gregtech/api/util/GT_ModHandler.java b/src/main/java/gregtech/api/util/GT_ModHandler.java index 3dff430782..3ed707822a 100644 --- a/src/main/java/gregtech/api/util/GT_ModHandler.java +++ b/src/main/java/gregtech/api/util/GT_ModHandler.java @@ -393,8 +393,34 @@ public class GT_ModHandler { * Gets an Item from the specified mod, and returns a Replacement Item if not possible */ public static ItemStack getModItem(String aModID, String aItem, long aAmount, ItemStack aReplacement) { - if (GT_Utility.isStringInvalid(aItem) || !GregTech_API.sPreloadStarted) return null; - return GT_Utility.copyAmount(aAmount, GameRegistry.findItemStack(aModID, aItem, (int) aAmount), aReplacement); + ItemStack result; + if (GT_Utility.isStringInvalid(aItem) || !GregTech_API.sPreloadStarted) { + result = null; + } else { + result = GT_Utility.copyAmount( + aAmount, + GameRegistry.findItemStack(aModID, aItem, (int) aAmount), + aReplacement); + } + + if (result == null) { + String reason; + if (GT_Utility.isStringInvalid(aItem)) { + reason = "the name of the item is an invalid string"; + } else if (!GregTech_API.sPreloadStarted) { + reason = "the GT5U preloading phase has not yet started"; + } else { + reason = "the item was not found in the game registry"; + } + String log_message = "getModItem call: object \"" + aItem + + "\" with mod id \"" + + aModID + + "\" has returned null because " + + reason; + GT_Log.out.println(log_message); + new Exception().printStackTrace(GT_Log.out); + } + return result; } /** -- cgit