mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 05:06:45 +01:00
Sweet Berry bushes now grant XP when harvested and no longer activate tools
This commit is contained in:
parent
2c5e11138b
commit
e40ab38bbd
@ -1,4 +1,6 @@
|
||||
Version 2.1.182
|
||||
Players now receive XP from harvesting Sweet Berry bushes (double XP for harvesting fully grown berries)
|
||||
Sweet Berry Bush will no longer ready tools for Super Abilities
|
||||
You can now use '.all' (for example: mcmmo.perks.xp.customboost.all) to give an XP perk to all skills
|
||||
Removed hardcore and vampirism commands, these commands are dangerous, just modify the config file if you want to use hardcore / vampirism
|
||||
Fixed several errors in de locale (Thanks TheBusyBiscuit & w1tcherrr)
|
||||
|
@ -841,10 +841,13 @@ public class PlayerListener implements Listener {
|
||||
if(!EventUtils.callSubSkillBlockEvent(player, SubSkillType.HERBALISM_SHROOM_THUMB, block).isCancelled()) {
|
||||
Bukkit.getPluginManager().callEvent(fakeSwing);
|
||||
event.setCancelled(true);
|
||||
if (herbalismManager.processShroomThumb(blockState) && EventUtils.simulateBlockBreak(block, player, false)) {
|
||||
if (herbalismManager.processShroomThumb(blockState)
|
||||
&& EventUtils.simulateBlockBreak(block, player, false)) {
|
||||
blockState.update(true);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
herbalismManager.processBerryBushHarvesting(blockState);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -40,6 +40,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@ -62,6 +63,10 @@ public class HerbalismManager extends SkillManager {
|
||||
}
|
||||
|
||||
public boolean canUseShroomThumb(BlockState blockState) {
|
||||
if(!BlockUtils.canMakeShroomy(blockState)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.HERBALISM_SHROOM_THUMB))
|
||||
return false;
|
||||
|
||||
@ -69,7 +74,57 @@ public class HerbalismManager extends SkillManager {
|
||||
PlayerInventory inventory = player.getInventory();
|
||||
Material itemType = inventory.getItemInMainHand().getType();
|
||||
|
||||
return (itemType == Material.BROWN_MUSHROOM || itemType == Material.RED_MUSHROOM) && inventory.contains(Material.BROWN_MUSHROOM, 1) && inventory.contains(Material.RED_MUSHROOM, 1) && BlockUtils.canMakeShroomy(blockState) && Permissions.isSubSkillEnabled(player, SubSkillType.HERBALISM_SHROOM_THUMB);
|
||||
return (itemType == Material.BROWN_MUSHROOM
|
||||
|| itemType == Material.RED_MUSHROOM)
|
||||
&& inventory.contains(Material.BROWN_MUSHROOM, 1)
|
||||
&& inventory.contains(Material.RED_MUSHROOM, 1)
|
||||
&& Permissions.isSubSkillEnabled(player, SubSkillType.HERBALISM_SHROOM_THUMB);
|
||||
}
|
||||
|
||||
public void processBerryBushHarvesting(@NotNull BlockState blockState) {
|
||||
/* Check if the player is harvesting a berry bush */
|
||||
if(blockState.getType().toString().equalsIgnoreCase("sweet_berry_bush")) {
|
||||
if(mmoPlayer.isDebugMode()) {
|
||||
mmoPlayer.getPlayer().sendMessage("Processing sweet berry bush rewards");
|
||||
}
|
||||
//Check the age
|
||||
if(blockState.getBlockData() instanceof Ageable) {
|
||||
int rewardByAge = 0;
|
||||
|
||||
Ageable ageable = (Ageable) blockState.getBlockData();
|
||||
|
||||
if(ageable.getAge() == 2) {
|
||||
rewardByAge = 1; //Normal XP
|
||||
} else if(ageable.getAge() == 3) {
|
||||
rewardByAge = 2; //Double XP
|
||||
} else {
|
||||
return; //Not old enough, back out of processing
|
||||
}
|
||||
|
||||
if(mmoPlayer.isDebugMode()) {
|
||||
mmoPlayer.getPlayer().sendMessage("Bush Reward Multiplier: " + rewardByAge);
|
||||
}
|
||||
|
||||
int xpReward = ExperienceConfig.getInstance().getXp(PrimarySkillType.HERBALISM, blockState) * rewardByAge;
|
||||
|
||||
if(mmoPlayer.isDebugMode()) {
|
||||
mmoPlayer.getPlayer().sendMessage("Bush XP: " + xpReward);
|
||||
}
|
||||
|
||||
//Check for double drops
|
||||
if(checkDoubleDrop(blockState)) {
|
||||
|
||||
if(mmoPlayer.isDebugMode()) {
|
||||
mmoPlayer.getPlayer().sendMessage("Double Drops succeeded for Berry Bush");
|
||||
}
|
||||
|
||||
//Add metadata to mark this block for double or triple drops
|
||||
markForBonusDrops(blockState);
|
||||
}
|
||||
|
||||
applyXpGain(xpReward, XPGainReason.PVE, XPGainSource.SELF);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canUseHylianLuck() {
|
||||
|
@ -1265,6 +1265,7 @@ public class MaterialMapStore {
|
||||
toolBlackList.add("stonecutter");
|
||||
toolBlackList.add("lodestone");
|
||||
toolBlackList.add("respawn_anchor");
|
||||
toolBlackList.add("sweet_berry_bush");
|
||||
}
|
||||
|
||||
public boolean isIntendedToolPickaxe(Material material) {
|
||||
|
Loading…
Reference in New Issue
Block a user