From 1edb11cedf98faf89230484076bf6ea8ce5e2c8d Mon Sep 17 00:00:00 2001 From: TfT_02 Date: Fri, 28 Jun 2013 13:36:48 +0200 Subject: [PATCH] Disable mob healthbars for boss mobs! Fixes #1210 --- Changelog.txt | 1 + .../gmail/nossr50/util/MobHealthbarUtils.java | 21 +++++++++++++++++++ .../java/com/gmail/nossr50/util/ModUtils.java | 11 ++++++++++ 3 files changed, 33 insertions(+) diff --git a/Changelog.txt b/Changelog.txt index fca63ac87..c0f42d934 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -53,6 +53,7 @@ Version 1.4.06-dev = Fixed bug where the chance of a successful Gracefull Roll was twice as high as displayed = Fixed bug where lucky perks where not working = Fixed bug with Ice Fishing on a single block of ice + = Fixed a small bug with mob healthbars and bosses, such as EnderDragons and Withers ! Changed Spout notification tiers to be stored in SpoutConfig instead of AdvancedConfig ! Changed Berserk to add items to inventory rather than denying pickup ! Changed Call of the Wild, newly summoned pet's will have a custom name. (added permission node to disable this) diff --git a/src/main/java/com/gmail/nossr50/util/MobHealthbarUtils.java b/src/main/java/com/gmail/nossr50/util/MobHealthbarUtils.java index c1c00f6fd..580d3ad9a 100644 --- a/src/main/java/com/gmail/nossr50/util/MobHealthbarUtils.java +++ b/src/main/java/com/gmail/nossr50/util/MobHealthbarUtils.java @@ -44,6 +44,10 @@ public final class MobHealthbarUtils { return; } + if (isBoss(target)) { + return; + } + PlayerProfile profile = UserManager.getPlayer(player).getProfile(); if (profile.getMobHealthbarType() == null) { @@ -149,4 +153,21 @@ public final class MobHealthbarUtils { return healthbar; } + + /** + * Check if a given LivingEntity is a boss. + * + * @param livingEntity The {@link LivingEntity} of the livingEntity to check + * @return true if the livingEntity is a boss, false otherwise + */ + public static boolean isBoss(LivingEntity livingEntity) { + switch (livingEntity.getType()) { + case ENDER_DRAGON: + case WITHER: + return true; + + default: + return ModUtils.isCustomBossEntity(livingEntity); + } + } } diff --git a/src/main/java/com/gmail/nossr50/util/ModUtils.java b/src/main/java/com/gmail/nossr50/util/ModUtils.java index c012022ce..aedc4151f 100644 --- a/src/main/java/com/gmail/nossr50/util/ModUtils.java +++ b/src/main/java/com/gmail/nossr50/util/ModUtils.java @@ -291,4 +291,15 @@ public final class ModUtils { return false; } + + /** + * Check if a custom entity is a boss. + * + * @param entity The entity to check + * @return true if the entity represents a boss, false otherwise + */ + public static boolean isCustomBossEntity(Entity entity) { + //TODO: Finish this method + return false; + } }