From 0ca4f1177cd2e5ee6bd2be38f6d0f2a60e143e33 Mon Sep 17 00:00:00 2001 From: Draknyte1 Date: Tue, 4 Oct 2016 20:54:10 +1000 Subject: $ Fixed a client crashing bug where aspects didn't register properly due to the changes I made in AspectStack handling. % Changed how logging is done for cable reflection tasks. --- src/Java/gtPlusPlus/core/util/Utils.java | 49 ++++++++++++++++------ .../base/GregtechMetaPipeEntityBase_Cable.java | 10 +++-- 2 files changed, 43 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/Java/gtPlusPlus/core/util/Utils.java b/src/Java/gtPlusPlus/core/util/Utils.java index 090d05e3b1..bee5de98ea 100644 --- a/src/Java/gtPlusPlus/core/util/Utils.java +++ b/src/Java/gtPlusPlus/core/util/Utils.java @@ -44,6 +44,9 @@ import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.oredict.OreDictionary; + +import org.apache.commons.lang3.EnumUtils; + import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.FMLLog; import cpw.mods.fml.common.registry.EntityRegistry; @@ -90,32 +93,52 @@ public class Utils { if (aspect.toUpperCase() == "COGNITIO"){ //Adds in Compat for older GT Versions which Misspell aspects. try { - returnValue = new TC_AspectStack(TC_Aspects.valueOf("COGNITIO"), size); + if (EnumUtils.isValidEnum(TC_Aspects.class, "COGNITIO")){ + Utils.LOG_WARNING("TC Aspect found - "+aspect); + returnValue = new TC_AspectStack(TC_Aspects.valueOf("COGNITIO"), size); + } + else { + Utils.LOG_INFO("Fallback TC Aspect found - "+aspect+" - PLEASE UPDATE GREGTECH TO A NEWER VERSION TO REMOVE THIS MESSAGE - THIS IS NOT AN ERROR"); + returnValue = new TC_AspectStack(TC_Aspects.valueOf("COGNITO"), size); + } } catch (NoSuchFieldError r){ - Utils.LOG_INFO("Fallback TC Aspect found - "+aspect+" - PLEASE UPDATE GREGTECH TO A NEWER VERSION TO REMOVE THIS MESSAGE - THIS IS NOT AN ERROR"); - returnValue = new TC_AspectStack(TC_Aspects.valueOf("COGNITO"), size); - + Utils.LOG_INFO("Invalid Thaumcraft Aspects - Report this issue to Alkalus"); } } else if (aspect.toUpperCase() == "EXANIMUS"){ - //Adds in Compat for older GT Versions which Misspell aspects. + //Adds in Compat for older GT Versions which Misspell aspects. try { - returnValue = new TC_AspectStack(TC_Aspects.valueOf("EXANIMUS"), size); + if (EnumUtils.isValidEnum(TC_Aspects.class, "EXANIMUS")){ + Utils.LOG_WARNING("TC Aspect found - "+aspect); + returnValue = new TC_AspectStack(TC_Aspects.valueOf("EXANIMUS"), size); + } + else { + Utils.LOG_INFO("Fallback TC Aspect found - "+aspect+" - PLEASE UPDATE GREGTECH TO A NEWER VERSION TO REMOVE THIS MESSAGE - THIS IS NOT AN ERROR"); + returnValue = new TC_AspectStack(TC_Aspects.valueOf("EXAMINIS"), size); + } } catch (NoSuchFieldError r){ - Utils.LOG_INFO("Fallback TC Aspect found - "+aspect+" - PLEASE UPDATE GREGTECH TO A NEWER VERSION TO REMOVE THIS MESSAGE - THIS IS NOT AN ERROR"); - returnValue = new TC_AspectStack(TC_Aspects.valueOf("EXAMINIS"), size); + Utils.LOG_INFO("Invalid Thaumcraft Aspects - Report this issue to Alkalus"); } + + } else if (aspect.toUpperCase() == "PRAECANTATIO"){ - //Adds in Compat for older GT Versions which Misspell aspects. + //Adds in Compat for older GT Versions which Misspell aspects. try { - returnValue = new TC_AspectStack(TC_Aspects.valueOf("PRAECANTATIO"), size); + if (EnumUtils.isValidEnum(TC_Aspects.class, "PRAECANTATIO")){ + Utils.LOG_WARNING("TC Aspect found - "+aspect); + returnValue = new TC_AspectStack(TC_Aspects.valueOf("PRAECANTATIO"), size); + } + else { + Utils.LOG_INFO("Fallback TC Aspect found - "+aspect+" - PLEASE UPDATE GREGTECH TO A NEWER VERSION TO REMOVE THIS MESSAGE - THIS IS NOT AN ERROR"); + returnValue = new TC_AspectStack(TC_Aspects.valueOf("PRAECANTIO"), size); + } } catch (NoSuchFieldError r){ - Utils.LOG_INFO("Fallback TC Aspect found - "+aspect+" - PLEASE UPDATE GREGTECH TO A NEWER VERSION TO REMOVE THIS MESSAGE - THIS IS NOT AN ERROR"); - returnValue = new TC_AspectStack(TC_Aspects.valueOf("PRAECANTIO"), size); - } + Utils.LOG_INFO("Invalid Thaumcraft Aspects - Report this issue to Alkalus"); + } } else { + Utils.LOG_WARNING("TC Aspect found - "+aspect); returnValue = new TC_AspectStack(TC_Aspects.valueOf(aspect), size); } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMetaPipeEntityBase_Cable.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMetaPipeEntityBase_Cable.java index 585987797c..e9947464be 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMetaPipeEntityBase_Cable.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMetaPipeEntityBase_Cable.java @@ -16,6 +16,7 @@ import gregtech.api.metatileentity.BaseMetaPipeEntity; import gregtech.api.metatileentity.MetaPipeEntity; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Utility; +import gregtech.common.GT_Proxy; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes.GT_Materials; @@ -71,13 +72,14 @@ public class GregtechMetaPipeEntityBase_Cable extends MetaPipeEntity implements } private int getGT5Var(){ - Class clazz = GT_Mod.gregtechproxy.getClass(); + Class clazz = GT_Mod.gregtechproxy.getClass(); String lookingForValue = "mWireHeatingTicks"; int temp = 4; Field field; + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK){ try { field = clazz.getClass().getField(lookingForValue); - Class clazzType = field.getType(); + Class clazzType = field.getType(); if (clazzType.toString().equals("int")){ temp = (field.getInt(clazz)); } @@ -85,10 +87,12 @@ public class GregtechMetaPipeEntityBase_Cable extends MetaPipeEntity implements temp = 4; } } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) { - Utils.LOG_INFO("FATAL ERROR - REFLECTION FAILED FOR GT CABLES - PLEASE REPORT THIS."); + //Utils.LOG_INFO("FATAL ERROR - REFLECTION FAILED FOR GT CABLES - PLEASE REPORT THIS."); Utils.LOG_WARNING("FATAL ERROR - REFLECTION FAILED FOR GT CABLES - PLEASE REPORT THIS."); Utils.LOG_ERROR("FATAL ERROR - REFLECTION FAILED FOR GT CABLES - PLEASE REPORT THIS."); + temp = 4; } + } return temp; } -- cgit