aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/core/util/enchanting
diff options
context:
space:
mode:
authorAlkalus <draknyte1@hotmail.com>2017-11-24 13:50:31 +1000
committerAlkalus <draknyte1@hotmail.com>2017-11-24 13:50:31 +1000
commit27a3675ced121616092334e68b8ae2719a86abaf (patch)
tree52a36d348762eb71e4a09ce8ff6442723eaa68a5 /src/Java/gtPlusPlus/core/util/enchanting
parentbe05aadfba9659ec68219554ae96b81de5549034 (diff)
downloadGT5-Unofficial-27a3675ced121616092334e68b8ae2719a86abaf.tar.gz
GT5-Unofficial-27a3675ced121616092334e68b8ae2719a86abaf.tar.bz2
GT5-Unofficial-27a3675ced121616092334e68b8ae2719a86abaf.zip
% Refactored a package and class name.
Diffstat (limited to 'src/Java/gtPlusPlus/core/util/enchanting')
-rw-r--r--src/Java/gtPlusPlus/core/util/enchanting/EnchantingUtils.java102
1 files changed, 102 insertions, 0 deletions
diff --git a/src/Java/gtPlusPlus/core/util/enchanting/EnchantingUtils.java b/src/Java/gtPlusPlus/core/util/enchanting/EnchantingUtils.java
new file mode 100644
index 0000000000..76336d4298
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/util/enchanting/EnchantingUtils.java
@@ -0,0 +1,102 @@
+package gtPlusPlus.core.util.enchanting;
+
+import gtPlusPlus.core.util.Utils;
+import net.minecraftforge.fluids.FluidRegistry;
+import net.minecraftforge.fluids.FluidStack;
+
+public class EnchantingUtils {
+
+
+ public static final int XP_PER_BOTTLE = 8;
+ public static final int RATIO = 20;
+ public static final int LIQUID_PER_XP_BOTTLE = 160;
+ public static final double RATIO_MOB_ESSENCE_TO_LIQUID_XP = 13.32;
+
+ public static int liquidToXpRatio(final int liquid) {
+ return liquid / RATIO;
+ }
+
+ public static int xpToLiquidRatio(final int xp) {
+ return xp * RATIO;
+ }
+
+ public static FluidStack getEssenceFromLiquidXp(final int xpAmount){
+ if (xpAmount <= 0){
+ return null;
+ }
+ return getMobEssence((int) (xpAmount*RATIO_MOB_ESSENCE_TO_LIQUID_XP));
+ }
+
+ public static FluidStack getLiquidXpFromEssence(final int essenceAmount){
+ if (essenceAmount <= 0){
+ return null;
+ }
+ return getLiquidXP((int) (essenceAmount/RATIO_MOB_ESSENCE_TO_LIQUID_XP));
+ }
+
+ public static int getLiquidForLevel(final int level) {
+ final int xp = getExperienceForLevel(level);
+ return xpToLiquidRatio(xp);
+ }
+
+ public static int getLevelForLiquid(final int liquid) {
+ final int xp = liquidToXpRatio(liquid);
+ return getLevelForExperience(xp);
+ }
+
+ public static int getExperienceForLevel(final int level) {
+ if (level == 0) {
+ return 0;
+ }
+ if ((level > 0) && (level < 16)) {
+ return level * 17;
+ }
+ if ((level > 15) && (level < 31)) {
+ return (int) (((1.5 * Math.pow(level, 2.0)) - (29.5 * level)) + 360.0);
+ }
+ return (int) (((3.5 * Math.pow(level, 2.0)) - (151.5 * level)) + 2220.0);
+ }
+
+ public static int getXpToNextLevel(final int level) {
+ final int levelXP = getLevelForExperience(level);
+ final int nextXP = getExperienceForLevel(level + 1);
+ return nextXP - levelXP;
+ }
+
+ public static int getLevelForExperience(final int experience) {
+ int i;
+ for (i = 0; getExperienceForLevel(i) <= experience; ++i) {
+ }
+ return i - 1;
+ }
+
+
+
+
+
+
+
+ //Xp Fluids
+ public static FluidStack getMobEssence(final int amount){
+ Utils.LOG_WARNING("Trying to get a fluid stack of Mob Essence.");
+ try {
+ return FluidRegistry.getFluidStack("mobessence", amount).copy();
+ }
+ catch (final Throwable e){
+ return null;
+ }
+
+ }
+
+ public static FluidStack getLiquidXP(final int amount){
+ Utils.LOG_WARNING("Trying to get a fluid stack of Liquid XP.");
+ try {
+ return FluidRegistry.getFluidStack("xpjuice", amount).copy();
+ }
+ catch (final Throwable e){
+ return null;
+ }
+
+ }
+
+}