2013-03-01 00:52:01 -05:00
|
|
|
package com.gmail.nossr50.skills.smelting;
|
|
|
|
|
2019-01-27 18:11:51 -08:00
|
|
|
import com.gmail.nossr50.datatypes.experience.XPGainReason;
|
|
|
|
import com.gmail.nossr50.datatypes.experience.XPGainSource;
|
2013-03-01 00:52:01 -05:00
|
|
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
2019-01-12 23:54:53 -08:00
|
|
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
2019-01-14 22:11:58 -08:00
|
|
|
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
2013-03-01 00:52:01 -05:00
|
|
|
import com.gmail.nossr50.skills.SkillManager;
|
|
|
|
import com.gmail.nossr50.util.Permissions;
|
2019-01-24 20:45:26 -08:00
|
|
|
import com.gmail.nossr50.util.random.RandomChanceUtil;
|
2019-01-17 08:46:10 -08:00
|
|
|
import com.gmail.nossr50.util.skills.RankUtils;
|
2019-01-08 19:52:52 -08:00
|
|
|
import com.gmail.nossr50.util.skills.SkillActivationType;
|
2018-07-25 20:29:40 -04:00
|
|
|
import org.bukkit.block.BlockState;
|
|
|
|
import org.bukkit.event.inventory.FurnaceBurnEvent;
|
|
|
|
import org.bukkit.inventory.ItemStack;
|
2013-03-01 00:52:01 -05:00
|
|
|
|
|
|
|
public class SmeltingManager extends SkillManager {
|
|
|
|
public SmeltingManager(McMMOPlayer mcMMOPlayer) {
|
2019-01-12 23:54:53 -08:00
|
|
|
super(mcMMOPlayer, PrimarySkillType.SMELTING);
|
2013-03-01 00:52:01 -05:00
|
|
|
}
|
|
|
|
|
2019-03-09 16:44:55 -08:00
|
|
|
/*public boolean canUseFluxMining(BlockState blockState) {
|
2019-01-27 18:11:51 -08:00
|
|
|
return getSkillLevel() >= Smelting.fluxMiningUnlockLevel
|
|
|
|
&& BlockUtils.affectedByFluxMining(blockState)
|
|
|
|
&& Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.SMELTING_FLUX_MINING)
|
|
|
|
&& !mcMMO.getPlaceStore().isTrue(blockState);
|
2019-03-09 16:44:55 -08:00
|
|
|
}*/
|
2013-03-01 00:52:01 -05:00
|
|
|
|
2013-11-22 12:32:23 -05:00
|
|
|
public boolean isSecondSmeltSuccessful() {
|
2019-01-27 18:11:51 -08: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 11:44:45 -04:00
|
|
|
}
|
|
|
|
|
2013-03-01 00:52:01 -05: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-09 16:44:55 -08:00
|
|
|
/*public boolean processFluxMining(BlockState blockState) {
|
2013-03-01 00:52:01 -05:00
|
|
|
Player player = getPlayer();
|
|
|
|
|
2019-01-27 19:36:16 -08:00
|
|
|
if (RandomChanceUtil.checkRandomChanceExecutionSuccess(getPlayer(), SubSkillType.SMELTING_FLUX_MINING, true)) {
|
2013-03-01 00:52:01 -05: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 08:46:10 -08:00
|
|
|
|
2015-11-04 15:27:03 -05:00
|
|
|
if (!EventUtils.simulateBlockBreak(blockState.getBlock(), player, true)) {
|
|
|
|
return false;
|
|
|
|
}
|
2013-03-01 00:52:01 -05: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-27 18:11:51 -08:00
|
|
|
applyXpGain(Mining.getBlockXp(blockState), XPGainReason.PVE, XPGainSource.PASSIVE);
|
2014-12-22 17:25:55 +01:00
|
|
|
|
2019-02-16 16:09:48 -08:00
|
|
|
SkillUtils.handleDurabilityChange(getPlayer().getInventory().getItemInMainHand(), MainConfig.getInstance().getAbilityToolDamage());
|
2014-12-22 16:58:22 +01:00
|
|
|
|
2016-03-16 11:47:40 -05:00
|
|
|
Misc.dropItems(Misc.getBlockCenter(blockState), item, isSecondSmeltSuccessful() ? 2 : 1);
|
2013-03-01 00:52:01 -05:00
|
|
|
|
|
|
|
blockState.setType(Material.AIR);
|
2014-12-22 16:58:22 +01:00
|
|
|
|
2019-02-16 16:09:48 -08:00
|
|
|
if (MainConfig.getInstance().getFluxPickaxeSoundEnabled()) {
|
2019-01-12 19:08:54 -08:00
|
|
|
SoundManager.sendSound(player, blockState.getLocation(), SoundType.FIZZ);
|
2014-12-22 16:58:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ParticleEffectUtils.playFluxEffect(blockState.getLocation());
|
2013-03-01 00:52:01 -05:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2019-03-09 16:44:55 -08:00
|
|
|
}*/
|
2013-03-01 00:52:01 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Increases burn time for furnace fuel.
|
|
|
|
*
|
|
|
|
* @param burnTime The initial burn time from the {@link FurnaceBurnEvent}
|
|
|
|
*/
|
|
|
|
public int fuelEfficiency(int burnTime) {
|
2019-03-09 16:22:20 -08:00
|
|
|
return burnTime * getFuelEfficiencyMultiplier();
|
|
|
|
}
|
2013-03-01 00:52:01 -05:00
|
|
|
|
2019-03-09 16:22:20 -08: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 00:52:01 -05:00
|
|
|
}
|
|
|
|
|
2013-10-31 13:25:06 -04:00
|
|
|
public ItemStack smeltProcessing(ItemStack smelting, ItemStack result) {
|
2019-01-27 18:11:51 -08:00
|
|
|
applyXpGain(Smelting.getResourceXp(smelting), XPGainReason.PVE, XPGainSource.PASSIVE);
|
2013-03-01 00:52:01 -05:00
|
|
|
|
2013-11-22 12:32:23 -05:00
|
|
|
if (isSecondSmeltSuccessful()) {
|
2013-04-24 07:08:24 -04:00
|
|
|
ItemStack newResult = result.clone();
|
|
|
|
|
|
|
|
newResult.setAmount(result.getAmount() + 1);
|
2013-03-01 00:52:01 -05: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 08:46:10 -08:00
|
|
|
return RankUtils.getRank(getPlayer(), SubSkillType.SMELTING_UNDERSTANDING_THE_ART);
|
2013-03-01 00:52:01 -05:00
|
|
|
}
|
2019-01-17 08:46:10 -08:00
|
|
|
}
|