diff options
Diffstat (limited to 'src/main/java/de/hysky/skyblocker/skyblock')
5 files changed, 183 insertions, 0 deletions
diff --git a/src/main/java/de/hysky/skyblocker/skyblock/crimson/dojo/DisciplineTestHelper.java b/src/main/java/de/hysky/skyblocker/skyblock/crimson/dojo/DisciplineTestHelper.java new file mode 100644 index 00000000..d5e19f28 --- /dev/null +++ b/src/main/java/de/hysky/skyblocker/skyblock/crimson/dojo/DisciplineTestHelper.java @@ -0,0 +1,51 @@ +package de.hysky.skyblocker.skyblock.crimson.dojo; + +import de.hysky.skyblocker.skyblock.item.tooltip.ItemTooltip; +import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext; +import net.minecraft.client.MinecraftClient; +import net.minecraft.item.ItemStack; +import net.minecraft.text.Text; +import net.minecraft.util.Util; + +import java.awt.*; +import java.util.HashMap; + +public class DisciplineTestHelper { + private static final MinecraftClient CLIENT = MinecraftClient.getInstance(); + + private static final HashMap<String, String> SWORD_TO_NAME_LOOKUP = Util.make(new HashMap<>(), map -> { + map.put("WOOD_SWORD","Wood"); + map.put("IRON_SWORD","Iron"); + map.put("GOLD_SWORD","Gold"); + map.put("DIAMOND_SWORD","Diamond"); + }); + private static final HashMap<String, Integer> SWORD_TO_COLOR_LOOKUP = Util.make(new HashMap<>(), map -> { + map.put("WOOD_SWORD",0xa52a2a); + map.put("IRON_SWORD",0xc0c0c0); + map.put("GOLD_SWORD",0xffd700); + map.put("DIAMOND_SWORD",0x00ffff); + }); + + public static boolean isCorrect(String name) { + if (DojoManager.currentChallenge != DojoManager.DojoChallenges.DISCIPLINE || CLIENT == null || CLIENT.player == null) { + return false; + } + String heldId = ItemTooltip.getInternalNameFromNBT(CLIENT.player.getMainHandStack(), true); + if (SWORD_TO_NAME_LOOKUP.containsKey(heldId)) { + + return SWORD_TO_NAME_LOOKUP.get(heldId).equals(name); + } + return false; + } + + public static int getColor() { + if (DojoManager.currentChallenge != DojoManager.DojoChallenges.DISCIPLINE || CLIENT == null || CLIENT.player == null) { + return 0; + } + String heldId = ItemTooltip.getInternalNameFromNBT(CLIENT.player.getMainHandStack(), true); + if (SWORD_TO_COLOR_LOOKUP.containsKey(heldId)) { + return SWORD_TO_COLOR_LOOKUP.get(heldId); + } + return 0; + } +} diff --git a/src/main/java/de/hysky/skyblocker/skyblock/crimson/dojo/DojoManager.java b/src/main/java/de/hysky/skyblocker/skyblock/crimson/dojo/DojoManager.java new file mode 100644 index 00000000..f133746a --- /dev/null +++ b/src/main/java/de/hysky/skyblocker/skyblock/crimson/dojo/DojoManager.java @@ -0,0 +1,93 @@ +package de.hysky.skyblocker.skyblock.crimson.dojo; + +import de.hysky.skyblocker.utils.Location; +import de.hysky.skyblocker.utils.Utils; +import net.fabricmc.fabric.api.client.message.v1.ClientReceiveMessageEvents; +import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents; +import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext; +import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents; +import net.minecraft.text.Text; + +import java.util.Arrays; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class DojoManager { + + private static final String START_MESSAGE = "§e[NPC] §eMaster Tao§f: Ahhh, here we go! Let's get you into the Arena."; + private static final Pattern TEST_OF_PATTERN = Pattern.compile("\\s+Test of (\\w+) OBJECTIVES"); + private static final String CHALLENGE_FINISHED_REGEX = "\\s+CHALLENGE ((COMPLEATED)|(FAILED))"; + + protected enum DojoChallenges { + NONE("none"), + DISCIPLINE("Discipline"), + SWIFTNESS("Swiftness"), + TENACITY("Tenacity"); + + private final String name; + + DojoChallenges(String name) { + this.name = name; + } + + public static DojoChallenges from(String name) { + return Arrays.stream(DojoChallenges.values()).filter(n -> name.equals(n.name)).findFirst().orElse(NONE); + } + } + + protected static DojoChallenges currentChallenge = DojoChallenges.NONE; + private static boolean inAreana = false; + + public static void init() { + ClientReceiveMessageEvents.GAME.register(DojoManager::onMessage); + WorldRenderEvents.AFTER_TRANSLUCENT.register(DojoManager::render); + ClientPlayConnectionEvents.JOIN.register((_handler, _sender, _client) -> reset()); + + } + + private static void reset() { + inAreana = false; + currentChallenge = DojoChallenges.NONE; + } + + + private static void onMessage(Text text, Boolean overlay) { + + if (Utils.getLocation() != Location.CRIMSON_ISLE || overlay) { + return; + } + if (text.getString().equals(START_MESSAGE)) { + inAreana = true; + return; + } + if (!inAreana) { + return; + } + if (text.getString().matches(CHALLENGE_FINISHED_REGEX)) { + reset(); + return; + } + + //look for a message saying what challenge is starting if one has not already been found + if (currentChallenge != DojoChallenges.NONE) { + return; + } + Matcher nextChallenge = TEST_OF_PATTERN.matcher(text.getString()); + if (nextChallenge.matches()) { + currentChallenge = DojoChallenges.from(nextChallenge.group(1)); + } + } + + private static void render(WorldRenderContext context) { + if (Utils.getLocation() != Location.CRIMSON_ISLE || !inAreana) { + return; + } + switch (currentChallenge) { + case SWIFTNESS -> SwiftnessTestHelper.render(context); + case TENACITY -> TenacityTestHelper.render(context); + } + //System.out.println(currentChallenge); + } + + +} diff --git a/src/main/java/de/hysky/skyblocker/skyblock/crimson/dojo/SwiftnessTestHelper.java b/src/main/java/de/hysky/skyblocker/skyblock/crimson/dojo/SwiftnessTestHelper.java new file mode 100644 index 00000000..580c7d87 --- /dev/null +++ b/src/main/java/de/hysky/skyblocker/skyblock/crimson/dojo/SwiftnessTestHelper.java @@ -0,0 +1,12 @@ +package de.hysky.skyblocker.skyblock.crimson.dojo; + +import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext; + +public class SwiftnessTestHelper { + + + + protected static void render(WorldRenderContext context) { + + } +} diff --git a/src/main/java/de/hysky/skyblocker/skyblock/crimson/dojo/TenacityTestHelper.java b/src/main/java/de/hysky/skyblocker/skyblock/crimson/dojo/TenacityTestHelper.java new file mode 100644 index 00000000..48c1aaa0 --- /dev/null +++ b/src/main/java/de/hysky/skyblocker/skyblock/crimson/dojo/TenacityTestHelper.java @@ -0,0 +1,11 @@ +package de.hysky.skyblocker.skyblock.crimson.dojo; + +import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext; + +public class TenacityTestHelper { + + + protected static void render(WorldRenderContext context) { + + } +} 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 d6f9410b..d373d2e1 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/entity/MobGlow.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/entity/MobGlow.java @@ -1,15 +1,18 @@ package de.hysky.skyblocker.skyblock.entity; import de.hysky.skyblocker.config.SkyblockerConfigManager; +import de.hysky.skyblocker.skyblock.crimson.dojo.DisciplineTestHelper; 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.Location; import de.hysky.skyblocker.utils.SlayerUtils; import de.hysky.skyblocker.utils.Utils; import de.hysky.skyblocker.utils.render.culling.OcclusionCulling; import net.minecraft.entity.Entity; import net.minecraft.entity.decoration.ArmorStandEntity; 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; @@ -28,6 +31,7 @@ public class MobGlow { if (OcclusionCulling.getReducedCuller().isVisible(box.minX, box.minY, box.minZ, box.maxX, box.maxY, box.maxZ)) { String name = entity.getName().getString(); + // Dungeons if (Utils.isInDungeons() && !entity.isInvisible()) { return switch (entity) { @@ -46,6 +50,7 @@ public class MobGlow { }; } + return switch (entity) { // Rift case PlayerEntity p when Utils.isInTheRift() && !entity.isInvisible() && name.equals("Blobbercyst ") -> SkyblockerConfigManager.get().otherLocations.rift.blobbercystGlow; @@ -57,6 +62,9 @@ public class MobGlow { // Special Zelot case EndermanEntity enderman when Utils.isInTheEnd() && !entity.isInvisible() -> TheEnd.isSpecialZealot(enderman); + //dojo + case ZombieEntity zombie when Utils.getLocation() == Location.CRIMSON_ISLE -> DisciplineTestHelper.isCorrect(getArmourStandName(zombie)); + default -> false; }; } @@ -73,6 +81,13 @@ public class MobGlow { List<ArmorStandEntity> armorStands = getArmorStands(entity); return !armorStands.isEmpty() && armorStands.getFirst().getName().getString().contains("✯"); } + public static String getArmourStandName(Entity entity) { + List<ArmorStandEntity> armorStands = getArmorStands(entity); + if (armorStands.isEmpty()) { + return null; + } + return armorStands.getFirst().getName().getString(); + } public static List<ArmorStandEntity> getArmorStands(Entity entity) { return getArmorStands(entity.getWorld(), entity.getBoundingBox()); @@ -94,6 +109,7 @@ public class MobGlow { case EndermanEntity enderman when TheEnd.isSpecialZealot(enderman) -> Formatting.RED.getColorValue(); case ArmorStandEntity armorStand when isNukekubiHead(armorStand) -> 0x990099; + case ZombieEntity zombie when Utils.getLocation() == Location.CRIMSON_ISLE -> DisciplineTestHelper.getColor(); default -> 0xf57738; }; |