mirror of
				https://github.com/mcMMO-Dev/mcMMO.git
				synced 2025-11-04 02:53:43 +01:00 
			
		
		
		
	Passing the event is bad - pass just event.getDamage() instead.
This commit is contained in:
		@@ -131,7 +131,7 @@ public class EntityListener implements Listener {
 | 
			
		||||
        if (defender instanceof LivingEntity) {
 | 
			
		||||
            LivingEntity livingDefender = (LivingEntity) defender;
 | 
			
		||||
 | 
			
		||||
            if (!CombatTools.isInvincible(livingDefender, event)) {
 | 
			
		||||
            if (!CombatTools.isInvincible(livingDefender, event.getDamage())) {
 | 
			
		||||
                CombatTools.combatChecks(event, attacker, livingDefender);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
@@ -160,6 +160,7 @@ public class EntityListener implements Listener {
 | 
			
		||||
        if (livingEntity instanceof Player) {
 | 
			
		||||
            Player player = (Player) entity;
 | 
			
		||||
 | 
			
		||||
            // TODO: Is it even possible for the player to be off-line here?
 | 
			
		||||
            if (!player.isOnline() || Misc.isNPCEntity(player)) {
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
@@ -173,7 +174,7 @@ public class EntityListener implements Listener {
 | 
			
		||||
                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)) {
 | 
			
		||||
                    AcrobaticsManager acrobaticsManager = new AcrobaticsManager(mcMMOPlayer);
 | 
			
		||||
                    acrobaticsManager.rollCheck(event);
 | 
			
		||||
@@ -192,7 +193,7 @@ public class EntityListener implements Listener {
 | 
			
		||||
            Tameable pet = (Tameable) livingEntity;
 | 
			
		||||
            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.preventDamage(event);
 | 
			
		||||
            }
 | 
			
		||||
 
 | 
			
		||||
@@ -572,17 +572,17 @@ public final class CombatTools {
 | 
			
		||||
    /**
 | 
			
		||||
     * Checks to see if an entity is currently invincible.
 | 
			
		||||
     *
 | 
			
		||||
     * @param le The LivingEntity to check
 | 
			
		||||
     * @param event The event the entity is involved in
 | 
			
		||||
     * @param entity The {@link LivingEntity} to check
 | 
			
		||||
     * @param eventDamage The damage from the event the entity is involved in
 | 
			
		||||
     * @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 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;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user