From 28d82396b363ddd82e138614727dd8c71a28bbb4 Mon Sep 17 00:00:00 2001 From: Yasin Date: Sun, 30 Jun 2024 14:25:40 +0200 Subject: fixes #539 #538 The logic of the livid code has been changed. The system checks whether the current color is the same as the last found livid color. The initial color is detected after the first blindness effect + 2 seconds. I also added the bounding box option for livid to make it easier to recognize the correct enemy. I changed default mob glow option to false by and bounding box option to true. --- src/main/java/de/hysky/skyblocker/skyblock/entity/MobBoundingBoxes.java | 2 ++ 1 file changed, 2 insertions(+) (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 095c5d10..da6e0226 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/entity/MobBoundingBoxes.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/entity/MobBoundingBoxes.java @@ -1,6 +1,7 @@ package de.hysky.skyblocker.skyblock.entity; import de.hysky.skyblocker.config.SkyblockerConfigManager; +import de.hysky.skyblocker.skyblock.dungeon.LividColor; import de.hysky.skyblocker.utils.Utils; import de.hysky.skyblocker.utils.render.FrustumUtils; import de.hysky.skyblocker.utils.render.RenderHelper; @@ -31,6 +32,7 @@ public class MobBoundingBoxes { return switch (entity) { case PlayerEntity _p when name.equals("Lost Adventurer") || name.equals("Shadow Assassin") || name.equals("Diamond Guy") -> SkyblockerConfigManager.get().dungeons.starredMobBoundingBoxes; + case PlayerEntity p when LividColor.LIVID_NAMES.contains(name) -> LividColor.shouldDrawBoundingBox(name); case ArmorStandEntity _armorStand -> false; // Regular Mobs -- cgit From a26143be386e78094d9a32e0d2c70439afd56369 Mon Sep 17 00:00:00 2001 From: Yasin Date: Tue, 23 Jul 2024 00:04:02 +0200 Subject: nukekubi head fix --- src/main/java/de/hysky/skyblocker/skyblock/entity/MobGlow.java | 5 +++-- 1 file changed, 3 insertions(+), 2 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 81e328ca..d1a7b83c 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/entity/MobGlow.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/entity/MobGlow.java @@ -123,14 +123,15 @@ public class MobGlow { } private static boolean isNukekubiHead(ArmorStandEntity entity) { + boolean armorfound = false; for (ItemStack armorItem : entity.getArmorItems()) { // eb07594e2df273921a77c101d0bfdfa1115abed5b9b2029eb496ceba9bdbb4b3 is texture id for the nukekubi head, // compare against it to exclusively find armorstands that are nukekubi heads // get the texture of the nukekubi head item itself and compare it String texture = ItemUtils.getHeadTexture(armorItem); - return texture.contains("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZWIwNzU5NGUyZGYyNzM5MjFhNzdjMTAxZDBiZmRmYTExMTVhYmVkNWI5YjIwMjllYjQ5NmNlYmE5YmRiYjRiMyJ9fX0="); + armorfound |= texture.contains("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZWIwNzU5NGUyZGYyNzM5MjFhNzdjMTAxZDBiZmRmYTExMTVhYmVkNWI5YjIwMjllYjQ5NmNlYmE5YmRiYjRiMyJ9fX0="); } - return false; + return armorfound; } } -- cgit From 646eaeee8a30b4edf82b2b401e930adf6627f65e Mon Sep 17 00:00:00 2001 From: Yasin Date: Tue, 23 Jul 2024 00:04:37 +0200 Subject: livid fix now it will only highlight the correct livid also after the "change" --- .../skyblocker/skyblock/dungeon/LividColor.java | 23 +++++++++++++++++++++- .../skyblock/entity/MobBoundingBoxes.java | 2 +- .../hysky/skyblocker/skyblock/entity/MobGlow.java | 7 +++---- 3 files changed, 26 insertions(+), 6 deletions(-) (limited to 'src/main/java/de/hysky/skyblocker/skyblock/entity') diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/LividColor.java b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/LividColor.java index 15d0d6dd..d360ae2e 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/LividColor.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/LividColor.java @@ -46,10 +46,12 @@ public class LividColor { ); public static final Set LIVID_NAMES = Set.copyOf(LIVID_TO_FORMATTING.keySet()); public static final DungeonsConfig.Livid CONFIG = SkyblockerConfigManager.get().dungeons.livid; - private static Formatting color; + private static Formatting color = Formatting.AQUA; private static Block lastColor = Blocks.AIR; + private static int lividID = 0; private static boolean isInitialized = false; + private static boolean originLividFound = false; private static final long OFFSET_DURATION = 2000; private static long toggleTime = 0; @@ -74,6 +76,18 @@ public class LividColor { isInitialized = true; } else if (isInitialized && System.currentTimeMillis() - toggleTime >= OFFSET_DURATION) { onLividColorFound(client, currentColor); + if (!originLividFound) { + String lividName = LIVID_TO_FORMATTING.entrySet().stream() + .filter(entry -> entry.getValue() == color) + .map(Map.Entry::getKey) + .findFirst() + .orElse("unknown"); + client.world.getPlayers().stream() + .filter(entity -> entity.getName().getString().equals(lividName)) + .findFirst() + .ifPresent(entity -> lividID = entity.getId()); + originLividFound = true; + } lastColor = currentColor; } @@ -114,9 +128,16 @@ public class LividColor { return Formatting.WHITE.getColorValue(); } + public static int getLividID(){ + return lividID; + } + private static void reset() { lastColor = Blocks.AIR; toggleTime = 0; isInitialized = false; + originLividFound = false; + lividID = 0; + color = Formatting.AQUA; } } 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 da6e0226..b7b3e0e0 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/entity/MobBoundingBoxes.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/entity/MobBoundingBoxes.java @@ -32,7 +32,7 @@ public class MobBoundingBoxes { return switch (entity) { case PlayerEntity _p when name.equals("Lost Adventurer") || name.equals("Shadow Assassin") || name.equals("Diamond Guy") -> SkyblockerConfigManager.get().dungeons.starredMobBoundingBoxes; - case PlayerEntity p when LividColor.LIVID_NAMES.contains(name) -> LividColor.shouldDrawBoundingBox(name); + case PlayerEntity p when entity.getId() == LividColor.getLividID() -> LividColor.shouldDrawBoundingBox(name); case ArmorStandEntity _armorStand -> false; // Regular Mobs 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 d1a7b83c..1322004e 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/entity/MobGlow.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/entity/MobGlow.java @@ -36,7 +36,7 @@ public class MobGlow { return switch (entity) { // Minibosses case PlayerEntity p when name.equals("Lost Adventurer") || name.equals("Shadow Assassin") || name.equals("Diamond Guy") -> SkyblockerConfigManager.get().dungeons.starredMobGlow; - case PlayerEntity p when LividColor.LIVID_NAMES.contains(name) -> LividColor.shouldGlow(name); + case PlayerEntity p when entity.getId() == LividColor.getLividID() -> LividColor.shouldGlow(name); // Bats case BatEntity b -> SkyblockerConfigManager.get().dungeons.starredMobGlow || SkyblockerConfigManager.get().dungeons.starredMobBoundingBoxes; @@ -49,7 +49,6 @@ public class MobGlow { }; } - return switch (entity) { // Rift case PlayerEntity p when Utils.isInTheRift() && !entity.isInvisible() && name.equals("Blobbercyst ") -> SkyblockerConfigManager.get().otherLocations.rift.blobbercystGlow; @@ -111,11 +110,11 @@ public class MobGlow { 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 entity.getId() == LividColor.getLividID() -> LividColor.getGlowColor(name); case PlayerEntity p when name.equals("Blobbercyst ") -> Formatting.GREEN.getColorValue(); case EndermanEntity enderman when TheEnd.isSpecialZealot(enderman) -> Formatting.RED.getColorValue(); - case ArmorStandEntity armorStand when isNukekubiHead(armorStand) -> 0x990099; + case ArmorStandEntity armorStand when isNukekubiHead(armorStand) -> Formatting.GREEN.getColorValue(); case ZombieEntity zombie when Utils.isInCrimson() && DojoManager.inArena -> DojoManager.getColor(); default -> 0xf57738; -- cgit From 8f27eb76273fe8424d44c2a1e08e45454e76b77c Mon Sep 17 00:00:00 2001 From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> Date: Fri, 26 Jul 2024 14:53:46 +0800 Subject: Refactor LividColor and Nukekubi head detection --- .../skyblocker/skyblock/dungeon/LividColor.java | 23 +++++++++++---------- .../skyblock/entity/MobBoundingBoxes.java | 2 +- .../hysky/skyblocker/skyblock/entity/MobGlow.java | 24 ++++++++++------------ 3 files changed, 24 insertions(+), 25 deletions(-) (limited to 'src/main/java/de/hysky/skyblocker/skyblock/entity') diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/LividColor.java b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/LividColor.java index d360ae2e..b6a035aa 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/LividColor.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/LividColor.java @@ -19,7 +19,6 @@ import net.minecraft.util.Formatting; import net.minecraft.util.math.BlockPos; import java.util.Map; -import java.util.Set; public class LividColor { private static final Map WOOL_TO_FORMATTING = Map.of( @@ -44,14 +43,16 @@ public class LividColor { "Doctor Livid", Formatting.GRAY, "Vendetta Livid", Formatting.WHITE ); - public static final Set LIVID_NAMES = Set.copyOf(LIVID_TO_FORMATTING.keySet()); public static final DungeonsConfig.Livid CONFIG = SkyblockerConfigManager.get().dungeons.livid; private static Formatting color = Formatting.AQUA; private static Block lastColor = Blocks.AIR; - private static int lividID = 0; private static boolean isInitialized = false; - private static boolean originLividFound = false; + /** + * The correct livid may change color in M5, so we use the entity id to track the correct original livid. + */ + private static boolean correctLividIdFound = false; + private static int correctLividId = 0; private static final long OFFSET_DURATION = 2000; private static long toggleTime = 0; @@ -76,7 +77,7 @@ public class LividColor { isInitialized = true; } else if (isInitialized && System.currentTimeMillis() - toggleTime >= OFFSET_DURATION) { onLividColorFound(client, currentColor); - if (!originLividFound) { + if (!correctLividIdFound) { String lividName = LIVID_TO_FORMATTING.entrySet().stream() .filter(entry -> entry.getValue() == color) .map(Map.Entry::getKey) @@ -85,8 +86,8 @@ public class LividColor { client.world.getPlayers().stream() .filter(entity -> entity.getName().getString().equals(lividName)) .findFirst() - .ifPresent(entity -> lividID = entity.getId()); - originLividFound = true; + .ifPresent(entity -> correctLividId = entity.getId()); + correctLividIdFound = true; } lastColor = currentColor; } @@ -128,16 +129,16 @@ public class LividColor { return Formatting.WHITE.getColorValue(); } - public static int getLividID(){ - return lividID; + public static int getCorrectLividId() { + return correctLividId; } private static void reset() { lastColor = Blocks.AIR; toggleTime = 0; isInitialized = false; - originLividFound = false; - lividID = 0; + correctLividIdFound = false; + correctLividId = 0; color = Formatting.AQUA; } } 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 b7b3e0e0..f005fc06 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/entity/MobBoundingBoxes.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/entity/MobBoundingBoxes.java @@ -32,7 +32,7 @@ public class MobBoundingBoxes { return switch (entity) { case PlayerEntity _p when name.equals("Lost Adventurer") || name.equals("Shadow Assassin") || name.equals("Diamond Guy") -> SkyblockerConfigManager.get().dungeons.starredMobBoundingBoxes; - case PlayerEntity p when entity.getId() == LividColor.getLividID() -> LividColor.shouldDrawBoundingBox(name); + case PlayerEntity p when entity.getId() == LividColor.getCorrectLividId() -> LividColor.shouldDrawBoundingBox(name); case ArmorStandEntity _armorStand -> false; // Regular Mobs 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 1322004e..0438a8ce 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/entity/MobGlow.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/entity/MobGlow.java @@ -1,5 +1,6 @@ package de.hysky.skyblocker.skyblock.entity; +import com.google.common.collect.Streams; import de.hysky.skyblocker.config.SkyblockerConfigManager; import de.hysky.skyblocker.skyblock.crimson.dojo.DojoManager; import de.hysky.skyblocker.skyblock.dungeon.LividColor; @@ -14,7 +15,6 @@ import net.minecraft.entity.mob.EndermanEntity; import net.minecraft.entity.mob.ZombieEntity; import net.minecraft.entity.passive.BatEntity; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; import net.minecraft.predicate.entity.EntityPredicates; import net.minecraft.util.Formatting; import net.minecraft.util.math.Box; @@ -23,6 +23,10 @@ import net.minecraft.world.World; import java.util.List; public class MobGlow { + /** + * The Nukekubi head texture id is eb07594e2df273921a77c101d0bfdfa1115abed5b9b2029eb496ceba9bdbb4b3. + */ + public static final String NUKEKUBI_HEAD_TEXTURE = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZWIwNzU5NGUyZGYyNzM5MjFhNzdjMTAxZDBiZmRmYTExMTVhYmVkNWI5YjIwMjllYjQ5NmNlYmE5YmRiYjRiMyJ9fX0="; public static boolean shouldMobGlow(Entity entity) { Box box = entity.getBoundingBox(); @@ -36,7 +40,7 @@ public class MobGlow { return switch (entity) { // Minibosses case PlayerEntity p when name.equals("Lost Adventurer") || name.equals("Shadow Assassin") || name.equals("Diamond Guy") -> SkyblockerConfigManager.get().dungeons.starredMobGlow; - case PlayerEntity p when entity.getId() == LividColor.getLividID() -> LividColor.shouldGlow(name); + case PlayerEntity p when entity.getId() == LividColor.getCorrectLividId() -> LividColor.shouldGlow(name); // Bats case BatEntity b -> SkyblockerConfigManager.get().dungeons.starredMobGlow || SkyblockerConfigManager.get().dungeons.starredMobBoundingBoxes; @@ -110,7 +114,7 @@ public class MobGlow { 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 entity.getId() == LividColor.getLividID() -> LividColor.getGlowColor(name); + case PlayerEntity p when entity.getId() == LividColor.getCorrectLividId() -> LividColor.getGlowColor(name); case PlayerEntity p when name.equals("Blobbercyst ") -> Formatting.GREEN.getColorValue(); case EndermanEntity enderman when TheEnd.isSpecialZealot(enderman) -> Formatting.RED.getColorValue(); @@ -121,16 +125,10 @@ public class MobGlow { }; } + /** + * Compares the armor items of an armor stand to the Nukekubi head texture to determine if it is a Nukekubi head. + */ private static boolean isNukekubiHead(ArmorStandEntity entity) { - boolean armorfound = false; - for (ItemStack armorItem : entity.getArmorItems()) { - // eb07594e2df273921a77c101d0bfdfa1115abed5b9b2029eb496ceba9bdbb4b3 is texture id for the nukekubi head, - // compare against it to exclusively find armorstands that are nukekubi heads - // get the texture of the nukekubi head item itself and compare it - String texture = ItemUtils.getHeadTexture(armorItem); - - armorfound |= texture.contains("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZWIwNzU5NGUyZGYyNzM5MjFhNzdjMTAxZDBiZmRmYTExMTVhYmVkNWI5YjIwMjllYjQ5NmNlYmE5YmRiYjRiMyJ9fX0="); - } - return armorfound; + return Streams.stream(entity.getArmorItems()).map(ItemUtils::getHeadTexture).anyMatch(headTexture -> headTexture.contains(NUKEKUBI_HEAD_TEXTURE)); } } -- cgit