mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 21:26:46 +01:00
Passing the event is bad - pass just event.getDamage() instead.
This commit is contained in:
parent
3b07d4055a
commit
63974f3968
@ -131,7 +131,7 @@ public class EntityListener implements Listener {
|
|||||||
if (defender instanceof LivingEntity) {
|
if (defender instanceof LivingEntity) {
|
||||||
LivingEntity livingDefender = (LivingEntity) defender;
|
LivingEntity livingDefender = (LivingEntity) defender;
|
||||||
|
|
||||||
if (!CombatTools.isInvincible(livingDefender, event)) {
|
if (!CombatTools.isInvincible(livingDefender, event.getDamage())) {
|
||||||
CombatTools.combatChecks(event, attacker, livingDefender);
|
CombatTools.combatChecks(event, attacker, livingDefender);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -160,6 +160,7 @@ public class EntityListener implements Listener {
|
|||||||
if (livingEntity instanceof Player) {
|
if (livingEntity instanceof Player) {
|
||||||
Player player = (Player) entity;
|
Player player = (Player) entity;
|
||||||
|
|
||||||
|
// TODO: Is it even possible for the player to be off-line here?
|
||||||
if (!player.isOnline() || Misc.isNPCEntity(player)) {
|
if (!player.isOnline() || Misc.isNPCEntity(player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -173,7 +174,7 @@ public class EntityListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!CombatTools.isInvincible(player, event)) {
|
if (!CombatTools.isInvincible(player, event.getDamage())) {
|
||||||
if (cause == DamageCause.FALL && player.getItemInHand().getType() != Material.ENDER_PEARL && !(Acrobatics.afkLevelingDisabled && player.isInsideVehicle()) && Permissions.roll(player)) {
|
if (cause == DamageCause.FALL && player.getItemInHand().getType() != Material.ENDER_PEARL && !(Acrobatics.afkLevelingDisabled && player.isInsideVehicle()) && Permissions.roll(player)) {
|
||||||
AcrobaticsManager acrobaticsManager = new AcrobaticsManager(mcMMOPlayer);
|
AcrobaticsManager acrobaticsManager = new AcrobaticsManager(mcMMOPlayer);
|
||||||
acrobaticsManager.rollCheck(event);
|
acrobaticsManager.rollCheck(event);
|
||||||
@ -192,7 +193,7 @@ public class EntityListener implements Listener {
|
|||||||
Tameable pet = (Tameable) livingEntity;
|
Tameable pet = (Tameable) livingEntity;
|
||||||
AnimalTamer owner = pet.getOwner();
|
AnimalTamer owner = pet.getOwner();
|
||||||
|
|
||||||
if ((!CombatTools.isInvincible(livingEntity, event)) && pet.isTamed() && owner instanceof Player && pet instanceof Wolf) {
|
if ((!CombatTools.isInvincible(livingEntity, event.getDamage())) && pet.isTamed() && owner instanceof Player && pet instanceof Wolf) {
|
||||||
TamingManager tamingManager = new TamingManager(Users.getPlayer((Player) owner));
|
TamingManager tamingManager = new TamingManager(Users.getPlayer((Player) owner));
|
||||||
tamingManager.preventDamage(event);
|
tamingManager.preventDamage(event);
|
||||||
}
|
}
|
||||||
|
@ -572,17 +572,17 @@ public final class CombatTools {
|
|||||||
/**
|
/**
|
||||||
* Checks to see if an entity is currently invincible.
|
* Checks to see if an entity is currently invincible.
|
||||||
*
|
*
|
||||||
* @param le The LivingEntity to check
|
* @param entity The {@link LivingEntity} to check
|
||||||
* @param event The event the entity is involved in
|
* @param eventDamage The damage from the event the entity is involved in
|
||||||
* @return true if the entity is invincible, false otherwise
|
* @return true if the entity is invincible, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isInvincible(LivingEntity le, EntityDamageEvent event) {
|
public static boolean isInvincible(LivingEntity entity, int eventDamage) {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* So apparently if you do more damage to a LivingEntity than its last damage int you bypass the invincibility.
|
* So apparently if you do more damage to a LivingEntity than its last damage int you bypass the invincibility.
|
||||||
* So yeah, this is for that.
|
* So yeah, this is for that.
|
||||||
*/
|
*/
|
||||||
if (le.getNoDamageTicks() > le.getMaximumNoDamageTicks() / 2.0F && event.getDamage() <= le.getLastDamage()) {
|
if ((entity.getNoDamageTicks() > entity.getMaximumNoDamageTicks() / 2.0F) && (eventDamage <= entity.getLastDamage())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user