Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,13 @@ public class MascotsDamageListener implements Listener {
EntityDamageEvent.DamageCause.LIGHTNING,
EntityDamageEvent.DamageCause.BLOCK_EXPLOSION,
EntityDamageEvent.DamageCause.ENTITY_EXPLOSION,
EntityDamageEvent.DamageCause.FIRE_TICK
EntityDamageEvent.DamageCause.FIRE_TICK,
EntityDamageEvent.DamageCause.ENTITY_ATTACK // Fix le fait de pouvoir attaquer sa propre mascotte
);

@EventHandler
void onMascotDamageCaused(EntityDamageEvent e) {
if (!(e.getEntity() instanceof LivingEntity entity)) return;

if (entity instanceof Player) return;

if (!MascotUtils.canBeAMascot(entity)) return;

EntityDamageEvent.DamageCause cause = e.getCause();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ public static boolean canBeAMascot(Entity entity) {
}

public static void updateDisplayName(LivingEntity entityMascot, Mascot mascot, double damage) {
double newHealth = Math.floor(entityMascot.getHealth());
entityMascot.setHealth(newHealth);
AttributeInstance maxHealthInst = entityMascot.getAttribute(Attribute.MAX_HEALTH);
if (maxHealthInst == null) return;
double maxHealth = maxHealthInst.getValue();
Expand All @@ -81,6 +79,7 @@ public static void updateDisplayName(LivingEntity entityMascot, Mascot mascot, d
healthAfterDamage,
maxHealth
)));
entityMascot.setHealth(healthAfterDamage);
}
}

Expand Down
Loading