mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-08-02 20:45:28 +02:00
RandomChanceUtil refactor part 4
This commit is contained in:
@@ -10,7 +10,6 @@ import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
|
||||
import com.gmail.nossr50.skills.SkillManager;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.random.RandomChanceUtil;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
import org.bukkit.Location;
|
||||
@@ -44,7 +43,7 @@ public class ExcavationManager extends SkillManager {
|
||||
&& SkillUtils.isStaticSkillRNGSuccessful(PrimarySkillType.EXCAVATION, getPlayer(), treasure.getDropProbability())) {
|
||||
|
||||
//Spawn Vanilla XP orbs if a dice roll succeeds
|
||||
if(RandomChanceUtil.rollDice(getArchaelogyExperienceOrbChance(), 100)) {
|
||||
if(SkillUtils.isStaticSkillRNGSuccessful(PrimarySkillType.EXCAVATION, getPlayer(), getArchaelogyExperienceOrbChance())) {
|
||||
Misc.spawnExperienceOrb(location, getExperienceOrbsReward());
|
||||
}
|
||||
|
||||
|
@@ -21,7 +21,6 @@ import com.gmail.nossr50.runnables.skills.DelayedHerbalismXPCheckTask;
|
||||
import com.gmail.nossr50.skills.SkillManager;
|
||||
import com.gmail.nossr50.util.*;
|
||||
import com.gmail.nossr50.util.player.NotificationManager;
|
||||
import com.gmail.nossr50.util.random.RandomChanceUtil;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
import com.gmail.nossr50.util.sounds.SoundManager;
|
||||
@@ -621,7 +620,7 @@ public class HerbalismManager extends SkillManager {
|
||||
|
||||
for (HylianTreasure treasure : treasures) {
|
||||
if (skillLevel >= treasure.getDropLevel()
|
||||
&& RandomChanceUtil.processProbabilityResults(new SkillProbabilityWrapperStatic(treasure.getDropChance(), getPlayer(), SubSkillType.HERBALISM_HYLIAN_LUCK))) {
|
||||
&& SkillUtils.isStaticSkillRNGSuccessful(PrimarySkillType.HERBALISM, player, treasure.getDropChance())) {
|
||||
if (!EventUtils.simulateBlockBreak(blockState.getBlock(), player, false)) {
|
||||
return false;
|
||||
}
|
||||
@@ -740,7 +739,7 @@ public class HerbalismManager extends SkillManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!greenTerra && !RandomChanceUtil.checkRandomChanceExecutionSuccess(player, SubSkillType.HERBALISM_GREEN_THUMB, true)) {
|
||||
if (!greenTerra && !SkillUtils.isSkillRNGSuccessful(SubSkillType.HERBALISM_GREEN_THUMB, player)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@@ -15,7 +15,6 @@ import com.gmail.nossr50.runnables.skills.AbilityCooldownTask;
|
||||
import com.gmail.nossr50.skills.SkillManager;
|
||||
import com.gmail.nossr50.util.*;
|
||||
import com.gmail.nossr50.util.player.NotificationManager;
|
||||
import com.gmail.nossr50.util.random.RandomChanceUtil;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
import org.apache.commons.lang.math.RandomUtils;
|
||||
@@ -114,7 +113,7 @@ public class MiningManager extends SkillManager {
|
||||
|
||||
private boolean processTripleDrops(@NotNull BlockState blockState) {
|
||||
//TODO: Make this readable
|
||||
if (RandomChanceUtil.checkRandomChanceExecutionSuccess(getPlayer(), SubSkillType.MINING_MOTHER_LODE, true)) {
|
||||
if (SkillUtils.isSkillRNGSuccessful(SubSkillType.MINING_MOTHER_LODE, getPlayer())) {
|
||||
BlockUtils.markDropsAsBonus(blockState, 2);
|
||||
return true;
|
||||
} else {
|
||||
@@ -124,7 +123,7 @@ public class MiningManager extends SkillManager {
|
||||
|
||||
private void processDoubleDrops(@NotNull BlockState blockState) {
|
||||
//TODO: Make this readable
|
||||
if (RandomChanceUtil.checkRandomChanceExecutionSuccess(getPlayer(), SubSkillType.MINING_DOUBLE_DROPS, true)) {
|
||||
if (SkillUtils.isSkillRNGSuccessful(SubSkillType.MINING_DOUBLE_DROPS, getPlayer())) {
|
||||
boolean useTriple = mmoPlayer.getAbilityMode(skill.getAbility()) && AdvancedConfig.getInstance().getAllowMiningTripleDrops();
|
||||
BlockUtils.markDropsAsBonus(blockState, useTriple);
|
||||
}
|
||||
|
@@ -16,7 +16,6 @@ import com.gmail.nossr50.util.EventUtils;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.NotificationManager;
|
||||
import com.gmail.nossr50.util.random.RandomChanceUtil;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
import com.gmail.nossr50.util.sounds.SoundManager;
|
||||
@@ -340,10 +339,10 @@ public class RepairManager extends SkillManager {
|
||||
|
||||
Enchantment enchantment = enchant.getKey();
|
||||
|
||||
if (RandomChanceUtil.processProbabilityResults(new SkillProbabilityWrapperStatic(getKeepEnchantChance(), getPlayer(), SubSkillType.REPAIR_ARCANE_FORGING))) {
|
||||
if (SkillUtils.isStaticSkillRNGSuccessful(PrimarySkillType.REPAIR, getPlayer(), getKeepEnchantChance())) {
|
||||
|
||||
if (ArcaneForging.arcaneForgingDowngrades && enchantLevel > 1
|
||||
&& (!RandomChanceUtil.processProbabilityResults(new SkillProbabilityWrapperStatic(100 - getDowngradeEnchantChance(), getPlayer(), SubSkillType.REPAIR_ARCANE_FORGING)))) {
|
||||
&& (!SkillUtils.isStaticSkillRNGSuccessful(PrimarySkillType.REPAIR, getPlayer(), 100 - getDowngradeEnchantChance()))) {
|
||||
item.addUnsafeEnchantment(enchantment, enchantLevel - 1);
|
||||
downgraded = true;
|
||||
}
|
||||
|
@@ -16,7 +16,6 @@ import com.gmail.nossr50.util.EventUtils;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.NotificationManager;
|
||||
import com.gmail.nossr50.util.random.RandomChanceUtil;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
import com.gmail.nossr50.util.sounds.SoundManager;
|
||||
@@ -122,7 +121,7 @@ public class SalvageManager extends SkillManager {
|
||||
|
||||
for(int x = 0; x < potentialSalvageYield-1; x++) {
|
||||
|
||||
if(RandomChanceUtil.rollDiceSimple(chanceOfSuccess, 100)) {
|
||||
if(SkillUtils.isStaticSkillRNGSuccessful(PrimarySkillType.SALVAGE, player, chanceOfSuccess)) {
|
||||
chanceOfSuccess-=3;
|
||||
chanceOfSuccess = Math.max(chanceOfSuccess, 90);
|
||||
|
||||
@@ -252,12 +251,12 @@ public class SalvageManager extends SkillManager {
|
||||
|
||||
if (!Salvage.arcaneSalvageEnchantLoss
|
||||
|| Permissions.hasSalvageEnchantBypassPerk(player)
|
||||
|| RandomChanceUtil.processProbabilityResults(new SkillProbabilityWrapperStatic(getExtractFullEnchantChance(), getPlayer(), SubSkillType.SALVAGE_ARCANE_SALVAGE))) {
|
||||
|| SkillUtils.isStaticSkillRNGSuccessful(PrimarySkillType.SALVAGE, player, getExtractFullEnchantChance())) {
|
||||
enchantMeta.addStoredEnchant(enchant.getKey(), enchantLevel, true);
|
||||
}
|
||||
else if (enchantLevel > 1
|
||||
&& Salvage.arcaneSalvageDowngrades
|
||||
&& RandomChanceUtil.processProbabilityResults(new SkillProbabilityWrapperStatic(getExtractPartialEnchantChance(), getPlayer(), SubSkillType.SALVAGE_ARCANE_SALVAGE))) {
|
||||
&& SkillUtils.isStaticSkillRNGSuccessful(PrimarySkillType.SALVAGE, player, getExtractPartialEnchantChance())) {
|
||||
enchantMeta.addStoredEnchant(enchant.getKey(), enchantLevel - 1, true);
|
||||
downgraded = true;
|
||||
} else {
|
||||
|
@@ -18,7 +18,6 @@ import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.compat.layers.persistentdata.MobMetaFlagType;
|
||||
import com.gmail.nossr50.util.player.NotificationManager;
|
||||
import com.gmail.nossr50.util.random.RandomChanceUtil;
|
||||
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
@@ -275,7 +274,7 @@ public class TamingManager extends SkillManager {
|
||||
if(!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_PUMMEL))
|
||||
return;
|
||||
|
||||
if(!RandomChanceUtil.processProbabilityResults(new SkillProbabilityWrapperStatic(AdvancedConfig.getInstance().getPummelChance(), getPlayer(), SubSkillType.TAMING_PUMMEL)))
|
||||
if(!SkillUtils.isStaticSkillRNGSuccessful(PrimarySkillType.TAMING, getPlayer(), AdvancedConfig.getInstance().getPummelChance()))
|
||||
return;
|
||||
|
||||
ParticleEffectUtils.playGreaterImpactEffect(target);
|
||||
|
@@ -14,7 +14,6 @@ import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.skills.SkillManager;
|
||||
import com.gmail.nossr50.util.*;
|
||||
import com.gmail.nossr50.util.player.NotificationManager;
|
||||
import com.gmail.nossr50.util.random.RandomChanceUtil;
|
||||
import com.gmail.nossr50.util.skills.CombatUtils;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
Reference in New Issue
Block a user