From 145b2432e0d43afe2e1c86f95ed14f846402395d Mon Sep 17 00:00:00 2001 From: nossr50 Date: Mon, 27 Apr 2020 17:04:01 -0700 Subject: [PATCH] Combat fix --- Changelog.txt | 2 +- .../nossr50/util/skills/CombatUtils.java | 28 +++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index c9fec6109..40d152a7d 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -14,7 +14,7 @@ Version 2.1.125 Version 2.1.124 Repair/Salvage can now be set to use vanilla blocks that already do something and that vanilla functionality will be disabled by mcMMO (you could use vanilla-anvils instead of iron_blocks for repair now) - Added Gold_Nugget to Mining's Bonus_Drops in config.yml (edit your config)g + Added Gold_Nugget to Mining's Bonus_Drops in config.yml (edit your config) Added Piglin to experience.yml combat XP tables with a value of 2.0 (edit your config) Added Hoglin to experience.yml combat XP tables with a value of 4.0 (edit your config) Added Zombified_Piglin & Zombie_Pigman to experience.yml combat XP tables with a value of 3.0 (edit your config) 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 edfbbca93..cb14dd20f 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java @@ -301,8 +301,9 @@ public final class CombatUtils { * * @param event The event to run the combat checks on. */ - public static void processCombatAttack(EntityDamageByEntityEvent event, Entity damageSourceEntity, LivingEntity target) { - EntityType entityType = damageSourceEntity.getType(); + public static void processCombatAttack(EntityDamageByEntityEvent event, Entity painSourceRoot, LivingEntity target) { + Entity painSource = event.getDamager(); + EntityType entityType = painSource.getType(); if (target instanceof Player) { if (Misc.isNPCEntityExcludingVillagers(target)) { @@ -318,7 +319,7 @@ public final class CombatUtils { AcrobaticsManager acrobaticsManager = mcMMOPlayer.getAcrobaticsManager(); if (acrobaticsManager.canDodge(target)) { - event.setDamage(acrobaticsManager.dodgeCheck(damageSourceEntity, event.getDamage())); + event.setDamage(acrobaticsManager.dodgeCheck(painSourceRoot, event.getDamage())); } if (ItemUtils.isSword(player.getInventory().getItemInMainHand())) { @@ -328,25 +329,24 @@ public final class CombatUtils { SwordsManager swordsManager = mcMMOPlayer.getSwordsManager(); - if (swordsManager.canUseCounterAttack(damageSourceEntity)) { - swordsManager.counterAttackChecks((LivingEntity) damageSourceEntity, event.getDamage()); + if (swordsManager.canUseCounterAttack(painSource)) { + swordsManager.counterAttackChecks((LivingEntity) painSource, event.getDamage()); } } } - if (damageSourceEntity instanceof Player && entityType == EntityType.PLAYER) { - Player player = (Player) damageSourceEntity; + if (painSourceRoot instanceof Player && entityType == EntityType.PLAYER) { + Player player = (Player) painSourceRoot; - if (UserManager.getPlayer(player) == null) { + if (!UserManager.hasPlayerDataKey(player)) { return; } - McMMOPlayer attackingPlayer = UserManager.getPlayer(player); ItemStack heldItem = player.getInventory().getItemInMainHand(); if (target instanceof Tameable) { if (heldItem.getType() == Material.BONE) { - TamingManager tamingManager = attackingPlayer.getTamingManager(); + TamingManager tamingManager = UserManager.getPlayer(player).getTamingManager(); if (tamingManager.canUseBeastLore()) { tamingManager.beastLore(target); @@ -390,10 +390,10 @@ public final class CombatUtils { } else if (entityType == EntityType.WOLF) { - Wolf wolf = (Wolf) damageSourceEntity; + Wolf wolf = (Wolf) painSource; AnimalTamer tamer = wolf.getOwner(); - if (tamer != null && tamer instanceof Player && PrimarySkillType.TAMING.shouldProcess(target)) { + if (tamer instanceof Player && PrimarySkillType.TAMING.shouldProcess(target)) { Player master = (Player) tamer; if (!Misc.isNPCEntityExcludingVillagers(master) && PrimarySkillType.TAMING.getPermissions(master)) { @@ -402,10 +402,10 @@ public final class CombatUtils { } } else if (entityType == EntityType.ARROW || entityType == EntityType.SPECTRAL_ARROW) { - Projectile arrow = (Projectile) damageSourceEntity; + Projectile arrow = (Projectile) painSource; ProjectileSource projectileSource = arrow.getShooter(); - if (projectileSource != null && projectileSource instanceof Player && PrimarySkillType.ARCHERY.shouldProcess(target)) { + if (projectileSource instanceof Player && PrimarySkillType.ARCHERY.shouldProcess(target)) { Player player = (Player) projectileSource; if (!Misc.isNPCEntityExcludingVillagers(player) && PrimarySkillType.ARCHERY.getPermissions(player)) {