aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKevinthegreat <92656833+kevinthegreat1@users.noreply.github.com>2024-07-26 14:53:46 +0800
committerKevinthegreat <92656833+kevinthegreat1@users.noreply.github.com>2024-07-26 15:09:20 +0800
commit8f27eb76273fe8424d44c2a1e08e45454e76b77c (patch)
tree300bef4c49905a4c2c439c8471e6a68ade4e526c /src
parent9f7fdb2a5e37907e7e4a5dd2400748b4a8e5f991 (diff)
downloadSkyblocker-8f27eb76273fe8424d44c2a1e08e45454e76b77c.tar.gz
Skyblocker-8f27eb76273fe8424d44c2a1e08e45454e76b77c.tar.bz2
Skyblocker-8f27eb76273fe8424d44c2a1e08e45454e76b77c.zip
Refactor LividColor and Nukekubi head detection
Diffstat (limited to 'src')
-rw-r--r--src/main/java/de/hysky/skyblocker/skyblock/dungeon/LividColor.java23
-rw-r--r--src/main/java/de/hysky/skyblocker/skyblock/entity/MobBoundingBoxes.java2
-rw-r--r--src/main/java/de/hysky/skyblocker/skyblock/entity/MobGlow.java24
3 files changed, 24 insertions, 25 deletions
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<Block, Formatting> WOOL_TO_FORMATTING = Map.of(
@@ -44,14 +43,16 @@ public class LividColor {
"Doctor Livid", Formatting.GRAY,
"Vendetta Livid", Formatting.WHITE
);
- public static final Set<String> 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));
}
}