From 4e2924407645b04c30d4a2823a1d9d0983c2c790 Mon Sep 17 00:00:00 2001 From: Aaron <51387595+AzureAaron@users.noreply.github.com> Date: Sat, 2 Mar 2024 15:16:27 -0500 Subject: 24w09a --- .../hysky/skyblocker/skyblock/entity/MobGlow.java | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'src/main/java/de/hysky/skyblocker/skyblock/entity') 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..9650e39b 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/entity/MobGlow.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/entity/MobGlow.java @@ -6,14 +6,15 @@ import de.hysky.skyblocker.skyblock.dungeon.LividColor; 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; @@ -21,6 +22,8 @@ import net.minecraft.world.World; import java.util.List; +import com.mojang.authlib.properties.Property; + public class MobGlow { public static boolean shouldMobGlow(Entity entity) { @@ -114,19 +117,18 @@ public class MobGlow { 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")) + if (!armorItem.isOf(Items.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) { + ProfileComponent profile = armorItem.get(DataComponentTypes.PROFILE); + if (profile != 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"); + String texture = profile.properties().get("textures").stream() + .map(Property::value) + .findFirst() + .orElse("None"); return texture.contains("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZWIwNzU5NGUyZGYyNzM5MjFhNzdjMTAxZDBiZmRmYTExMTVhYmVkNWI5YjIwMjllYjQ5NmNlYmE5YmRiYjRiMyJ9fX0="); } -- cgit From aface0d01336c444093f4bee21e623cc8bfb4062 Mon Sep 17 00:00:00 2001 From: Aaron <51387595+AzureAaron@users.noreply.github.com> Date: Mon, 22 Apr 2024 12:43:29 -0400 Subject: Refactor MobGlow and MobBoundingBoxes to use pattern matching --- .../skyblock/entity/MobBoundingBoxes.java | 25 +++--- .../hysky/skyblocker/skyblock/entity/MobGlow.java | 94 ++++++++++------------ 2 files changed, 54 insertions(+), 65 deletions(-) (limited to 'src/main/java/de/hysky/skyblocker/skyblock/entity') diff --git a/src/main/java/de/hysky/skyblocker/skyblock/entity/MobBoundingBoxes.java b/src/main/java/de/hysky/skyblocker/skyblock/entity/MobBoundingBoxes.java index b969ba0b..6ab4e3f2 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/entity/MobBoundingBoxes.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/entity/MobBoundingBoxes.java @@ -31,20 +31,21 @@ public class MobBoundingBoxes { if (Utils.isInDungeons() && FrustumUtils.isVisible(box) && !entity.isInvisible()) { String name = entity.getName().getString(); - // Minibosses - if (entity instanceof PlayerEntity) { - switch (name) { - case "Lost Adventurer", "Shadow Assassin", "Diamond Guy": return SkyblockerConfigManager.get().locations.dungeons.starredMobBoundingBoxes; - } - } + return switch (entity) { + case PlayerEntity p when name.equals("Lost Adventurer") || name.equals("Shadow Assassin") || name.equals("Diamond Guy") -> SkyblockerConfigManager.get().locations.dungeons.starredMobBoundingBoxes; + + default -> { + // Regular Mobs + if (!(entity instanceof ArmorStandEntity)) { + List armorStands = MobGlow.getArmorStands(entity); - // Regular Mobs - if (!(entity instanceof ArmorStandEntity)) { - List armorStands = MobGlow.getArmorStands(entity); + if (!armorStands.isEmpty() && armorStands.get(0).getName().getString().contains("✯")) + yield SkyblockerConfigManager.get().locations.dungeons.starredMobBoundingBoxes; + } - if (!armorStands.isEmpty() && armorStands.get(0).getName().getString().contains("✯")) - return SkyblockerConfigManager.get().locations.dungeons.starredMobBoundingBoxes; - } + yield false; + } + }; } return false; 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 9650e39b..5076e153 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/entity/MobGlow.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/entity/MobGlow.java @@ -30,55 +30,48 @@ public class MobGlow { Box box = entity.getBoundingBox(); if (OcclusionCulling.getReducedCuller().isVisible(box.minX, box.minY, box.minZ, box.maxX, box.maxY, box.maxZ)) { - String name = entity.getName().getString(); - - if (!entity.isInvisible()) { + if (entity.isInvisible()) return false; - // Dungeons - if (Utils.isInDungeons()) { + String name = entity.getName().getString(); + // Dungeons + if (Utils.isInDungeons()) { + return switch (entity) { // 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); - } - } + 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); - // Regular Mobs - if (!(entity instanceof ArmorStandEntity)) { - List armorStands = getArmorStands(entity); + //Bats + case BatEntity b -> SkyblockerConfigManager.get().locations.dungeons.starredMobGlow || SkyblockerConfigManager.get().locations.dungeons.starredMobBoundingBoxes; - if (!armorStands.isEmpty() && armorStands.get(0).getName().getString().contains("✯")) - return SkyblockerConfigManager.get().locations.dungeons.starredMobGlow; - } - - // Bats - return (SkyblockerConfigManager.get().locations.dungeons.starredMobGlow || SkyblockerConfigManager.get().locations.dungeons.starredMobBoundingBoxes) && entity instanceof BatEntity; - } + default -> { + // Regular Mobs + if (!(entity instanceof ArmorStandEntity)) { + List armorStands = getArmorStands(entity); - // 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; + if (!armorStands.isEmpty() && armorStands.get(0).getName().getString().contains("✯")) + yield SkyblockerConfigManager.get().locations.dungeons.starredMobGlow; } + + yield false; } - } + }; } - // Enderman Slayer - // Highlights Nukekubi Heads - return SkyblockerConfigManager.get().slayer.endermanSlayer.highlightNukekubiHeads - && SlayerUtils.isInSlayer() - && entity instanceof ArmorStandEntity armorStandEntity - && isNukekubiHead(armorStandEntity); - } + return switch (entity) { + // Rift + case PlayerEntity p when Utils.isInTheRift() && name.equals("Blobbercyst ") -> SkyblockerConfigManager.get().locations.rift.blobbercystGlow; + + // Enderman Slayer + // Highlights Nukekubi Heads + case ArmorStandEntity armorStand when Utils.isInTheEnd() && SlayerUtils.isInSlayer() && isNukekubiHead(armorStand) -> SkyblockerConfigManager.get().slayer.endermanSlayer.highlightNukekubiHeads; + + // Special Zelot + case EndermanEntity enderman when Utils.isInTheEnd() -> TheEnd.isSpecialZealot(enderman); - // Special Zelot - if (entity instanceof EndermanEntity enderman && TheEnd.isSpecialZealot(enderman)) return true; + default -> false; + }; + } return false; } @@ -94,23 +87,18 @@ 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) { -- cgit From 86e8f24272ada7d38006e09650ebe77c8cf6a532 Mon Sep 17 00:00:00 2001 From: Aaron <51387595+AzureAaron@users.noreply.github.com> Date: Wed, 24 Apr 2024 16:28:42 -0400 Subject: Fix Nukekubi Head Highlight --- src/main/java/de/hysky/skyblocker/skyblock/entity/MobGlow.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src/main/java/de/hysky/skyblocker/skyblock/entity') 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 5076e153..d21ad881 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/entity/MobGlow.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/entity/MobGlow.java @@ -30,12 +30,10 @@ public class MobGlow { Box box = entity.getBoundingBox(); if (OcclusionCulling.getReducedCuller().isVisible(box.minX, box.minY, box.minZ, box.maxX, box.maxY, box.maxZ)) { - if (entity.isInvisible()) return false; - String name = entity.getName().getString(); // Dungeons - if (Utils.isInDungeons()) { + 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; @@ -60,14 +58,14 @@ public class MobGlow { return switch (entity) { // Rift - case PlayerEntity p when Utils.isInTheRift() && name.equals("Blobbercyst ") -> SkyblockerConfigManager.get().locations.rift.blobbercystGlow; + case PlayerEntity p when Utils.isInTheRift() && !entity.isInvisible() && name.equals("Blobbercyst ") -> SkyblockerConfigManager.get().locations.rift.blobbercystGlow; // Enderman Slayer // Highlights Nukekubi Heads case ArmorStandEntity armorStand when Utils.isInTheEnd() && SlayerUtils.isInSlayer() && isNukekubiHead(armorStand) -> SkyblockerConfigManager.get().slayer.endermanSlayer.highlightNukekubiHeads; // Special Zelot - case EndermanEntity enderman when Utils.isInTheEnd() -> TheEnd.isSpecialZealot(enderman); + case EndermanEntity enderman when Utils.isInTheEnd() && !entity.isInvisible() -> TheEnd.isSpecialZealot(enderman); default -> false; }; -- cgit From c61ffbe25dea8f57e91ce3fb7892aa8540224b0e Mon Sep 17 00:00:00 2001 From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> Date: Fri, 26 Apr 2024 23:14:28 -0400 Subject: Refactor updated code --- .../skyblock/entity/MobBoundingBoxes.java | 18 +++---------- .../hysky/skyblocker/skyblock/entity/MobGlow.java | 31 ++++++++++++---------- 2 files changed, 21 insertions(+), 28 deletions(-) (limited to 'src/main/java/de/hysky/skyblocker/skyblock/entity') diff --git a/src/main/java/de/hysky/skyblocker/skyblock/entity/MobBoundingBoxes.java b/src/main/java/de/hysky/skyblocker/skyblock/entity/MobBoundingBoxes.java index 6ab4e3f2..5522ceca 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/entity/MobBoundingBoxes.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/entity/MobBoundingBoxes.java @@ -1,7 +1,5 @@ package de.hysky.skyblocker.skyblock.entity; -import java.util.List; - import de.hysky.skyblocker.config.SkyblockerConfigManager; import de.hysky.skyblocker.utils.Utils; import de.hysky.skyblocker.utils.render.FrustumUtils; @@ -32,19 +30,11 @@ public class MobBoundingBoxes { String name = entity.getName().getString(); return switch (entity) { - case PlayerEntity p when name.equals("Lost Adventurer") || name.equals("Shadow Assassin") || name.equals("Diamond Guy") -> SkyblockerConfigManager.get().locations.dungeons.starredMobBoundingBoxes; - - default -> { - // Regular Mobs - if (!(entity instanceof ArmorStandEntity)) { - List armorStands = MobGlow.getArmorStands(entity); - - if (!armorStands.isEmpty() && armorStands.get(0).getName().getString().contains("✯")) - yield SkyblockerConfigManager.get().locations.dungeons.starredMobBoundingBoxes; - } + case PlayerEntity _p when name.equals("Lost Adventurer") || name.equals("Shadow Assassin") || name.equals("Diamond Guy") -> SkyblockerConfigManager.get().locations.dungeons.starredMobBoundingBoxes; + case ArmorStandEntity _armorStand -> false; - yield false; - } + // Regular Mobs + default -> SkyblockerConfigManager.get().locations.dungeons.starredMobBoundingBoxes && MobGlow.isStarred(entity); }; } 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 d21ad881..8343c6a5 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/entity/MobGlow.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/entity/MobGlow.java @@ -1,8 +1,9 @@ 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.SlayerUtils; import de.hysky.skyblocker.utils.Utils; import de.hysky.skyblocker.utils.render.culling.OcclusionCulling; @@ -22,8 +23,6 @@ import net.minecraft.world.World; import java.util.List; -import com.mojang.authlib.properties.Property; - public class MobGlow { public static boolean shouldMobGlow(Entity entity) { @@ -39,20 +38,14 @@ public class MobGlow { 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); - //Bats + // Bats case BatEntity b -> SkyblockerConfigManager.get().locations.dungeons.starredMobGlow || SkyblockerConfigManager.get().locations.dungeons.starredMobBoundingBoxes; - default -> { - // Regular Mobs - if (!(entity instanceof ArmorStandEntity)) { - List armorStands = getArmorStands(entity); - - if (!armorStands.isEmpty() && armorStands.get(0).getName().getString().contains("✯")) - yield SkyblockerConfigManager.get().locations.dungeons.starredMobGlow; - } + // Armor Stands + case ArmorStandEntity _armorStand -> false; - yield false; - } + // Regular Mobs + default -> SkyblockerConfigManager.get().locations.dungeons.starredMobGlow && isStarred(entity); }; } @@ -74,6 +67,16 @@ public class MobGlow { 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 armorStands = getArmorStands(entity); + return !armorStands.isEmpty() && armorStands.getFirst().getName().getString().contains("✯"); + } + public static List getArmorStands(Entity entity) { return getArmorStands(entity.getWorld(), entity.getBoundingBox()); } -- cgit From 45bcbe967ac58a2dc5ef606381e1653003ac17e3 Mon Sep 17 00:00:00 2001 From: Aaron <51387595+AzureAaron@users.noreply.github.com> Date: Sun, 28 Apr 2024 15:06:24 -0400 Subject: Add invisible armour stand toggle and dumping head textures to debug --- .../de/hysky/skyblocker/skyblock/entity/MobGlow.java | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) (limited to 'src/main/java/de/hysky/skyblocker/skyblock/entity') 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 8343c6a5..75ba700e 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/entity/MobGlow.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/entity/MobGlow.java @@ -4,6 +4,7 @@ import com.mojang.authlib.properties.Property; import de.hysky.skyblocker.config.SkyblockerConfigManager; 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; @@ -104,23 +105,12 @@ public class MobGlow { 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.isOf(Items.PLAYER_HEAD)) - continue; - // eb07594e2df273921a77c101d0bfdfa1115abed5b9b2029eb496ceba9bdbb4b3 is texture id for the nukekubi head, // compare against it to exclusively find armorstands that are nukekubi heads - ProfileComponent profile = armorItem.get(DataComponentTypes.PROFILE); - if (profile != null) { - // get the texture of the nukekubi head item itself and compare it - String texture = profile.properties().get("textures").stream() - .map(Property::value) - .findFirst() - .orElse("None"); - - 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; } -- cgit