aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authornmccullagh <narhanael64@gmail.com>2024-08-04 15:04:17 +0100
committernmccullagh <narhanael64@gmail.com>2024-08-04 15:04:17 +0100
commitd167b8671da767da2335aa4eebd5335a8a790acb (patch)
tree89e0eda3ed29830f4f5cd56e4d251da504ead84a /src
parentfb398d98ea1084ebb4248877701bf50ca8abfeb2 (diff)
downloadSkyblocker-d167b8671da767da2335aa4eebd5335a8a790acb.tar.gz
Skyblocker-d167b8671da767da2335aa4eebd5335a8a790acb.tar.bz2
Skyblocker-d167b8671da767da2335aa4eebd5335a8a790acb.zip
refine detection
Diffstat (limited to 'src')
-rw-r--r--src/main/java/de/hysky/skyblocker/skyblock/slayers/SlayerEntitiesGlow.java23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/main/java/de/hysky/skyblocker/skyblock/slayers/SlayerEntitiesGlow.java b/src/main/java/de/hysky/skyblocker/skyblock/slayers/SlayerEntitiesGlow.java
index 54060829..0ba3223d 100644
--- a/src/main/java/de/hysky/skyblocker/skyblock/slayers/SlayerEntitiesGlow.java
+++ b/src/main/java/de/hysky/skyblocker/skyblock/slayers/SlayerEntitiesGlow.java
@@ -35,6 +35,9 @@ public class SlayerEntitiesGlow {
Map.entry("Burningsoul Demon", SlayerUtils.DEMONLORD)
);
+ public static void init() {
+ SkyblockEvents.LOCATION_CHANGE.register(SlayerEntitiesGlow::clearGlow);
+ }
private static final Map<String, Class<? extends MobEntity>> SLAYER_MOB_TYPE = Map.of(
SlayerUtils.REVENANT, ZombieEntity.class,
SlayerUtils.TARA, SpiderEntity.class,
@@ -50,13 +53,15 @@ public class SlayerEntitiesGlow {
}
public static boolean isSlayer(LivingEntity e) {
- return SlayerUtils.isInSlayer() && SlayerUtils.getEntityArmorStands(e).stream().anyMatch(entity -> entity.getDisplayName().getString().contains(MinecraftClient.getInstance().getSession().getUsername()));
+ return SlayerUtils.isInSlayer() && SlayerUtils.getEntityArmorStands(e).stream().anyMatch(entity ->
+ entity.getDisplayName().getString().contains(MinecraftClient.getInstance().getSession().getUsername()));
}
public static boolean isSlayerMiniMob(LivingEntity entity) {
if (entity.getCustomName() == null) return false;
String entityName = entity.getCustomName().getString();
- return SLAYER_MINI_NAMES.keySet().stream().anyMatch(slayerMobName -> entityName.contains(slayerMobName) && SlayerUtils.isInSlayerQuestType(SLAYER_MINI_NAMES.get(slayerMobName)));
+ return SLAYER_MINI_NAMES.keySet().stream().anyMatch(slayerMobName ->
+ entityName.contains(slayerMobName) && SlayerUtils.isInSlayerQuestType(SLAYER_MINI_NAMES.get(slayerMobName)));
}
public static Box getSlayerMobBoundingBox(LivingEntity entity) {
@@ -86,12 +91,21 @@ public class SlayerEntitiesGlow {
.getBoxAt(armorStand.getPos()).expand(1.5), entity ->
!entity.isDead() && entity.age > armorStand.age - 4 && entity.age < armorStand.age + 4)
.stream()
- .filter(entity -> !(entity instanceof CaveSpiderEntity)) // CaveSpider extends Spider so filter out mob for BroodFather highlight
+ .filter(entity -> !(entity instanceof CaveSpiderEntity))
+ .filter(SlayerEntitiesGlow::isValidSlayerMob)
.min(Comparator.comparingDouble((MobEntity e) -> e.distanceTo(armorStand)))
.orElse(null);
}
/**
+ * Use this func to add checks to prevent accidental highlights
+ * i.e. Cavespider extends spider and thus will highlight the broodfather's head pet instead and
+ */
+ private static boolean isValidSlayerMob(MobEntity entity) {
+ return !(entity instanceof CaveSpiderEntity) && !(entity.isBaby());
+ }
+
+ /**
* <p> Adds the Entity UUID to the Hashset of Slayer Mobs to glow </p>
*
* @param armorStand the entity that contains the display name of the Slayer (mini)boss
@@ -113,7 +127,4 @@ public class SlayerEntitiesGlow {
MOBS_TO_GLOW.clear();
}
- public static void init() {
- SkyblockEvents.LOCATION_CHANGE.register(SlayerEntitiesGlow::clearGlow);
- }
} \ No newline at end of file