From cbe0e497be8e466c380a5b4fa781b314ede9ada3 Mon Sep 17 00:00:00 2001 From: Draknyte1 Date: Sun, 6 Nov 2016 19:32:27 +1000 Subject: Revert "$ Cleaned up the entire project." This reverts commit 0669f5eb9d5029a8b94ec552171b0837605f7747. # Conflicts: # src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMTE_NuclearReactor.java # src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_MassFabricator.java Revert "% Cleaned up Imports." This reverts commit 3654052fb63a571c5eaca7f20714b87c17f7e966. --- src/Java/gtPlusPlus/core/util/BaseHandler.java | 8 +- src/Java/gtPlusPlus/core/util/ClassUtils.java | 83 +- src/Java/gtPlusPlus/core/util/Log.java | 41 +- src/Java/gtPlusPlus/core/util/LoggingUtils.java | 60 +- src/Java/gtPlusPlus/core/util/Quality.java | 87 +- src/Java/gtPlusPlus/core/util/Utils.java | 741 ++++----- .../gtPlusPlus/core/util/UtilsChatFormatting.java | 271 +-- src/Java/gtPlusPlus/core/util/UtilsRarity.java | 29 +- src/Java/gtPlusPlus/core/util/UtilsText.java | 24 +- .../gtPlusPlus/core/util/array/ArrayUtils.java | 16 +- src/Java/gtPlusPlus/core/util/array/Pair.java | 28 +- src/Java/gtPlusPlus/core/util/array/Triplet.java | 38 +- .../core/util/debug/DEBUG_BLOCK_ShapeSpawner.java | 145 +- .../gtPlusPlus/core/util/debug/DEBUG_INIT.java | 29 +- .../core/util/debug/DEBUG_ITEM_ShapeSpawner.java | 51 +- .../util/debug/DEBUG_MULTIBLOCK_ShapeSpawner.java | 1722 +++++++++----------- .../core/util/debug/DEBUG_ScreenOverlay.java | 60 +- .../core/util/debug/DEBUG_TimerThread.java | 71 +- .../core/util/debug/UtilityGL11Debug.java | 853 ++++------ .../gtPlusPlus/core/util/entity/EntityUtils.java | 92 +- src/Java/gtPlusPlus/core/util/fluid/FluidGT6.java | 42 +- .../gtPlusPlus/core/util/fluid/FluidUtils.java | 539 +++--- .../gregtech/recipehandlers/GregtechRecipe.java | 74 +- src/Java/gtPlusPlus/core/util/item/ItemUtils.java | 681 ++++---- .../core/util/materials/MaterialUtils.java | 343 ++-- src/Java/gtPlusPlus/core/util/math/MathUtils.java | 376 ++--- .../core/util/networking/NetworkUtils.java | 50 +- .../util/particles/EntityParticleFXMysterious.java | 19 +- .../gtPlusPlus/core/util/player/PlayerCache.java | 282 ++-- .../gtPlusPlus/core/util/player/PlayerUtils.java | 179 +- .../gtPlusPlus/core/util/player/UtilsMining.java | 204 ++- .../gtPlusPlus/core/util/recipe/RecipeUtils.java | 648 +++----- .../core/util/recipe/shapeless/ShapelessUtils.java | 46 +- .../core/util/reflect/ClientProxyFinder.java | 43 +- .../core/util/reflect/ReflectionUtils.java | 81 +- src/Java/gtPlusPlus/core/util/wrapper/var.java | 116 +- 36 files changed, 3812 insertions(+), 4360 deletions(-) (limited to 'src/Java/gtPlusPlus/core/util') diff --git a/src/Java/gtPlusPlus/core/util/BaseHandler.java b/src/Java/gtPlusPlus/core/util/BaseHandler.java index e8fb919ab0..63f22f3763 100644 --- a/src/Java/gtPlusPlus/core/util/BaseHandler.java +++ b/src/Java/gtPlusPlus/core/util/BaseHandler.java @@ -2,10 +2,10 @@ package gtPlusPlus.core.util; public abstract class BaseHandler { + public abstract void preInit(); + public abstract void init(); - + public abstract void postInit(); - - public abstract void preInit(); - + } diff --git a/src/Java/gtPlusPlus/core/util/ClassUtils.java b/src/Java/gtPlusPlus/core/util/ClassUtils.java index e58c2f2785..ba3db748f9 100644 --- a/src/Java/gtPlusPlus/core/util/ClassUtils.java +++ b/src/Java/gtPlusPlus/core/util/ClassUtils.java @@ -1,56 +1,70 @@ package gtPlusPlus.core.util; -import java.lang.reflect.*; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; public class ClassUtils { - public static Method getMethodViaReflection(final Class lookupClass, final String methodName, - final boolean invoke) throws Exception { - final Class lookup = lookupClass.getClass(); - final Method m = lookup.getDeclaredMethod(methodName); - m.setAccessible(true);// Abracadabra - if (invoke) { + + /*@ 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(String className) { + try { + Class.forName(className); + return true; + } catch (Throwable ex) { + // Class or one of its dependencies is not present... + return false; + } + } + + public static Method getMethodViaReflection(Class lookupClass, String methodName, boolean invoke) throws Exception{ + Class lookup = lookupClass.getClass(); + Method m = lookup.getDeclaredMethod(methodName); + m.setAccessible(true);// Abracadabra + if (invoke){ m.invoke(lookup);// now its OK } return m; } - public static Class getNonPublicClass(final String className) { + public static Class getNonPublicClass(String className){ Class c = null; try { c = Class.forName(className); - } - catch (final ClassNotFoundException e) { + } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } - // full package name --------^^^^^^^^^^ - // or simpler without Class.forName: - // Class c = package1.A.class; + //full package name --------^^^^^^^^^^ + //or simpler without Class.forName: + //Class 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(); - } - catch (NoSuchMethodException | SecurityException e) { + } catch (NoSuchMethodException | SecurityException e) { // 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(); + 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(); } @@ -59,21 +73,6 @@ public class ClassUtils { return null; } - /* - * @ 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); - return true; - } - catch (final Throwable ex) { - // Class or one of its dependencies is not present... - return false; - } - } + } diff --git a/src/Java/gtPlusPlus/core/util/Log.java b/src/Java/gtPlusPlus/core/util/Log.java index 460f8598dc..ea7076e453 100644 --- a/src/Java/gtPlusPlus/core/util/Log.java +++ b/src/Java/gtPlusPlus/core/util/Log.java @@ -3,22 +3,27 @@ package gtPlusPlus.core.util; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -public final class Log { - public static final Logger LOGGER = LogManager.getLogger("MiscUtils"); - - public static void debug(final String msg) { - Log.LOGGER.debug(msg); - } - - public static void error(final String msg) { - Log.LOGGER.error(msg); - } - - public static void info(final String msg) { - Log.LOGGER.info(msg); - } - - public static void warn(final String msg) { - Log.LOGGER.warn(msg); - } +public final class Log +{ + public static final Logger LOGGER = LogManager.getLogger("MiscUtils"); + + public static void warn(String msg) + { + LOGGER.warn(msg); + } + + public static void error(String msg) + { + LOGGER.error(msg); + } + + public static void info(String msg) + { + LOGGER.info(msg); + } + + public static void debug(String msg) + { + LOGGER.debug(msg); + } } diff --git a/src/Java/gtPlusPlus/core/util/LoggingUtils.java b/src/Java/gtPlusPlus/core/util/LoggingUtils.java index ffae71c40d..7783577ee2 100644 --- a/src/Java/gtPlusPlus/core/util/LoggingUtils.java +++ b/src/Java/gtPlusPlus/core/util/LoggingUtils.java @@ -1,52 +1,54 @@ package gtPlusPlus.core.util; -import java.io.*; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; import java.util.Date; public class LoggingUtils { - public static boolean logCurrentSystemTime(final String message) { - final Date date = new Date(System.currentTimeMillis()); - try { - LoggingUtils.profileLog(message + " | " + date.toString()); - return true; - } - catch (final Throwable r) { - return false; - } - - } - - public static void profileLog(final Object o) { - try { + public static void profileLog(Object o){ + try { String content; - final File file = new File("GregtechTimingsTC.txt"); + File file = new File("GregtechTimingsTC.txt"); // if file doesnt exists, then create it if (!file.exists()) { file.createNewFile(); - final FileWriter fw = new FileWriter(file.getAbsoluteFile(), true); - final BufferedWriter bw = new BufferedWriter(fw); + FileWriter fw = new FileWriter(file.getAbsoluteFile(), true); + BufferedWriter bw = new BufferedWriter(fw); bw.write("============================================================"); bw.write(System.lineSeparator()); bw.close(); - } - if (o instanceof String) { + } + if (o instanceof String){ content = (String) o; - } - else { - content = o.toString(); - } - final FileWriter fw = new FileWriter(file.getAbsoluteFile(), true); - final BufferedWriter bw = new BufferedWriter(fw); + } + else { + content = o.toString(); + } + FileWriter fw = new FileWriter(file.getAbsoluteFile(), true); + BufferedWriter bw = new BufferedWriter(fw); bw.write(content); bw.write(System.lineSeparator()); bw.close(); System.out.println("Data Logged."); - } - catch (final IOException e) { + } catch (IOException e) { System.out.println("Data logging failed."); } + } + + public static boolean logCurrentSystemTime(String message){ + Date date = new Date(System.currentTimeMillis()); + try { + profileLog(message+" | "+date.toString()); + return true; + } + catch (Throwable r) { + return false; + } + } - + } diff --git a/src/Java/gtPlusPlus/core/util/Quality.java b/src/Java/gtPlusPlus/core/util/Quality.java index 50d1b9fc90..1ce29c7a58 100644 --- a/src/Java/gtPlusPlus/core/util/Quality.java +++ b/src/Java/gtPlusPlus/core/util/Quality.java @@ -4,65 +4,56 @@ import gtPlusPlus.core.util.math.MathUtils; import net.minecraft.util.EnumChatFormatting; public enum Quality { - + // Magic Blue // Rare Yellow // Set Green // 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); - - 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 { - return null; - } - } - private String LOOT; - - private EnumChatFormatting COLOUR; - - private Quality(final String lootTier, final EnumChatFormatting tooltipColour) { + + 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) + { this.LOOT = lootTier; this.COLOUR = tooltipColour; } - public String formatted() { - return this.COLOUR + this.LOOT; + public String getQuality() { + return LOOT; } - - protected EnumChatFormatting getColour() { - return this.COLOUR; + + protected EnumChatFormatting getColour(){ + return COLOUR; } - - public String getQuality() { - return this.LOOT; + + public String formatted(){ + return this.COLOUR+this.LOOT; + } + + public static Quality getRandomQuality(){ + 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 return null; } } + + diff --git a/src/Java/gtPlusPlus/core/util/Utils.java b/src/Java/gtPlusPlus/core/util/Utils.java index e65e0f2ea9..2e25b8b0e9 100644 --- a/src/Java/gtPlusPlus/core/util/Utils.java +++ b/src/Java/gtPlusPlus/core/util/Utils.java @@ -1,14 +1,5 @@ package gtPlusPlus.core.util; -import java.awt.Color; -import java.awt.Graphics; -import java.lang.reflect.Method; -import java.util.*; - -import org.apache.commons.lang3.EnumUtils; - -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.FMLLog; import gregtech.api.enums.Materials; import gregtech.api.enums.TC_Aspects; import gregtech.api.enums.TC_Aspects.TC_AspectStack; @@ -20,285 +11,237 @@ import gtPlusPlus.core.util.math.MathUtils; import ic2.core.Ic2Items; import ic2.core.init.InternalName; import ic2.core.item.resources.ItemCell; + +import java.awt.Color; +import java.awt.Graphics; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Timer; +import java.util.TimerTask; + import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.item.Item.ToolMaterial; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import net.minecraftforge.common.util.EnumHelper; -import net.minecraftforge.fluids.*; +import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.oredict.OreDictionary; +import org.apache.commons.lang3.EnumUtils; + +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.FMLLog; + public class Utils { + public static final int WILDCARD_VALUE = Short.MAX_VALUE; + + public static final boolean isServer(){ + return FMLCommonHandler.instance().getEffectiveSide().isServer(); + } + static class ShortTimerTask extends TimerTask { @Override public void run() { Utils.LOG_WARNING("Timer expired."); } } - - public static final int WILDCARD_VALUE = Short.MAX_VALUE; - - private static short cellID = 15; - - public static Integer appenedHexNotationToInteger(final int hexAsStringOrInt) { - final String hexChar = "0x"; - String result; - Utils.LOG_INFO(String.valueOf(hexAsStringOrInt)); - result = hexChar + String.valueOf(hexAsStringOrInt); - return Integer.getInteger(result); - } - - public static String appenedHexNotationToString(final Object hexAsStringOrInt) { - final String hexChar = "0x"; - String result; - if (hexAsStringOrInt.getClass() == String.class) { - - if (((String) hexAsStringOrInt).length() != 6) { - final String temp = Utils.leftPadWithZeroes((String) hexAsStringOrInt, 6); - result = temp; - } - result = hexChar + hexAsStringOrInt; - return result; - } - else if (hexAsStringOrInt.getClass() == Integer.class) { - ; - if (((String) hexAsStringOrInt).length() != 6) { - final String temp = Utils.leftPadWithZeroes((String) hexAsStringOrInt, 6); - result = temp; - } - result = hexChar + String.valueOf(hexAsStringOrInt); - return result; - } - else { - return null; - } - } - - public static String byteToHex(final byte b) { - final int i = b & 0xFF; - return Integer.toHexString(i); - } - - public static String checkCorrectMiningToolForBlock(final Block currentBlock, final World currentWorld) { - String correctTool = ""; - if (!currentWorld.isRemote) { - try { - correctTool = currentBlock.getHarvestTool(0); - Utils.LOG_WARNING(correctTool); - - } - catch (final NullPointerException e) { - - } - } - - return correctTool; - } - - public static boolean containsMatch(final boolean strict, final ItemStack[] inputs, final ItemStack... targets) { - for (final ItemStack input : inputs) { - for (final ItemStack target : targets) { - if (Utils.itemMatches(target, input, strict)) { - return true; - } - } - } - return false; - } - - public static List convertArrayListToList(final ArrayList sourceArray) { - final List targetList = new ArrayList(Arrays.asList(sourceArray)); - return targetList; - } - - public static List convertArrayToFixedSizeList(final Object[] sourceArray) { - final List targetList = Arrays.asList(sourceArray); - return targetList; - } - - public static List convertArrayToList(final Object[] sourceArray) { - final List targetList = new ArrayList(Arrays.asList(sourceArray)); - return targetList; - } - - public static Object[] convertListToArray(final List sourceList) { - final Object[] targetArray = sourceList.toArray(new Object[sourceList.size()]); - return targetArray; - } - - 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("4"); - final Class clz = item.getClass(); - Utils.LOG_WARNING("5 " + clz.getSimpleName()); - final Method methode = clz.getDeclaredMethod("addCell", int.class, InternalName.class, Block[].class); - Utils.LOG_WARNING("6 " + methode.getName()); - methode.setAccessible(true); - Utils.LOG_WARNING("7 " + methode.isAccessible()); - final ItemStack temp = (ItemStack) methode.invoke(item, Utils.cellID++, yourName, new Block[0]); - Utils.LOG_INFO("Successfully created " + temp.getDisplayName() + "s."); - FluidContainerRegistry.registerFluidContainer(FluidUtils.getFluidStack(s.toLowerCase(), 0), temp.copy(), - Ic2Items.cell.copy()); - ItemUtils.addItemToOreDictionary(temp.copy(), "cell" + s); - return temp; - } - catch (final Exception e) { - e.printStackTrace(); - } - return null; - } - - public static boolean doesEntryExistAlreadyInOreDictionary(final String OreDictName) { - if (OreDictionary.getOres(OreDictName).size() != 0) { + + public static boolean isModUpToDate(){ + + if (CORE.MASTER_VERSION.equals(CORE.VERSION.toLowerCase())){ return true; - } + } return false; } - - public static ToolMaterial generateMaterialFromGT(final Materials gtMaterial) { - final String name = gtMaterial.name(); - 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); - return temp; - + + public static TC_AspectStack getTcAspectStack (TC_Aspects aspect, long size){ + return getTcAspectStack(aspect.name(), (int) size); } - - /** - * Returns a Liquid Stack with given amount of IC2Steam. - */ - public static FluidStack getIC2Steam(final long aAmount) { - return FluidRegistry.getFluidStack("ic2steam", (int) aAmount); + + public static TC_AspectStack getTcAspectStack (String aspect, long size){ + return getTcAspectStack(aspect, (int) size); } - public static TC_AspectStack getTcAspectStack(final String aspect, final int size) { + public static TC_AspectStack getTcAspectStack (TC_Aspects aspect, int size){ + return getTcAspectStack(aspect.name(), size); + } + + public static TC_AspectStack getTcAspectStack (String aspect, int size){ TC_AspectStack returnValue = null; - if (aspect.toUpperCase() == "COGNITIO") { - // Adds in Compat for older GT Versions which Misspell aspects. + if (aspect.toUpperCase() == "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"); + 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 (NoSuchFieldError r){ Utils.LOG_INFO("Invalid Thaumcraft Aspects - Report this issue to Alkalus"); } } - else if (aspect.toUpperCase() == "EXANIMUS") { - // Adds in Compat for older GT Versions which Misspell aspects. + else if (aspect.toUpperCase() == "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"); + 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 (NoSuchFieldError r){ Utils.LOG_INFO("Invalid Thaumcraft Aspects - Report this issue to Alkalus"); } - + + } - else if (aspect.toUpperCase() == "PRAECANTATIO") { - // Adds in Compat for older GT Versions which Misspell aspects. + else if (aspect.toUpperCase() == "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"); + 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 (NoSuchFieldError r){ Utils.LOG_INFO("Invalid Thaumcraft Aspects - Report this issue to Alkalus"); - } + } } else { - Utils.LOG_WARNING("TC Aspect found - " + aspect); + Utils.LOG_WARNING("TC Aspect found - "+aspect); returnValue = new TC_AspectStack(TC_Aspects.valueOf(aspect), size); } return returnValue; } - /* - * 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 boolean containsMatch(boolean strict, ItemStack[] inputs, ItemStack... targets) + { + for (ItemStack input : inputs) + { + for (ItemStack target : targets) + { + if (itemMatches(target, input, strict)) + { + return true; + } + } + } + return false; + } + + public static boolean itemMatches(ItemStack target, ItemStack input, boolean strict) + { + if (input == null || target == null) + { + return false; + } + return (target.getItem() == input.getItem() && ((target.getItemDamage() == WILDCARD_VALUE && !strict) || target.getItemDamage() == input.getItemDamage())); + } + + //Non-Dev Comments + public static void LOG_INFO(String s){ + //if (CORE.DEBUG){ + FMLLog.info("GT++: "+s); + //} + } + + //Developer Comments + public static void LOG_WARNING(String s){ + if (CORE.DEBUG){ + FMLLog.warning("GT++: "+s); + } + } - public static TC_AspectStack getTcAspectStack(final String aspect, final long size) { - return Utils.getTcAspectStack(aspect, (int) size); + //Errors + public static void LOG_ERROR(String s){ + if (CORE.DEBUG){ + FMLLog.severe("GT++: "+s); + } } - public static TC_AspectStack getTcAspectStack(final TC_Aspects aspect, final int size) { - return Utils.getTcAspectStack(aspect.name(), size); + //Developer Logger + public static void LOG_SPECIFIC_WARNING(String whatToLog, String msg, int line){ + if (CORE.DEBUG){ + FMLLog.warning("GT++ |"+line+"| "+whatToLog+" | "+msg); + } } - public static TC_AspectStack getTcAspectStack(final TC_Aspects aspect, final long size) { - return Utils.getTcAspectStack(aspect.name(), (int) size); + public static void paintBox(Graphics g, int MinA, int MinB, int MaxA, int MaxB){ + g.drawRect (MinA, MinB, MaxA, MaxB); } /** - * - * @param colourInt - * e.g. 0XFFFFFF - * @return Colour + * Returns if that Liquid is IC2Steam. */ - public static Color hex2Rgb(final int colourInt) { - return Color.decode(String.valueOf(colourInt)); + public static boolean isIC2Steam(FluidStack aFluid) { + if (aFluid == null) return false; + return aFluid.isFluidEqual(getIC2Steam(1)); } /** - * - * @param colourStr - * e.g. "#FFFFFF" - * @return + * Returns a Liquid Stack with given amount of IC2Steam. */ - 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)); + public static FluidStack getIC2Steam(long 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 String checkCorrectMiningToolForBlock(Block currentBlock, World currentWorld){ + String correctTool = ""; + if (!currentWorld.isRemote){ + try { + correctTool = currentBlock.getHarvestTool(0); + Utils.LOG_WARNING(correctTool); + + } catch (NullPointerException e){ + + } + } + + return correctTool; } /** - * - * @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)); + public static String hex2RgbFormatted(String hexString) { + 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(); + StringBuffer sb = new StringBuffer(); sb.append("rgb("); sb.append(c.getRed()); sb.append(","); @@ -308,162 +251,256 @@ public class Utils { sb.append(")"); return sb.toString(); } - + + /** + * + * @param colourStr e.g. "#FFFFFF" + * @return + */ + public static Color hex2Rgb(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 ) ); + } + + /** + * + * @param colourInt e.g. 0XFFFFFF + * @return Colour + */ + public static Color hex2Rgb(int colourInt) { + return Color.decode(String.valueOf(colourInt)); + } + /** - * - * @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() - }; + public static short[] hex2RgbShort(int colourInt) { + Color rgb = Color.decode(String.valueOf(colourInt)); + short[] rgba = {(short) rgb.getRed(), (short) rgb.getGreen(), (short) rgb.getBlue(), (short) rgb.getAlpha()}; return rgba; } - /* - * Original Code by Chandana Napagoda - - * https://cnapagoda.blogspot.com.au/2011/03/java-hex-color-code-generator. - * html - */ - public static Map hexColourGenerator(final int colorCount) { - final int maxColorValue = 16777215; - // this is decimal value of the "FFFFFF" - final int devidedvalue = maxColorValue / colorCount; - int countValue = 0; - final HashMap 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()); - } - } - return hexColorMap; + public static Timer ShortTimer(int seconds) { + Timer timer; + timer = new Timer(); + timer.schedule(new ShortTimerTask(), seconds * 1000); + return timer; } - /* - * Original Code by Chandana Napagoda - - * https://cnapagoda.blogspot.com.au/2011/03/java-hex-color-code-generator. - * html - */ - public static Map hexColourGeneratorRandom(final int colorCount) { - final HashMap 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_INFO("" + Integer.toHexString(0x1000000 | i).substring(1).toUpperCase()); - } - return hexColorMap; + public static String byteToHex(byte b) { + int i = b & 0xFF; + return Integer.toHexString(i); } - public static boolean invertBoolean(final boolean booleans) { - if (booleans == true) { - return false; - } - return true; + public static Object[] convertListToArray(List sourceList) { + Object[] targetArray = sourceList.toArray(new Object[sourceList.size()]); + return targetArray; } - /** - * Returns if that Liquid is IC2Steam. - */ - public static boolean isIC2Steam(final FluidStack aFluid) { - if (aFluid == null) { - return false; - } - return aFluid.isFluidEqual(Utils.getIC2Steam(1)); + public static List convertArrayToFixedSizeList(Object[] sourceArray) { + List targetList = Arrays.asList(sourceArray); + return targetList; } - public static boolean isModUpToDate() { - - if (CORE.MASTER_VERSION.equals(CORE.VERSION.toLowerCase())) { - return true; - } - return false; + public static List convertArrayToList(Object[] sourceArray) { + List targetList = new ArrayList(Arrays.asList(sourceArray)); + return targetList; + } + + public static List convertArrayListToList(ArrayList sourceArray) { + List targetList = new ArrayList(Arrays.asList(sourceArray)); + return targetList; } - public static final boolean isServer() { - return FMLCommonHandler.instance().getEffectiveSide().isServer(); + public static void spawnCustomParticle(Entity entity){ + GTplusplus.proxy.generateMysteriousParticles(entity); + } + + public static void spawnFX(World world, int x, int y, int z, String particleName, Object particleName2){ + if (!world.isRemote){ + if (particleName2 == null || particleName2.equals("")){ + particleName2 = particleName; + } + int l = MathUtils.randInt(0, 4); + double d0 = (double)((float)x + 0.5F); + double d1 = (double)((float)y + 0.7F); + double d2 = (double)((float)z + 0.5F); + double d3 = 0.2199999988079071D; + double d4 = 0.27000001072883606D; + + if (l == 1) + { + world.spawnParticle(particleName, d0 - d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D); + } + else if (l == 2) + { + world.spawnParticle((String) particleName2, d0 + d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D); + } + else if (l == 3) + { + world.spawnParticle(particleName, d0, d1 + d3, d2 - d4, 0.0D, 0.0D, 0.0D); + } + else if (l == 4) + { + world.spawnParticle((String) particleName2, d0, d1 + d3, d2 + d4, 0.0D, 0.0D, 0.0D); + } + else + { + world.spawnParticle(particleName, d0, d1, d2, 0.0D, 0.0D, 0.0D); + if (particleName2 != null){ + world.spawnParticle((String) particleName2, d0, d1, d2, 0.0D, 0.0D, 0.0D); + } + } + } } - public static boolean itemMatches(final ItemStack target, final ItemStack input, final boolean strict) { - if (input == null || target == null) { - return false; + public static int rgbtoHexValue(int r, int g, int b){ + if (r > 255 || g > 255 || b > 255 || r < 0 || g < 0 || b < 0){ + return 0; } - return target.getItem() == input.getItem() && (target.getItemDamage() == Utils.WILDCARD_VALUE && !strict - || target.getItemDamage() == input.getItemDamage()); + 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); + 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)+"."); + return Integer.decode(temp); } /* * http://javadevnotes.com/java-left-pad-string-with-zeros-examples */ - public static String leftPadWithZeroes(final String originalString, final int length) { - final StringBuilder sb = new StringBuilder(); + public static String leftPadWithZeroes(String originalString, int length) { + StringBuilder sb = new StringBuilder(); while (sb.length() + originalString.length() < length) { sb.append('0'); } sb.append(originalString); - final String paddedString = sb.toString(); + String paddedString = sb.toString(); return paddedString; } - // Errors - public static void LOG_ERROR(final String s) { - if (CORE.DEBUG) { - FMLLog.severe("GT++: " + s); + /* + * Original Code by Chandana Napagoda - https://cnapagoda.blogspot.com.au/2011/03/java-hex-color-code-generator.html + */ + public static Map hexColourGenerator(int colorCount){ + int maxColorValue = 16777215; + // this is decimal value of the "FFFFFF" + int devidedvalue = maxColorValue/colorCount; + int countValue = 0; + HashMap 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()); + } } + return hexColorMap; } - // Non-Dev Comments - public static void LOG_INFO(final String s) { - // if (CORE.DEBUG){ - FMLLog.info("GT++: " + 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); + /* + * Original Code by Chandana Napagoda - https://cnapagoda.blogspot.com.au/2011/03/java-hex-color-code-generator.html + */ + public static Map hexColourGeneratorRandom(int colorCount){ + HashMap hexColorMap = new HashMap(); + for(int a=0;a < colorCount; a++){ + String code = ""+(int)(Math.random()*256); + code = code+code+code; + int i = Integer.parseInt(code); + hexColorMap.put(a,Integer.toHexString( 0x1000000 | i).substring(1).toUpperCase()); + Utils.LOG_INFO(""+Integer.toHexString( 0x1000000 | i).substring(1).toUpperCase()); } + return hexColorMap; } - // Developer Comments - public static void LOG_WARNING(final String s) { - if (CORE.DEBUG) { - FMLLog.warning("GT++: " + s); + public static String appenedHexNotationToString(Object hexAsStringOrInt){ + String hexChar = "0x"; + String result; + if (hexAsStringOrInt.getClass() == String.class){ + + if (((String) hexAsStringOrInt).length() != 6){ + String temp = leftPadWithZeroes((String) hexAsStringOrInt, 6); + result = temp; + } + result = hexChar+hexAsStringOrInt; + return result; + } + else if (hexAsStringOrInt.getClass() == Integer.class){ + ; + if (((String) hexAsStringOrInt).length() != 6){ + String temp = leftPadWithZeroes((String) hexAsStringOrInt, 6); + result = temp; + } + result = hexChar+String.valueOf(hexAsStringOrInt); + return result; + } + else { + return null; } } - 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 Integer appenedHexNotationToInteger(int hexAsStringOrInt){ + String hexChar = "0x"; + String result; + Utils.LOG_INFO(String.valueOf(hexAsStringOrInt)); + result = hexChar+String.valueOf(hexAsStringOrInt); + return Integer.getInteger(result); } - 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; + public static boolean doesEntryExistAlreadyInOreDictionary(String OreDictName){ + if (OreDictionary.getOres(OreDictName).size() != 0) { + return true; } - final Color c = new Color(r, g, b); - String temp = Integer.toHexString(c.getRGB() & 0xFFFFFF).toUpperCase(); + return false; + } - // 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) + "."); - return Integer.decode(temp); + public static boolean invertBoolean(boolean booleans){ + if (booleans == true){ + return false; + } + return true; } - public static String sanitizeString(final String input) { + private static short cellID = 15; + public static ItemStack createInternalNameAndFluidCell(String s){ + Utils.LOG_WARNING("1"); + InternalName yourName = EnumHelper.addEnum(InternalName.class, s, new Class[0], new Object[0]); + Utils.LOG_WARNING("2 "+yourName.name()); + ItemCell item = (ItemCell)Ic2Items.cell.getItem(); + Utils.LOG_WARNING("3 "+item.getUnlocalizedName()); + try + { + Utils.LOG_WARNING("4"); + Class clz = item.getClass(); + Utils.LOG_WARNING("5 "+clz.getSimpleName()); + Method methode = clz.getDeclaredMethod("addCell", int.class, InternalName.class, Block[].class); + Utils.LOG_WARNING("6 "+methode.getName()); + methode.setAccessible(true); + Utils.LOG_WARNING("7 "+methode.isAccessible()); + ItemStack temp = (ItemStack) methode.invoke(item, cellID++, yourName, new Block[0]); + Utils.LOG_INFO("Successfully created "+temp.getDisplayName()+"s."); + FluidContainerRegistry.registerFluidContainer(FluidUtils.getFluidStack(s.toLowerCase(), 0), temp.copy(), Ic2Items.cell.copy()); + ItemUtils.addItemToOreDictionary(temp.copy(), "cell"+s); + return temp; + } + catch(Exception e){ + e.printStackTrace(); + } + return null; + } + + public static String sanitizeString(String input){ String temp; String output; - + temp = input.replace(" ", ""); temp = temp.replace("-", ""); temp = temp.replace("_", ""); @@ -478,54 +515,24 @@ public class Utils { temp = temp.replace("[", ""); temp = temp.replace("]", ""); temp = temp.replace(" ", ""); - output = temp; + output = temp; return output; - + + } + + public static ToolMaterial generateMaterialFromGT(Materials gtMaterial){ + String name = gtMaterial.name(); + int harvestLevel = gtMaterial.mToolQuality; + int durability = gtMaterial.mDurability; + float damage = gtMaterial.mToolQuality; + int efficiency = (int) gtMaterial.mToolSpeed; + int enchantability = gtMaterial.mEnchantmentToolsLevel; + ToolMaterial temp = EnumHelper.addToolMaterial(name, harvestLevel, durability, efficiency, damage, enchantability); + return temp; + } - public static Timer ShortTimer(final int seconds) { - Timer timer; - timer = new Timer(); - timer.schedule(new ShortTimerTask(), seconds * 1000); - return timer; - } - 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("")) { - particleName2 = particleName; - } - final int l = MathUtils.randInt(0, 4); - final double d0 = x + 0.5F; - final double d1 = y + 0.7F; - final double d2 = z + 0.5F; - final double d3 = 0.2199999988079071D; - final double d4 = 0.27000001072883606D; - - if (l == 1) { - world.spawnParticle(particleName, d0 - d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D); - } - else if (l == 2) { - world.spawnParticle((String) particleName2, d0 + d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D); - } - else if (l == 3) { - world.spawnParticle(particleName, d0, d1 + d3, d2 - d4, 0.0D, 0.0D, 0.0D); - } - else if (l == 4) { - world.spawnParticle((String) particleName2, d0, d1 + d3, d2 + d4, 0.0D, 0.0D, 0.0D); - } - else { - world.spawnParticle(particleName, d0, d1, d2, 0.0D, 0.0D, 0.0D); - if (particleName2 != null) { - world.spawnParticle((String) particleName2, d0, d1, d2, 0.0D, 0.0D, 0.0D); - } - } - } - } -} diff --git a/src/Java/gtPlusPlus/core/util/UtilsChatFormatting.java b/src/Java/gtPlusPlus/core/util/UtilsChatFormatting.java index 38fa9eeca9..9e358b3074 100644 --- a/src/Java/gtPlusPlus/core/util/UtilsChatFormatting.java +++ b/src/Java/gtPlusPlus/core/util/UtilsChatFormatting.java @@ -1,131 +1,156 @@ package gtPlusPlus.core.util; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; 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). - */ - private static final Map formattingCodeMapping = new HashMap(); - /** - * Maps a name (e.g., 'underline') to its corresponding enum value (e.g., - * UNDERLINE). - */ - private static final Map nameMapping = new HashMap(); - /** - * 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]"); - static { - final UtilsChatFormatting[] var0 = UtilsChatFormatting.values(); - final int var1 = var0.length; - - for (int var2 = 0; var2 < var1; ++var2) { - final UtilsChatFormatting var3 = var0[var2]; - UtilsChatFormatting.formattingCodeMapping.put(Character.valueOf(var3.getFormattingCode()), var3); - UtilsChatFormatting.nameMapping.put(var3.getFriendlyName(), var3); - } - } - /** - * Returns a copy of the given string, with formatting codes stripped away. - */ - @SideOnly(Side.CLIENT) - public static String getTextWithoutFormattingCodes(final String p_110646_0_) { - return p_110646_0_ == null ? null - : UtilsChatFormatting.formattingCodePattern.matcher(p_110646_0_).replaceAll(""); - } - /** - * 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 getValidValues(final boolean p_96296_0_, final boolean p_96296_1_) { - final ArrayList arraylist = new ArrayList(); - final UtilsChatFormatting[] aenumchatformatting = UtilsChatFormatting.values(); - final int i = aenumchatformatting.length; - - for (int j = 0; j < i; ++j) { - final UtilsChatFormatting enumchatformatting = aenumchatformatting[j]; - - if ((!enumchatformatting.isColor() || p_96296_0_) && (!enumchatformatting.isFancyStyling() || p_96296_1_)) { - arraylist.add(enumchatformatting.getFriendlyName()); - } - } - - return arraylist; - } - - /** - * 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) UtilsChatFormatting.nameMapping.get(p_96300_0_.toLowerCase()); - } - - /** 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. - */ - private final String controlString; - - private UtilsChatFormatting(final char p_i1336_3_) { - this(p_i1336_3_, false); - } - - 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_; - } - - /** - * Gets the formatting code that produces this format. - */ - public char getFormattingCode() { - return this.formattingCode; - } - - /** - * Gets the friendly name of this value. - */ - public String getFriendlyName() { - return this.name().toLowerCase(); - } - - /** - * Checks if typo is a color. - */ - public boolean isColor() { - return !this.fancyStyling && this != RESET; - } - - /** - * False if this is just changing the color or resetting; true otherwise. - */ - public boolean isFancyStyling() { - return this.fancyStyling; - } - - @Override - public String toString() { - return this.controlString; - } +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 formattingCodeMapping = new HashMap(); + /** Maps a name (e.g., 'underline') to its corresponding enum value (e.g., UNDERLINE). */ + private static final Map nameMapping = new HashMap(); + /** + * 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]"); + /** 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. + */ + private final String controlString; + + private UtilsChatFormatting(char p_i1336_3_) + { + this(p_i1336_3_, false); + } + + private UtilsChatFormatting(char p_i1337_3_, boolean p_i1337_4_) + { + this.formattingCode = p_i1337_3_; + this.fancyStyling = p_i1337_4_; + this.controlString = "\u00a7" + p_i1337_3_; + } + + /** + * Gets the formatting code that produces this format. + */ + public char getFormattingCode() + { + return this.formattingCode; + } + + /** + * False if this is just changing the color or resetting; true otherwise. + */ + public boolean isFancyStyling() + { + return this.fancyStyling; + } + + /** + * Checks if typo is a color. + */ + public boolean isColor() + { + return !this.fancyStyling && this != RESET; + } + + /** + * Gets the friendly name of this value. + */ + public String getFriendlyName() + { + return this.name().toLowerCase(); + } + + @Override + public String toString() + { + return this.controlString; + } + + /** + * Returns a copy of the given string, with formatting codes stripped away. + */ + @SideOnly(Side.CLIENT) + public static String getTextWithoutFormattingCodes(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. + */ + public static UtilsChatFormatting getValueByName(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). + */ + public static Collection getValidValues(boolean p_96296_0_, boolean p_96296_1_) + { + ArrayList arraylist = new ArrayList(); + UtilsChatFormatting[] aenumchatformatting = values(); + int i = aenumchatformatting.length; + + for (int j = 0; j < i; ++j) + { + UtilsChatFormatting enumchatformatting = aenumchatformatting[j]; + + if ((!enumchatformatting.isColor() || p_96296_0_) && (!enumchatformatting.isFancyStyling() || p_96296_1_)) + { + arraylist.add(enumchatformatting.getFriendlyName()); + } + } + + return arraylist; + } + + static + { + UtilsChatFormatting[] var0 = values(); + int var1 = var0.length; + + for (int var2 = 0; var2 < var1; ++var2) + { + UtilsChatFormatting var3 = var0[var2]; + formattingCodeMapping.put(Character.valueOf(var3.getFormattingCode()), var3); + nameMapping.put(var3.getFriendlyName(), var3); + } + } } \ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/util/UtilsRarity.java b/src/Java/gtPlusPlus/core/util/UtilsRarity.java index 1eed211613..19339b7717 100644 --- a/src/Java/gtPlusPlus/core/util/UtilsRarity.java +++ b/src/Java/gtPlusPlus/core/util/UtilsRarity.java @@ -2,17 +2,22 @@ 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; - public final EnumChatFormatting rarityColor; - public final String rarityName; - - private UtilsRarity(final EnumChatFormatting rarity, final String name) { - this.rarityColor = rarity; - this.rarityName = name; - } + private UtilsRarity(EnumChatFormatting rarity, String name) + { + this.rarityColor = rarity; + this.rarityName = name; + } } \ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/util/UtilsText.java b/src/Java/gtPlusPlus/core/util/UtilsText.java index 0db7dd35a2..e91fa95e4c 100644 --- a/src/Java/gtPlusPlus/core/util/UtilsText.java +++ b/src/Java/gtPlusPlus/core/util/UtilsText.java @@ -2,17 +2,31 @@ 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 (char value) + { this.colourValue = value; } public String colour() { - return "�" + this.colourValue; + return "§"+colourValue; } } diff --git a/src/Java/gtPlusPlus/core/util/array/ArrayUtils.java b/src/Java/gtPlusPlus/core/util/array/ArrayUtils.java index 0d78c76681..ea02aaf1da 100644 --- a/src/Java/gtPlusPlus/core/util/array/ArrayUtils.java +++ b/src/Java/gtPlusPlus/core/util/array/ArrayUtils.java @@ -4,15 +4,15 @@ import java.util.Arrays; public class ArrayUtils { - private static Object[] addElement(Object[] series, final Object newValueToAdd) { - series = Arrays.copyOf(series, series.length + 1); - series[series.length - 1] = newValueToAdd; - return series; - } - - public static void expandArray(final Object[] someArray, final Object newValueToAdd) { + public static void expandArray(Object[] someArray, Object newValueToAdd) { Object[] series = someArray; - series = ArrayUtils.addElement(series, newValueToAdd); + series = addElement(series, newValueToAdd); } + private static Object[] addElement(Object[] series, Object newValueToAdd) { + series = Arrays.copyOf(series, series.length + 1); + series[series.length - 1] = newValueToAdd; + return series; + } + } diff --git a/src/Java/gtPlusPlus/core/util/array/Pair.java b/src/Java/gtPlusPlus/core/util/array/Pair.java index 45c6aacc23..94437e6779 100644 --- a/src/Java/gtPlusPlus/core/util/array/Pair.java +++ b/src/Java/gtPlusPlus/core/util/array/Pair.java @@ -1,21 +1,21 @@ package gtPlusPlus.core.util.array; -public class Pair { - - private final K key; - private final V value; - - public Pair(final K key, final V value) { +public class Pair { + + private final K key; + private final V value; + + public Pair(final K key, final V value){ this.key = key; this.value = value; } - - final public K getKey() { - return this.key; - } - - final public V getValue() { - return this.value; - } + + final public K getKey(){ + return key; + } + + final public V getValue(){ + return value; + } } \ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/util/array/Triplet.java b/src/Java/gtPlusPlus/core/util/array/Triplet.java index 7882c2f13a..07f29ae6c8 100644 --- a/src/Java/gtPlusPlus/core/util/array/Triplet.java +++ b/src/Java/gtPlusPlus/core/util/array/Triplet.java @@ -1,27 +1,27 @@ package gtPlusPlus.core.util.array; -public class Triplet { - - private final K key; - private final V value; - private final C count; - - public Triplet(final K key, final V value, final C value2) { +public class Triplet { + + private final K key; + private final V value; + private final C count; + + public Triplet(final K key, final V value, final C value2){ this.key = key; this.value = value; this.count = value2; } - - final public K getKey() { - return this.key; - } - - final public C getSecondValue() { - return this.count; - } - - final public V getValue() { - return this.value; - } + + final public K getKey(){ + return key; + } + + final public V getValue(){ + return value; + } + + final public C getSecondValue(){ + return count; + } } \ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/util/debug/DEBUG_BLOCK_ShapeSpawner.java b/src/Java/gtPlusPlus/core/util/debug/DEBUG_BLOCK_ShapeSpawner.java index 1f90697e52..74df9f90ba 100644 --- a/src/Java/gtPlusPlus/core/util/debug/DEBUG_BLOCK_ShapeSpawner.java +++ b/src/Java/gtPlusPlus/core/util/debug/DEBUG_BLOCK_ShapeSpawner.java @@ -11,67 +11,95 @@ public class DEBUG_BLOCK_ShapeSpawner extends DEBUG_MULTIBLOCK_ShapeSpawner { private static boolean controller; - public DEBUG_BLOCK_ShapeSpawner(final int aID, final String aName, final String aNameRegional) { + public DEBUG_BLOCK_ShapeSpawner(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); } - public DEBUG_BLOCK_ShapeSpawner(final String aName) { + public DEBUG_BLOCK_ShapeSpawner(String aName) { super(aName); } @Override - public boolean checkMachine(final IGregTechTileEntity aBaseMetaTileEntity, final ItemStack aStack) { + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new DEBUG_BLOCK_ShapeSpawner(this.mName); + } + + + public String[] getDescription() { + return new String[]{ + "Controller Block for the Testing", + "Create the shapes for Multiblocks.",}; + } + + + @Override + public ITexture[] getTexture(IGregTechTileEntity arg0, byte arg1, + byte arg2, byte arg3, boolean arg4, boolean arg5) { + // TODO Auto-generated method stub + return null; + } + + @Override + public boolean isCorrectMachinePart(ItemStack aStack) { + // TODO Auto-generated method stub + return false; + } - final int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; - final int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; + @Override + public boolean checkRecipe(ItemStack aStack) { + // TODO Auto-generated method stub + return false; + } + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + + int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; + int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; + if (!aBaseMetaTileEntity.getAirOffset(xDir, 0, zDir)) { return false; } - + int stepX = aBaseMetaTileEntity.getXCoord(); - final int stepY = aBaseMetaTileEntity.getYCoord(); + int stepY = aBaseMetaTileEntity.getYCoord(); int stepZ = aBaseMetaTileEntity.getZCoord(); - final int temp = 0; + int temp = 0; - Utils.LOG_INFO("Starting Block located @ " + "[X:" + stepX + "][Y:" + stepY + "][Z:" + stepZ + "]"); + Utils.LOG_INFO("Starting Block located @ "+"[X:"+stepX+"][Y:"+stepY+"][Z:"+stepZ+"]"); - final int tAmount = 0; + int tAmount = 0; switch (xDir) { - case -1: - stepX++; - Utils.LOG_INFO("Modifying stepX + accomodate a " + xDir + " xDir - [X:" + stepX + "][Y:" + stepY - + "][Z:" + stepZ + "]"); - break; - - case 1: - stepX--; - Utils.LOG_INFO("Modifying stepX - accomodate a " + xDir + " xDir - [X:" + stepX + "][Y:" + stepY - + "][Z:" + stepZ + "]"); - break; + case -1: + stepX++; + Utils.LOG_INFO("Modifying stepX + accomodate a "+xDir+" xDir - [X:"+stepX+"][Y:"+stepY+"][Z:"+stepZ+"]"); + break; + + case 1: + stepX--; + Utils.LOG_INFO("Modifying stepX - accomodate a "+xDir+" xDir - [X:"+stepX+"][Y:"+stepY+"][Z:"+stepZ+"]"); + break; } switch (zDir) { - case -1: - stepZ++; - Utils.LOG_INFO("Modifying stepZ + accomodate a " + zDir + " zDir - [X:" + stepX + "][Y:" + stepY - + "][Z:" + stepZ + "]"); - break; - - case 1: - stepZ--; - Utils.LOG_INFO("Modifying stepZ - accomodate a " + zDir + " zDir - [X:" + stepX + "][Y:" + stepY - + "][Z:" + stepZ + "]"); - break; + case -1: + stepZ++; + Utils.LOG_INFO("Modifying stepZ + accomodate a "+zDir+" zDir - [X:"+stepX+"][Y:"+stepY+"][Z:"+stepZ+"]"); + break; + + case 1: + stepZ--; + Utils.LOG_INFO("Modifying stepZ - accomodate a "+zDir+" zDir - [X:"+stepX+"][Y:"+stepY+"][Z:"+stepZ+"]"); + break; } - for (int i = stepX - 1; i <= stepX + 1; i++) { - for (int j = stepZ - 1; j <= stepZ + 1; j++) { - for (int h = stepY - 1; h <= stepY + 1; h++) { + for (int i = stepX-1; i <= stepX+1; i++){ + for (int j = stepZ-1; j <= stepZ+1; j++){ + for (int h = stepY-1; h <= stepY+1; h++){ + - Utils.LOG_INFO("Block Facing - X:" + xDir + " Z:" + zDir); + Utils.