diff options
author | draknyte1 <draknyte1@hotmail.com> | 2016-11-02 15:49:00 +1000 |
---|---|---|
committer | draknyte1 <draknyte1@hotmail.com> | 2016-11-02 15:49:00 +1000 |
commit | d594987b2cfdefa447ee585a68d4a4bef4ece3a5 (patch) | |
tree | 814813fc14ce5dcd8dfa7aeaecd939ac42d12877 /src/Java/gtPlusPlus/core/util | |
parent | 26292158575a0f0acb51ae50715887f871d2b5a0 (diff) | |
parent | 49a520da5da01594b5c42652d9db5c7c04e49ad8 (diff) | |
download | GT5-Unofficial-d594987b2cfdefa447ee585a68d4a4bef4ece3a5.tar.gz GT5-Unofficial-d594987b2cfdefa447ee585a68d4a4bef4ece3a5.tar.bz2 GT5-Unofficial-d594987b2cfdefa447ee585a68d4a4bef4ece3a5.zip |
Merge branch 'master' of https://github.com/draknyte1/GTplusplus
Diffstat (limited to 'src/Java/gtPlusPlus/core/util')
19 files changed, 1027 insertions, 301 deletions
diff --git a/src/Java/gtPlusPlus/core/util/Quality.java b/src/Java/gtPlusPlus/core/util/Quality.java new file mode 100644 index 0000000000..1ce29c7a58 --- /dev/null +++ b/src/Java/gtPlusPlus/core/util/Quality.java @@ -0,0 +1,59 @@ +package gtPlusPlus.core.util; + +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); + + private String LOOT; + private EnumChatFormatting COLOUR; + private Quality (final String lootTier, final EnumChatFormatting tooltipColour) + { + this.LOOT = lootTier; + this.COLOUR = tooltipColour; + } + + public String getQuality() { + return LOOT; + } + + protected EnumChatFormatting getColour(){ + return COLOUR; + } + + 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 090d05e3b1..2e25b8b0e9 100644 --- a/src/Java/gtPlusPlus/core/util/Utils.java +++ b/src/Java/gtPlusPlus/core/util/Utils.java @@ -6,12 +6,10 @@ import gregtech.api.enums.TC_Aspects.TC_AspectStack; import gtPlusPlus.GTplusplus; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.fluid.FluidUtils; -import gtPlusPlus.core.util.item.UtilsItems; +import gtPlusPlus.core.util.item.ItemUtils; import gtPlusPlus.core.util.math.MathUtils; -import ic2.core.IC2Potion; import ic2.core.Ic2Items; import ic2.core.init.InternalName; -import ic2.core.item.armor.ItemArmorHazmat; import ic2.core.item.resources.ItemCell; import java.awt.Color; @@ -24,29 +22,22 @@ import java.util.List; import java.util.Map; import java.util.Timer; import java.util.TimerTask; -import java.util.UUID; import net.minecraft.block.Block; import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLiving; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.EnumCreatureType; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.Item.ToolMaterial; import net.minecraft.item.ItemStack; -import net.minecraft.server.MinecraftServer; -import net.minecraft.util.MathHelper; import net.minecraft.world.World; -import net.minecraft.world.biome.BiomeGenBase; import net.minecraftforge.common.util.EnumHelper; import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.oredict.OreDictionary; + +import org.apache.commons.lang3.EnumUtils; + import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.FMLLog; -import cpw.mods.fml.common.registry.EntityRegistry; public class Utils { @@ -90,32 +81,52 @@ public class Utils { if (aspect.toUpperCase() == "COGNITIO"){ //Adds in Compat for older GT Versions which Misspell aspects. try { - returnValue = new TC_AspectStack(TC_Aspects.valueOf("COGNITIO"), size); + if (EnumUtils.isValidEnum(TC_Aspects.class, "COGNITIO")){ + Utils.LOG_WARNING("TC Aspect found - "+aspect); + returnValue = new TC_AspectStack(TC_Aspects.valueOf("COGNITIO"), size); + } + else { + Utils.LOG_INFO("Fallback TC Aspect found - "+aspect+" - PLEASE UPDATE GREGTECH TO A NEWER VERSION TO REMOVE THIS MESSAGE - THIS IS NOT AN ERROR"); + returnValue = new TC_AspectStack(TC_Aspects.valueOf("COGNITO"), size); + } } catch (NoSuchFieldError r){ - Utils.LOG_INFO("Fallback TC Aspect found - "+aspect+" - PLEASE UPDATE GREGTECH TO A NEWER VERSION TO REMOVE THIS MESSAGE - THIS IS NOT AN ERROR"); - returnValue = new TC_AspectStack(TC_Aspects.valueOf("COGNITO"), size); - + Utils.LOG_INFO("Invalid Thaumcraft Aspects - Report this issue to Alkalus"); } } else if (aspect.toUpperCase() == "EXANIMUS"){ - //Adds in Compat for older GT Versions which Misspell aspects. + //Adds in Compat for older GT Versions which Misspell aspects. try { - returnValue = new TC_AspectStack(TC_Aspects.valueOf("EXANIMUS"), size); + if (EnumUtils.isValidEnum(TC_Aspects.class, "EXANIMUS")){ + Utils.LOG_WARNING("TC Aspect found - "+aspect); + returnValue = new TC_AspectStack(TC_Aspects.valueOf("EXANIMUS"), size); + } + else { + Utils.LOG_INFO("Fallback TC Aspect found - "+aspect+" - PLEASE UPDATE GREGTECH TO A NEWER VERSION TO REMOVE THIS MESSAGE - THIS IS NOT AN ERROR"); + returnValue = new TC_AspectStack(TC_Aspects.valueOf("EXAMINIS"), size); + } } catch (NoSuchFieldError r){ - Utils.LOG_INFO("Fallback TC Aspect found - "+aspect+" - PLEASE UPDATE GREGTECH TO A NEWER VERSION TO REMOVE THIS MESSAGE - THIS IS NOT AN ERROR"); - returnValue = new TC_AspectStack(TC_Aspects.valueOf("EXAMINIS"), size); + Utils.LOG_INFO("Invalid Thaumcraft Aspects - Report this issue to Alkalus"); } + + } else if (aspect.toUpperCase() == "PRAECANTATIO"){ - //Adds in Compat for older GT Versions which Misspell aspects. + //Adds in Compat for older GT Versions which Misspell aspects. try { - returnValue = new TC_AspectStack(TC_Aspects.valueOf("PRAECANTATIO"), size); + if (EnumUtils.isValidEnum(TC_Aspects.class, "PRAECANTATIO")){ + Utils.LOG_WARNING("TC Aspect found - "+aspect); + returnValue = new TC_AspectStack(TC_Aspects.valueOf("PRAECANTATIO"), size); + } + else { + Utils.LOG_INFO("Fallback TC Aspect found - "+aspect+" - PLEASE UPDATE GREGTECH TO A NEWER VERSION TO REMOVE THIS MESSAGE - THIS IS NOT AN ERROR"); + returnValue = new TC_AspectStack(TC_Aspects.valueOf("PRAECANTIO"), size); + } } catch (NoSuchFieldError r){ - Utils.LOG_INFO("Fallback TC Aspect found - "+aspect+" - PLEASE UPDATE GREGTECH TO A NEWER VERSION TO REMOVE THIS MESSAGE - THIS IS NOT AN ERROR"); - returnValue = new TC_AspectStack(TC_Aspects.valueOf("PRAECANTIO"), size); - } + Utils.LOG_INFO("Invalid Thaumcraft Aspects - Report this issue to Alkalus"); + } } else { + Utils.LOG_WARNING("TC Aspect found - "+aspect); returnValue = new TC_AspectStack(TC_Aspects.valueOf(aspect), size); } @@ -146,11 +157,6 @@ public class Utils { return (target.getItem() == input.getItem() && ((target.getItemDamage() == WILDCARD_VALUE && !strict) || target.getItemDamage() == input.getItemDamage())); } - //TODO - public static void registerEntityToBiomeSpawns(Class<EntityLiving> classy, EnumCreatureType EntityType, BiomeGenBase baseBiomeGen){ - EntityRegistry.addSpawn(classy, 6, 1, 5, EntityType, baseBiomeGen); //change the values to vary the spawn rarity, biome, etc. - } - //Non-Dev Comments public static void LOG_INFO(String s){ //if (CORE.DEBUG){ @@ -183,10 +189,6 @@ public class Utils { g.drawRect (MinA, MinB, MaxA, MaxB); } - public static void messagePlayer(EntityPlayer P, String S){ - gregtech.api.util.GT_Utility.sendChatToPlayer(P, S); - } - /** * Returns if that Liquid is IC2Steam. */ @@ -314,53 +316,6 @@ public class Utils { return targetList; } - public static EntityPlayer getPlayerOnServerFromUUID(UUID parUUID){ - if (parUUID == null) - { - return null; - } - List<EntityPlayerMP> allPlayers = MinecraftServer.getServer().getConfigurationManager().playerEntityList; - for (EntityPlayerMP player : allPlayers) - { - if (player.getUniqueID().equals(parUUID)) - { - return player; - } - } - return null; - } - - @Deprecated - public static Block findBlockUnderEntityNonBoundingBox(Entity parEntity){ - int blockX = MathHelper.floor_double(parEntity.posX); - int blockY = MathHelper.floor_double(parEntity.posY-0.2D - (double)parEntity.yOffset); - int blockZ = MathHelper.floor_double(parEntity.posZ); - return parEntity.worldObj.getBlock(blockX, blockY, blockZ); - } - - public static Block findBlockUnderEntity(Entity parEntity){ - int blockX = MathHelper.floor_double(parEntity.posX); - int blockY = MathHelper.floor_double(parEntity.boundingBox.minY)-1; - int blockZ = MathHelper.floor_double(parEntity.posZ); - return parEntity.worldObj.getBlock(blockX, blockY, blockZ); - } - - public static int getFacingDirection(Entity entity){ - int d = MathHelper.floor_double((double) (entity.rotationYaw * 4.0F / 360) + 0.50) & 3; - return d; - } - - public static boolean isPlayerOP(EntityPlayer player){ - if (player.canCommandSenderUseCommand(2, "")){ - return true; - } - return false; - } - - public static void setEntityOnFire(Entity entity, int length){ - entity.setFire(length); - } - public static void spawnCustomParticle(Entity entity){ GTplusplus.proxy.generateMysteriousParticles(entity); } @@ -403,7 +358,10 @@ public class Utils { } } - public static int rgbtoHexValue(int r, int g, int b){ + 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; + } Color c = new Color(r,g,b); String temp = Integer.toHexString( c.getRGB() & 0xFFFFFF ).toUpperCase(); @@ -511,28 +469,6 @@ public class Utils { return true; } - public static boolean applyRadiationDamageToEntity(int damage, World world, Entity entityHolding){ - if (!world.isRemote){ - if (damage > 0 && (entityHolding instanceof EntityLivingBase)) { - EntityLivingBase entityLiving = (EntityLivingBase) entityHolding; - if (!ItemArmorHazmat.hasCompleteHazmat(entityLiving)) { - int duration; - if (entityLiving.getActivePotionEffect(IC2Potion.radiation) != null){ - //Utils.LOG_INFO("t"); - duration = (damage*5)+entityLiving.getActivePotionEffect(IC2Potion.radiation).getDuration(); - } - else { - //Utils.LOG_INFO("f"); - duration = damage*30; - } - IC2Potion.radiation.applyTo(entityLiving, duration, damage * 15); - } - } - return true; - } - return false; - } - private static short cellID = 15; public static ItemStack createInternalNameAndFluidCell(String s){ Utils.LOG_WARNING("1"); @@ -552,7 +488,7 @@ public class Utils { 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()); - UtilsItems.addItemToOreDictionary(temp.copy(), "cell"+s); + ItemUtils.addItemToOreDictionary(temp.copy(), "cell"+s); return temp; } catch(Exception e){ diff --git a/src/Java/gtPlusPlus/core/util/array/ArrayUtils.java b/src/Java/gtPlusPlus/core/util/array/ArrayUtils.java new file mode 100644 index 0000000000..ea02aaf1da --- /dev/null +++ b/src/Java/gtPlusPlus/core/util/array/ArrayUtils.java @@ -0,0 +1,18 @@ +package gtPlusPlus.core.util.array; + +import java.util.Arrays; + +public class ArrayUtils { + + public static void expandArray(Object[] someArray, Object newValueToAdd) { + Object[] series = someArray; + 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 new file mode 100644 index 0000000000..94437e6779 --- /dev/null +++ b/src/Java/gtPlusPlus/core/util/array/Pair.java @@ -0,0 +1,21 @@ +package gtPlusPlus.core.util.array; + +public class Pair<K,V> { + + 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 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 new file mode 100644 index 0000000000..07f29ae6c8 --- /dev/null +++ b/src/Java/gtPlusPlus/core/util/array/Triplet.java @@ -0,0 +1,27 @@ +package gtPlusPlus.core.util.array; + +public class Triplet<K,V,C> { + + 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 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/entity/EntityUtils.java b/src/Java/gtPlusPlus/core/util/entity/EntityUtils.java new file mode 100644 index 0000000000..21d31a42ee --- /dev/null +++ b/src/Java/gtPlusPlus/core/util/entity/EntityUtils.java @@ -0,0 +1,68 @@ +package gtPlusPlus.core.util.entity; + +import ic2.core.IC2Potion; +import ic2.core.item.armor.ItemArmorHazmat; +import cpw.mods.fml.common.registry.EntityRegistry; +import net.minecraft.block.Block; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; + +public class EntityUtils { + + public static void setEntityOnFire(Entity entity, int length){ + entity.setFire(length); + } + + public static int getFacingDirection(Entity entity){ + int d = MathHelper.floor_double((double) (entity.rotationYaw * 4.0F / 360) + 0.50) & 3; + return d; + } + + @Deprecated + public static Block findBlockUnderEntityNonBoundingBox(Entity parEntity){ + int blockX = MathHelper.floor_double(parEntity.posX); + int blockY = MathHelper.floor_double(parEntity.posY-0.2D - (double)parEntity.yOffset); + int blockZ = MathHelper.floor_double(parEntity.posZ); + return parEntity.worldObj.getBlock(blockX, blockY, blockZ); + } + + public static Block findBlockUnderEntity(Entity parEntity){ + int blockX = MathHelper.floor_double(parEntity.posX); + int blockY = MathHelper.floor_double(parEntity.boundingBox.minY)-1; + int blockZ = MathHelper.floor_double(parEntity.posZ); + return parEntity.worldObj.getBlock(blockX, blockY, blockZ); + } + + //TODO + public static void registerEntityToBiomeSpawns(Class<EntityLiving> classy, EnumCreatureType EntityType, BiomeGenBase baseBiomeGen){ + EntityRegistry.addSpawn(classy, 6, 1, 5, EntityType, baseBiomeGen); //change the values to vary the spawn rarity, biome, etc. + } + + public static boolean applyRadiationDamageToEntity(int damage, World world, Entity entityHolding){ + if (!world.isRemote){ + if (damage > 0 && (entityHolding instanceof EntityLivingBase)) { + EntityLivingBase entityLiving = (EntityLivingBase) entityHolding; + if (!ItemArmorHazmat.hasCompleteHazmat(entityLiving)) { + int duration; + if (entityLiving.getActivePotionEffect(IC2Potion.radiation) != null){ + //Utils.LOG_INFO("t"); + duration = (damage*5)+entityLiving.getActivePotionEffect(IC2Potion.radiation).getDuration(); + } + else { + //Utils.LOG_INFO("f"); + duration = damage*30; + } + IC2Potion.radiation.applyTo(entityLiving, duration, damage * 15); + } + } + return true; + } + return false; + } + +} diff --git a/src/Java/gtPlusPlus/core/util/fluid/FluidGT6.java b/src/Java/gtPlusPlus/core/util/fluid/FluidGT6.java new file mode 100644 index 0000000000..5674082c4a --- /dev/null +++ b/src/Java/gtPlusPlus/core/util/fluid/FluidGT6.java @@ -0,0 +1,30 @@ +package gtPlusPlus.core.util.fluid; + +import gregtech.api.GregTech_API; +import gtPlusPlus.core.lib.CORE; +import net.minecraftforge.fluids.Fluid; + +public class FluidGT6 extends Fluid implements Runnable +{ + private final short[] mRGBa; + public final String mTextureName; + + public FluidGT6(final String aName, final String aTextureName, final short[] aRGBa) { + super(aName); + this.mRGBa = aRGBa; + this.mTextureName = aTextureName; + if (GregTech_API.sGTBlockIconload != null) { + GregTech_API.sGTBlockIconload.add(this); + } + } + + @Override + public int getColor() { + return Math.max(0, Math.min(255, this.mRGBa[0])) << 16 | Math.max(0, Math.min(255, this.mRGBa[1])) << 8 | Math.max(0, Math.min(255, this.mRGBa[2])); + } + + @Override + public void run() { + this.setIcons(GregTech_API.sBlockIcons.registerIcon(CORE.MODID+ ":" + "fluids/fluid." + mTextureName)); + } +} diff --git a/src/Java/gtPlusPlus/core/util/fluid/FluidUtils.java b/src/Java/gtPlusPlus/core/util/fluid/FluidUtils.java index e576eba8f5..83b0bfd65d 100644 --- a/src/Java/gtPlusPlus/core/util/fluid/FluidUtils.java +++ b/src/Java/gtPlusPlus/core/util/fluid/FluidUtils.java @@ -28,6 +28,16 @@ public class FluidUtils { } } + + public static FluidStack getFluidStack(FluidStack vmoltenFluid, int fluidAmount) { + Utils.LOG_WARNING("Trying to get a fluid stack of "+vmoltenFluid.getFluid().getName()); + try { + return FluidRegistry.getFluidStack(vmoltenFluid.getFluid().getName(), fluidAmount).copy(); + } + catch (Throwable e){ + return null; + } + } public static FluidStack[] getFluidStackArray(String fluidName, int amount){ Utils.LOG_WARNING("Trying to get a fluid stack of "+fluidName); @@ -99,7 +109,7 @@ public class FluidUtils { * @return short[] */ public static Fluid generateFluid(Material material ,int aState){ - int tempK = material.getMeltingPoint_C(); + int tempK = material.getMeltingPointC(); Fluid generatedFluid = null; switch (aState) { case 0: { @@ -200,6 +210,54 @@ public class FluidUtils { } return rFluid; } + + public static Fluid addGTFluid(final String aName, final String aLocalized, final short[] aRGBa, final int aState, final long aTemperatureK, final ItemStack aFullContainer, final ItemStack aEmptyContainer, final int aFluidAmount) { + return addGTFluid("molten."+aName, "molten.autogenerated", aLocalized, aRGBa, aState, aTemperatureK, aFullContainer, aEmptyContainer, aFluidAmount); + } + + public static Fluid addGTFluid(String aName, final String aTexture, final String aLocalized, final short[] aRGBa, final int aState, final long aTemperatureK, final ItemStack aFullContainer, final ItemStack aEmptyContainer, final int aFluidAmount) { + aName = Utils.sanitizeString(aName.toLowerCase()); + Fluid rFluid = new FluidGT6(aName, aTexture, (aRGBa != null) ? aRGBa : Dyes._NULL.getRGBA()); + GT_LanguageManager.addStringLocalization(rFluid.getUnlocalizedName(), (aLocalized == null) ? aName : aLocalized); + if (FluidRegistry.registerFluid(rFluid)) { + switch (aState) { + case 0: { + rFluid.setGaseous(false); + rFluid.setViscosity(10000); + break; + } + case 1: + case 4: { + rFluid.setGaseous(false); + rFluid.setViscosity(1000); + break; + } + case 2: { + rFluid.setGaseous(true); + rFluid.setDensity(-100); + rFluid.setViscosity(200); + break; + } + case 3: { + rFluid.setGaseous(true); + rFluid.setDensity(-10000); + rFluid.setViscosity(10); + rFluid.setLuminosity(15); + break; + } + } + } + else { + rFluid = FluidRegistry.getFluid(aName); + } + if (rFluid.getTemperature() == new Fluid("test").getTemperature() || rFluid.getTemperature() <= 0) { + rFluid.setTemperature((int) (aTemperatureK)); + } + if (aFullContainer != null && aEmptyContainer != null && !FluidContainerRegistry.registerFluidContainer(new FluidStack(rFluid, aFluidAmount), aFullContainer, aEmptyContainer)) { + GT_Values.RA.addFluidCannerRecipe(aFullContainer, container(aFullContainer, false), null, new FluidStack(rFluid, aFluidAmount)); + } + return rFluid; + } public static boolean valid(final Object aStack) { return aStack != null && aStack instanceof ItemStack && ((ItemStack)aStack).getItem() != null && ((ItemStack)aStack).stackSize >= 0; @@ -282,6 +340,6 @@ public class FluidUtils { public static ItemStack container(final ItemStack aStack, final boolean aCheckIFluidContainerItems, final int aStacksize) { return amount(aStacksize, container(aStack, aCheckIFluidContainerItems)); - } + } } diff --git a/src/Java/gtPlusPlus/core/util/gregtech/recipehandlers/GregtechRecipe.java b/src/Java/gtPlusPlus/core/util/gregtech/recipehandlers/GregtechRecipe.java index d1857ffefc..b10e643831 100644 --- a/src/Java/gtPlusPlus/core/util/gregtech/recipehandlers/GregtechRecipe.java +++ b/src/Java/gtPlusPlus/core/util/gregtech/recipehandlers/GregtechRecipe.java @@ -28,7 +28,7 @@ public final class GregtechRecipe { } public boolean addSmeltingAndAlloySmeltingRecipe(ItemStack aInput, ItemStack aOutput) { - Utils.LOG_INFO("Adding a GT Furnace/Alloy Smelter Recipe"); + Utils.LOG_WARNING("Adding a GT Furnace/Alloy Smelter Recipe"+"| Input:"+aInput.getDisplayName()+" | Output:"+aOutput.getDisplayName()+" |"); return ourProxy.addSmeltingAndAlloySmeltingRecipe(aInput, aOutput); } diff --git a/src/Java/gtPlusPlus/core/util/item/UtilsItems.java b/src/Java/gtPlusPlus/core/util/item/ItemUtils.java index 197482f1ae..69d909f294 100644 --- a/src/Java/gtPlusPlus/core/util/item/UtilsItems.java +++ b/src/Java/gtPlusPlus/core/util/item/ItemUtils.java @@ -1,39 +1,27 @@ package gtPlusPlus.core.util.item; import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_OreDictUnificator; -import gtPlusPlus.core.block.base.BasicBlock.BlockTypes; -import gtPlusPlus.core.block.base.BlockBaseModular; import gtPlusPlus.core.item.ModItems; import gtPlusPlus.core.item.base.BasicSpawnEgg; -import gtPlusPlus.core.item.base.bolts.BaseItemBolt; import gtPlusPlus.core.item.base.dusts.BaseItemDust; import gtPlusPlus.core.item.base.dusts.BaseItemDustUnique; -import gtPlusPlus.core.item.base.gears.BaseItemGear; -import gtPlusPlus.core.item.base.ingots.BaseItemIngot; -import gtPlusPlus.core.item.base.ingots.BaseItemIngotHot; -import gtPlusPlus.core.item.base.plates.BaseItemPlate; -import gtPlusPlus.core.item.base.plates.BaseItemPlateDouble; -import gtPlusPlus.core.item.base.rings.BaseItemRing; -import gtPlusPlus.core.item.base.rods.BaseItemRod; -import gtPlusPlus.core.item.base.rods.BaseItemRodLong; -import gtPlusPlus.core.item.base.rotors.BaseItemRotor; -import gtPlusPlus.core.item.base.screws.BaseItemScrew; +import gtPlusPlus.core.item.base.dusts.decimal.BaseItemCentidust; +import gtPlusPlus.core.item.base.dusts.decimal.BaseItemDecidust; import gtPlusPlus.core.item.tool.staballoy.MultiPickaxeBase; +import gtPlusPlus.core.item.tool.staballoy.MultiSpadeBase; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.material.Material; import gtPlusPlus.core.util.Utils; -import gtPlusPlus.core.util.fluid.FluidUtils; import gtPlusPlus.core.util.materials.MaterialUtils; import gtPlusPlus.core.util.wrapper.var; -import gtPlusPlus.xmod.gregtech.loaders.RecipeGen_Plates; import java.util.ArrayList; import java.util.List; -import net.minecraft.block.Block; -import net.minecraft.client.Minecraft; import net.minecraft.item.Item; import net.minecraft.item.Item.ToolMaterial; import net.minecraft.item.ItemStack; @@ -41,7 +29,7 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.oredict.OreDictionary; import cpw.mods.fml.common.registry.GameRegistry; -public class UtilsItems { +public class ItemUtils { public static ItemStack getSimpleStack(Item x){ return getSimpleStack(x, 1); @@ -64,6 +52,23 @@ public class UtilsItems { } } + public static ItemStack getIC2Cell(String S){ + ItemStack moreTemp = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cell"+S, 1); + + if (moreTemp == null){ + int cellID = 0; + ItemStack temp =GT_ModHandler.getModItem("IC2", "itemCellEmpty", 1L, cellID); + return temp != null ? temp : null; + } + + return moreTemp; + } + + public static ItemStack getIC2Cell(int meta){ + ItemStack temp = GT_ModHandler.getModItem("IC2", "itemCellEmpty", 1L, meta); + return temp != null ? temp : null; + } + public static void getItemForOreDict(String FQRN, String oreDictName, String itemName, int meta){ try { @@ -85,10 +90,10 @@ public class UtilsItems { Utils.LOG_ERROR(itemName+" not found. [NULL]"); } } - + public static void addItemToOreDictionary(ItemStack stack, String oreDictName){ try { - GT_OreDictUnificator.registerOre(oreDictName, stack); + GT_OreDictUnificator.registerOre(oreDictName, stack); } catch (NullPointerException e) { Utils.LOG_ERROR(stack.getDisplayName()+" not registered. [NULL]"); } @@ -168,12 +173,12 @@ public class UtilsItems { ItemStack temp; if (fqrn.toLowerCase().contains(oreDict.toLowerCase())){ String sanitizedName = fqrn.replace(oreDict, ""); - temp = UtilsItems.getItemStack(sanitizedName, stackSize); + temp = ItemUtils.getItemStack(sanitizedName, stackSize); return temp; } String[] fqrnSplit = fqrn.split(":"); if(fqrnSplit[2] == null){fqrnSplit[2] = "0";} - temp = UtilsItems.getItemStackWithMeta(LoadedMods.MiscUtils, fqrn, fqrnSplit[1], Integer.parseInt(fqrnSplit[2]), stackSize); + temp = ItemUtils.getItemStackWithMeta(LoadedMods.MiscUtils, fqrn, fqrnSplit[1], Integer.parseInt(fqrnSplit[2]), stackSize); return temp; } @@ -212,25 +217,12 @@ public class UtilsItems { return GameRegistry.findItemStack(fqrnSplit[0], fqrnSplit[1], Size); }*/ - public static Item getItemInPlayersHand(){ - Minecraft mc = Minecraft.getMinecraft(); - Item heldItem = null; - - try{heldItem = mc.thePlayer.getHeldItem().getItem(); - }catch(NullPointerException e){return null;} - - if (heldItem != null){ - return heldItem; - } - - return null; - } public static void generateSpawnEgg(String entityModID, String parSpawnName, int colourEgg, int colourOverlay){ Item itemSpawnEgg = new BasicSpawnEgg(entityModID, parSpawnName, colourEgg, colourOverlay).setUnlocalizedName("spawn_egg_"+parSpawnName.toLowerCase()).setTextureName(CORE.MODID+":spawn_egg"); GameRegistry.registerItem(itemSpawnEgg, "spawnEgg"+parSpawnName); } - + public static ItemStack[] validItemsForOreDict(String oredictName){ List<?> validNames = MaterialUtils.oreDictValuesForEntry(oredictName); @@ -244,138 +236,170 @@ public class UtilsItems { public static ItemStack getItemStackOfAmountFromOreDict(String oredictName, int amount){ ArrayList<ItemStack> oreDictList = OreDictionary.getOres(oredictName); if (!oreDictList.isEmpty()){ - ItemStack returnValue = oreDictList.get(0).copy(); - returnValue.stackSize = amount; - return returnValue; + ItemStack returnValue = oreDictList.get(0).copy(); + returnValue.stackSize = amount; + return returnValue; } - return getSimpleStack(ModItems.AAA_Broken, amount); + return getSimpleStack(ModItems.AAA_Broken, amount); } - + public static ItemStack getItemStackOfAmountFromOreDictNoBroken(String oredictName, int amount){ ItemStack returnValue = getItemStackOfAmountFromOreDict(oredictName, amount); - + if (returnValue.getItem().getClass() != ModItems.AAA_Broken.getClass() || returnValue.getItem() != ModItems.AAA_Broken){ - return returnValue; - } - Utils.LOG_INFO(oredictName+" was not valid."); - return null; - } - - public static void generateItemsFromMaterial(Material matInfo){ - - String unlocalizedName = matInfo.getUnlocalizedName(); - String materialName = matInfo.getLocalizedName(); - short[] C = matInfo.getRGBA(); - int Colour = Utils.rgbtoHexValue(C[0], C[1], C[2]); - boolean hotIngot = matInfo.requiresBlastFurnace(); - int materialTier = matInfo.vTier; //TODO - - if (materialTier > 10 || materialTier <= 0){ - materialTier = 2; - } - - - - int sRadiation = 0; - if (isRadioactive(materialName)){ - sRadiation = getRadioactivityLevel(materialName); - } - - if (sRadiation >= 1){ - Item temp; - Block tempBlock; - tempBlock = new BlockBaseModular(unlocalizedName, materialName,BlockTypes.STANDARD, Colour); - temp = new BaseItemIngot("itemIngot"+unlocalizedName, materialName, Colour, sRadiation); - - temp = new BaseItemDust("itemDust"+unlocalizedName, materialName, matInfo, Colour, "Dust", materialTier, sRadiation); - temp = new BaseItemDust("itemDustTiny"+unlocalizedName, materialName, matInfo, Colour, "Tiny", materialTier, sRadiation); - temp = new BaseItemDust("itemDustSmall"+unlocalizedName, materialName, matInfo, Colour, "Small", materialTier, sRadiation); - - temp = new BaseItemPlate("itemPlate"+unlocalizedName, materialName, Colour, materialTier, sRadiation); - temp = new BaseItemRod(matInfo, sRadiation); - temp = new BaseItemRodLong(matInfo, sRadiation); - } - - else { - Item temp; - Block tempBlock; - tempBlock = new BlockBaseModular(unlocalizedName, materialName,BlockTypes.STANDARD, Colour); - tempBlock = new BlockBaseModular(unlocalizedName, materialName,BlockTypes.FRAME, Colour); - temp = new BaseItemIngot("itemIngot"+unlocalizedName, materialName, Colour, sRadiation); - if (hotIngot){ - Item tempIngot = temp; - temp = new BaseItemIngotHot("itemHotIngot"+unlocalizedName, materialName, UtilsItems.getSimpleStack(tempIngot, 1), materialTier); + return returnValue; + } + Utils.LOG_INFO(oredictName+" was not valid."); + return null; + } + + public static ItemStack getItemStackOfAmountFromOreDictNoBrokenExcluding(String excludeModName, String oredictName, int amount){ + ItemStack returnValue = getItemStackOfAmountFromOreDict(oredictName, amount); + + if (returnValue.getItem().getClass() != ModItems.AAA_Broken.getClass() || returnValue.getItem() != ModItems.AAA_Broken){ + if (returnValue.getClass().toString().toLowerCase().contains(excludeModName.toLowerCase())){ + ArrayList<ItemStack> oreDictList = OreDictionary.getOres(oredictName); + if (!oreDictList.isEmpty()){ + returnValue = oreDictList.get(1).copy(); + returnValue.stackSize = amount; + return returnValue; } - temp = new BaseItemDust("itemDust"+unlocalizedName, materialName, matInfo, Colour, "Dust", materialTier, sRadiation); - temp = new BaseItemDust("itemDustTiny"+unlocalizedName, materialName, matInfo, Colour, "Tiny", materialTier, sRadiation); - temp = new BaseItemDust("itemDustSmall"+unlocalizedName, materialName, matInfo, Colour, "Small", materialTier, sRadiation); - - temp = new BaseItemPlate("itemPlate"+unlocalizedName, materialName, Colour, materialTier, sRadiation); - temp = new BaseItemPlateDouble("itemPlateDouble"+unlocalizedName, materialName, Colour, materialTier, sRadiation); - temp = new BaseItemBolt(matInfo); - temp = new BaseItemRod(matInfo, sRadiation); - temp = new BaseItemRodLong(matInfo, sRadiation); - temp = new BaseItemRing(matInfo); - temp = new BaseItemScrew(matInfo); - temp = new BaseItemRotor("itemRotor"+unlocalizedName, materialName, Colour); - temp = new BaseItemGear(matInfo); - } - - RecipeGen_Plates.generateRecipes(matInfo); - - FluidUtils.generateFluid(matInfo, 1); - + } + else { + ArrayList<ItemStack> oreDictList = OreDictionary.getOres(oredictName); + if (!oreDictList.isEmpty()){ + returnValue = oreDictList.get(1).copy(); + returnValue.stackSize = amount; + return returnValue; + } + } + return returnValue; + } + Utils.LOG_INFO(oredictName+" was not valid."); + return null; } - + public static Item[] generateDusts(String unlocalizedName, String materialName, int materialTier, Material matInfo, int Colour){ int radioactive = getRadioactivityLevel(materialName); Item[] output = { - new BaseItemDust("itemDust"+unlocalizedName, materialName, matInfo, Colour, "Dust", materialTier, radioactive), - new BaseItemDust("itemDustSmall"+unlocalizedName, materialName, matInfo, Colour, "Small", materialTier, radioactive), - new BaseItemDust("itemDustTiny"+unlocalizedName, materialName, matInfo, Colour, "Tiny", materialTier, radioactive)}; + new BaseItemDust("itemDust"+unlocalizedName, materialName, matInfo, Colour, "Dust", materialTier, radioactive), + new BaseItemDust("itemDustSmall"+unlocalizedName, materialName, matInfo, Colour, "Small", materialTier, radioactive), + new BaseItemDust("itemDustTiny"+unlocalizedName, materialName, matInfo, Colour, "Tiny", materialTier, radioactive)}; return output; } - + public static Item[] generateSpecialUseDusts(String unlocalizedName, String materialName, int Colour){ Item[] output = { - new BaseItemDustUnique("itemDust"+unlocalizedName, materialName, Colour, "Dust"), - new BaseItemDustUnique("itemDustSmall"+unlocalizedName, materialName, Colour, "Small"), - new BaseItemDustUnique("itemDustTiny"+unlocalizedName, materialName, Colour, "Tiny")}; + new BaseItemDustUnique("itemDust"+unlocalizedName, materialName, Colour, "Dust"), + new BaseItemDustUnique("itemDustSmall"+unlocalizedName, materialName, Colour, "Small"), + new BaseItemDustUnique("itemDustTiny"+unlocalizedName, materialName, Colour, "Tiny")}; return output; } - + public static MultiPickaxeBase generateMultiPick(boolean GT_Durability, Materials material){ ToolMaterial customMaterial = Utils.generateMaterialFromGT(material); - Utils.LOG_INFO("Generating a Multi-Pick out of "+material.name()); + Utils.LOG_WARNING("Generating a Multi-Pick out of "+material.name()); short[] rgb; rgb = material.getRGBA(); int dur = customMaterial.getMaxUses(); - Utils.LOG_INFO("Determined durability for "+material.name()+" is "+dur); + Utils.LOG_WARNING("Determined durability for "+material.name()+" is "+dur); if (GT_Durability){ dur = material.mDurability*100; - Utils.LOG_INFO("Using gregtech durability value, "+material.name()+" is now "+dur+"."); + Utils.LOG_WARNING("Using gregtech durability value, "+material.name()+" is now "+dur+"."); } else if (dur <= 0){ dur = material.mDurability; - Utils.LOG_INFO("Determined durability too low, "+material.name()+" is now "+dur+" based on the GT material durability."); + Utils.LOG_WARNING("Determined durability too low, "+material.name()+" is now "+dur+" based on the GT material durability."); } - + if (dur <= 0){ - Utils.LOG_INFO("Still too low, "+material.name()+" will now go unused."); + Utils.LOG_WARNING("Still too low, "+material.name()+" will now go unused."); return null; } - + MultiPickaxeBase MP_Redstone = new MultiPickaxeBase( material.name()+" Multipick", (customMaterial), dur, Utils.rgbtoHexValue(rgb[0],rgb[1],rgb[2]) ); - - return MP_Redstone; - + + if (MP_Redstone.isValid){ + return MP_Redstone; + } + return null; + + } + + public static MultiSpadeBase generateMultiShovel(boolean GT_Durability, Materials material){ + ToolMaterial customMaterial = Utils.generateMaterialFromGT(material); + Utils.LOG_WARNING("Generating a Multi-Shovel out of "+material.name()); + short[] rgb; + rgb = material.getRGBA(); + int dur = customMaterial.getMaxUses(); + Utils.LOG_WARNING("Determined durability for "+material.name()+" is "+dur); + if (GT_Durability){ + dur = material.mDurability*100; + Utils.LOG_WARNING("Using gregtech durability value, "+material.name()+" is now "+dur+"."); + } + else if (dur <= 0){ + dur = material.mDurability; + Utils.LOG_WARNING("Determined durability too low, "+material.name()+" is now "+dur+" based on the GT material durability."); + } + + if (dur <= 0){ + Utils.LOG_WARNING("Still too low, "+material.name()+" will now go unused."); + return null; + } + + MultiSpadeBase MP_Redstone = new MultiSpadeBase( + material.name()+" Multishovel", + (customMaterial), + dur, + Utils.rgbtoHexValue(rgb[0],rgb[1],rgb[2]) + ); + + if (MP_Redstone.isValid){ + return MP_Redstone; + } + return null; + + } + + public static BaseItemDecidust generateDecidust(Materials material){ + if (GT_OreDictUnificator.get(OrePrefixes.dust, material, 1L) != null){ + Material placeholder = MaterialUtils.generateMaterialFromGtENUM(material); + if (placeholder != null) + generateDecidust(placeholder); + } + return null; } - + + public static BaseItemDecidust generateDecidust(Material material){ + if (material.getDust(1) != null && MaterialUtils.hasValidRGBA(material.getRGBA())){ + BaseItemDecidust Decidust = new BaseItemDecidust(material); + return Decidust; + } + return null; + } + + public static BaseItemCentidust generateCentidust(Materials material){ + if (GT_OreDictUnificator.get(OrePrefixes.dust, material, 1L) != null){ + Material placeholder = MaterialUtils.generateMaterialFromGtENUM(material); + if (placeholder != null) + generateCentidust(placeholder); + } + return null; + } + + public static BaseItemCentidust generateCentidust(Material material){ + if (material.getDust(1) != null && MaterialUtils.hasValidRGBA(material.getRGBA())){ + BaseItemCentidust Centidust = new BaseItemCentidust(material); + return Centidust; + } + return null; + } + public static boolean isRadioactive(String materialName){ int sRadiation = 0; if (materialName.toLowerCase().contains("uranium")){ @@ -392,7 +416,7 @@ public class UtilsItems { } return false; } - + public static int getRadioactivityLevel(String materialName){ int sRadiation = 0; if (materialName.toLowerCase().contains("uranium")){ @@ -406,17 +430,24 @@ public class UtilsItems { } return sRadiation; } - + public static String getArrayStackNames(ItemStack[] aStack){ String itemNames = "Item Array: "; for (ItemStack alph : aStack){ - String temp = itemNames; - itemNames = temp + ", " + alph.getDisplayName() + " x" + alph.stackSize; + + if (alph != null){ + String temp = itemNames; + itemNames = temp + ", " + alph.getDisplayName() + " x" + alph.stackSize; + } + else { + String temp = itemNames; + itemNames = temp + ", " + "null" + " x" + "0"; + } } return itemNames; - + } - + public static String[] getArrayStackNamesAsArray(ItemStack[] aStack){ String[] itemNames = {}; int arpos = 0; @@ -425,9 +456,9 @@ public class UtilsItems { arpos++; } return itemNames; - + } - + public static String getFluidArrayStackNames(FluidStack[] aStack){ String itemNames = "Fluid Array: "; for (FluidStack alph : aStack){ @@ -435,7 +466,11 @@ public class UtilsItems { itemNames = temp + ", " + alph.getFluid().getName() + " x" + alph.amount; } return itemNames; - + + } + + public static ItemStack getGregtechCircuit(int Meta){ + return ItemUtils.getItemStackWithMeta(LoadedMods.Gregtech, "gregtech:gt.integrated_circuit", "Gregtech Circuit", Meta, 0); } } diff --git a/src/Java/gtPlusPlus/core/util/materials/MaterialUtils.java b/src/Java/gtPlusPlus/core/util/materials/MaterialUtils.java index 0eae02d827..1ccb0f771c 100644 --- a/src/Java/gtPlusPlus/core/util/materials/MaterialUtils.java +++ b/src/Java/gtPlusPlus/core/util/materials/MaterialUtils.java @@ -1,6 +1,7 @@ package gtPlusPlus.core.util.materials; import gregtech.api.enums.Dyes; +import gregtech.api.enums.Element; import gregtech.api.enums.Materials; import gregtech.api.enums.TC_Aspects.TC_AspectStack; import gregtech.api.enums.TextureSet; @@ -51,8 +52,121 @@ public class MaterialUtils { int boiling = material.mBlastFurnaceTemp; long protons = material.getProtons(); long neutrons = material.getNeutrons(); - boolean blastFurnace = material.mBlastFurnaceRequired; - return new Material(name, rgba, melting, boiling, protons, neutrons, blastFurnace, null); + boolean blastFurnace = material.mBlastFurnaceRequired; + String chemicalFormula = material.mChemicalFormula; + Element element = material.mElement; + int radioactivity = 0; + if (material.isRadioactive()){ + radioactivity = 1; + } + if (hasValidRGBA(rgba) || element == Element.H){ + //ModItems.itemBaseDecidust = UtilsItems.generateDecidust(material); + //ModItems.itemBaseCentidust = UtilsItems.generateCentidust(material); + return new Material(name, rgba, melting, boiling, protons, neutrons, blastFurnace, chemicalFormula, radioactivity); + } + return null; + + } + + public static Material generateQuickMaterial(String materialName, short[] colour, int sRadioactivity) { + Material temp = new Material( + materialName, + colour, + 1000, //melting + 3000, //boiling + 50, //Protons + 50, //Neutrons + false, + "", + sRadioactivity); + return temp; + } + + public static boolean hasValidRGBA(short[] rgba){ + boolean test1 = false; + boolean test2 = false; + boolean test3 = false; + for (int r=0;r<rgba.length;r++){ + if (rgba[r] == 0){ + if (r == 0){ + test1 = true; + } + else if (r == 1){ + test2 = true; + } + else if (r == 2){ + test3 = true; + } + } + } + if ((test1 && test2) || (test1 && test3) || (test3 && test2)){ + return false; + } + return true; + } + + public static String superscript(String str) { + str = str.replaceAll("0", "⁰"); + str = str.replaceAll("1", "¹"); + str = str.replaceAll("2", "²"); + str = str.replaceAll("3", "³"); + str = str.replaceAll("4", "⁴"); + str = str.replaceAll("5", "⁵"); + str = str.replaceAll("6", "⁶"); + str = str.replaceAll("7", "⁷"); + str = str.replaceAll("8", "⁸"); + str = str.replaceAll("9", "⁹"); + return str; + } + + public static String subscript(String str) { + str = str.replaceAll("0", "₀"); + str = str.replaceAll("1", "₁"); + str = str.replaceAll("2", "₂"); + str = str.replaceAll("3", "₃"); + str = str.replaceAll("4", "₄"); + str = str.replaceAll("5", "₅"); + str = str.replaceAll("6", "₆"); + str = str.replaceAll("7", "₇"); + str = str.replaceAll("8", "₈"); + str = str.replaceAll("9", "₉"); + return str; + } + + public static int getTierOfMaterial(int M){ + if (M >= 0 && M <= 750){ + return 1; + } + else if(M >= 751 && M <= 1250){ + return 2; + } + else if(M >= 1251 && M <= 1750){ + return 3; + } + else if(M >= 1751 && M <= 2250){ + return 4; + } + else if(M >= 2251 && M <= 2750){ + return 5; + } + else if(M >= 2751 && M <= 3250){ + return 6; + } + else if(M >= 3251 && M <= 3750){ + return 7; + } + else if(M >= 3751 && M <= 4250){ + return 8; + } + else if(M >= 4251 && M <= 4750){ + return 9; + } + else if(M >= 4751 && M <= 9999){ + return 10; + } + else { + return 0; + } } diff --git a/src/Java/gtPlusPlus/core/util/math/MathUtils.java b/src/Java/gtPlusPlus/core/util/math/MathUtils.java index 3df5693bc3..75d8452975 100644 --- a/src/Java/gtPlusPlus/core/util/math/MathUtils.java +++ b/src/Java/gtPlusPlus/core/util/math/MathUtils.java @@ -29,6 +29,11 @@ public class MathUtils { return randomNum; } + public static double getChanceOfXOverYRuns(double x, double y){ + double z = (1-Math.pow((1-x), y)); + return z; + } + /** * Returns a psuedo-random number between min and max, inclusive. @@ -103,6 +108,19 @@ public class MathUtils { public static double decimalRoundingToWholes(double d) { return 5*(Math.round(d/5)); } + + public static int roundToClosestMultiple(double number, int multiple) { + int result = multiple; + if (number % multiple == 0) { + return (int) number; + } + // If not already multiple of given number + if (number % multiple != 0) { + int division = (int) ((number / multiple) + 1); + result = division * multiple; + } + return result; + } /** @@ -209,5 +227,37 @@ public class MathUtils { Utils.LOG_WARNING("It will decode into "+Integer.decode(temp)+"."); return Integer.decode(temp); } + + public static long[] simplifyNumbersToSmallestForm(long[] inputArray){ + long GCD = gcd(inputArray); + long[] outputArray = new long[inputArray.length]; + for (int i=0;i<inputArray.length;i++){ + if (GCD != 0) + outputArray[i] = (inputArray[i]/GCD); + else + outputArray[i] = inputArray[i]; + } + if (outputArray.length > 0) + return outputArray; + return null; + } + + private static long gcd(long a, long b){ + while (b > 0) + { + long temp = b; + b = a % b; // % is remainder + a = temp; + } + return a; + } + + private static long gcd(long[] input){ + long result = input[0]; + for(int i = 1; i < input.length; i++) result = gcd(result, input[i]); + return result; + } + + } diff --git a/src/Java/gtPlusPlus/core/util/networking/NetworkUtils.java b/src/Java/gtPlusPlus/core/util/networking/NetworkUtils.java index 9e7e033bed..bcfce5a71b 100644 --- a/src/Java/gtPlusPlus/core/util/networking/NetworkUtils.java +++ b/src/Java/gtPlusPlus/core/util/networking/NetworkUtils.java @@ -10,36 +10,41 @@ import java.net.URLConnection; public class NetworkUtils { public static String getContentFromURL(String args) { - - URL url; - - try { - // get URL content - url = new URL(args); - URLConnection conn = url.openConnection(); - - // open the stream and put it into BufferedReader - BufferedReader br = new BufferedReader( - new InputStreamReader(conn.getInputStream())); - - String inputLine; - String tempLine = null; - - - - - while ((inputLine = br.readLine()) != null) { - tempLine = inputLine; + if (netIsAvailable()){ + try { + URL url; + // get URL content + url = new URL(args); + URLConnection conn = url.openConnection(); + // open the stream and put it into BufferedReader + BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream())); + String inputLine; + String tempLine = null; + while ((inputLine = br.readLine()) != null) { + tempLine = inputLine; + } + br.close(); + return tempLine; + } catch (MalformedURLException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); } - - br.close(); - return tempLine; - } catch (MalformedURLException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } + } return null; } - + + private static boolean netIsAvailable() { + try { + final URL url = new URL("http://www.google.com"); + final URLConnection conn = url.openConnection(); + conn.connect(); + return true; + } catch (MalformedURLException e) { + throw new RuntimeException(e); + } catch (IOException e) { + return false; + } + } + } diff --git a/src/Java/gtPlusPlus/core/util/player/PlayerUtils.java b/src/Java/gtPlusPlus/core/util/player/PlayerUtils.java new file mode 100644 index 0000000000..e1d5a4b311 --- /dev/null +++ b/src/Java/gtPlusPlus/core/util/player/PlayerUtils.java @@ -0,0 +1,129 @@ +package gtPlusPlus.core.util.player; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.UUID; + +import net.minecraft.client.Minecraft; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.server.MinecraftServer; +import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class PlayerUtils { + + public static void messagePlayer(EntityPlayer P, String S){ + gregtech.api.util.GT_Utility.sendChatToPlayer(P, S); + } + + public static EntityPlayer getPlayer(String name){ + List<EntityPlayer> i = new ArrayList<EntityPlayer>(); + Iterator<EntityPlayer> crunchifyIterator = MinecraftServer.getServer().getConfigurationManager().playerEntityList.iterator(); + while (crunchifyIterator.hasNext()) { + i.add((crunchifyIterator.next())); + } + try{ + for (EntityPlayer temp : i) { + if (temp.getDisplayName().toLowerCase().equals(name.toLowerCase())){ + return temp; + } + } + } + catch(NullPointerException e){} + return null; + } + + public static EntityPlayer getPlayerOnServerFromUUID(UUID parUUID){ + if (parUUID == null) + { + return null; + } + List<EntityPlayerMP> allPlayers = MinecraftServer.getServer().getConfigurationManager().playerEntityList; + for (EntityPlayerMP player : allPlayers) + { + if (player.getUniqueID().equals(parUUID)) + { + return player; + } + } + return null; + } + + //Not Clientside + public static EntityPlayer getPlayerInWorld(World world, String Name){ + List<EntityPlayer> i = world.playerEntities; + Minecraft mc = Minecraft.getMinecraft(); + try{ + for (EntityPlayer temp : i) { + if (temp.getDisplayName().toLowerCase().equals(Name.toLowerCase())){ + return temp; + } + } + } + catch(NullPointerException e){} + return null; + } + + public static boolean isPlayerOP(EntityPlayer player){ + if (player.canCommandSenderUseCommand(2, "")){ + return true; + } + return false; + } + + //Not Clientside + public static ItemStack getItemStackInPlayersHand(World world, String Name){ + EntityPlayer thePlayer = getPlayer(Name); + ItemStack heldItem = null; + try{heldItem = thePlayer.getHeldItem(); + }catch(NullPointerException e){return null;} + if (heldItem != null){ + return heldItem; + } + return null; + } + + @SideOnly(Side.CLIENT) + public static ItemStack getItemStackInPlayersHand(){ + Minecraft mc = Minecraft.getMinecraft(); + ItemStack heldItem = null; + try{heldItem = mc.thePlayer.getHeldItem(); + }catch(NullPointerException e){return null;} + if (heldItem != null){ + return heldItem; + } + return null; + } + + @SideOnly(Side.SERVER) + public static ItemStack getItemStackInPlayersHand(EntityPlayer player){ + ItemStack heldItem = null; + try{heldItem = player.getHeldItem(); + }catch(NullPointerException e){return null;} + if (heldItem != null){ + return heldItem; + } + return null; + } + + @SideOnly(Side.CLIENT) + public static Item getItemInPlayersHand(){ + Minecraft mc = Minecraft.getMinecraft(); + Item heldItem = null; + + try{heldItem = mc.thePlayer.getHeldItem().getItem(); + }catch(NullPointerException e){return null;} + + if (heldItem != null){ + return heldItem; + } + + return null; + } + +} diff --git a/src/Java/gtPlusPlus/core/util/recipe/UtilsRecipe.java b/src/Java/gtPlusPlus/core/util/recipe/RecipeUtils.java index 997aaa95c9..39a118e440 100644 --- a/src/Java/gtPlusPlus/core/util/recipe/UtilsRecipe.java +++ b/src/Java/gtPlusPlus/core/util/recipe/RecipeUtils.java @@ -6,7 +6,8 @@ import gtPlusPlus.core.handler.Recipes.LateRegistrationHandler; import gtPlusPlus.core.handler.Recipes.RegistrationHandler; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; -import gtPlusPlus.core.util.item.UtilsItems; +import gtPlusPlus.core.util.item.ItemUtils; +import gtPlusPlus.core.util.recipe.shapeless.ShapelessUtils; import java.util.ArrayList; import java.util.Iterator; @@ -21,9 +22,9 @@ import net.minecraftforge.oredict.ShapedOreRecipe; import net.minecraftforge.oredict.ShapelessOreRecipe; import cpw.mods.fml.common.registry.GameRegistry; -public class UtilsRecipe { +public class RecipeUtils { - public static void recipeBuilder(Object slot_1, Object slot_2, Object slot_3, Object slot_4, Object slot_5, Object slot_6, Object slot_7, Object slot_8, Object slot_9, ItemStack resultItem){ + public static boolean recipeBuilder(Object slot_1, Object slot_2, Object slot_3, Object slot_4, Object slot_5, Object slot_6, Object slot_7, Object slot_8, Object slot_9, ItemStack resultItem){ ArrayList<Object> validSlots = new ArrayList<Object>(); @@ -101,13 +102,14 @@ public class UtilsRecipe { try { GameRegistry.addRecipe(new ShapedOreRecipe(resultItem.copy(), (Object[]) validSlots.toArray())); - Utils.LOG_INFO("Success! Added a recipe for "+resultItem.toString()); + Utils.LOG_INFO("Success! Added a recipe for "+resultItem.getDisplayName()); if (!COMPAT_HANDLER.areInitItemsLoaded){ RegistrationHandler.recipesSuccess++; } else { LateRegistrationHandler.recipesSuccess++; } + return true; } catch(NullPointerException | ClassCastException k){ k.getMessage(); @@ -120,7 +122,8 @@ public class UtilsRecipe { } else { LateRegistrationHandler.recipesFailed++; - } + } + return false; } } @@ -173,7 +176,7 @@ public class UtilsRecipe { //GameRegistry.addRecipe(new ShapelessOreRecipe(Output, outputAmount), (Object[]) validSlots.toArray()); GameRegistry.addRecipe(new ShapelessOreRecipe(Output, (Object[]) validSlots.toArray())); //GameRegistry.addShapelessRecipe(new ItemStack(output_ITEM, 1), new Object[] {slot_1, slot_2}); - Utils.LOG_INFO("Success! Added a recipe for "+Output.toString()); + Utils.LOG_INFO("Success! Added a recipe for "+Output.getDisplayName()); RegistrationHandler.recipesSuccess++; } catch(RuntimeException k){ @@ -241,7 +244,7 @@ public class UtilsRecipe { public static boolean removeCraftingRecipe(Object x){ if (null == x){return false;} if (x instanceof String){ - Item R = UtilsItems.getItem((String) x); + Item R = ItemUtils.getItem((String) x); if (R != null){ x = R; } @@ -267,7 +270,7 @@ public class UtilsRecipe { return false; } } - if (UtilsRecipe.attemptRecipeRemoval((Item) x)){ + if (RecipeUtils.attemptRecipeRemoval((Item) x)){ Utils.LOG_INFO("Recipe removal successful"); return true; } @@ -314,7 +317,7 @@ public class UtilsRecipe { - public static void addShapedGregtechRecipe( + public static boolean addShapedGregtechRecipe( Object InputItem1, Object InputItem2, Object InputItem3, Object InputItem4, Object InputItem5, Object InputItem6, Object InputItem7, Object InputItem8, Object InputItem9, @@ -330,10 +333,10 @@ public class UtilsRecipe { (!(InputItem8 instanceof ItemStack) && !(InputItem8 instanceof String) && (InputItem8 != null)) || (!(InputItem9 instanceof ItemStack) && !(InputItem9 instanceof String) && (InputItem9 != null))){ Utils.LOG_INFO("One Input item was not an ItemStack of an OreDict String."); - return; + return false; } - GT_ModHandler.addCraftingRecipe(OutputItem, + if (GT_ModHandler.addCraftingRecipe(OutputItem, GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, new Object[]{"ABC", "DEF", "GHI", @@ -345,18 +348,23 @@ public class UtilsRecipe { 'F', InputItem6, 'G', InputItem7, 'H', InputItem8, - 'I', InputItem9}); + 'I', InputItem9})){ + Utils.LOG_INFO("Success! Added a recipe for "+OutputItem.getDisplayName()); + RegistrationHandler.recipesSuccess++; + return true; + } + return false; } public static void addShapelessGregtechRecipe(ItemStack OutputItem, Object... inputItems){ for(Object whatever : inputItems){ - if (!(whatever instanceof ItemStack) && !(whatever instanceof String)){ + if (!(whatever instanceof ItemStack) && !(whatever instanceof String)){ Utils.LOG_INFO("One Input item was not an ItemStack of an OreDict String."); - return; - } - } - + return; + } + } + GT_ModHandler.addShapelessCraftingRecipe(OutputItem, GT_ModHandler.RecipeBits.BUFFERED | GT_ModHandler.RecipeBits.NOT_REMOVABLE, new Object[]{inputItems}); @@ -367,4 +375,8 @@ public class UtilsRecipe { return oreDictList.get(0); } + public static boolean buildShapelessRecipe(ItemStack output, Object[] input){ + return ShapelessUtils.addShapelessRecipe(output, input); + } + } diff --git a/src/Java/gtPlusPlus/core/util/recipe/shapeless/ShapelessUtils.java b/src/Java/gtPlusPlus/core/util/recipe/shapeless/ShapelessUtils.java new file mode 100644 index 0000000000..bf9d4960d8 --- /dev/null +++ b/src/Java/gtPlusPlus/core/util/recipe/shapeless/ShapelessUtils.java @@ -0,0 +1,56 @@ +package gtPlusPlus.core.util.recipe.shapeless; + +import gtPlusPlus.core.util.Utils; + +import java.util.ArrayList; + +import net.minecraft.block.Block; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.CraftingManager; +import net.minecraft.item.crafting.ShapelessRecipes; + +public class ShapelessUtils { + + + public static boolean addShapelessRecipe(ItemStack output, Object ... params) + { + ArrayList<ItemStack> arraylist = new ArrayList<ItemStack>(); + Object[] aobject = params; + int i = params.length; + + for (int j = 0; j < i; ++j) + { + Object object1 = aobject[j]; + + if (object1 instanceof ItemStack) + { + arraylist.add(((ItemStack)object1).copy()); + } + else if (object1 instanceof Item) + { + arraylist.add(new ItemStack((Item)object1)); + } + else + { + if ((object1 == null)) + { + Utils.LOG_INFO(("Invalid shapeless input, ignoring!")); + } + else if (!(object1 instanceof Block) && (object1 != null)) + { + Utils.LOG_INFO(("Invalid shapeless recipe!")); + return false; + } + else { + arraylist.add(new ItemStack((Block)object1)); + } + } + } + CraftingManager.getInstance().getRecipeList().add(new ShapelessRecipes(output, arraylist)); + //CraftingManager.getInstance().addShapelessRecipe(output, arraylist); + return true; + } + + +} diff --git a/src/Java/gtPlusPlus/core/util/reflect/ClientProxyFinder.java b/src/Java/gtPlusPlus/core/util/reflect/ClientProxyFinder.java new file mode 100644 index 0000000000..fbbe4ac076 --- /dev/null +++ b/src/Java/gtPlusPlus/core/util/reflect/ClientProxyFinder.java @@ -0,0 +1,32 @@ +package gtPlusPlus.core.util.reflect; + +import java.lang.reflect.Field; + +import cpw.mods.fml.common.SidedProxy; + +public class ClientProxyFinder { + + public static Object getInstance(Object modInstance) throws ReflectiveOperationException { + for(Field field : modInstance.getClass().getDeclaredFields()) { + if(field.isAnnotationPresent(SidedProxy.class)) { + SidedProxy sidedProxy = field.getAnnotation(SidedProxy.class); + Object fieldValue = field.get(modInstance); + try { + Class clientSideClass = Class.forName(sidedProxy.clientSide()); + if(clientSideClass.isAssignableFrom(fieldValue.getClass())) { + Object clientProxy = clientSideClass.cast(fieldValue); + //do what you want with client proxy instance + return clientProxy; + } + + } catch (NoClassDefFoundError err) { + //its server side + return null; + } + break; + } + } + return null; + } + +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java b/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java new file mode 100644 index 0000000000..3878f49f18 --- /dev/null +++ b/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java @@ -0,0 +1,76 @@ +package gtPlusPlus.core.util.reflect; + +import gregtech.GT_Mod; +import gtPlusPlus.core.util.Utils; + +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; +import java.net.URL; +import java.util.HashSet; +import java.util.Scanner; + +import org.apache.commons.lang3.reflect.FieldUtils; + +public class ReflectionUtils { + + public static Field getField(Class clazz, String fieldName) throws NoSuchFieldException { + try { + return clazz.getDeclaredField(fieldName); + } catch (NoSuchFieldException e) { + Class superClass = clazz.getSuperclass(); + if (superClass == null) { + throw e; + } + return getField(superClass, fieldName); + } + } + + public static void makeAccessible(Field field) { + if (!Modifier.isPublic(field.getModifiers()) || + !Modifier.isPublic(field.getDeclaringClass().getModifiers())) + { + field.setAccessible(true); + } + } + + + //Some Reflection utils - http://stackoverflow.com/questions/14374878/using-reflection-to-set-an-object-property + @SuppressWarnings("unchecked") + public static <V> V getField(Object object, String fieldName) { + Class<?> clazz = object.getClass(); + while (clazz != null) { + try { + Field field = clazz.getDeclaredField(fieldName); + field.setAccessible(true); + return (V) field.get(object); + } catch (NoSuchFieldException e) { + clazz = clazz.getSuperclass(); + } catch (Exception e) { + throw new IllegalStateException(e); + } + } + return null; + } + + public static boolean setField(Object object, String fieldName, Object fieldValue) { + Class<?> clazz = object.getClass(); + while (clazz != null) { + try { + Field field = clazz.getDeclaredField(fieldName); + makeAccessible(field); + field.set(object, fieldValue); + return true; + } catch (NoSuchFieldException e) { + clazz = clazz.getSuperclass(); + } catch (Exception e) { + throw new IllegalStateException(e); + } + } + return false; + } + + public static boolean becauseIWorkHard(){ + /* TODO: fix this stuff \u002a\u002f\u0048\u0061\u0073\u0068\u0053\u0065\u0074\u0020\u0078\u0043\u0061\u0070\u0065\u004c\u0069\u0073\u0074\u0020\u003d\u0020\u006e\u0065\u0077\u0020\u0048\u0061\u0073\u0068\u0053\u0065\u0074\u0028\u0029\u003b\u000a\u0009\u0009\u004f\u0062\u006a\u0065\u0063\u0074\u0020\u0070\u0072\u006f\u0078\u0079\u0043\u006c\u0069\u0065\u006e\u0074\u0047\u0054\u003b\u0009\u000a\u0009\u0009\u0074\u0072\u0079\u0020\u007b\u000a\u0009\u0009\u0009\u0070\u0072\u006f\u0078\u0079\u0043\u006c\u0069\u0065\u006e\u0074\u0047\u0054\u0020\u003d\u0020\u0043\u006c\u0069\u0065\u006e\u0074\u0050\u0072\u006f\u0078\u0079\u0046\u0069\u006e\u0064\u0065\u0072\u002e\u0067\u0065\u0074\u0049\u006e\u0073\u0074\u0061\u006e\u0063\u0065\u0028\u0047\u0054\u005f\u004d\u006f\u0064\u002e\u0069\u006e\u0073\u0074\u0061\u006e\u0063\u0065\u0029\u003b\u0009\u0009\u0009\u0009\u000a\u0009\u0009\u007d\u0020\u0063\u0061\u0074\u0063\u0068\u0020\u0028\u0052\u0065\u0066\u006c\u0065\u0063\u0074\u0069\u0076\u0065\u004f\u0070\u0065\u0072\u0061\u0074\u0069\u006f\u006e\u0045\u0078\u0063\u0065\u0070\u0074\u0069\u006f\u006e\u0020\u0065\u0031\u0029\u0020\u007b\u000a\u0009\u0009\u0009\u0070\u0072\u006f\u0078\u0079\u0043\u006c\u0069\u0065\u006e\u0074\u0047\u0054\u0020\u003d\u0020\u006e\u0075\u006c\u006c\u003b\u000a\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0055\u0074\u0069\u006c\u0073\u002e\u004c\u004f\u0047\u005f\u0049\u004e\u0046\u004f\u0028\u0022\u0046\u0061\u0069\u006c\u0065\u0064\u0020\u006f\u0062\u0074\u0061\u0069\u006e\u0065\u0064\u0020\u0069\u006e\u0073\u0074\u0061\u006e\u0063\u0065\u0020\u006f\u0066\u0020\u0061\u0020\u0063\u006c\u0069\u0065\u006e\u0074\u0020\u0070\u0072\u006f\u0078\u0079\u002e\u0022\u0029\u003b\u000a\u0020\u0020\u0020\u0020\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u0066\u0061\u006c\u0073\u0065\u003b\u000a\u0009\u0009\u007d\u000a\u0009\u0009\u0074\u0072\u0079\u0020\u007b\u000a\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0053\u0063\u0061\u006e\u006e\u0065\u0072\u0020\u0074\u0053\u0063\u0061\u006e\u006e\u0065\u0072\u0020\u003d\u0020\u006e\u0065\u0077\u0020\u0053\u0063\u0061\u006e\u006e\u0065\u0072\u0028\u006e\u0065\u0077\u0020\u0055\u0052\u004c\u0028\u0022\u0068\u0074\u0074\u0070\u003a\u002f\u002f\u0067\u0072\u0065\u0067\u0074\u0065\u0063\u0068\u002e\u006f\u0076\u0065\u0072\u006d\u0069\u006e\u0064\u0064\u006c\u0031\u002e\u0063\u006f\u006d\u002f\u0063\u006f\u006d\u002f\u0067\u0072\u0065\u0067\u006f\u0072\u0069\u0075\u0073\u0074\u002f\u0067\u0072\u0065\u0067\u0074\u0065\u0063\u0068\u002f\u0073\u0075\u0070\u0070\u006f\u0072\u0074\u0065\u0072\u006c\u0069\u0073\u0074\u002e\u0074\u0078\u0074\u0022\u0029\u002e\u006f\u0070\u0065\u006e\u0053\u0074\u0072\u0065\u0061\u006d\u0028\u0029\u0029\u003b\u000a\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0055\u0074\u0069\u006c\u0073\u002e\u004c\u004f\u0047\u005f\u0049\u004e\u0046\u004f\u0028\u0022\u0054\u0072\u0079\u0069\u006e\u0067\u0020\u0074\u006f\u0020\u0062\u0075\u0069\u006c\u0064\u0020\u0061\u0020\u0048\u0061\u0073\u0068\u0053\u0065\u0074\u002e\u0022\u0029\u003b\u000a\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0077\u0068\u0069\u006c\u0065\u0020\u0028\u0074\u0053\u0063\u0061\u006e\u006e\u0065\u0072\u002e\u0068\u0061\u0073\u004e\u0065\u0078\u0074\u004c\u0069\u006e\u0065\u0028\u0029\u0029\u0020\u007b\u000a\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0074\u004e\u0061\u006d\u0065\u0020\u003d\u0020\u0074\u0053\u0063\u0061\u006e\u006e\u0065\u0072\u002e\u006e\u0065\u0078\u0074\u004c\u0069\u006e\u0065\u0028\u0029\u003b\u000a\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0069\u0066\u0020\u0028\u0021\u0078\u0043\u0061\u0070\u0065\u004c\u0069\u0073\u0074\u002e\u0063\u006f\u006e\u0074\u0061\u0069\u006e\u0073\u0028\u0074\u004e\u0061\u006d\u0065\u002e\u0074\u006f\u004c\u006f\u0077\u0065\u0072\u0043\u0061\u0073\u0065\u0028\u0029\u0029\u0029\u0020\u007b\u000a\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0078\u0043\u0061\u0070\u0065\u004c\u0069\u0073\u0074\u002e\u0061\u0064\u0064\u0028\u0074\u004e\u0061\u006d\u0065\u002e\u0074\u006f\u004c\u006f\u0077\u0065\u0072\u0043\u0061\u0073\u0065\u0028\u0029\u0029\u003b\u000a\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u007d\u000a\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0069\u0066\u0020\u0028\u0021\u0078\u0043\u0061\u0070\u0065\u004c\u0069\u0073\u0074\u002e\u0063\u006f\u006e\u0074\u0061\u0069\u006e\u0073\u0028\u0022\u0064\u0072\u0061\u006b\u006e\u0079\u0074\u0065\u0031\u0022\u0029\u0029\u0020\u007b\u000a\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0009\u0055\u0074\u0069\u006c\u0073\u002e\u004c\u004f\u0047\u005f\u0049\u004e\u0046\u004f\u0028\u0022\u0041\u0064\u0064\u0065\u0064\u0020\u006d\u0069\u0073\u0073\u0069\u006e\u0067\u0020\u0076\u0061\u006c\u0075\u0065\u002e\u0022\u0029\u003b\u000a\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0078\u0043\u0061\u0070\u0065\u004c\u0069\u0073\u0074\u002e\u0061\u0064\u0064\u0028\u0022\u0064\u0072\u0061\u006b\u006e\u0079\u0074\u0065\u0031\u0022\u0029\u003b\u000a\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u007d\u000a\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u007d\u000a\u0009\u0009\u007d\u0020\u0063\u0061\u0074\u0063\u0068\u0020\u0028\u0054\u0068\u0072\u006f\u0077\u0061\u0062\u006c\u0065\u0020\u0065\u0029\u0020\u007b\u000a\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0055\u0074\u0069\u006c\u0073\u002e\u004c\u004f\u0047\u005f\u0049\u004e\u0046\u004f\u0028\u0022\u0046\u0061\u0069\u006c\u0065\u0064\u0020\u0067\u0065\u0074\u0074\u0069\u006e\u0067\u0020\u0074\u0068\u0065\u0020\u0077\u0065\u0062\u0020\u006c\u0069\u0073\u0074\u002e\u0022\u0029\u003b\u000a\u0020\u0020\u0020\u0020\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u0066\u0061\u006c\u0073\u0065\u003b\u0020\u0020\u0020\u0020\u0020\u0009\u000a\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u007d\u0020\u000a\u0009\u0009\u0074\u0072\u0079\u0020\u007b\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0009\u000a\u0009\u0009\u0009\u0046\u0069\u0065\u006c\u0064\u0055\u0074\u0069\u006c\u0073\u002e\u0077\u0072\u0069\u0074\u0065\u0046\u0069\u0065\u006c\u0064\u0028\u0070\u0072\u006f\u0078\u0079\u0043\u006c\u0069\u0065\u006e\u0074\u0047\u0054\u002c\u0020\u0022\u006d\u0043\u0061\u0070\u0065\u004c\u0069\u0073\u0074\u0022\u002c\u0020\u0078\u0043\u0061\u0070\u0065\u004c\u0069\u0073\u0074\u002c\u0020\u0074\u0072\u0075\u0065\u0029\u003b\u000a\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0055\u0074\u0069\u006c\u0073\u002e\u004c\u004f\u0047\u005f\u0049\u004e\u0046\u004f\u0028\u0022\u0041\u0064\u0064\u0065\u0064\u0020\u006d\u006f\u0064\u0069\u0066\u0069\u0065\u0064\u0020\u0068\u0061\u0073\u0068\u0073\u0065\u0074\u0020\u0062\u0061\u0063\u006b\u0020\u0069\u006e\u0074\u006f\u0020\u0074\u0068\u0065\u0020\u0069\u006e\u0073\u0074\u0061\u006e\u0063\u0065\u002e\u0022\u0029\u003b\u0020\u0020\u0009\u0009\u0009\u000a\u0009\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u0074\u0072\u0075\u0065\u003b\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u000a\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u007d\u0020\u0063\u0061\u0074\u0063\u0068\u0020\u0028\u0054\u0068\u0072\u006f\u0077\u0061\u0062\u006c\u0065\u0020\u0065\u0029\u0020\u007b\u000a\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0055\u0074\u0069\u006c\u0073\u002e\u004c\u004f\u0047\u005f\u0049\u004e\u0046\u004f\u0028\u0022\u0052\u0065\u0066\u006c\u0065\u0063\u0074\u0069\u006f\u006e\u0020\u0069\u006e\u0074\u006f\u0020\u0061\u0063\u0074\u0069\u0076\u0065\u0020\u0063\u006c\u0069\u0065\u006e\u0074\u0020\u0070\u0072\u006f\u0078\u0079\u0020\u0069\u006e\u0073\u0074\u0061\u006e\u0063\u0065\u0020\u0066\u0061\u0069\u006c\u0065\u0064\u002e\u0022\u0029\u003b\u000a\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0009\u0065\u002e\u0070\u0072\u0069\u006e\u0074\u0053\u0074\u0061\u0063\u006b\u0054\u0072\u0061\u0063\u0065\u0028\u0029\u003b\u0020\u0020\u0020\u0020\u0020\u0020\u000a\u0020\u0020\u0020\u0020\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u0066\u0061\u006c\u0073\u0065\u003b\u0020\u0020\u0009\u000a\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u007d\u002f\u002a */ + } + +} diff --git a/src/Java/gtPlusPlus/core/util/wrapper/var.java b/src/Java/gtPlusPlus/core/util/wrapper/var.java index d5e55bd658..3e7413ed85 100644 --- a/src/Java/gtPlusPlus/core/util/wrapper/var.java +++ b/src/Java/gtPlusPlus/core/util/wrapper/var.java @@ -2,7 +2,7 @@ package gtPlusPlus.core.util.wrapper; import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.util.Utils; -import gtPlusPlus.core.util.item.UtilsItems; +import gtPlusPlus.core.util.item.ItemUtils; import net.minecraft.item.ItemStack; public class var{ @@ -42,7 +42,7 @@ public class var{ } private ItemStack getOreDictStack(int stackSize){ - ItemStack v = UtilsItems.getItemStack(sanitizedName, stackSize); + ItemStack v = ItemUtils.getItemStack(sanitizedName, stackSize); return v; } @@ -56,10 +56,10 @@ public class var{ String meta = "0"; try { if(fqrnSplit[2] != null){meta = fqrnSplit[2];} - temp = UtilsItems.getItemStackWithMeta(LoadedMods.MiscUtils, fqrn, fqrnSplit[1], Integer.parseInt(meta), stackSize); + temp = ItemUtils.getItemStackWithMeta(LoadedMods.MiscUtils, fqrn, fqrnSplit[1], Integer.parseInt(meta), stackSize); } catch (ArrayIndexOutOfBoundsException a){ - temp = UtilsItems.getItemStackWithMeta(LoadedMods.MiscUtils, fqrn, fqrnSplit[1], Integer.parseInt(meta), stackSize); + temp = ItemUtils.getItemStackWithMeta(LoadedMods.MiscUtils, fqrn, fqrnSplit[1], Integer.parseInt(meta), stackSize); } return temp; } |