mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 15:16:45 +01:00
Merge pull request #2799 from DorCoMaNdO/patch-3
Use getItemInMainHand()
This commit is contained in:
commit
376abdf49e
@ -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;
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
|
@ -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")));
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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();
|
||||
@ -47,17 +50,74 @@ public class Herbalism {
|
||||
}
|
||||
}
|
||||
|
||||
public static List<Block> findChorusPlant(Block target) {
|
||||
return findChorusPlant(target, true);
|
||||
}
|
||||
|
||||
private static List<Block> findChorusPlant(Block target, boolean origin) {
|
||||
List<Block> blocks = new ArrayList<Block>();
|
||||
|
||||
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<Block>(new LinkedHashSet<Block>(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;
|
||||
|
||||
if(blockType == Material.CHORUS_PLANT) {
|
||||
dropAmount = 1;
|
||||
|
||||
if(block.getRelative(BlockFace.DOWN, 1).getType() == Material.ENDER_STONE) {
|
||||
List<Block> 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);
|
||||
@ -73,6 +133,7 @@ public class Herbalism {
|
||||
dropAmount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return dropAmount;
|
||||
}
|
||||
|
@ -52,10 +52,7 @@ 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) {
|
||||
@ -63,10 +60,7 @@ public class HerbalismManager extends SkillManager {
|
||||
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,7 +123,7 @@ 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;
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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)) {
|
||||
|
@ -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<Enchantment, Integer> enchants = item.getEnchantments();
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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"));
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
|
@ -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:
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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:
|
||||
|
@ -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<DamageModifier, Double> 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:
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user