2013-03-01 06:52:01 +01:00
|
|
|
package com.gmail.nossr50.skills.smelting;
|
|
|
|
|
2019-01-28 03:11:51 +01:00
|
|
|
import com.gmail.nossr50.datatypes.experience.XPGainReason;
|
|
|
|
import com.gmail.nossr50.datatypes.experience.XPGainSource;
|
2013-03-01 06:52:01 +01:00
|
|
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
2019-01-13 08:54:53 +01:00
|
|
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
2019-01-15 07:11:58 +01:00
|
|
|
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
2013-03-01 06:52:01 +01:00
|
|
|
import com.gmail.nossr50.skills.SkillManager;
|
|
|
|
import com.gmail.nossr50.util.Permissions;
|
2019-01-25 05:45:26 +01:00
|
|
|
import com.gmail.nossr50.util.random.RandomChanceUtil;
|
2019-01-17 17:46:10 +01:00
|
|
|
import com.gmail.nossr50.util.skills.RankUtils;
|
2019-01-09 04:52:52 +01:00
|
|
|
import com.gmail.nossr50.util.skills.SkillActivationType;
|
2018-07-26 02:29:40 +02:00
|
|
|
import org.bukkit.block.BlockState;
|
|
|
|
import org.bukkit.event.inventory.FurnaceBurnEvent;
|
|
|
|
import org.bukkit.inventory.ItemStack;
|
2013-03-01 06:52:01 +01:00
|
|
|
|
|
|
|
public class SmeltingManager extends SkillManager {
|
|
|
|
public SmeltingManager(McMMOPlayer mcMMOPlayer) {
|
2019-01-13 08:54:53 +01:00
|
|
|
super(mcMMOPlayer, PrimarySkillType.SMELTING);
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
2019-03-10 01:44:55 +01:00
|
|
|
/*public boolean canUseFluxMining(BlockState blockState) {
|
2019-01-28 03:11:51 +01:00
|
|
|
return getSkillLevel() >= Smelting.fluxMiningUnlockLevel
|
|
|
|
&& BlockUtils.affectedByFluxMining(blockState)
|
|
|
|
&& Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.SMELTING_FLUX_MINING)
|
|
|
|
&& !mcMMO.getPlaceStore().isTrue(blockState);
|
2019-03-10 01:44:55 +01:00
|
|
|
}*/
|
2013-03-01 06:52:01 +01:00
|
|
|
|
2013-11-22 18:32:23 +01:00
|
|
|
public boolean isSecondSmeltSuccessful() {
|
2019-01-28 03:11:51 +01:00
|
|
|
return Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.SMELTING_SECOND_SMELT)
|
|
|
|
&& RandomChanceUtil.isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.SMELTING_SECOND_SMELT, getPlayer());
|
2013-10-09 17:44:45 +02:00
|
|
|
}
|
|
|
|
|
2013-03-01 06:52:01 +01:00
|
|
|
/**
|
|
|
|
* Process the Flux Mining ability.
|
|
|
|
*
|
|
|
|
* @param blockState The {@link BlockState} to check ability activation for
|
|
|
|
* @return true if the ability was successful, false otherwise
|
|
|
|
*/
|
2019-03-10 01:44:55 +01:00
|
|
|
/*public boolean processFluxMining(BlockState blockState) {
|
2013-03-01 06:52:01 +01:00
|
|
|
Player player = getPlayer();
|
|
|
|
|
2019-01-28 04:36:16 +01:00
|
|
|
if (RandomChanceUtil.checkRandomChanceExecutionSuccess(getPlayer(), SubSkillType.SMELTING_FLUX_MINING, true)) {
|
2013-03-01 06:52:01 +01:00
|
|
|
ItemStack item = null;
|
|
|
|
|
|
|
|
switch (blockState.getType()) {
|
|
|
|
case IRON_ORE:
|
|
|
|
item = new ItemStack(Material.IRON_INGOT);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GOLD_ORE:
|
|
|
|
item = new ItemStack(Material.GOLD_INGOT);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (item == null) {
|
|
|
|
return false;
|
|
|
|
}
|
2019-01-17 17:46:10 +01:00
|
|
|
|
2015-11-04 21:27:03 +01:00
|
|
|
if (!EventUtils.simulateBlockBreak(blockState.getBlock(), player, true)) {
|
|
|
|
return false;
|
|
|
|
}
|
2013-03-01 06:52:01 +01:00
|
|
|
|
2014-12-22 17:25:55 +01:00
|
|
|
// We need to distribute Mining XP here, because the block break event gets cancelled
|
2019-01-28 03:11:51 +01:00
|
|
|
applyXpGain(Mining.getBlockXp(blockState), XPGainReason.PVE, XPGainSource.PASSIVE);
|
2014-12-22 17:25:55 +01:00
|
|
|
|
2016-03-11 15:20:23 +01:00
|
|
|
SkillUtils.handleDurabilityChange(getPlayer().getInventory().getItemInMainHand(), Config.getInstance().getAbilityToolDamage());
|
2014-12-22 16:58:22 +01:00
|
|
|
|
2016-03-16 17:47:40 +01:00
|
|
|
Misc.dropItems(Misc.getBlockCenter(blockState), item, isSecondSmeltSuccessful() ? 2 : 1);
|
2013-03-01 06:52:01 +01:00
|
|
|
|
|
|
|
blockState.setType(Material.AIR);
|
2014-12-22 16:58:22 +01:00
|
|
|
|
|
|
|
if (Config.getInstance().getFluxPickaxeSoundEnabled()) {
|
2019-01-13 04:08:54 +01:00
|
|
|
SoundManager.sendSound(player, blockState.getLocation(), SoundType.FIZZ);
|
2014-12-22 16:58:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ParticleEffectUtils.playFluxEffect(blockState.getLocation());
|
2013-03-01 06:52:01 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2019-03-10 01:44:55 +01:00
|
|
|
}*/
|
2013-03-01 06:52:01 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Increases burn time for furnace fuel.
|
|
|
|
*
|
|
|
|
* @param burnTime The initial burn time from the {@link FurnaceBurnEvent}
|
|
|
|
*/
|
|
|
|
public int fuelEfficiency(int burnTime) {
|
2019-03-10 01:22:20 +01:00
|
|
|
return burnTime * getFuelEfficiencyMultiplier();
|
|
|
|
}
|
2013-03-01 06:52:01 +01:00
|
|
|
|
2019-03-10 01:22:20 +01:00
|
|
|
public int getFuelEfficiencyMultiplier()
|
|
|
|
{
|
|
|
|
switch(RankUtils.getRank(getPlayer(), SubSkillType.SMELTING_FUEL_EFFICIENCY))
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
return 2;
|
|
|
|
case 2:
|
|
|
|
return 3;
|
|
|
|
case 3:
|
|
|
|
return 4;
|
|
|
|
default:
|
|
|
|
return 1;
|
|
|
|
}
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
2013-10-31 18:25:06 +01:00
|
|
|
public ItemStack smeltProcessing(ItemStack smelting, ItemStack result) {
|
2019-01-28 03:11:51 +01:00
|
|
|
applyXpGain(Smelting.getResourceXp(smelting), XPGainReason.PVE, XPGainSource.PASSIVE);
|
2013-03-01 06:52:01 +01:00
|
|
|
|
2013-11-22 18:32:23 +01:00
|
|
|
if (isSecondSmeltSuccessful()) {
|
2013-04-24 13:08:24 +02:00
|
|
|
ItemStack newResult = result.clone();
|
|
|
|
|
|
|
|
newResult.setAmount(result.getAmount() + 1);
|
2013-03-01 06:52:01 +01:00
|
|
|
return newResult;
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int vanillaXPBoost(int experience) {
|
|
|
|
return experience * getVanillaXpMultiplier();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the vanilla XP multiplier
|
|
|
|
*
|
|
|
|
* @return the vanilla XP multiplier
|
|
|
|
*/
|
|
|
|
public int getVanillaXpMultiplier() {
|
2019-01-17 17:46:10 +01:00
|
|
|
return RankUtils.getRank(getPlayer(), SubSkillType.SMELTING_UNDERSTANDING_THE_ART);
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
2019-01-17 17:46:10 +01:00
|
|
|
}
|