aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/de/hysky/skyblocker/skyblock/entity/MobGlow.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/de/hysky/skyblocker/skyblock/entity/MobGlow.java')
-rw-r--r--src/main/java/de/hysky/skyblocker/skyblock/entity/MobGlow.java125
1 files changed, 53 insertions, 72 deletions
diff --git a/src/main/java/de/hysky/skyblocker/skyblock/entity/MobGlow.java b/src/main/java/de/hysky/skyblocker/skyblock/entity/MobGlow.java
index 12ae468f..75ba700e 100644
--- a/src/main/java/de/hysky/skyblocker/skyblock/entity/MobGlow.java
+++ b/src/main/java/de/hysky/skyblocker/skyblock/entity/MobGlow.java
@@ -1,19 +1,22 @@
package de.hysky.skyblocker.skyblock.entity;
+import com.mojang.authlib.properties.Property;
import de.hysky.skyblocker.config.SkyblockerConfigManager;
-import de.hysky.skyblocker.skyblock.end.TheEnd;
import de.hysky.skyblocker.skyblock.dungeon.LividColor;
+import de.hysky.skyblocker.skyblock.end.TheEnd;
+import de.hysky.skyblocker.utils.ItemUtils;
import de.hysky.skyblocker.utils.SlayerUtils;
import de.hysky.skyblocker.utils.Utils;
import de.hysky.skyblocker.utils.render.culling.OcclusionCulling;
+import net.minecraft.component.DataComponentTypes;
+import net.minecraft.component.type.ProfileComponent;
import net.minecraft.entity.Entity;
import net.minecraft.entity.decoration.ArmorStandEntity;
import net.minecraft.entity.mob.EndermanEntity;
import net.minecraft.entity.passive.BatEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
-import net.minecraft.nbt.NbtCompound;
-import net.minecraft.nbt.NbtElement;
+import net.minecraft.item.Items;
import net.minecraft.predicate.entity.EntityPredicates;
import net.minecraft.util.Formatting;
import net.minecraft.util.math.Box;
@@ -29,57 +32,52 @@ public class MobGlow {
if (OcclusionCulling.getReducedCuller().isVisible(box.minX, box.minY, box.minZ, box.maxX, box.maxY, box.maxZ)) {
String name = entity.getName().getString();
- if (!entity.isInvisible()) {
+ // Dungeons
+ if (Utils.isInDungeons() && !entity.isInvisible()) {
+ return switch (entity) {
+ // Minibosses
+ case PlayerEntity p when name.equals("Lost Adventurer") || name.equals("Shadow Assassin") || name.equals("Diamond Guy") -> SkyblockerConfigManager.get().locations.dungeons.starredMobGlow;
+ case PlayerEntity p when LividColor.LIVID_NAMES.contains(name) -> LividColor.shouldGlow(name);
- // Dungeons
- if (Utils.isInDungeons()) {
+ // Bats
+ case BatEntity b -> SkyblockerConfigManager.get().locations.dungeons.starredMobGlow || SkyblockerConfigManager.get().locations.dungeons.starredMobBoundingBoxes;
- // Minibosses
- if (entity instanceof PlayerEntity) {
- switch (name) {
- case "Lost Adventurer", "Shadow Assassin", "Diamond Guy": return SkyblockerConfigManager.get().locations.dungeons.starredMobGlow;
- case "Arcade Livid", "Crossed Livid", "Doctor Livid", "Frog Livid", "Hockey Livid",
- "Purple Livid", "Scream Livid", "Smile Livid", "Vendetta Livid": return LividColor.shouldGlow(name);
- }
- }
+ // Armor Stands
+ case ArmorStandEntity _armorStand -> false;
// Regular Mobs
- if (!(entity instanceof ArmorStandEntity)) {
- List<ArmorStandEntity> armorStands = getArmorStands(entity);
+ default -> SkyblockerConfigManager.get().locations.dungeons.starredMobGlow && isStarred(entity);
+ };
+ }
- if (!armorStands.isEmpty() && armorStands.get(0).getName().getString().contains("✯"))
- return SkyblockerConfigManager.get().locations.dungeons.starredMobGlow;
- }
+ return switch (entity) {
+ // Rift
+ case PlayerEntity p when Utils.isInTheRift() && !entity.isInvisible() && name.equals("Blobbercyst ") -> SkyblockerConfigManager.get().locations.rift.blobbercystGlow;
- // Bats
- return (SkyblockerConfigManager.get().locations.dungeons.starredMobGlow || SkyblockerConfigManager.get().locations.dungeons.starredMobBoundingBoxes) && entity instanceof BatEntity;
- }
+ // Enderman Slayer
+ // Highlights Nukekubi Heads
+ case ArmorStandEntity armorStand when Utils.isInTheEnd() && SlayerUtils.isInSlayer() && isNukekubiHead(armorStand) -> SkyblockerConfigManager.get().slayer.endermanSlayer.highlightNukekubiHeads;
- // Rift
- if (Utils.isInTheRift()) {
- if (entity instanceof PlayerEntity) {
- switch (name) {
- // They have a space in their name for some reason...
- case "Blobbercyst ": return SkyblockerConfigManager.get().locations.rift.blobbercystGlow;
- }
- }
- }
- }
+ // Special Zelot
+ case EndermanEntity enderman when Utils.isInTheEnd() && !entity.isInvisible() -> TheEnd.isSpecialZealot(enderman);
- // Enderman Slayer
- // Highlights Nukekubi Heads
- return SkyblockerConfigManager.get().slayer.endermanSlayer.highlightNukekubiHeads
- && SlayerUtils.isInSlayer()
- && entity instanceof ArmorStandEntity armorStandEntity
- && isNukekubiHead(armorStandEntity);
+ default -> false;
+ };
}
- // Special Zelot
- if (entity instanceof EndermanEntity enderman && TheEnd.isSpecialZealot(enderman)) return true;
-
return false;
}
+ /**
+ * Checks if an entity is starred by checking if its armor stand contains a star in its name.
+ * @param entity the entity to check.
+ * @return true if the entity is starred, false otherwise
+ */
+ public static boolean isStarred(Entity entity) {
+ List<ArmorStandEntity> armorStands = getArmorStands(entity);
+ return !armorStands.isEmpty() && armorStands.getFirst().getName().getString().contains("✯");
+ }
+
public static List<ArmorStandEntity> getArmorStands(Entity entity) {
return getArmorStands(entity.getWorld(), entity.getBoundingBox());
}
@@ -91,45 +89,28 @@ public class MobGlow {
public static int getGlowColor(Entity entity) {
String name = entity.getName().getString();
- if (entity instanceof PlayerEntity) {
- return switch (name) {
- case "Lost Adventurer" -> 0xfee15c;
- case "Shadow Assassin" -> 0x5b2cb2;
- case "Diamond Guy" -> 0x57c2f7;
- case "Arcade Livid", "Crossed Livid", "Doctor Livid", "Frog Livid", "Hockey Livid",
- "Purple Livid", "Scream Livid", "Smile Livid", "Vendetta Livid" -> LividColor.getGlowColor(name);
- case "Blobbercyst " -> Formatting.GREEN.getColorValue();
- default -> 0xf57738;
- };
- }
- if (entity instanceof EndermanEntity enderman && TheEnd.isSpecialZealot(enderman)) return Formatting.RED.getColorValue();
+ return switch (entity) {
+ case PlayerEntity p when name.equals("Lost Adventurer") -> 0xfee15c;
+ case PlayerEntity p when name.equals("Shadow Assassin") -> 0x5b2cb2;
+ case PlayerEntity p when name.equals("Diamond Guy") -> 0x57c2f7;
+ case PlayerEntity p when LividColor.LIVID_NAMES.contains(name) -> LividColor.getGlowColor(name);
+ case PlayerEntity p when name.equals("Blobbercyst ") -> Formatting.GREEN.getColorValue();
- // copypaste nukekebi head logic
- if (entity instanceof ArmorStandEntity armorStandEntity && isNukekubiHead(armorStandEntity)) return 0x990099;
+ case EndermanEntity enderman when TheEnd.isSpecialZealot(enderman) -> Formatting.RED.getColorValue();
+ case ArmorStandEntity armorStand when isNukekubiHead(armorStand) -> 0x990099;
- return 0xf57738;
+ default -> 0xf57738;
+ };
}
private static boolean isNukekubiHead(ArmorStandEntity entity) {
for (ItemStack armorItem : entity.getArmorItems()) {
- // hacky way to check if an item is a player head w/o
- // some shenanigans
- if (!armorItem.toString().startsWith("1 player_head"))
- continue;
-
// eb07594e2df273921a77c101d0bfdfa1115abed5b9b2029eb496ceba9bdbb4b3 is texture id for the nukekubi head,
// compare against it to exclusively find armorstands that are nukekubi heads
- NbtCompound skullOwner = armorItem.getSubNbt("SkullOwner");
- if (skullOwner != null) {
- // get the texture of the nukekubi head item itself and compare it
- String texture = skullOwner
- .getCompound("Properties")
- .getList("textures", NbtElement.COMPOUND_TYPE)
- .getCompound(0)
- .getString("Value");
-
- return texture.contains("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZWIwNzU5NGUyZGYyNzM5MjFhNzdjMTAxZDBiZmRmYTExMTVhYmVkNWI5YjIwMjllYjQ5NmNlYmE5YmRiYjRiMyJ9fX0=");
- }
+ // get the texture of the nukekubi head item itself and compare it
+ String texture = ItemUtils.getHeadTexture(armorItem);
+
+ return texture.contains("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZWIwNzU5NGUyZGYyNzM5MjFhNzdjMTAxZDBiZmRmYTExMTVhYmVkNWI5YjIwMjllYjQ5NmNlYmE5YmRiYjRiMyJ9fX0=");
}
return false;
}