From a557fc7d3c0b3bbee4e79232b2a9ccbb7556a9ef Mon Sep 17 00:00:00 2001 From: Dor Date: Fri, 11 Mar 2016 16:20:23 +0200 Subject: [PATCH] Use getItemInMainHand() Add 1.9 blocks to be detected for experience rewards. Add experience rewards for the Chorus plant. Add experience rewards for the Shulker mob. --- .../java/com/gmail/nossr50/config/Config.java | 2 +- .../nossr50/datatypes/player/McMMOPlayer.java | 4 +- .../nossr50/listeners/BlockListener.java | 10 +-- .../nossr50/listeners/EntityListener.java | 2 +- .../nossr50/listeners/InventoryListener.java | 2 +- .../nossr50/listeners/PlayerListener.java | 9 +- .../runnables/items/ChimaeraWingWarmup.java | 2 +- .../skills/acrobatics/AcrobaticsManager.java | 2 +- .../skills/excavation/ExcavationManager.java | 2 +- .../skills/fishing/FishingManager.java | 6 +- .../nossr50/skills/herbalism/Herbalism.java | 87 ++++++++++++++++--- .../skills/herbalism/HerbalismManager.java | 20 ++--- .../nossr50/skills/mining/MiningManager.java | 6 +- .../skills/salvage/SalvageManager.java | 2 +- .../skills/smelting/SmeltingManager.java | 2 +- .../nossr50/skills/taming/TamingManager.java | 4 +- .../skills/unarmed/UnarmedManager.java | 8 +- .../woodcutting/WoodcuttingManager.java | 2 +- .../com/gmail/nossr50/util/BlockUtils.java | 8 ++ .../com/gmail/nossr50/util/ChimaeraWing.java | 6 +- .../com/gmail/nossr50/util/EventUtils.java | 2 +- .../com/gmail/nossr50/util/ItemUtils.java | 2 + .../nossr50/util/skills/CombatUtils.java | 10 ++- .../gmail/nossr50/util/skills/SkillUtils.java | 2 +- src/main/resources/config.yml | 2 +- src/main/resources/experience.yml | 8 ++ 26 files changed, 145 insertions(+), 67 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/config/Config.java b/src/main/java/com/gmail/nossr50/config/Config.java index 6a0cf3d96..fef247371 100644 --- a/src/main/java/com/gmail/nossr50/config/Config.java +++ b/src/main/java/com/gmail/nossr50/config/Config.java @@ -533,6 +533,6 @@ public class Config extends AutoUpdateConfigLoader { /* PVP & PVE Settings */ public boolean getPVPEnabled(SkillType skill) { return config.getBoolean("Skills." + StringUtils.getCapitalized(skill.toString()) + ".Enabled_For_PVP", true); } public boolean getPVEEnabled(SkillType skill) { return config.getBoolean("Skills." + StringUtils.getCapitalized(skill.toString()) + ".Enabled_For_PVE", true); } - + public float getMasterVolume() { return (float) config.getDouble("Sounds.MasterVolume", 1.0); } } diff --git a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java index 6897c0291..0c9a3d72f 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java +++ b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java @@ -690,7 +690,7 @@ public class McMMOPlayer { xp = (float) (xp / skillType.getXpModifier() * ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier()); if (Config.getInstance().getToolModsEnabled()) { - CustomTool tool = mcMMO.getModManager().getTool(player.getItemInHand()); + CustomTool tool = mcMMO.getModManager().getTool(player.getInventory().getItemInMainHand()); if (tool != null) { xp *= tool.getXpMultiplier(); @@ -774,7 +774,7 @@ public class McMMOPlayer { return; } - ItemStack inHand = player.getItemInHand(); + ItemStack inHand = player.getInventory().getItemInMainHand(); if (mcMMO.getModManager().isCustomTool(inHand) && !mcMMO.getModManager().getTool(inHand).isAbilityEnabled()) { return; diff --git a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java index fdc1a182a..9822031ad 100644 --- a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java @@ -170,7 +170,7 @@ public class BlockListener implements Listener { BlockState blockState = event.getBlock().getState(); /* Check if the blocks placed should be monitored so they do not give out XP in the future */ - if (BlockUtils.shouldBeWatched(blockState)) { + if (BlockUtils.shouldBeWatched(blockState) && blockState.getType() != Material.CHORUS_FLOWER) { mcMMO.getPlaceStore().setTrue(blockState); } @@ -214,7 +214,7 @@ public class BlockListener implements Listener { } McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); - ItemStack heldItem = player.getItemInHand(); + ItemStack heldItem = player.getInventory().getItemInMainHand(); /* HERBALISM */ if (BlockUtils.affectedByGreenTerra(blockState)) { @@ -284,7 +284,7 @@ public class BlockListener implements Listener { } BlockState blockState = event.getBlock().getState(); - ItemStack heldItem = player.getItemInHand(); + ItemStack heldItem = player.getInventory().getItemInMainHand(); if (Herbalism.isRecentlyRegrown(blockState)) { event.setCancelled(true); @@ -344,7 +344,7 @@ public class BlockListener implements Listener { * We check permissions here before processing activation. */ if (BlockUtils.canActivateAbilities(blockState)) { - ItemStack heldItem = player.getItemInHand(); + ItemStack heldItem = player.getInventory().getItemInMainHand(); if (HiddenConfig.getInstance().useEnchantmentBuffs()) { if ((ItemUtils.isPickaxe(heldItem) && !mcMMOPlayer.getAbilityMode(AbilityType.SUPER_BREAKER)) || (ItemUtils.isShovel(heldItem) && !mcMMOPlayer.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER))) { @@ -402,7 +402,7 @@ public class BlockListener implements Listener { } McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); - ItemStack heldItem = player.getItemInHand(); + ItemStack heldItem = player.getInventory().getItemInMainHand(); Block block = event.getBlock(); BlockState blockState = block.getState(); diff --git a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java index e6aedeaf9..be758edce 100644 --- a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java @@ -570,7 +570,7 @@ public class EntityListener implements Listener { * is based on how 'common' the item is We can adjust this quite easily * if we find something is giving too much of a bonus */ - switch (player.getItemInHand().getType()) { + switch (player.getInventory().getItemInMainHand().getType()) { case BAKED_POTATO: /* * RESTORES 3 HUNGER - RESTORES 5 1/2 HUNGER @ * 1000 diff --git a/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java b/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java index 8fb34c935..89d938a48 100644 --- a/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java @@ -321,7 +321,7 @@ public class InventoryListener implements Listener { @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onInventoryOpenEvent(InventoryOpenEvent event) { - SkillUtils.removeAbilityBuff(event.getPlayer().getItemInHand()); + SkillUtils.removeAbilityBuff(event.getPlayer().getInventory().getItemInMainHand()); } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index ca15c9f42..c611dc432 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -434,7 +434,7 @@ public class PlayerListener implements Listener { McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); MiningManager miningManager = mcMMOPlayer.getMiningManager(); Block block = event.getClickedBlock(); - ItemStack heldItem = player.getItemInHand(); + ItemStack heldItem = player.getInventory().getItemInMainHand(); switch (event.getAction()) { case RIGHT_CLICK_BLOCK: @@ -480,7 +480,7 @@ public class PlayerListener implements Listener { case LEFT_CLICK_BLOCK: type = block.getType(); - if ((Config.getInstance().getAbilitiesOnlyActivateWhenSneaking() && player.isSneaking()) || !Config.getInstance().getAbilitiesOnlyActivateWhenSneaking()) { + if (!Config.getInstance().getAbilitiesOnlyActivateWhenSneaking() || player.isSneaking()) { /* REPAIR CHECKS */ if (type == Repair.anvilMaterial && SkillType.REPAIR.getPermissions(player) && mcMMO.getRepairableManager().isRepairable(heldItem)) { RepairManager repairManager = mcMMOPlayer.getRepairManager(); @@ -524,7 +524,7 @@ public class PlayerListener implements Listener { } McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); - ItemStack heldItem = player.getItemInHand(); + ItemStack heldItem = player.getInventory().getItemInMainHand(); switch (event.getAction()) { case RIGHT_CLICK_BLOCK: @@ -553,7 +553,7 @@ public class PlayerListener implements Listener { HerbalismManager herbalismManager = mcMMOPlayer.getHerbalismManager(); if (herbalismManager.canGreenThumbBlock(blockState)) { - player.setItemInHand(new ItemStack(Material.SEEDS, heldItem.getAmount() - 1)); + player.getInventory().setItemInMainHand(new ItemStack(Material.SEEDS, heldItem.getAmount() - 1)); if (herbalismManager.processGreenThumbBlocks(blockState) && EventUtils.simulateBlockBreak(block, player, false)) { blockState.update(true); @@ -569,7 +569,6 @@ public class PlayerListener implements Listener { break; case RIGHT_CLICK_AIR: - /* ACTIVATION CHECKS */ if (Config.getInstance().getAbilitiesEnabled()) { mcMMOPlayer.processAbilityActivation(SkillType.AXES); diff --git a/src/main/java/com/gmail/nossr50/runnables/items/ChimaeraWingWarmup.java b/src/main/java/com/gmail/nossr50/runnables/items/ChimaeraWingWarmup.java index c23e13b7c..e8811ba42 100644 --- a/src/main/java/com/gmail/nossr50/runnables/items/ChimaeraWingWarmup.java +++ b/src/main/java/com/gmail/nossr50/runnables/items/ChimaeraWingWarmup.java @@ -34,7 +34,7 @@ public class ChimaeraWingWarmup extends BukkitRunnable { return; } - ItemStack inHand = player.getItemInHand(); + ItemStack inHand = player.getInventory().getItemInMainHand(); if (!ItemUtils.isChimaeraWing(inHand) || inHand.getAmount() < Config.getInstance().getChimaeraUseCost()) { player.sendMessage(LocaleLoader.getString("Skills.NeedMore", LocaleLoader.getString("Item.ChimaeraWing.Name"))); diff --git a/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java b/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java index c8b4f7fd1..3de0eef41 100644 --- a/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java +++ b/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java @@ -137,7 +137,7 @@ public class AcrobaticsManager extends SkillManager { Player player = getPlayer(); - if (player.getItemInHand().getType() == Material.ENDER_PEARL || player.isInsideVehicle()) { + if (player.getInventory().getItemInMainHand().getType() == Material.ENDER_PEARL || player.isInsideVehicle()) { return true; } diff --git a/src/main/java/com/gmail/nossr50/skills/excavation/ExcavationManager.java b/src/main/java/com/gmail/nossr50/skills/excavation/ExcavationManager.java index ab4a4df3f..1f0ed74ce 100644 --- a/src/main/java/com/gmail/nossr50/skills/excavation/ExcavationManager.java +++ b/src/main/java/com/gmail/nossr50/skills/excavation/ExcavationManager.java @@ -57,6 +57,6 @@ public class ExcavationManager extends SkillManager { excavationBlockCheck(blockState); excavationBlockCheck(blockState); - SkillUtils.handleDurabilityChange(getPlayer().getItemInHand(), Config.getInstance().getAbilityToolDamage()); + SkillUtils.handleDurabilityChange(getPlayer().getInventory().getItemInMainHand(), Config.getInstance().getAbilityToolDamage()); } } diff --git a/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java b/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java index ca5dfdce1..d4ac8062a 100644 --- a/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java @@ -134,8 +134,8 @@ public class FishingManager extends SkillManager { player.playSound(location, SoundAdapter.GHAST_SCREAM, Misc.GHAST_VOLUME, Misc.getGhastPitch()); } - if (player.getItemInHand().getType() == Material.FISHING_ROD) { - player.setItemInHand(null); + if (player.getInventory().getItemInMainHand().getType() == Material.FISHING_ROD) { + player.getInventory().setItemInMainHand(null); } LivingEntity kraken = (LivingEntity) world.spawnEntity(player.getEyeLocation(), (Misc.getRandom().nextInt(100) == 0 ? EntityType.CHICKEN : EntityType.SQUID)); @@ -491,7 +491,7 @@ public class FishingManager extends SkillManager { */ private FishingTreasure getFishingTreasure() { double diceRoll = Misc.getRandom().nextDouble() * 100; - diceRoll -= getPlayer().getItemInHand().getEnchantmentLevel(Enchantment.LUCK); + diceRoll -= getPlayer().getInventory().getItemInMainHand().getEnchantmentLevel(Enchantment.LUCK); FishingTreasure treasure = null; diff --git a/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java b/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java index 52368eb68..df8e25eb6 100644 --- a/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java +++ b/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java @@ -9,6 +9,9 @@ import org.bukkit.material.SmoothBrick; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.util.skills.SkillUtils; +import java.util.ArrayList; +import java.util.LinkedHashSet; +import java.util.List; public class Herbalism { public static int farmersDietRankLevel1 = AdvancedConfig.getInstance().getFarmerDietRankChange(); @@ -46,31 +49,89 @@ public class Herbalism { return false; } } + + public static List findChorusPlant(Block target) { + return findChorusPlant(target, true); + } + + private static List findChorusPlant(Block target, boolean origin) { + List blocks = new ArrayList(); + + if(target.getType() != Material.CHORUS_PLANT) { + return blocks; + } + + blocks.add(target); + + Block relative = target.getRelative(BlockFace.UP, 1); + if(relative.getType() == Material.CHORUS_PLANT) { + blocks.addAll(findChorusPlant(relative, false)); + } + + if(origin || target.getRelative(BlockFace.DOWN, 1).getType() == Material.CHORUS_PLANT) { + relative = target.getRelative(BlockFace.NORTH, 1); + if(relative.getType() == Material.CHORUS_PLANT) { + blocks.addAll(findChorusPlant(relative, false)); + } + + relative = target.getRelative(BlockFace.SOUTH, 1); + if(relative.getType() == Material.CHORUS_PLANT) { + blocks.addAll(findChorusPlant(relative, false)); + } + + relative = target.getRelative(BlockFace.EAST, 1); + if(relative.getType() == Material.CHORUS_PLANT) { + blocks.addAll(findChorusPlant(relative, false)); + } + + relative = target.getRelative(BlockFace.WEST, 1); + if(relative.getType() == Material.CHORUS_PLANT) { + blocks.addAll(findChorusPlant(relative, false)); + } + } + + return new ArrayList(new LinkedHashSet(blocks)); + } /** - * Calculate the drop amounts for cacti & sugar cane based on the blocks above them. + * Calculate the drop amounts for multi block plants based on the blocks relative to them. * * @param blockState The {@link BlockState} of the bottom block of the plant * @return the number of bonus drops to award from the blocks in this plant */ - protected static int calculateCatciAndSugarDrops(BlockState blockState) { + protected static int calculateMultiBlockPlantDrops(BlockState blockState) { Block block = blockState.getBlock(); Material blockType = blockState.getType(); int dropAmount = mcMMO.getPlaceStore().isTrue(block) ? 0 : 1; - // Handle the two blocks above it - cacti & sugar cane can only grow 3 high naturally - for (int y = 1; y < 3; y++) { - Block relativeBlock = block.getRelative(BlockFace.UP, y); - - if (relativeBlock.getType() != blockType) { - break; + if(blockType == Material.CHORUS_PLANT) { + dropAmount = 1; + + if(block.getRelative(BlockFace.DOWN, 1).getType() == Material.ENDER_STONE) { + List blocks = findChorusPlant(block); + + dropAmount = blocks.size(); + + /*for(Block b : blocks) { + b.breakNaturally(); + }*/ } + } + else { + // Handle the two blocks above it - cacti & sugar cane can only grow 3 high naturally + for (int y = 1; y < 3; y++) { + Block relativeBlock = block.getRelative(BlockFace.UP, y); - if (mcMMO.getPlaceStore().isTrue(relativeBlock)) { - mcMMO.getPlaceStore().setFalse(relativeBlock); - } - else { - dropAmount++; + if (relativeBlock.getType() != blockType) { + break; + } + + if (mcMMO.getPlaceStore().isTrue(relativeBlock)) { + mcMMO.getPlaceStore().setFalse(relativeBlock); + } + else { + dropAmount++; + } } } diff --git a/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java b/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java index 21c2d1e40..393fa6b4e 100644 --- a/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java +++ b/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java @@ -52,21 +52,15 @@ public class HerbalismManager extends SkillManager { Player player = getPlayer(); ItemStack item = player.getInventory().getItemInMainHand(); - if (item.getAmount() <= 0) - return false; - - return item.getType() == Material.SEEDS && BlockUtils.canMakeMossy(blockState) && Permissions.greenThumbBlock(player, blockState.getType()); + return item.getAmount() > 0 && item.getType() == Material.SEEDS && BlockUtils.canMakeMossy(blockState) && Permissions.greenThumbBlock(player, blockState.getType()); } public boolean canUseShroomThumb(BlockState blockState) { Player player = getPlayer(); ItemStack item = player.getInventory().getItemInMainHand(); Material itemType = item.getType(); - - if (item.getAmount() <= 0) - return false; - return (itemType == Material.RED_MUSHROOM || itemType == Material.BROWN_MUSHROOM) && BlockUtils.canMakeShroomy(blockState) && Permissions.secondaryAbilityEnabled(player, SecondaryAbility.SHROOM_THUMB); + return item.getAmount() > 0 && (itemType == Material.RED_MUSHROOM || itemType == Material.BROWN_MUSHROOM) && BlockUtils.canMakeShroomy(blockState) && Permissions.secondaryAbilityEnabled(player, SecondaryAbility.SHROOM_THUMB); } public boolean canUseHylianLuck() { @@ -129,12 +123,12 @@ public class HerbalismManager extends SkillManager { public void herbalismBlockCheck(BlockState blockState) { Player player = getPlayer(); Material material = blockState.getType(); - boolean oneBlockPlant = !(material == Material.CACTUS || material == Material.SUGAR_CANE_BLOCK); + boolean oneBlockPlant = !(material == Material.CACTUS || material == Material.CHORUS_PLANT || material == Material.SUGAR_CANE_BLOCK); if (oneBlockPlant && mcMMO.getPlaceStore().isTrue(blockState)) { return; } - + if (!canBlockCheck()) { return; } @@ -161,6 +155,10 @@ public class HerbalismManager extends SkillManager { xp = ExperienceConfig.getInstance().getFlowerAndGrassXp(blockState.getData()); } else { + if(material == Material.CHORUS_FLOWER && blockState.getRawData() != 5) { + return; + } + xp = ExperienceConfig.getInstance().getXp(skill, material); } @@ -169,7 +167,7 @@ public class HerbalismManager extends SkillManager { } if (!oneBlockPlant) { - amount = Herbalism.calculateCatciAndSugarDrops(blockState); + amount = Herbalism.calculateMultiBlockPlantDrops(blockState); xp *= amount; } } diff --git a/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java b/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java index 4d3f92913..491795007 100644 --- a/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java +++ b/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java @@ -40,7 +40,7 @@ public class MiningManager extends SkillManager { public boolean canDetonate() { Player player = getPlayer(); - return canUseBlastMining() && player.isSneaking() && player.getItemInHand().getType() == BlastMining.detonator && Permissions.remoteDetonation(player); + return canUseBlastMining() && player.isSneaking() && player.getInventory().getItemInMainHand().getType() == BlastMining.detonator && Permissions.remoteDetonation(player); } public boolean canUseBlastMining() { @@ -68,14 +68,14 @@ public class MiningManager extends SkillManager { Material material = blockState.getType(); if (mcMMOPlayer.getAbilityMode(skill.getAbility())) { - SkillUtils.handleDurabilityChange(getPlayer().getItemInHand(), Config.getInstance().getAbilityToolDamage()); + SkillUtils.handleDurabilityChange(getPlayer().getInventory().getItemInMainHand(), Config.getInstance().getAbilityToolDamage()); } if ((mcMMO.getModManager().isCustomMiningBlock(blockState) && !mcMMO.getModManager().getBlock(blockState).isDoubleDropEnabled()) || material != Material.GLOWING_REDSTONE_ORE && !Config.getInstance().getDoubleDropsEnabled(skill, material)) { return; } - boolean silkTouch = player.getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH); + boolean silkTouch = player.getInventory().getItemInMainHand().containsEnchantment(Enchantment.SILK_TOUCH); for (int i = mcMMOPlayer.getAbilityMode(skill.getAbility()) ? 2 : 1; i != 0; i--) { if (SkillUtils.activationSuccessful(SecondaryAbility.MINING_DOUBLE_DROPS, getPlayer(), getSkillLevel(), activationChance)) { diff --git a/src/main/java/com/gmail/nossr50/skills/salvage/SalvageManager.java b/src/main/java/com/gmail/nossr50/skills/salvage/SalvageManager.java index 08bd93ad2..86df9ee2e 100644 --- a/src/main/java/com/gmail/nossr50/skills/salvage/SalvageManager.java +++ b/src/main/java/com/gmail/nossr50/skills/salvage/SalvageManager.java @@ -94,7 +94,7 @@ public class SalvageManager extends SkillManager { salvageableAmount = Math.max((int) (salvageableAmount * getMaxSalvagePercentage()), 1); // Always get at least something back, if you're capable of salvaging it. - player.setItemInHand(new ItemStack(Material.AIR)); + player.getInventory().setItemInMainHand(new ItemStack(Material.AIR)); location.add(0, 1, 0); Map enchants = item.getEnchantments(); diff --git a/src/main/java/com/gmail/nossr50/skills/smelting/SmeltingManager.java b/src/main/java/com/gmail/nossr50/skills/smelting/SmeltingManager.java index 624e4c738..a9b09f004 100644 --- a/src/main/java/com/gmail/nossr50/skills/smelting/SmeltingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/smelting/SmeltingManager.java @@ -83,7 +83,7 @@ public class SmeltingManager extends SkillManager { // We need to distribute Mining XP here, because the block break event gets cancelled applyXpGain(Mining.getBlockXp(blockState), XPGainReason.PVE); - SkillUtils.handleDurabilityChange(getPlayer().getItemInHand(), Config.getInstance().getAbilityToolDamage()); + SkillUtils.handleDurabilityChange(getPlayer().getInventory().getItemInMainHand(), Config.getInstance().getAbilityToolDamage()); Misc.dropItems(blockState.getLocation(), item, isSecondSmeltSuccessful() ? 2 : 1); diff --git a/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java b/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java index 43911bb3f..1426fa247 100644 --- a/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java @@ -257,7 +257,7 @@ public class TamingManager extends SkillManager { private void callOfTheWild(EntityType type, int summonAmount) { Player player = getPlayer(); - ItemStack heldItem = player.getItemInHand(); + ItemStack heldItem = player.getInventory().getItemInMainHand(); int heldItemAmount = heldItem.getAmount(); Location location = player.getLocation(); @@ -326,7 +326,7 @@ public class TamingManager extends SkillManager { ParticleEffectUtils.playCallOfTheWildEffect(entity); } - player.setItemInHand(heldItemAmount == summonAmount ? null : new ItemStack(heldItem.getType(), heldItemAmount - summonAmount)); + player.getInventory().setItemInMainHand(heldItemAmount == summonAmount ? null : new ItemStack(heldItem.getType(), heldItemAmount - summonAmount)); String lifeSpan = ""; if (tamingCOTWLength > 0) { diff --git a/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java b/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java index 53c7d9627..c7e1d9d60 100644 --- a/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java +++ b/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java @@ -43,13 +43,13 @@ public class UnarmedManager extends SkillManager { } public boolean canDisarm(LivingEntity target) { - return target instanceof Player && ((Player) target).getItemInHand().getType() != Material.AIR && Permissions.secondaryAbilityEnabled(getPlayer(), SecondaryAbility.DISARM); + return target instanceof Player && ((Player) target).getInventory().getItemInMainHand().getType() != Material.AIR && Permissions.secondaryAbilityEnabled(getPlayer(), SecondaryAbility.DISARM); } public boolean canDeflect() { Player player = getPlayer(); - return ItemUtils.isUnarmed(player.getItemInHand()) && Permissions.secondaryAbilityEnabled(getPlayer(), SecondaryAbility.DEFLECT); + return ItemUtils.isUnarmed(player.getInventory().getItemInMainHand()) && Permissions.secondaryAbilityEnabled(getPlayer(), SecondaryAbility.DEFLECT); } public boolean canUseBlockCracker() { @@ -95,13 +95,13 @@ public class UnarmedManager extends SkillManager { return; } - Item item = Misc.dropItem(defender.getLocation(), defender.getItemInHand()); + Item item = Misc.dropItem(defender.getLocation(), defender.getInventory().getItemInMainHand()); if (item != null && AdvancedConfig.getInstance().getDisarmProtected()) { item.setMetadata(mcMMO.disarmedItemKey, UserManager.getPlayer(defender).getPlayerMetadata()); } - defender.setItemInHand(new ItemStack(Material.AIR)); + defender.getInventory().setItemInMainHand(new ItemStack(Material.AIR)); defender.sendMessage(LocaleLoader.getString("Skills.Disarmed")); } } diff --git a/src/main/java/com/gmail/nossr50/skills/woodcutting/WoodcuttingManager.java b/src/main/java/com/gmail/nossr50/skills/woodcutting/WoodcuttingManager.java index 47f1e6766..cd9e84db3 100644 --- a/src/main/java/com/gmail/nossr50/skills/woodcutting/WoodcuttingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/woodcutting/WoodcuttingManager.java @@ -89,7 +89,7 @@ public class WoodcuttingManager extends SkillManager { } // If the tool can't sustain the durability loss - if (!Woodcutting.handleDurabilityLoss(treeFellerBlocks, player.getItemInHand())) { + if (!Woodcutting.handleDurabilityLoss(treeFellerBlocks, player.getInventory().getItemInMainHand())) { player.sendMessage(LocaleLoader.getString("Woodcutting.Skills.TreeFeller.Splinter")); double health = player.getHealth(); diff --git a/src/main/java/com/gmail/nossr50/util/BlockUtils.java b/src/main/java/com/gmail/nossr50/util/BlockUtils.java index b485f49bb..4298adeb8 100644 --- a/src/main/java/com/gmail/nossr50/util/BlockUtils.java +++ b/src/main/java/com/gmail/nossr50/util/BlockUtils.java @@ -132,6 +132,8 @@ public final class BlockUtils { switch (blockState.getType()) { case BROWN_MUSHROOM: case CACTUS: + case CHORUS_PLANT: + case CHORUS_FLOWER: case DOUBLE_PLANT: case MELON_BLOCK: case LONG_GRASS: @@ -170,6 +172,7 @@ public final class BlockUtils { */ public static Boolean affectedBySuperBreaker(BlockState blockState) { switch (blockState.getType()) { + case END_BRICKS: case ENDER_STONE: case GLOWSTONE: case HARD_CLAY: @@ -177,11 +180,16 @@ public final class BlockUtils { case NETHERRACK: case OBSIDIAN: case PACKED_ICE: + case PURPUR_BLOCK: + case PURPUR_PILLAR: + case PURPUR_SLAB: + case PURPUR_STAIRS: case SANDSTONE: case STAINED_CLAY: case STONE: case PRISMARINE: case RED_SANDSTONE: + return true; default: diff --git a/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java b/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java index e83dc8023..f68fbf083 100644 --- a/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java +++ b/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java @@ -39,7 +39,7 @@ public final class ChimaeraWing { return; } - ItemStack inHand = player.getItemInHand(); + ItemStack inHand = player.getInventory().getItemInMainHand(); if (!ItemUtils.isChimaeraWing(inHand)) { return; @@ -91,7 +91,7 @@ public final class ChimaeraWing { if (Config.getInstance().getChimaeraPreventUseUnderground()) { if (location.getY() < player.getWorld().getHighestBlockYAt(location)) { - player.setItemInHand(new ItemStack(getChimaeraWing(amount - Config.getInstance().getChimaeraUseCost()))); + player.getInventory().setItemInMainHand(new ItemStack(getChimaeraWing(amount - Config.getInstance().getChimaeraUseCost()))); player.sendMessage(LocaleLoader.getString("Item.ChimaeraWing.Fail")); player.updateInventory(); player.setVelocity(new Vector(0, 0.5D, 0)); @@ -130,7 +130,7 @@ public final class ChimaeraWing { } } - player.setItemInHand(new ItemStack(getChimaeraWing(player.getItemInHand().getAmount() - Config.getInstance().getChimaeraUseCost()))); + player.getInventory().setItemInMainHand(new ItemStack(getChimaeraWing(player.getInventory().getItemInMainHand().getAmount() - Config.getInstance().getChimaeraUseCost()))); player.updateInventory(); mcMMOPlayer.actualizeChimeraWingLastUse(); mcMMOPlayer.setTeleportCommenceLocation(null); diff --git a/src/main/java/com/gmail/nossr50/util/EventUtils.java b/src/main/java/com/gmail/nossr50/util/EventUtils.java index 94a72b56f..6c4f293d9 100644 --- a/src/main/java/com/gmail/nossr50/util/EventUtils.java +++ b/src/main/java/com/gmail/nossr50/util/EventUtils.java @@ -97,7 +97,7 @@ public class EventUtils { callFakeArmSwingEvent(player); } - FakeBlockDamageEvent damageEvent = new FakeBlockDamageEvent(player, block, player.getItemInHand(), true); + FakeBlockDamageEvent damageEvent = new FakeBlockDamageEvent(player, block, player.getInventory().getItemInMainHand(), true); pluginManager.callEvent(damageEvent); FakeBlockBreakEvent breakEvent = new FakeBlockBreakEvent(block, player); diff --git a/src/main/java/com/gmail/nossr50/util/ItemUtils.java b/src/main/java/com/gmail/nossr50/util/ItemUtils.java index ff84cddca..55720d868 100644 --- a/src/main/java/com/gmail/nossr50/util/ItemUtils.java +++ b/src/main/java/com/gmail/nossr50/util/ItemUtils.java @@ -589,6 +589,8 @@ public final class ItemUtils { case WHEAT: case SEEDS: case CARROT_ITEM: + case CHORUS_FRUIT: + case CHORUS_FLOWER: case POTATO_ITEM: case NETHER_WARTS: case BROWN_MUSHROOM: diff --git a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java index 7635af9dd..92d19fb29 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java @@ -214,7 +214,7 @@ public final class CombatUtils { return; } - ItemStack heldItem = player.getItemInHand(); + ItemStack heldItem = player.getInventory().getItemInMainHand(); if (target instanceof Tameable) { if (heldItem.getType() == Material.BONE) { @@ -308,7 +308,7 @@ public final class CombatUtils { event.setDamage(acrobaticsManager.dodgeCheck(event.getDamage())); } - if (ItemUtils.isSword(player.getItemInHand())) { + if (ItemUtils.isSword(player.getInventory().getItemInMainHand())) { if (!SkillType.SWORDS.shouldProcess(target)) { return; } @@ -386,7 +386,7 @@ public final class CombatUtils { * @param type The type of skill being used */ public static void applyAbilityAoE(Player attacker, LivingEntity target, double damage, Map modifiers, SkillType type) { - int numberOfTargets = getTier(attacker.getItemInHand()); // The higher the weapon tier, the more targets you hit + int numberOfTargets = getTier(attacker.getInventory().getItemInMainHand()); // The higher the weapon tier, the more targets you hit double damageAmount = Math.max(damage, 1); for (Entity entity : target.getNearbyEntities(2.5, 2.5, 2.5)) { @@ -475,18 +475,20 @@ public final class CombatUtils { case CREEPER: case ENDER_DRAGON: case ENDERMAN: + case ENDERMITE: case GHAST: case GIANT: case MAGMA_CUBE: case PIG_ZOMBIE: + case SHULKER: case SILVERFISH: case SLIME: case SPIDER: case WITCH: case WITHER: case ZOMBIE: - case ENDERMITE: baseXP = ExperienceConfig.getInstance().getCombatXP(type); + break; case SKELETON: diff --git a/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java b/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java index f4dbec446..e384d07bc 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java @@ -97,7 +97,7 @@ public class SkillUtils { public static void handleAbilitySpeedIncrease(Player player) { if (HiddenConfig.getInstance().useEnchantmentBuffs()) { - ItemStack heldItem = player.getItemInHand(); + ItemStack heldItem = player.getInventory().getItemInMainHand(); if (heldItem == null || heldItem.getType() == Material.AIR) { return; diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 5f4ade1d9..fa068b027 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -508,4 +508,4 @@ Particles: Sounds: # This setting controls the master volume. 1.0 is Max, 0 would be off MasterVolume: 1.0 - + \ No newline at end of file diff --git a/src/main/resources/experience.yml b/src/main/resources/experience.yml index 5d53711e0..90360229b 100644 --- a/src/main/resources/experience.yml +++ b/src/main/resources/experience.yml @@ -155,6 +155,8 @@ Experience: Brown_Mushroom: 150 Cactus: 30 Carrot: 50 + Chorus_Flower: 25 + Chorus_Plant: 2 Cocoa: 30 Crops: 50 Dead_Bush: 30 @@ -185,6 +187,7 @@ Experience: Coal_Ore: 100 Diamond_Ore: 750 Emerald_Ore: 1000 + End_Bricks: 200 Ender_Stone: 150 Glowstone: 30 Gold_Ore: 350 @@ -202,6 +205,10 @@ Experience: Stone: 30 Red_Sandstone: 100 Prismarine: 70 + Purpur_Block: 200 + Purpur_Pillar: 250 + Purpur_Slab: 150 + Purpur_Stairs: 250 Repair: Base: 1000.0 Wood: 0.6 @@ -250,3 +257,4 @@ Experience: Endermite: 2.0 Guardian: 3.0 Elder_Guardian: 4.0 + Shulker: 2.0