From c918a1b6d8008773e9beebb48ba1a770405aee20 Mon Sep 17 00:00:00 2001 From: bculkin2442 Date: Thu, 22 Aug 2019 19:54:41 -0400 Subject: Bulk update back to sanity --- YWD/src/main/java/fyresmodjam/EntityLevelStat.java | 152 ++++++++++----------- 1 file changed, 70 insertions(+), 82 deletions(-) (limited to 'YWD/src/main/java/fyresmodjam/EntityLevelStat.java') diff --git a/YWD/src/main/java/fyresmodjam/EntityLevelStat.java b/YWD/src/main/java/fyresmodjam/EntityLevelStat.java index 93ff574..249e6ae 100755 --- a/YWD/src/main/java/fyresmodjam/EntityLevelStat.java +++ b/YWD/src/main/java/fyresmodjam/EntityLevelStat.java @@ -3,6 +3,7 @@ package fyresmodjam; import java.util.Random; import fyresmodjam.blessings.BlessingUtils; +import fyresmodjam.misc.ConfigData; import fyresmodjam.misc.EntityStat; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLiving; @@ -11,10 +12,6 @@ import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.monster.EntityCreeper; public final class EntityLevelStat extends EntityStat { - private static final int DIABOLIC_CHANCE = 20; - private static final int BLESSING_LEVEL = 5; - private static final int LEVELUP_CHANCE = 3; - public EntityLevelStat(String name, String value) { super(name, value); } @@ -26,7 +23,7 @@ public final class EntityLevelStat extends EntityStat { while (true) { int chance = 5 * (Math.max(1, lvl / 5)); - if (ModjamMod.r.nextInt(chance) < LEVELUP_CHANCE) { + if (ModjamMod.r.nextInt(chance) < ConfigData.levelupChance) { return lvl; } @@ -39,8 +36,7 @@ public final class EntityLevelStat extends EntityStat { int level = 1; try { - String entityName = entity.getEntityData() - .getString(name); + String entityName = entity.getEntityData().getString(name); level = Integer.parseInt(entityName); } catch (Exception e) { @@ -57,36 +53,36 @@ public final class EntityLevelStat extends EntityStat { String rank = "Unelisted "; switch (level) { - case 2: - rank = "Private"; - break; - case 3: - rank = "Corporal"; - break; - case 4: - rank = "Sergeant"; - break; - case 5: - rank = "Lieutenant"; - break; - case 6: - rank = "Captain"; - break; - case 7: - rank = "Major"; - break; - case 8: - rank = "Colonel"; - break; - case 9: - rank = "General"; - break; - default: - if (level > 9) { - rank = "Field Marshal"; - } else { - rank = "Unelisted"; - } + case 2: + rank = "Private"; + break; + case 3: + rank = "Corporal"; + break; + case 4: + rank = "Sergeant"; + break; + case 5: + rank = "Lieutenant"; + break; + case 6: + rank = "Captain"; + break; + case 7: + rank = "Major"; + break; + case 8: + rank = "Colonel"; + break; + case 9: + rank = "General"; + break; + default: + if (level > 9) { + rank = "Field Marshal"; + } else { + rank = "Unelisted"; + } } newName = String.format("%s %s", rank, entityName); @@ -97,8 +93,7 @@ public final class EntityLevelStat extends EntityStat { colPrefix = "\u00A7c"; } - newName = String.format("%s%s, %s", colPrefix, - entityName, levelSuffix); + newName = String.format("%s%s, %s", colPrefix, entityName, levelSuffix); } return newName; @@ -109,8 +104,7 @@ public final class EntityLevelStat extends EntityStat { int level = 1; try { - level = Integer.parseInt(entity.getEntityData() - .getString(name)); + level = Integer.parseInt(entity.getEntityData().getString(name)); } catch (Exception e) { e.printStackTrace(); } @@ -120,21 +114,16 @@ public final class EntityLevelStat extends EntityStat { if (healthGain != 0) { EntityLivingBase livingBase = (EntityLivingBase) entity; - float newHealth = livingBase.getMaxHealth() - + healthGain; + float newHealth = livingBase.getMaxHealth() + healthGain; - livingBase.getEntityAttribute( - SharedMonsterAttributes.maxHealth) - .setBaseValue(newHealth); + livingBase.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(newHealth); livingBase.setHealth(newHealth); } - if (level >= BLESSING_LEVEL) { + if (level >= ConfigData.blessingLevel) { blessMob(entity); - } else if (BlessingUtils.hasDisadvantage("Diabolic") - && ModjamMod.r.nextInt( - DIABOLIC_CHANCE) == 0) { + } else if (BlessingUtils.hasDisadvantage("Diabolic") && ModjamMod.r.nextInt(ConfigData.diabolicChance) == 0) { blessMob(entity); } @@ -148,14 +137,11 @@ public final class EntityLevelStat extends EntityStat { return; } - float regionalDifficulty = entity.worldObj.func_147462_b( - entity.posX, entity.posY, entity.posZ); + float regionalDifficulty = entity.worldObj.func_147462_b(entity.posX, entity.posY, entity.posZ); - int adjustedDifficulty = (int) Math - .ceil(level + regionalDifficulty); + int adjustedDifficulty = (int) Math.ceil(level + regionalDifficulty); - if (ModjamMod.r.nextInt(10) == 0 - || adjustedDifficulty > 5) { + if (ModjamMod.r.nextInt(10) == 0 || adjustedDifficulty > 5) { } @@ -163,43 +149,45 @@ public final class EntityLevelStat extends EntityStat { } private int calculateMobHealthGain(Entity entity, int level) { - int levelBase = level - 1; - float quarteredHealth = ((EntityLivingBase) entity) - .getMaxHealth() / 4; - - float adjustedMaxHealth = quarteredHealth; - - float bonusLevel5Health; - - if (level >= 5) { - bonusLevel5Health = quarteredHealth; - - bonusLevel5Health *= Math.max(1, level / 5); - } else { - bonusLevel5Health = 0; - } - - return (int) ((levelBase * adjustedMaxHealth) - + bonusLevel5Health); + float initHealth = ((EntityLivingBase) entity).getMaxHealth(); + + double mult = level * ConfigData.healthLevelMult; + double addHealth = initHealth * mult; + + int flatHealth = level * ConfigData.healthLevelFlat; + + /* + * int levelBase = level - 1; float quarteredHealth = ((EntityLivingBase) + * entity).getMaxHealth() / 4; + * + * float adjustedMaxHealth = quarteredHealth; + * + * float bonusLevel5Health; + * + * if (level >= 5) { bonusLevel5Health = quarteredHealth; + * + * bonusLevel5Health *= Math.max(1, level / 5); } else { bonusLevel5Health = 0; + * } + */ + + return (int) ((initHealth + addHealth) + flatHealth); } private void blessMob(Entity entity) { String chosenBlessing = BlessingUtils.getMobBlessing(); - entity.getEntityData().setString("Blessing", - chosenBlessing); + entity.getEntityData().setString("Blessing", chosenBlessing); - BlessingUtils.getBlessingInstance(chosenBlessing) - .correctBlessing(entity); + // Make sure that any mob type specific blessings are patched up + BlessingUtils.getBlessingInstance(chosenBlessing).correctBlessing(entity); if (entity instanceof EntityCreeper) { + // Blessed creepers are auto-empowered EntityCreeper creeper = (EntityCreeper) entity; - creeper.getDataWatcher().updateObject(17, - (byte) 1); + creeper.getDataWatcher().updateObject(17, (byte) 1); - creeper.getEntityData().setBoolean("powered", - true); + creeper.getEntityData().setBoolean("powered", true); } } } \ No newline at end of file -- cgit v1.2.3