aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/core/util
diff options
context:
space:
mode:
authorAlkalus <draknyte1@hotmail.com>2017-11-14 23:34:28 +1000
committerAlkalus <draknyte1@hotmail.com>2017-11-14 23:34:28 +1000
commit390ac495e051df79017840504912adda10b04584 (patch)
tree9244c2d2f3af66250dd21a9258c5c7afa8835921 /src/Java/gtPlusPlus/core/util
parent9ca3689c05efa82a4b5efe3f8d3b6013ebd54cd5 (diff)
downloadGT5-Unofficial-390ac495e051df79017840504912adda10b04584.tar.gz
GT5-Unofficial-390ac495e051df79017840504912adda10b04584.tar.bz2
GT5-Unofficial-390ac495e051df79017840504912adda10b04584.zip
% Formatting changes.
Diffstat (limited to 'src/Java/gtPlusPlus/core/util')
-rw-r--r--src/Java/gtPlusPlus/core/util/ClassUtils.java45
-rw-r--r--src/Java/gtPlusPlus/core/util/Log.java15
-rw-r--r--src/Java/gtPlusPlus/core/util/LoggingUtils.java14
-rw-r--r--src/Java/gtPlusPlus/core/util/PollutionUtils.java29
-rw-r--r--src/Java/gtPlusPlus/core/util/Quality.java51
-rw-r--r--src/Java/gtPlusPlus/core/util/Utils.java526
-rw-r--r--src/Java/gtPlusPlus/core/util/UtilsChatFormatting.java102
-rw-r--r--src/Java/gtPlusPlus/core/util/UtilsRarity.java17
-rw-r--r--src/Java/gtPlusPlus/core/util/UtilsText.java24
-rw-r--r--src/Java/gtPlusPlus/core/util/nbt/ModularArmourUtils.java2
-rw-r--r--src/Java/gtPlusPlus/core/util/nbt/NBTUtils.java48
11 files changed, 387 insertions, 486 deletions
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(OreDict