diff options
Diffstat (limited to 'src/main/java/pers/gwyog/gtneioreplugin/util/GuiRecipeHelper.java')
-rw-r--r-- | src/main/java/pers/gwyog/gtneioreplugin/util/GuiRecipeHelper.java | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/src/main/java/pers/gwyog/gtneioreplugin/util/GuiRecipeHelper.java b/src/main/java/pers/gwyog/gtneioreplugin/util/GuiRecipeHelper.java index 78d43f1bdd..8cf6a8faac 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/util/GuiRecipeHelper.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/util/GuiRecipeHelper.java @@ -1,25 +1,23 @@ package pers.gwyog.gtneioreplugin.util; -import java.lang.reflect.Field; - -import org.apache.logging.log4j.Level; - import codechicken.nei.recipe.GuiRecipe; import cpw.mods.fml.common.FMLLog; +import java.lang.reflect.Field; import net.minecraft.client.Minecraft; +import org.apache.logging.log4j.Level; public class GuiRecipeHelper { - private static final String INIT_ERROR = "pers.gwyog.gtneioreplugin.util.GuiRecipeHelper failed setting up reflection : "; + private static final String INIT_ERROR = + "pers.gwyog.gtneioreplugin.util.GuiRecipeHelper failed setting up reflection : "; private static final int DEFAULT_XSIZE = 176; - private static Class<GuiRecipe> guiRecipeClass; public static Field xSizeField; public static Field guiLeftField; public static Field guiTopField; /** * Access the xSize field of a GuiRecipe instance, or use a fallback hardcoded value if that fails - * + * * @param gui GuiRecipe object * @return Integer value of the xSize field of that object */ @@ -31,15 +29,14 @@ public class GuiRecipeHelper { // Fail silently, hoping that it it fails it will be during initialization } } - + // Fallback should work unless codechicken.nei.recipe.GuiRecipe implementation changes return DEFAULT_XSIZE; } - /** * Access the guiLeft field of a GuiRecipe instance, or use a fallback hardcoded value if that fails - * + * * @param gui GuiRecipe object * @return Integer value of the guiLeft field of that object */ @@ -51,14 +48,14 @@ public class GuiRecipeHelper { // Fail silently, hoping that it it fails it will be during initialization } } - + // Fallback should work unless codechicken.nei.recipe.GuiRecipe implementation changes return (Minecraft.getMinecraft().currentScreen.width - DEFAULT_XSIZE) / 2; } - + /** * Access the guiTop field of a GuiRecipe instance, or use a fallback hardcoded value if that fails - * + * * @param gui GuiRecipe object * @return Integer value of the guiTop field of that object */ @@ -70,7 +67,7 @@ public class GuiRecipeHelper { // Fail silently, hoping that it it fails it will be during initialization } } - + // Fallback should work unless codechicken.nei.recipe.GuiRecipe implementation changes int height = Minecraft.getMinecraft().currentScreen.height; int ySize = Math.min(Math.max(height - 68, 166), 370); @@ -81,15 +78,15 @@ public class GuiRecipeHelper { * Initialize the GuiRecipe Field accessors through reflection */ public GuiRecipeHelper() { - guiRecipeClass = GuiRecipe.class; + Class<GuiRecipe> guiRecipeClass = GuiRecipe.class; try { - guiLeftField = guiRecipeClass.getField("guiLeft"); + guiLeftField = guiRecipeClass.getField("guiLeft"); guiLeftField.setAccessible(true); guiTopField = guiRecipeClass.getField("guiTop"); guiTopField.setAccessible(true); xSizeField = guiRecipeClass.getField("xSize"); xSizeField.setAccessible(true); - } catch(NoSuchFieldException|SecurityException e) { + } catch (NoSuchFieldException | SecurityException e) { FMLLog.log(Level.ERROR, INIT_ERROR + e.getMessage()); } } |