diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Java/gtPlusPlus/core/handler/BookHandler.java | 10 | ||||
-rw-r--r-- | src/Java/gtPlusPlus/core/slots/SlotDataStick.java | 9 | ||||
-rw-r--r-- | src/Java/gtPlusPlus/core/util/ClassUtils.java | 45 | ||||
-rw-r--r-- | src/Java/gtPlusPlus/core/util/Log.java | 15 | ||||
-rw-r--r-- | src/Java/gtPlusPlus/core/util/LoggingUtils.java | 14 | ||||
-rw-r--r-- | src/Java/gtPlusPlus/core/util/PollutionUtils.java | 29 | ||||
-rw-r--r-- | src/Java/gtPlusPlus/core/util/Quality.java | 51 | ||||
-rw-r--r-- | src/Java/gtPlusPlus/core/util/Utils.java | 526 | ||||
-rw-r--r-- | src/Java/gtPlusPlus/core/util/UtilsChatFormatting.java | 102 | ||||
-rw-r--r-- | src/Java/gtPlusPlus/core/util/UtilsRarity.java | 17 | ||||
-rw-r--r-- | src/Java/gtPlusPlus/core/util/UtilsText.java | 24 | ||||
-rw-r--r-- | src/Java/gtPlusPlus/core/util/nbt/ModularArmourUtils.java | 2 | ||||
-rw-r--r-- | src/Java/gtPlusPlus/core/util/nbt/NBTUtils.java | 48 |
13 files changed, 393 insertions, 499 deletions
diff --git a/src/Java/gtPlusPlus/core/handler/BookHandler.java b/src/Java/gtPlusPlus/core/handler/BookHandler.java index ebfed327f9..98b7fd5485 100644 --- a/src/Java/gtPlusPlus/core/handler/BookHandler.java +++ b/src/Java/gtPlusPlus/core/handler/BookHandler.java @@ -61,11 +61,11 @@ public class BookHandler { + " After this has been constructed, you can now combine the upgrades listed within this book to improve the baubles level /100.", "Defence:" + " Can be upgraded by combining metal plates with the bauble." - + "+1 | Aluminium Plate" - + "+2 | Stainless Steel Plate" - + "+3 | Tungsten Plate" - + "+4 | TungstenSteel Plate" - + "+5 | Naquadah Plate", + + " | +1 | Aluminium Plate" + + " | +2 | Stainless Steel Plate" + + " | +3 | Tungsten Plate" + + " | +4 | TungstenSteel Plate" + + " | +5 | Naquadah Plate", "There was once a sad and lonely oak tree.", "There was once a sad and lonely oak tree.", "There was once a sad and lonely oak tree."}); diff --git a/src/Java/gtPlusPlus/core/slots/SlotDataStick.java b/src/Java/gtPlusPlus/core/slots/SlotDataStick.java index 1f628f4a9c..b32bc02624 100644 --- a/src/Java/gtPlusPlus/core/slots/SlotDataStick.java +++ b/src/Java/gtPlusPlus/core/slots/SlotDataStick.java @@ -1,13 +1,7 @@ package gtPlusPlus.core.slots; import gregtech.api.enums.ItemList; -import gregtech.api.enums.OrePrefixes; -import gregtech.api.items.GT_MetaGenerated_Tool; import gregtech.common.items.GT_MetaGenerated_Item_01; -import gregtech.common.items.GT_MetaGenerated_Item_02; -import gregtech.common.items.behaviors.Behaviour_DataStick; -import gtPlusPlus.core.item.bauble.ModularBauble; -import gtPlusPlus.core.util.Utils; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; import gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedGregtechItems; import net.minecraft.inventory.IInventory; @@ -29,8 +23,7 @@ public class SlotDataStick extends Slot{ if ((itemstack.getItem() instanceof GT_MetaGenerated_Item_01 && itemstack.getItemDamage() == 32708) || (itemstack == ItemList.Tool_DataStick.get(1)) || (itemstack == GregtechItemList.Old_Tool_DataStick.get(1)) - || (itemstack.getItem() instanceof MetaGeneratedGregtechItems && itemstack.getItemDamage() == 32208) - || (itemstack.getItem() instanceof ModularBauble)){ + || (itemstack.getItem() instanceof MetaGeneratedGregtechItems && itemstack.getItemDamage() == 32208)){ isValid = true; } } diff --git a/src/Java/gtPlusPlus/core/util/ClassUtils.java b/src/Java/gtPlusPlus/core/util/ClassUtils.java index 498362e817..8f55fca299 100644 --- a/src/Java/gtPlusPlus/core/util/ClassUtils.java +++ b/src/Java/gtPlusPlus/core/util/ClassUtils.java @@ -4,12 +4,12 @@ import java.lang.reflect.*; public class ClassUtils { - - /*@ if (isPresent("com.optionaldependency.DependencyClass")) { - // This block will never execute when the dependency is not present - // There is therefore no more risk of code throwing NoClassDefFoundException. - executeCodeLinkingToDependency(); - }*/ + /* + * @ if (isPresent("com.optionaldependency.DependencyClass")) { // This + * block will never execute when the dependency is not present // There is + * therefore no more risk of code throwing NoClassDefFoundException. + * executeCodeLinkingToDependency(); } + */ public static boolean isPresent(final String className) { try { Class.forName(className); @@ -21,17 +21,18 @@ public class ClassUtils { } @SuppressWarnings("rawtypes") - public static Method getMethodViaReflection(final Class<?> lookupClass, final String methodName, final boolean invoke) throws Exception{ + public static Method getMethodViaReflection(final Class<?> lookupClass, final String methodName, + final boolean invoke) throws Exception { final Class<? extends Class> lookup = lookupClass.getClass(); final Method m = lookup.getDeclaredMethod(methodName); m.setAccessible(true);// Abracadabra - if (invoke){ + if (invoke) { m.invoke(lookup);// now its OK } return m; } - public static Class<?> getNonPublicClass(final String className){ + public static Class<?> getNonPublicClass(final String className) { Class<?> c = null; try { c = Class.forName(className); @@ -39,12 +40,12 @@ public class ClassUtils { // TODO Auto-generated catch block e.printStackTrace(); } - //full package name --------^^^^^^^^^^ - //or simpler without Class.forName: - //Class<package1.A> c = package1.A.class; + // full package name --------^^^^^^^^^^ + // or simpler without Class.forName: + // Class<package1.A> c = package1.A.class; - if (null != c){ - //In our case we need to use + if (null != c) { + // In our case we need to use Constructor<?> constructor = null; try { constructor = c.getDeclaredConstructor(); @@ -52,18 +53,18 @@ public class ClassUtils { // TODO Auto-generated catch block e.printStackTrace(); } - //note: getConstructor() can return only public constructors - //so we needed to search for any Declared constructor + // note: getConstructor() can return only public constructors + // so we needed to search for any Declared constructor - //now we need to make this constructor accessible - if (null != constructor){ - constructor.setAccessible(true);//ABRACADABRA! + // now we need to make this constructor accessible + if (null != constructor) { + constructor.setAccessible(true);// ABRACADABRA! try { final Object o = constructor.newInstance(); return (Class<?>) o; - } catch (InstantiationException | IllegalAccessException - | IllegalArgumentException | InvocationTargetException e) { + } catch (InstantiationException | IllegalAccessException | IllegalArgumentException + | InvocationTargetException e) { // TODO Auto-generated catch block e.printStackTrace(); } @@ -72,6 +73,4 @@ public class ClassUtils { return null; } - - } diff --git a/src/Java/gtPlusPlus/core/util/Log.java b/src/Java/gtPlusPlus/core/util/Log.java index aa0231b954..fe06fcb271 100644 --- a/src/Java/gtPlusPlus/core/util/Log.java +++ b/src/Java/gtPlusPlus/core/util/Log.java @@ -3,27 +3,22 @@ package gtPlusPlus.core.util; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -public final class Log -{ +public final class Log { public static final Logger LOGGER = LogManager.getLogger("MiscUtils"); - public static void warn(final String msg) - { + public static void warn(final String msg) { LOGGER.warn(msg); } - public static void error(final String msg) - { + public static void error(final String msg) { LOGGER.error(msg); } - public static void info(final String msg) - { + public static void info(final String msg) { LOGGER.info(msg); } - public static void debug(final String msg) - { + public static void debug(final String msg) { LOGGER.debug(msg); } } diff --git a/src/Java/gtPlusPlus/core/util/LoggingUtils.java b/src/Java/gtPlusPlus/core/util/LoggingUtils.java index 3e8219d53a..6aae8e52ec 100644 --- a/src/Java/gtPlusPlus/core/util/LoggingUtils.java +++ b/src/Java/gtPlusPlus/core/util/LoggingUtils.java @@ -5,7 +5,7 @@ import java.util.Date; public class LoggingUtils { - public static void profileLog(final Object o){ + public static void profileLog(final Object o) { try { String content; final File file = new File("GregtechTimingsTC.txt"); @@ -18,10 +18,9 @@ public class LoggingUtils { bw.write(System.lineSeparator()); bw.close(); } - if (o instanceof String){ + if (o instanceof String) { content = (String) o; - } - else { + } else { content = o.toString(); } final FileWriter fw = new FileWriter(file.getAbsoluteFile(), true); @@ -36,13 +35,12 @@ public class LoggingUtils { } } - public static boolean logCurrentSystemTime(final String message){ + public static boolean logCurrentSystemTime(final String message) { final Date date = new Date(System.currentTimeMillis()); try { - profileLog(message+" | "+date.toString()); + profileLog(message + " | " + date.toString()); return true; - } - catch (final Throwable r) { + } catch (final Throwable r) { return false; } diff --git a/src/Java/gtPlusPlus/core/util/PollutionUtils.java b/src/Java/gtPlusPlus/core/util/PollutionUtils.java index 13546b616a..a73a89b85c 100644 --- a/src/Java/gtPlusPlus/core/util/PollutionUtils.java +++ b/src/Java/gtPlusPlus/core/util/PollutionUtils.java @@ -8,50 +8,49 @@ import gregtech.common.GT_Proxy; public class PollutionUtils { - public static boolean mPollution (){ + public static boolean mPollution() { try { GT_Proxy GT_Pollution = GT_Mod.gregtechproxy; - if (GT_Pollution != null){ + if (GT_Pollution != null) { Field mPollution = GT_Pollution.getClass().getField("mPollution"); - if (mPollution != null){ + if (mPollution != null) { return mPollution.getBoolean(GT_Pollution); } } - } - catch (SecurityException | IllegalArgumentException | NoSuchFieldException | IllegalAccessException e) { + } catch (SecurityException | IllegalArgumentException | NoSuchFieldException | IllegalAccessException e) { return false; } return false; } - public static boolean addPollution(IGregTechTileEntity te, int pollutionValue){ + public static boolean addPollution(IGregTechTileEntity te, int pollutionValue) { try { Class<?> GT_Pollution = Class.forName("gregtech.common.GT_Pollution"); - if (GT_Pollution != null){ + if (GT_Pollution != null) { Method addPollution = GT_Pollution.getMethod("addPollution", IGregTechTileEntity.class, int.class); - if (addPollution != null){ + if (addPollution != null) { addPollution.invoke(null, te, pollutionValue); return true; } } - } - catch (ClassNotFoundException | SecurityException | NoSuchMethodException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + } catch (ClassNotFoundException | SecurityException | NoSuchMethodException | IllegalAccessException + | IllegalArgumentException | InvocationTargetException e) { return false; } return false; } - public static int getPollution(IGregTechTileEntity te){ + public static int getPollution(IGregTechTileEntity te) { try { Class<?> GT_Pollution = Class.forName("gregtech.common.GT_Pollution"); - if (GT_Pollution != null){ + if (GT_Pollution != null) { Method addPollution = GT_Pollution.getMethod("getPollution", IGregTechTileEntity.class); - if (addPollution != null){ + if (addPollution != null) { return (int) addPollution.invoke(null, te); } } - } - catch (ClassNotFoundException | SecurityException | NoSuchMethodException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + } catch (ClassNotFoundException | SecurityException | NoSuchMethodException | IllegalAccessException + | IllegalArgumentException | InvocationTargetException e) { return 0; } return 0; diff --git a/src/Java/gtPlusPlus/core/util/Quality.java b/src/Java/gtPlusPlus/core/util/Quality.java index b866b2e28b..3e13409a10 100644 --- a/src/Java/gtPlusPlus/core/util/Quality.java +++ b/src/Java/gtPlusPlus/core/util/Quality.java @@ -11,21 +11,16 @@ public enum Quality { // Unique Gold/Purple // Trade-off Brown - POOR("Poor", EnumChatFormatting.GRAY), - COMMON("Common", EnumChatFormatting.WHITE), - UNCOMMON("Uncommon", EnumChatFormatting.DARK_GREEN), - MAGIC("Magic", EnumChatFormatting.BLUE), - RARE("Rare", EnumChatFormatting.YELLOW), - UNIQUE("Unique", EnumChatFormatting.GOLD), - ARTIFACT("Artifact", EnumChatFormatting.AQUA), - SET("Set Piece", EnumChatFormatting.GREEN), - TRADEOFF("Trade-off", EnumChatFormatting.DARK_RED), - EPIC("Epic", EnumChatFormatting.LIGHT_PURPLE); + POOR("Poor", EnumChatFormatting.GRAY), COMMON("Common", EnumChatFormatting.WHITE), UNCOMMON("Uncommon", + EnumChatFormatting.DARK_GREEN), MAGIC("Magic", EnumChatFormatting.BLUE), RARE("Rare", + EnumChatFormatting.YELLOW), UNIQUE("Unique", EnumChatFormatting.GOLD), ARTIFACT("Artifact", + EnumChatFormatting.AQUA), SET("Set Piece", EnumChatFormatting.GREEN), TRADEOFF("Trade-off", + EnumChatFormatting.DARK_RED), EPIC("Epic", EnumChatFormatting.LIGHT_PURPLE); private String LOOT; private EnumChatFormatting COLOUR; - private Quality (final String lootTier, final EnumChatFormatting tooltipColour) - { + + private Quality(final String lootTier, final EnumChatFormatting tooltipColour) { this.LOOT = lootTier; this.COLOUR = tooltipColour; } @@ -34,27 +29,33 @@ public enum Quality { return this.LOOT; } - protected EnumChatFormatting getColour(){ + protected EnumChatFormatting getColour() { return this.COLOUR; } - public String formatted(){ - return this.COLOUR+this.LOOT; + public String formatted() { + return this.COLOUR + this.LOOT; } - public static Quality getRandomQuality(){ + public static Quality getRandomQuality() { final int lootChance = MathUtils.randInt(0, 100); - if (lootChance <= 10){return Quality.POOR;} - else if (lootChance <= 45){return Quality.COMMON;} - else if (lootChance <= 65){return Quality.UNCOMMON;} - else if (lootChance <= 82){return Quality.MAGIC;} - else if (lootChance <= 92){return Quality.EPIC;} - else if (lootChance <= 97){return Quality.RARE;} - else if (lootChance <= 99){return Quality.ARTIFACT;} else { + if (lootChance <= 10) { + return Quality.POOR; + } else if (lootChance <= 45) { + return Quality.COMMON; + } else if (lootChance <= 65) { + return Quality.UNCOMMON; + } else if (lootChance <= 82) { + return Quality.MAGIC; + } else if (lootChance <= 92) { + return Quality.EPIC; + } else if (lootChance <= 97) { + return Quality.RARE; + } else if (lootChance <= 99) { + return Quality.ARTIFACT; + } else { return null; } } } - - diff --git a/src/Java/gtPlusPlus/core/util/Utils.java b/src/Java/gtPlusPlus/core/util/Utils.java index c59d227f0e..f9315a2966 100644 --- a/src/Java/gtPlusPlus/core/util/Utils.java +++ b/src/Java/gtPlusPlus/core/util/Utils.java @@ -56,7 +56,7 @@ public class Utils { public static final int WILDCARD_VALUE = Short.MAX_VALUE; - public static final boolean isServer(){ + public static final boolean isServer() { return FMLCommonHandler.instance().getEffectiveSide().isServer(); } @@ -67,98 +67,89 @@ public class Utils { } } - public static boolean isModUpToDate(){ - if (CORE.MASTER_VERSION.toLowerCase().equals("offline")){ + public static boolean isModUpToDate() { + if (CORE.MASTER_VERSION.toLowerCase().equals("offline")) { return false; } - else if (CORE.MASTER_VERSION.toLowerCase().equals(CORE.VERSION.toLowerCase())){ + else if (CORE.MASTER_VERSION.toLowerCase().equals(CORE.VERSION.toLowerCase())) { return true; - } - else { + } else { return false; } } - public static TC_AspectStack getTcAspectStack (final TC_Aspects aspect, final long size){ + public static TC_AspectStack getTcAspectStack(final TC_Aspects aspect, final long size) { return getTcAspectStack(aspect.name(), (int) size); } - public static TC_AspectStack getTcAspectStack (final String aspect, final long size){ + public static TC_AspectStack getTcAspectStack(final String aspect, final long size) { return getTcAspectStack(aspect, (int) size); } - public static TC_AspectStack getTcAspectStack (final TC_Aspects aspect, final int size){ + public static TC_AspectStack getTcAspectStack(final TC_Aspects aspect, final int size) { return getTcAspectStack(aspect.name(), size); } - public static TC_AspectStack getTcAspectStack (final String aspect, final int size){ + public static TC_AspectStack getTcAspectStack(final String aspect, final int size) { TC_AspectStack returnValue = null; - if (aspect.toUpperCase().equals("COGNITIO")){ - //Adds in Compat for older GT Versions which Misspell aspects. + if (aspect.toUpperCase().equals("COGNITIO")) { + // Adds in Compat for older GT Versions which Misspell aspects. try { - if (EnumUtils.isValidEnum(TC_Aspects.class, "COGNITIO")){ - Utils.LOG_WARNING("TC Aspect found - "+aspect); + 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"); + } 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 (final NoSuchFieldError r){ + } catch (final NoSuchFieldError r) { Utils.LOG_INFO("Invalid Thaumcraft Aspects - Report this issue to Alkalus"); } - } - else if (aspect.toUpperCase().equals("EXANIMUS")){ - //Adds in Compat for older GT Versions which Misspell aspects. + } else if (aspect.toUpperCase().equals("EXANIMUS")) { + // Adds in Compat for older GT Versions which Misspell aspects. try { - if (EnumUtils.isValidEnum(TC_Aspects.class, "EXANIMUS")){ - Utils.LOG_WARNING("TC Aspect found - "+aspect); + 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"); + } 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 (final NoSuchFieldError r){ + } catch (final NoSuchFieldError r) { Utils.LOG_INFO("Invalid Thaumcraft Aspects - Report this issue to Alkalus"); } - - } - else if (aspect.toUpperCase().equals("PRAECANTATIO")){ - //Adds in Compat for older GT Versions which Misspell aspects. + } else if (aspect.toUpperCase().equals("PRAECANTATIO")) { + // Adds in Compat for older GT Versions which Misspell aspects. try { - if (EnumUtils.isValidEnum(TC_Aspects.class, "PRAECANTATIO")){ - Utils.LOG_WARNING("TC Aspect found - "+aspect); + 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"); + } 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 (final NoSuchFieldError r){ + } catch (final NoSuchFieldError r) { Utils.LOG_INFO("Invalid Thaumcraft Aspects - Report this issue to Alkalus"); } - } - else { - Utils.LOG_WARNING("TC Aspect found - "+aspect); + } else { + Utils.LOG_WARNING("TC Aspect found - " + aspect); returnValue = new TC_AspectStack(TC_Aspects.valueOf(aspect), size); } return returnValue; } - public static boolean containsMatch(final boolean strict, final ItemStack[] inputs, final ItemStack... targets) - { - for (final ItemStack input : inputs) - { - for (final ItemStack target : targets) - { - if (itemMatches(target, input, strict)) - { + public static boolean containsMatch(final boolean strict, final ItemStack[] inputs, final ItemStack... targets) { + for (final ItemStack input : inputs) { + for (final ItemStack target : targets) { + if (itemMatches(target, input, strict)) { return true; } } @@ -166,74 +157,73 @@ public class Utils { return false; } - public static boolean itemMatches(final ItemStack target, final ItemStack input, final boolean strict) - { - if ((input == null) || (target == null)) - { + public static boolean itemMatches(final ItemStack target, final ItemStack input, final boolean strict) { + if ((input == null) || (target == null)) { return false; } - return ((target.getItem() == input.getItem()) && (((target.getItemDamage() == WILDCARD_VALUE) && !strict) || (target.getItemDamage() == input.getItemDamage()))); + return ((target.getItem() == input.getItem()) && (((target.getItemDamage() == WILDCARD_VALUE) && !strict) + || (target.getItemDamage() == input.getItemDamage()))); } - //Logging Functions + // Logging Functions private static final Logger modLogger = makeLogger(); - //Generate GT++ Logger - public static Logger makeLogger(){ + // Generate GT++ Logger + public static Logger makeLogger() { final Logger gtPlusPlusLogger = LogManager.getLogger("GT++"); return gtPlusPlusLogger; } - - //Non-Dev Comments - public static void LOG_INFO(final String s){ - //if (CORE.DEBUG){ + // Non-Dev Comments + public static void LOG_INFO(final String s) { + // if (CORE.DEBUG){ modLogger.info(s); - //} + // } } - //Non-Dev Comments - public static void LOG_MACHINE_INFO(final String s){ - if (CORE.configSwitches.MACHINE_INFO || ClientProxy.playerName.toLowerCase().contains("draknyte1")){ + // Non-Dev Comments + public static void LOG_MACHINE_INFO(final String s) { + if (CORE.configSwitches.MACHINE_INFO || ClientProxy.playerName.toLowerCase().contains("draknyte1")) { String name1 = gtPlusPlus.core.util.reflect.ReflectionUtils.getMethodName(2); - modLogger.info("Machine Info: "+s+" | "+name1); + modLogger.info("Machine Info: " + s + " | " + name1); } } - //Developer Comments - public static void LOG_WARNING(final String s){ - if (CORE.DEBUG){ + // Developer Comments + public static void LOG_WARNING(final String s) { + if (CORE.DEBUG) { modLogger.warn(s); } } - //Errors - public static void LOG_ERROR(final String s){ - if (CORE.DEBUG){ + // Errors + public static void LOG_ERROR(final String s) { + if (CORE.DEBUG) { modLogger.fatal(s); } } - //Developer Logger - public static void LOG_SPECIFIC_WARNING(final String whatToLog, final String msg, final int line){ - //if (!CORE.DEBUG){ - FMLLog.warning("GT++ |"+line+"| "+whatToLog+" | "+msg); - //} + // Developer Logger + public static void LOG_SPECIFIC_WARNING(final String whatToLog, final String msg, final int line) { + // if (!CORE.DEBUG){ + FMLLog.warning("GT++ |" + line + "| " + whatToLog + " | " + msg); + // } } - //Non-Dev Comments - public static void LOG_ASM(final String s){ + // Non-Dev Comments + public static void LOG_ASM(final String s) { FMLRelaunchLog.info("", s); } - public static void paintBox(final Graphics g, final int MinA, final int MinB, final int MaxA, final int MaxB){ - g.drawRect (MinA, MinB, MaxA, MaxB); + public static void paintBox(final Graphics g, final int MinA, final int MinB, final int MaxA, final int MaxB) { + g.drawRect(MinA, MinB, MaxA, MaxB); } // Send a message to all players on the server public static void sendServerMessage(final String translationKey) { sendServerMessage(new ChatComponentText(translationKey)); } + // Send a message to all players on the server public static void sendServerMessage(final IChatComponent chatComponent) { MinecraftServer.getServer().getConfigurationManager().sendChatMsg(chatComponent); @@ -253,28 +243,26 @@ public class Utils { * Returns a Liquid Stack with given amount of IC2Steam. */ public static FluidStack getIC2Steam(final long aAmount) { - return FluidRegistry.getFluidStack("ic2steam", (int)aAmount); + return FluidRegistry.getFluidStack("ic2steam", (int) aAmount); } + /* + * public static void recipeBuilderBlock(ItemStack slot_1, ItemStack slot_2, + * ItemStack slot_3, ItemStack slot_4, ItemStack slot_5, ItemStack slot_6, + * ItemStack slot_7, ItemStack slot_8, ItemStack slot_9, Block resultBlock){ + * GameRegistry.addRecipe(new ItemStack(resultBlock), new Object[] {"ABC", + * "DEF", "GHI", 'A',slot_1,'B',slot_2,'C',slot_3, + * 'D',slot_4,'E',slot_5,'F',slot_6, 'G',slot_7,'H',slot_8,'I',slot_9 }); } + */ - - /*public static void recipeBuilderBlock(ItemStack slot_1, ItemStack slot_2, ItemStack slot_3, ItemStack slot_4, ItemStack slot_5, ItemStack slot_6, ItemStack slot_7, ItemStack slot_8, ItemStack slot_9, Block resultBlock){ - GameRegistry.addRecipe(new ItemStack(resultBlock), - new Object[] {"ABC", "DEF", "GHI", - 'A',slot_1,'B',slot_2,'C',slot_3, - 'D',slot_4,'E',slot_5,'F',slot_6, - 'G',slot_7,'H',slot_8,'I',slot_9 - }); - }*/ - - public static String checkCorrectMiningToolForBlock(final Block currentBlock, final World currentWorld){ + public static String checkCorrectMiningToolForBlock(final Block currentBlock, final World currentWorld) { String correctTool = ""; - if (!currentWorld.isRemote){ + if (!currentWorld.isRemote) { try { correctTool = currentBlock.getHarvestTool(0); Utils.LOG_WARNING(correctTool); - } catch (final NullPointerException e){ + } catch (final NullPointerException e) { } } @@ -284,14 +272,13 @@ public class Utils { /** * - * @param colourStr e.g. "#FFFFFF" + * @param colourStr + * e.g. "#FFFFFF" * @return String - formatted "rgb(0,0,0)" */ public static String hex2RgbFormatted(final String hexString) { - final Color c = new Color( - Integer.valueOf(hexString.substring(1, 3), 16), - Integer.valueOf(hexString.substring(3, 5), 16), - Integer.valueOf(hexString.substring(5, 7), 16)); + final Color c = new Color(Integer.valueOf(hexString.substring(1, 3), 16), + Integer.valueOf(hexString.substring(3, 5), 16), Integer.valueOf(hexString.substring(5, 7), 16)); final StringBuffer sb = new StringBuffer(); sb.append("rgb("); @@ -306,19 +293,19 @@ public class Utils { /** * - * @param colourStr e.g. "#FFFFFF" + * @param colourStr + * e.g. "#FFFFFF" * @return */ public static Color hex2Rgb(final String colorStr) { - return new Color( - Integer.valueOf( colorStr.substring( 1, 3 ), 16 ), - Integer.valueOf( colorStr.substring( 3, 5 ), 16 ), - Integer.valueOf( colorStr.substring( 5, 7 ), 16 ) ); + return new Color(Integer.valueOf(colorStr.substring(1, 3), 16), Integer.valueOf(colorStr.substring(3, 5), 16), + Integer.valueOf(colorStr.substring(5, 7), 16)); } /** * - * @param colourInt e.g. 0XFFFFFF + * @param colourInt + * e.g. 0XFFFFFF * @return Colour */ public static Color hex2Rgb(final int colourInt) { @@ -327,12 +314,14 @@ public class Utils { /** * - * @param colourInt e.g. 0XFFFFFF + * @param colourInt + * e.g. 0XFFFFFF * @return short[] */ public static short[] hex2RgbShort(final int colourInt) { final Color rgb = Color.decode(String.valueOf(colourInt)); - final short[] rgba = {(short) rgb.getRed(), (short) rgb.getGreen(), (short) rgb.getBlue(), (short) rgb.getAlpha()}; + final short[] rgba = { (short) rgb.getRed(), (short) rgb.getGreen(), (short) rgb.getBlue(), + (short) rgb.getAlpha() }; return rgba; } @@ -368,13 +357,14 @@ public class Utils { return targetList; } - public static void spawnCustomParticle(final Entity entity){ + public static void spawnCustomParticle(final Entity entity) { GTplusplus.proxy.generateMysteriousParticles(entity); } - public static void spawnFX(final World world, final int x, final int y, final int z, final String particleName, Object particleName2){ - if (!world.isRemote){ - if ((particleName2 == null) || particleName2.equals("")){ + public static void spawnFX(final World world, final int x, final int y, final int z, final String particleName, + Object particleName2) { + if (!world.isRemote) { + if ((particleName2 == null) || particleName2.equals("")) { particleName2 = particleName; } final int l = MathUtils.randInt(0, 4); @@ -384,43 +374,35 @@ public class Utils { final double d3 = 0.2199999988079071D; final double d4 = 0.27000001072883606D; - if (l == 1) - { + if (l == 1) { world.spawnParticle(particleName, d0 - d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D); - } - else if (l == 2) - { + } else if (l == 2) { world.spawnParticle((String) particleName2, d0 + d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D); - } - else if (l == 3) - { + } else if (l == 3) { world.spawnParticle(particleName, d0, d1 + d3, d2 - d4, 0.0D, 0.0D, 0.0D); - } - else if (l == 4) - { + } else if (l == 4) { world.spawnParticle((String) particleName2, d0, d1 + d3, d2 + d4, 0.0D, 0.0D, 0.0D); - } - else - { + } else { world.spawnParticle(particleName, d0, d1, d2, 0.0D, 0.0D, 0.0D); - if (particleName2 != null){ + if (particleName2 != null) { world.spawnParticle((String) particleName2, d0, d1, d2, 0.0D, 0.0D, 0.0D); } } } } - public static int rgbtoHexValue(final int r, final int g, final int b){ - if ((r > 255) || (g > 255) || (b > 255) || (r < 0) || (g < 0) || (b < 0)){ + public static int rgbtoHexValue(final int r, final int g, final int b) { + if ((r > 255) || (g > 255) || (b > 255) || (r < 0) || (g < 0) || (b < 0)) { return 0; } - final Color c = new Color(r,g,b); - String temp = Integer.toHexString( c.getRGB() & 0xFFFFFF ).toUpperCase(); + final Color c = new Color(r, g, b); + String temp = Integer.toHexString(c.getRGB() & 0xFFFFFF).toUpperCase(); - //System.out.println( "hex: " + Integer.toHexString( c.getRGB() & 0xFFFFFF ) + " hex value:"+temp); + // System.out.println( "hex: " + Integer.toHexString( c.getRGB() & + // 0xFFFFFF ) + " hex value:"+temp); temp = Utils.appenedHexNotationToString(String.valueOf(temp)); - Utils.LOG_WARNING("Made "+temp+" - Hopefully it's not a mess."); - Utils.LOG_WARNING("It will decode into "+Integer.decode(temp)+"."); + Utils.LOG_WARNING("Made " + temp + " - Hopefully it's not a mess."); + Utils.LOG_WARNING("It will decode into " + Integer.decode(temp) + "."); return Integer.decode(temp); } @@ -438,151 +420,151 @@ public class Utils { } /* - * Original Code by Chandana Napagoda - https://cnapagoda.blogspot.com.au/2011/03/java-hex-color-code-generator.html + * Original Code by Chandana Napagoda - + * https://cnapagoda.blogspot.com.au/2011/03/java-hex-color-code-generator. + * html */ - public static Map<Integer, String> hexColourGenerator(final int colorCount){ + public static Map<Integer, String> hexColourGenerator(final int colorCount) { final int maxColorValue = 16777215; // this is decimal value of the "FFFFFF" - final int devidedvalue = maxColorValue/colorCount; + final int devidedvalue = maxColorValue / colorCount; int countValue = 0; final HashMap<Integer, String> hexColorMap = new HashMap<>(); - for(int a=0; (a < colorCount) && (maxColorValue >= countValue) ; a++){ - if(a != 0){ - countValue+=devidedvalue; - hexColorMap.put(a,Integer.toHexString( 0x10000 | countValue).substring(1).toUpperCase()); - } - else { - hexColorMap.put(a,Integer.toHexString( 0x10000 | countValue).substring(1).toUpperCase()); + for (int a = 0; (a < colorCount) && (maxColorValue >= countValue); a++) { + if (a != 0) { + countValue += devidedvalue; + hexColorMap.put(a, Integer.toHexString(0x10000 | countValue).substring(1).toUpperCase()); + } else { + hexColorMap.put(a, Integer.toHexString(0x10000 | countValue).substring(1).toUpperCase()); } } return hexColorMap; } /* - * Original Code by Chandana Napagoda - https://cnapagoda.blogspot.com.au/2011/03/java-hex-color-code-generator.html + * Original Code by Chandana Napagoda - + * https://cnapagoda.blogspot.com.au/2011/03/java-hex-color-code-generator. + * html */ - public static Map<Integer, String> hexColourGeneratorRandom(final int colorCount){ + public static Map<Integer, String> hexColourGeneratorRandom(final int colorCount) { final HashMap<Integer, String> hexColorMap = new HashMap<>(); - for(int a=0;a < colorCount; a++){ - String code = ""+(int)(Math.random()*256); - code = code+code+code; - final int i = Integer.parseInt(code); - hexColorMap.put(a,Integer.toHexString( 0x1000000 | i).substring(1).toUpperCase()); - Utils.LOG_WARNING(""+Integer.toHexString( 0x1000000 | i).substring(1).toUpperCase()); + for (int a = 0; a < colorCount; a++) { + String code = "" + (int) (Math.random() * 256); + code = code + code + code; + final int i = Integer.parseInt(code); + hexColorMap.put(a, Integer.toHexString(0x1000000 | i).substring(1).toUpperCase()); + Utils.LOG_WARNING("" + Integer.toHexString(0x1000000 | i).substring(1).toUpperCase()); } return hexColorMap; } - public static String appenedHexNotationToString(final Object hexAsStringOrInt){ + public static String appenedHexNotationToString(final Object hexAsStringOrInt) { final String hexChar = "0x"; String result; - if (hexAsStringOrInt.getClass() == String.class){ + if (hexAsStringOrInt.getClass() == String.class) { - if (((String) hexAsStringOrInt).length() != 6){ + if (((String) hexAsStringOrInt).length() != 6) { final String temp = leftPadWithZeroes((String) hexAsStringOrInt, 6); result = temp; } - result = hexChar+hexAsStringOrInt; + result = hexChar + hexAsStringOrInt; return result; - } - else if (hexAsStringOrInt.getClass() == Integer.class){ - if (((String) hexAsStringOrInt).length() != 6){ + } else if (hexAsStringOrInt.getClass() == Integer.class) { + if (((String) hexAsStringOrInt).length() != 6) { final String temp = leftPadWithZeroes((String) hexAsStringOrInt, 6); result = temp; } - result = hexChar+String.valueOf(hexAsStringOrInt); + result = hexChar + String.valueOf(hexAsStringOrInt); return result; - } - else { + } else { return null; } } - public static Integer appenedHexNotationToInteger(final int hexAsStringOrInt){ + public static Integer appenedHexNotationToInteger(final int hexAsStringOrInt) { final String hexChar = "0x"; String result; Utils.LOG_WARNING(String.valueOf(hexAsStringOrInt)); - result = hexChar+String.valueOf(hexAsStringOrInt); + result = hexChar + String.valueOf(hexAsStringOrInt); return Integer.getInteger(result); } - public static boolean doesEntryExistAlreadyInOreDictionary(final String OreDictName){ + public static boolean doesEntryExistAlreadyInOreDictionary(final String OreDictName) { if (OreDictionary.getOres(OreDictName).size() != 0) { return true; } return false; } - public static boolean invertBoolean(final boolean booleans){ - if (booleans == true){ + public static boolean invertBoolean(final boolean booleans) { + if (booleans == true) { return false; } return true; } - - public static File getMcDir(){ - if (MinecraftServer.getServer() != null && MinecraftServer.getServer().isDedicatedServer()){ + + public static File getMcDir() { + if (MinecraftServer.getServer() != null && MinecraftServer.getServer().isDedicatedServer()) { return new File("."); } return Minecraft.getMinecraft().mcDataDir; } private static short cellID = 15; - public static ItemStack createInternalNameAndFluidCell(final String s){ + + public static ItemStack createInternalNameAndFluidCell(final String s) { Utils.LOG_WARNING("1"); final InternalName yourName = EnumHelper.addEnum(InternalName.class, s, new Class[0], new Object[0]); - Utils.LOG_WARNING("2 "+yourName.name()); - final ItemCell item = (ItemCell)Ic2Items.cell.getItem(); - Utils.LOG_WARNING("3 "+item.getUnlocalizedName()); - try - { + Utils.LOG_WARNING("2 " + yourName.name()); + final ItemCell item = (ItemCell) Ic2Items.cell.getItem(); + Utils.LOG_WARNING("3 " + item.getUnlocalizedName()); + try { Utils.LOG_WARNING("4"); final Class<? extends ItemCell> clz = item.getClass(); - Utils.LOG_WARNING("5 "+clz.getSimpleName()); + Utils.LOG_WARNING("5 " + clz.getSimpleName()); final Method methode = clz.getDeclaredMethod("addCell", int.class, InternalName.class, Block[].class); - Utils.LOG_WARNING("6 "+methode.getName()); + Utils.LOG_WARNING("6 " + methode.getName()); methode.setAccessible(true); - Utils.LOG_WARNING("7 "+methode.isAccessible()); + Utils.LOG_WARNING("7 " + methode.isAccessible()); final ItemStack temp = (ItemStack) methode.invoke(item, cellID++, yourName, new Block[0]); - Utils.LOG_WARNING("Successfully created "+temp.getDisplayName()+"s."); - FluidContainerRegistry.registerFluidContainer(FluidUtils.getFluidStack(s.toLowerCase(), 1000), temp.copy(), Ic2Items.cell.copy()); - ItemUtils.addItemToOreDictionary(temp.copy(), "cell"+s); + Utils.LOG_WARNING("Successfully created " + temp.getDisplayName() + "s."); + FluidContainerRegistry.registerFluidContainer(FluidUtils.getFluidStack(s.toLowerCase(), 1000), temp.copy(), + Ic2Items.cell.copy()); + ItemUtils.addItemToOreDictionary(temp.copy(), "cell" + s); return temp; - } - catch(final Exception e){ + } catch (final Exception e) { e.printStackTrace(); } return null; } - - public static ItemStack createInternalNameAndFluidCellNoOreDict(final String s){ + + public static ItemStack createInternalNameAndFluidCellNoOreDict(final String s) { Utils.LOG_WARNING("1"); final InternalName yourName = EnumHelper.addEnum(InternalName.class, s, new Class[0], new Object[0]); - Utils.LOG_WARNING("2 "+yourName.name()); - final ItemCell item = (ItemCell)Ic2Items.cell.getItem(); - Utils.LOG_WARNING("3 "+item.getUnlocalizedName()); - try - { + Utils.LOG_WARNING("2 " + yourName.name()); + final ItemCell item = (ItemCell) Ic2Items.cell.getItem(); + Utils.LOG_WARNING("3 " + item.getUnlocalizedName()); + try { Utils.LOG_WARNING("4"); final Class<? extends ItemCell> clz = item.getClass(); - Utils.LOG_WARNING("5 "+clz.getSimpleName()); + Utils.LOG_WARNING("5 " + clz.getSimpleName()); final Method methode = clz.getDeclaredMethod("addCell", int.class, InternalName.class, Block[].class); - Utils.LOG_WARNING("6 "+methode.getName()); + Utils.LOG_WARNING("6 " + methode.getName()); methode.setAccessible(true); - Utils.LOG_WARNING("7 "+methode.isAccessible()); + Utils.LOG_WARNING("7 " + methode.isAccessible()); final ItemStack temp = (ItemStack) methode.invoke(item, cellID++, yourName, new Block[0]); - Utils.LOG_WARNING("Successfully created "+temp.getDisplayName()+"s."); - FluidContainerRegistry.registerFluidContainer(FluidUtils.getFluidStack(s.toLowerCase(), 1000), temp.copy(), Ic2Items.cell.copy()); - //ItemUtils.addItemToOreDictionary(temp.copy(), "cell"+s); + Utils.LOG_WARNING("Successfully created " + temp.getDisplayName() + "s."); + FluidContainerRegistry.registerFluidContainer(FluidUtils.getFluidStack(s.toLowerCase(), 1000), temp.copy(), + Ic2Items.cell.copy()); + // ItemUtils.addItemToOreDictionary(temp.copy(), "cell"+s); return temp; - } - catch(final Exception e){ + } catch (final Exception e) { e.printStackTrace(); } return null; } - public static String sanitizeString(final String input){ + public static String sanitizeString(final String input) { String temp; String output; @@ -605,7 +587,7 @@ public class Utils { } - public static String sanitizeStringKeepBrackets(final String input){ + public static String sanitizeStringKeepBrackets(final String input) { String temp; String output; @@ -621,93 +603,79 @@ public class Utils { return output; } - - public static int calculateVoltageTier(int Voltage){ + + public static int calculateVoltageTier(int Voltage) { int V; - if (Voltage == 8){ + if (Voltage == 8) { V = 0; - } - else if (Voltage == 32){ + } else if (Voltage == 32) { V = 1; - } - else if (Voltage == 128){ + } else if (Voltage == 128) { V = 2; - } - else if (Voltage == 512){ + } else if (Voltage == 512) { V = 3; - } - else if (Voltage == 2048){ + } else if (Voltage == 2048) { V = 4; - } - else if (Voltage == 8196){ + } else if (Voltage == 8196) { V = 5; - } - else if (Voltage == 32768){ + } else if (Voltage == 32768) { V = 6; - } - else if (Voltage == 131072){ + } else if (Voltage == 131072) { V = 7; - } - else if (Voltage == 524288){ + } else if (Voltage == 524288) { V = 8; - } - else if (Voltage == Integer.MAX_VALUE){ + } else if (Voltage == Integer.MAX_VALUE) { V = 9; - } - else { + } else { V = -1; } return V; } - public static String[] parseVersion(final String version){ + public static String[] parseVersion(final String version) { return parseVersion(version, "//."); } - public static String[] parseVersion(final String version, final String delimiter){ + public static String[] parseVersion(final String version, final String delimiter) { final String[] versionArray = version.split(delimiter); return versionArray; } - public static Versioning compareModVersion (final String currentVersion, final String expectedVersion){ + public static Versioning compareModVersion(final String currentVersion, final String expectedVersion) { return compareModVersion(currentVersion, expectedVersion, "//."); } - public static Versioning compareModVersion (final String currentVersion, final String expectedVersion, final String delimiter){ + public static Versioning compareModVersion(final String currentVersion, final String expectedVersion, + final String delimiter) { final String[] a = parseVersion(currentVersion, delimiter); final String[] b = parseVersion(expectedVersion, delimiter); final int[] c = new int[a.length]; final int[] d = new int[b.length]; - for (int r=0;r<a.length;r++){ - c[r]=Integer.parseInt(a[r]); + for (int r = 0; r < a.length; r++) { + c[r] = Integer.parseInt(a[r]); } - for (int r=0;r<b.length;r++){ - d[r]=Integer.parseInt(b[r]); + for (int r = 0; r < b.length; r++) { + d[r] = Integer.parseInt(b[r]); } final Versioning[] e = new Versioning[MathUtils.returnLargestNumber(c.length, d.length)]; - for (int r=0;r<e.length;r++){ + for (int r = 0; r < e.length; r++) { - - if (c[r] > d[r]){ + if (c[r] > d[r]) { e[r] = Versioning.NEWER; - } - else if (c[r] < d[r]){ + } else if (c[r] < d[r]) { e[r] = Versioning.OLDER; - } - else if (c[r] == d[r]){ + } else if (c[r] == d[r]) { e[r] = Versioning.EQUAL; } } - for (int r=0;r<e.length;r++){ - if (e[0] == Versioning.NEWER){ + for (int r = 0; r < e.length; r++) { + if (e[0] == Versioning.NEWER) { return Versioning.NEWER; - } - else if (e[0] == Versioning.OLDER){ + } else if (e[0] == Versioning.OLDER) { return Versioning.OLDER; - } - else { - if (e[r] == Versioning.OLDER){ + } else { + if (e[r] == Versioning.OLDER) { } @@ -718,85 +686,74 @@ public class Utils { return null; } - - - public static ToolMaterial generateToolMaterialFromGT(final Materials gtMaterial){ + public static ToolMaterial generateToolMaterialFromGT(final Materials gtMaterial) { final String name = Utils.sanitizeString(gtMaterial.mDefaultLocalName); final int harvestLevel = gtMaterial.mToolQuality; final int durability = gtMaterial.mDurability; final float damage = gtMaterial.mToolQuality; final int efficiency = (int) gtMaterial.mToolSpeed; final int enchantability = gtMaterial.mEnchantmentToolsLevel; - final ToolMaterial temp = EnumHelper.addToolMaterial(name, harvestLevel, durability, efficiency, damage, enchantability); + final ToolMaterial temp = EnumHelper.addToolMaterial(name, harvestLevel, durability, efficiency, damage, + enchantability); return temp; } - public static ToolMaterial generateToolMaterial(final Material material){ + public static ToolMaterial generateToolMaterial(final Material material) { final String name = material.getLocalizedName(); final int harvestLevel = material.vHarvestLevel; final int durability = (int) material.vDurability; final float damage = material.vToolQuality; final int efficiency = material.vToolQuality; - //int enchantability = material.mEnchantmentToolsLevel; - Utils.LOG_INFO("ToolMaterial stats for "+material.getLocalizedName()+" | harvestLevel:"+harvestLevel+" | durability:"+durability+" | toolQuality:"+damage+" | toolSpeed:"+damage); + // int enchantability = material.mEnchantmentToolsLevel; + Utils.LOG_INFO("ToolMaterial stats for " + material.getLocalizedName() + " | harvestLevel:" + harvestLevel + + " | durability:" + durability + " | toolQuality:" + damage + " | toolSpeed:" + damage); final ToolMaterial temp = EnumHelper.addToolMaterial(name, harvestLevel, durability, efficiency, damage, 0); return temp; } - - - - - - - - - - - public static enum Versioning { - EQUAL(0), - NEWER(1), - OLDER(-1); + EQUAL(0), NEWER(1), OLDER(-1); private final int versioningInfo; - private Versioning (final int versionStatus){ + + private Versioning(final int versionStatus) { this.versioningInfo = versionStatus; } + public int getTexture() { return this.versioningInfo; } } - private static int sBookCount = 0; - public static int getBookCount(){ + + public static int getBookCount() { return sBookCount; } - - public static ItemStack getWrittenBook(ItemStack aBook, int aID, String aMapping, String aTitle, String aAuthor, String[] aPages) { + + public static ItemStack getWrittenBook(ItemStack aBook, int aID, String aMapping, String aTitle, String aAuthor, + String[] aPages) { if (GT_Utility.isStringInvalid(aMapping)) return null; ItemStack rStack = (ItemStack) CORE.sBookList.get(aMapping); if (rStack != null) - return GT_Utility.copyAmount(1L, new Object[]{rStack}); + return GT_Utility.copyAmount(1L, new Object[] { rStack }); if ((GT_Utility.isStringInvalid(aTitle)) || (GT_Utility.isStringInvalid(aAuthor)) || (aPages.length <= 0)) return null; sBookCount += 1; int vMeta = (aID == -1 ? sBookCount : aID); - rStack = (aBook == null ? new ItemStack(ModItems.itemCustomBook, 1, vMeta) : aBook); + rStack = (aBook == null ? new ItemStack(ModItems.itemCustomBook, 1, vMeta) : aBook); NBTTagCompound tNBT = new NBTTagCompound(); tNBT.setString("title", GT_LanguageManager.addStringLocalization( new StringBuilder().append("Book.").append(aTitle).append(".Name").toString(), aTitle)); tNBT.setString("author", aAuthor); NBTTagList tNBTList = new NBTTagList(); for (byte i = 0; i < aPages.length; i = (byte) (i + 1)) { - aPages[i] = GT_LanguageManager.addStringLocalization( - new StringBuilder().append("Book.").append(aTitle).append(".Page").append((i < 10) - ? new StringBuilder().append("0").append(i).toString() - : Byte.valueOf(i)).toString(), - aPages[i]); + aPages[i] = GT_LanguageManager + .addStringLocalization(new StringBuilder().append("Book.").append(aTitle).append(".Page") + .append((i < 10) ? new StringBuilder().append("0").append(i).toString() : Byte.valueOf(i)) + .toString(), aPages[i]); if (i < 48) { if (aPages[i].length() < 256) tNBTList.appendTag(new NBTTagString(aPages[i])); @@ -814,16 +771,13 @@ public class Utils { .append(" at its creation. Gotta get 'em all!").toString())); tNBT.setTag("pages", tNBTList); rStack.setTagCompound(tNBT); - GT_Log.out.println(new StringBuilder().append("GT++_Mod: Added Book to Book++ List - Mapping: '").append(aMapping) - .append("' - Name: '").append(aTitle).append("' - Author: '").append(aAuthor).append("'") - .toString()); + GT_Log.out.println(new StringBuilder().append("GT++_Mod: Added Book to Book++ List - Mapping: '") + .append(aMapping).append("' - Name: '").append(aTitle).append("' - Author: '").append(aAuthor) + .append("'").toString()); NBTUtils.createIntegerTagCompound(rStack, "stats", "mMeta", vMeta); CORE.sBookList.put(aMapping, rStack); - Utils.LOG_INFO("Creating book: "+aTitle+" by "+aAuthor+". Using Meta "+vMeta+"."); - return GT_Utility.copy(new Object[]{rStack}); + Utils.LOG_INFO("Creating book: " + aTitle + " by " + aAuthor + ". Using Meta " + vMeta + "."); + return GT_Utility.copy(new Object[] { rStack }); } - } - - diff --git a/src/Java/gtPlusPlus/core/util/UtilsChatFormatting.java b/src/Java/gtPlusPlus/core/util/UtilsChatFormatting.java index f340e9be59..a7945311d6 100644 --- a/src/Java/gtPlusPlus/core/util/UtilsChatFormatting.java +++ b/src/Java/gtPlusPlus/core/util/UtilsChatFormatting.java @@ -6,55 +6,41 @@ import java.util.regex.Pattern; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -public enum UtilsChatFormatting -{ - BLACK('0'), - DARK_BLUE('1'), - DARK_GREEN('2'), - DARK_AQUA('3'), - DARK_RED('4'), - DARK_PURPLE('5'), - GOLD('6'), - GRAY('7'), - DARK_GRAY('8'), - BLUE('9'), - GREEN('a'), - AQUA('b'), - RED('c'), - LIGHT_PURPLE('d'), - YELLOW('e'), - WHITE('f'), - OBFUSCATED('k', true), - BOLD('l', true), - STRIKETHROUGH('m', true), - UNDERLINE('n', true), - ITALIC('o', true), - RESET('r'); - /** Maps a formatting code (e.g., 'f') to its corresponding enum value (e.g., WHITE). */ +public enum UtilsChatFormatting { + BLACK('0'), DARK_BLUE('1'), DARK_GREEN('2'), DARK_AQUA('3'), DARK_RED('4'), DARK_PURPLE('5'), GOLD('6'), GRAY( + '7'), DARK_GRAY('8'), BLUE('9'), GREEN('a'), AQUA('b'), RED('c'), LIGHT_PURPLE('d'), YELLOW('e'), WHITE( + 'f'), OBFUSCATED('k', true), BOLD('l', + true), STRIKETHROUGH('m', true), UNDERLINE('n', true), ITALIC('o', true), RESET('r'); + /** + * Maps a formatting code (e.g., 'f') to its corresponding enum value (e.g., + * WHITE). + */ private static final Map<Character, UtilsChatFormatting> formattingCodeMapping = new HashMap<>(); - /** Maps a name (e.g., 'underline') to its corresponding enum value (e.g., UNDERLINE). */ + /** + * Maps a name (e.g., 'underline') to its corresponding enum value (e.g., + * UNDERLINE). + */ private static final Map<String, UtilsChatFormatting> nameMapping = new HashMap<>(); /** - * Matches formatting codes that indicate that the client should treat the following text as bold, recolored, - * obfuscated, etc. + * Matches formatting codes that indicate that the client should treat the + * following text as bold, recolored, obfuscated, etc. */ - private static final Pattern formattingCodePattern = Pattern.compile("(?i)" + String.valueOf('\u00a7') + "[0-9A-FK-OR]"); + private static final Pattern formattingCodePattern = Pattern + .compile("(?i)" + String.valueOf('\u00a7') + "[0-9A-FK-OR]"); /** The formatting code that produces this format. */ private final char formattingCode; private final boolean fancyStyling; /** - * The control string (section sign + formatting code) that can be inserted into client-side text to display - * subsequent text in this format. + * The control string (section sign + formatting code) that can be inserted + * into client-side text to display subsequent text in this format. */ private final String controlString; - private UtilsChatFormatting(final char p_i1336_3_) - { + private UtilsChatFormatting(final char p_i1336_3_) { this(p_i1336_3_, false); } - private UtilsChatFormatting(final char p_i1337_3_, final boolean p_i1337_4_) - { + private UtilsChatFormatting(final char p_i1337_3_, final boolean p_i1337_4_) { this.formattingCode = p_i1337_3_; this.fancyStyling = p_i1337_4_; this.controlString = "\u00a7" + p_i1337_3_; @@ -63,38 +49,33 @@ public enum UtilsChatFormatting /** * Gets the formatting code that produces this format. */ - public char getFormattingCode() - { + public char getFormattingCode() { return this.formattingCode; } /** * False if this is just changing the color or resetting; true otherwise. */ - public boolean isFancyStyling() - { + public boolean isFancyStyling() { return this.fancyStyling; } /** * Checks if typo is a color. */ - public boolean isColor() - { + public boolean isColor() { return !this.fancyStyling && (this != RESET); } /** * Gets the friendly name of this value. */ - public String getFriendlyName() - { + public String getFriendlyName() { return this.name().toLowerCase(); } @Override - public String toString() - { + public String toString() { return this.controlString; } @@ -102,35 +83,32 @@ public enum UtilsChatFormatting * Returns a copy of the given string, with formatting codes stripped away. */ @SideOnly(Side.CLIENT) - public static String getTextWithoutFormattingCodes(final String p_110646_0_) - { + public static String getTextWithoutFormattingCodes(final String p_110646_0_) { return p_110646_0_ == null ? null : formattingCodePattern.matcher(p_110646_0_).replaceAll(""); } /** - * Gets a value by its friendly name; null if the given name does not map to a defined value. + * Gets a value by its friendly name; null if the given name does not map to + * a defined value. */ - public static UtilsChatFormatting getValueByName(final String p_96300_0_) - { - return p_96300_0_ == null ? null : (UtilsChatFormatting)nameMapping.get(p_96300_0_.toLowerCase()); + public static UtilsChatFormatting getValueByName(final String p_96300_0_) { + return p_96300_0_ == null ? null : (UtilsChatFormatting) nameMapping.get(p_96300_0_.toLowerCase()); } /** - * Gets all the valid values. Args: @param par0: Whether or not to include color values. @param par1: Whether or not - * to include fancy-styling values (anything that isn't a color value or the "reset" value). + * Gets all the valid values. Args: @param par0: Whether or not to include + * color values. @param par1: Whether or not to include fancy-styling values + * (anything that isn't a color value or the "reset" value). */ - public static Collection<String> getValidValues(final boolean p_96296_0_, final boolean p_96296_1_) - { + public static Collection<String> getValidValues(final boolean p_96296_0_, final boolean p_96296_1_) { final ArrayList<String> arraylist = new ArrayList<>(); final UtilsChatFormatting[] aenumchatformatting = values(); final int i = aenumchatformatting.length; - for (int j = 0; j < i; ++j) - { + for (int j = 0; j < i; ++j) { final UtilsChatFormatting enumchatformatting = aenumchatformatting[j]; - if ((!enumchatformatting.isColor() || p_96296_0_) && (!enumchatformatting.isFancyStyling() || p_96296_1_)) - { + if ((!enumchatformatting.isColor() || p_96296_0_) && (!enumchatformatting.isFancyStyling() || p_96296_1_)) { arraylist.add(enumchatformatting.getFriendlyName()); } } @@ -138,13 +116,11 @@ public enum UtilsChatFormatting return arraylist; } - static - { + static { final UtilsChatFormatting[] var0 = values(); final int var1 = var0.length; - for (int var2 = 0; var2 < var1; ++var2) - { + for (int var2 = 0; var2 < var1; ++var2) { final UtilsChatFormatting var3 = var0[var2]; formattingCodeMapping.put(Character.valueOf(var3.getFormattingCode()), var3); nameMapping.put(var3.getFriendlyName(), var3); diff --git a/src/Java/gtPlusPlus/core/util/UtilsRarity.java b/src/Java/gtPlusPlus/core/util/UtilsRarity.java index 78f3a10bdb..54f4ba8c07 100644 --- a/src/Java/gtPlusPlus/core/util/UtilsRarity.java +++ b/src/Java/gtPlusPlus/core/util/UtilsRarity.java @@ -2,21 +2,16 @@ package gtPlusPlus.core.util; import net.minecraft.util.EnumChatFormatting; -public enum UtilsRarity -{ - T1_poor(EnumChatFormatting.GRAY, "Poor"), - T2_normal(EnumChatFormatting.WHITE, "Common"), - T3_uncommon(EnumChatFormatting.GREEN, "Uncommon"), - T4_magic(EnumChatFormatting.BLUE, "Magic"), - T5_rare(EnumChatFormatting.LIGHT_PURPLE, "Rare"), - T6_epic(EnumChatFormatting.YELLOW, "Epic"), - T8_unique(EnumChatFormatting.GOLD, "Unique"); +public enum UtilsRarity { + T1_poor(EnumChatFormatting.GRAY, "Poor"), T2_normal(EnumChatFormatting.WHITE, "Common"), T3_uncommon( + EnumChatFormatting.GREEN, + "Uncommon"), T4_magic(EnumChatFormatting.BLUE, "Magic"), T5_rare(EnumChatFormatting.LIGHT_PURPLE, + "Rare"), T6_epic(EnumChatFormatting.YELLOW, "Epic"), T8_unique(EnumChatFormatting.GOLD, "Unique"); public final EnumChatFormatting rarityColor; public final String rarityName; - private UtilsRarity(final EnumChatFormatting rarity, final String name) - { + private UtilsRarity(final EnumChatFormatting rarity, final String name) { this.rarityColor = rarity; this.rarityName = name; } diff --git a/src/Java/gtPlusPlus/core/util/UtilsText.java b/src/Java/gtPlusPlus/core/util/UtilsText.java index 6d26676ce3..0db7dd35a2 100644 --- a/src/Java/gtPlusPlus/core/util/UtilsText.java +++ b/src/Java/gtPlusPlus/core/util/UtilsText.java @@ -2,31 +2,17 @@ package gtPlusPlus.core.util; public enum UtilsText { - blue('1'), - green('2'), - teal('3'), - maroon('4'), - purple('5'), - orange('6'), - lightGray('7'), - darkGray('8'), - lightBlue('9'), - black('0'), - lime('a'), - aqua('b'), - red('c'), - pink('d'), - yellow('e'), - white('f'); + blue('1'), green('2'), teal('3'), maroon('4'), purple('5'), orange('6'), lightGray('7'), darkGray('8'), lightBlue( + '9'), black('0'), lime('a'), aqua('b'), red('c'), pink('d'), yellow('e'), white('f'); private char colourValue; - private UtilsText (final char value) - { + + private UtilsText(final char value) { this.colourValue = value; } public String colour() { - return "�"+this.colourValue; + return "�" + this.colourValue; } } diff --git a/src/Java/gtPlusPlus/core/util/nbt/ModularArmourUtils.java b/src/Java/gtPlusPlus/core/util/nbt/ModularArmourUtils.java index 81981bbac5..5d9da4da1e 100644 --- a/src/Java/gtPlusPlus/core/util/nbt/ModularArmourUtils.java +++ b/src/Java/gtPlusPlus/core/util/nbt/ModularArmourUtils.java @@ -4,8 +4,6 @@ import baubles.api.BaubleType; import gregtech.api.util.GT_Utility; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.array.Pair; -import gtPlusPlus.core.util.nbt.ModularArmourUtils.Modifiers; -import net.minecraft.block.Block.SoundType; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; diff --git a/src/Java/gtPlusPlus/core/util/nbt/NBTUtils.java b/src/Java/gtPlusPlus/core/util/nbt/NBTUtils.java index c5f3942997..817dc9807f 100644 --- a/src/Java/gtPlusPlus/core/util/nbt/NBTUtils.java +++ b/src/Java/gtPlusPlus/core/util/nbt/NBTUtils.java @@ -206,7 +206,7 @@ public class NBTUtils { NBTTagCompound aNBT = NBTUtils.getNBT(aStack); if (aNBT != null) { if (!aNBT.hasNoTags()) { - int tagCount = 0; + // int tagCount = 0; Map<?, ?> mInternalMap = ReflectionUtils.getField(aNBT, "tagMap"); if (mInternalMap != null) { @@ -250,44 +250,44 @@ public class NBTUtils { return tNBT.getString(TAG_SOULBIND); } - public static boolean hasKey(ItemStack stack, String key){ - if (stack.hasTagCompound()) { + public static boolean hasKey(ItemStack stack, String key) { + if (stack.hasTagCompound()) { final NBTTagCompound itemData = stack.getTagCompound(); - if (itemData.hasKey(key)){ + if (itemData.hasKey(key)) { return true; } } return false; } - - public static boolean createIntegerTagCompound(ItemStack rStack, String tagName, String keyName, int keyValue){ + + public static boolean createIntegerTagCompound(ItemStack rStack, String tagName, String keyName, int keyValue) { final NBTTagCompound tagMain = new NBTTagCompound(); final NBTTagCompound tagNBT = new NBTTagCompound(); tagNBT.setInteger(keyName, keyValue); - tagMain.setTag(tagName, tagNBT); - rStack.setTagCompound(tagMain); + tagMain.setTag(tagName, tagNBT); + rStack.setTagCompound(tagMain); return true; } - - public static boolean createLongTagCompound(ItemStack rStack, String tagName, String keyName, long keyValue){ + + public static boolean createLongTagCompound(ItemStack rStack, String tagName, String keyName, long keyValue) { final NBTTagCompound tagMain = new NBTTagCompound(); final NBTTagCompound tagNBT = new NBTTagCompound(); tagNBT.setLong(keyName, keyValue); - tagMain.setTag(tagName, tagNBT); - rStack.setTagCompound(tagMain); + tagMain.setTag(tagName, tagNBT); + rStack.setTagCompound(tagMain); return true; } - - public static boolean createStringTagCompound(ItemStack rStack, String tagName, String keyName, String keyValue){ + + public static boolean createStringTagCompound(ItemStack rStack, String tagName, String keyName, String keyValue) { final NBTTagCompound tagMain = new NBTTagCompound(); final NBTTagCompound tagNBT = new NBTTagCompound(); tagNBT.setString(keyName, keyValue); - tagMain.setTag(tagName, tagNBT); - rStack.setTagCompound(tagMain); + tagMain.setTag(tagName, tagNBT); + rStack.setTagCompound(tagMain); return true; } - - public static int getIntegerTagCompound(ItemStack aStack, String tagName, String keyName){ + + public static int getIntegerTagCompound(ItemStack aStack, String tagName, String keyName) { NBTTagCompound aNBT = aStack.getTagCompound(); if (aNBT != null) { aNBT = aNBT.getCompoundTag(tagName); @@ -297,8 +297,8 @@ public class NBTUtils { } return 0; } - - public static long getLongTagCompound(ItemStack aStack, String tagName, String keyName){ + + public static long getLongTagCompound(ItemStack aStack, String tagName, String keyName) { NBTTagCompound aNBT = aStack.getTagCompound(); if (aNBT != null) { aNBT = aNBT.getCompoundTag(tagName); @@ -308,8 +308,8 @@ public class NBTUtils { } return 0L; } - - public static String getStringTagCompound(ItemStack aStack, String tagName, String keyName){ + + public static String getStringTagCompound(ItemStack aStack, String tagName, String keyName) { NBTTagCompound aNBT = aStack.getTagCompound(); if (aNBT != null) { aNBT = aNBT.getCompoundTag(tagName); @@ -319,8 +319,8 @@ public class NBTUtils { } return null; } - - public static boolean hasKeyInTagCompound(ItemStack stack, String tag, String key){ + + public static boolean hasKeyInTagCompound(ItemStack stack, String tag, String key) { NBTTagCompound aNBT = stack.getTagCompound(); if (aNBT != null) { aNBT = aNBT.getCompoundTag(tag); |