aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/de/hysky/skyblocker
diff options
context:
space:
mode:
authorolim <bobq4582@gmail.com>2024-05-01 17:03:56 +0100
committerolim <bobq4582@gmail.com>2024-07-01 14:26:13 +0100
commit654b66e62bdb63a2ef3dc9607c941027c6c07812 (patch)
tree359e1be12a6b4c30feebc1ccab2c7a408c284e85 /src/main/java/de/hysky/skyblocker
parent18e3b77939d726e2aedfddfda76f488c864bbe94 (diff)
downloadSkyblocker-654b66e62bdb63a2ef3dc9607c941027c6c07812.tar.gz
Skyblocker-654b66e62bdb63a2ef3dc9607c941027c6c07812.tar.bz2
Skyblocker-654b66e62bdb63a2ef3dc9607c941027c6c07812.zip
add force test helpder
add helper for the force test. unsure if timer is correct. sometimes last to long?
Diffstat (limited to 'src/main/java/de/hysky/skyblocker')
-rw-r--r--src/main/java/de/hysky/skyblocker/skyblock/crimson/dojo/DisciplineTestHelper.java22
-rw-r--r--src/main/java/de/hysky/skyblocker/skyblock/crimson/dojo/DojoManager.java49
-rw-r--r--src/main/java/de/hysky/skyblocker/skyblock/crimson/dojo/ForceTestHelper.java55
-rw-r--r--src/main/java/de/hysky/skyblocker/skyblock/entity/MobGlow.java6
4 files changed, 111 insertions, 21 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
index d5e19f28..6312bbdc 100644
--- a/src/main/java/de/hysky/skyblocker/skyblock/crimson/dojo/DisciplineTestHelper.java
+++ b/src/main/java/de/hysky/skyblocker/skyblock/crimson/dojo/DisciplineTestHelper.java
@@ -1,17 +1,23 @@
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.entity.mob.ZombieEntity;
import net.minecraft.util.Util;
-import java.awt.*;
+import java.text.DecimalFormat;
import java.util.HashMap;
+import java.util.Map;
public class DisciplineTestHelper {
private static final MinecraftClient CLIENT = MinecraftClient.getInstance();
+ private static final DecimalFormat FORMATTER = new DecimalFormat("0.0");
+
+ private static final Map<ZombieEntity, Long> zombies = new HashMap<>();
+
+ protected static void reset() {
+ zombies.clear();
+ }
private static final HashMap<String, String> SWORD_TO_NAME_LOOKUP = Util.make(new HashMap<>(), map -> {
map.put("WOOD_SWORD","Wood");
@@ -26,8 +32,8 @@ public class DisciplineTestHelper {
map.put("DIAMOND_SWORD",0x00ffff);
});
- public static boolean isCorrect(String name) {
- if (DojoManager.currentChallenge != DojoManager.DojoChallenges.DISCIPLINE || CLIENT == null || CLIENT.player == null) {
+ protected static boolean shouldGlow(String name) {
+ if (CLIENT == null || CLIENT.player == null) {
return false;
}
String heldId = ItemTooltip.getInternalNameFromNBT(CLIENT.player.getMainHandStack(), true);
@@ -38,7 +44,7 @@ public class DisciplineTestHelper {
return false;
}
- public static int getColor() {
+ protected static int getColor() {
if (DojoManager.currentChallenge != DojoManager.DojoChallenges.DISCIPLINE || CLIENT == null || CLIENT.player == null) {
return 0;
}
@@ -48,4 +54,6 @@ public class DisciplineTestHelper {
}
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
index b7b39f32..61a8d010 100644
--- a/src/main/java/de/hysky/skyblocker/skyblock/crimson/dojo/DojoManager.java
+++ b/src/main/java/de/hysky/skyblocker/skyblock/crimson/dojo/DojoManager.java
@@ -26,6 +26,7 @@ public class DojoManager {
protected enum DojoChallenges {
NONE("none"),
+ FORCE("Force"),
MASTERY("Mastery"),
DISCIPLINE("Discipline"),
SWIFTNESS("Swiftness"),
@@ -43,7 +44,7 @@ public class DojoManager {
}
protected static DojoChallenges currentChallenge = DojoChallenges.NONE;
- private static boolean inAreana = false;
+ public static boolean inArena = false;
public static void init() {
ClientReceiveMessageEvents.GAME.register(DojoManager::onMessage);
@@ -55,11 +56,12 @@ public class DojoManager {
}
private static void reset() {
- inAreana = false;
+ inArena = false;
currentChallenge = DojoChallenges.NONE;
SwiftnessTestHelper.reset();
MasteryTestHelper.reset();
TenacityTestHelper.reset();
+ ForceTestHelper.reset();
}
private static void onMessage(Text text, Boolean overlay) {
@@ -67,10 +69,10 @@ public class DojoManager {
return;
}
if (text.getString().equals(START_MESSAGE)) {
- inAreana = true;
+ inArena = true;
return;
}
- if (!inAreana) {
+ if (!inArena) {
return;
}
if (text.getString().matches(CHALLENGE_FINISHED_REGEX)) {
@@ -88,8 +90,30 @@ public class DojoManager {
}
}
+ public static boolean shouldGlow(String name) {
+ if (Utils.getLocation() != Location.CRIMSON_ISLE || !inArena) {
+ return false;
+ }
+ return switch (currentChallenge) {
+ case DISCIPLINE -> DisciplineTestHelper.shouldGlow(name);
+ case FORCE -> ForceTestHelper.shouldGlow(name);
+ default -> false;
+ };
+ }
+
+ public static int getColor() {
+ if (Utils.getLocation() != Location.CRIMSON_ISLE || !inArena) {
+ return 0xf57738;
+ }
+ return switch (currentChallenge) {
+ case DISCIPLINE -> DisciplineTestHelper.getColor();
+ case FORCE -> ForceTestHelper.getColor();
+ default -> 0xf57738;
+ };
+ }
+
public static void onBlockUpdate(BlockUpdateS2CPacket packet) {
- if (Utils.getLocation() != Location.CRIMSON_ISLE || !inAreana) {
+ if (Utils.getLocation() != Location.CRIMSON_ISLE || !inArena) {
return;
}
switch (currentChallenge) {
@@ -98,37 +122,40 @@ public class DojoManager {
}
}
private static void onEntitySpawn(Entity entity, ClientWorld clientWorld) {
- if (Utils.getLocation() != Location.CRIMSON_ISLE || !inAreana) {
+ if (Utils.getLocation() != Location.CRIMSON_ISLE || !inArena) {
return;
}
switch (currentChallenge) {
case TENACITY -> TenacityTestHelper.onEntitySpawn(entity);
+ case FORCE -> ForceTestHelper.onEntitySpawn(entity);
}
}
private static void onEntityDespawn(Entity entity, ClientWorld clientWorld) {
- if (Utils.getLocation() != Location.CRIMSON_ISLE || !inAreana) {
+ if (Utils.getLocation() != Location.CRIMSON_ISLE || !inArena) {
return;
}
switch (currentChallenge) {
case TENACITY -> TenacityTestHelper.onEntityDespawn(entity);
+ case FORCE -> ForceTestHelper.onEntityDespawn(entity);
}
}
public static void onParticle(ParticleS2CPacket packet) {
- if (Utils.getLocation() != Location.CRIMSON_ISLE || !inAreana) {
+ if (Utils.getLocation() != Location.CRIMSON_ISLE || !inArena) {
return;
}
- switch (currentChallenge) {
- case TENACITY -> TenacityTestHelper.onParticle(packet);
+ if (currentChallenge == DojoChallenges.TENACITY) {
+ TenacityTestHelper.onParticle(packet);
}
}
private static void render(WorldRenderContext context) {
- if (Utils.getLocation() != Location.CRIMSON_ISLE || !inAreana) {
+ if (Utils.getLocation() != Location.CRIMSON_ISLE || !inArena) {
return;
}
switch (currentChallenge) {
+ case FORCE -> ForceTestHelper.render(context);
case SWIFTNESS -> SwiftnessTestHelper.render(context);
case TENACITY -> TenacityTestHelper.render(context);
case MASTERY -> MasteryTestHelper.render(context);
diff --git a/src/main/java/de/hysky/skyblocker/skyblock/crimson/dojo/ForceTestHelper.java b/src/main/java/de/hysky/skyblocker/skyblock/crimson/dojo/ForceTestHelper.java
new file mode 100644
index 00000000..bf27ce1f
--- /dev/null
+++ b/src/main/java/de/hysky/skyblocker/skyblock/crimson/dojo/ForceTestHelper.java
@@ -0,0 +1,55 @@
+package de.hysky.skyblocker.skyblock.crimson.dojo;
+
+import de.hysky.skyblocker.utils.render.RenderHelper;
+import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext;
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.mob.ZombieEntity;
+import net.minecraft.text.Text;
+import net.minecraft.util.math.Vec3d;
+
+import java.awt.*;
+import java.text.DecimalFormat;
+import java.util.HashMap;
+import java.util.Map;
+
+public class ForceTestHelper {
+
+ private static final DecimalFormat FORMATTER = new DecimalFormat("0.0");
+
+ private static final Map<ZombieEntity, Long> zombies = new HashMap<>();
+
+ protected static void reset() {
+ zombies.clear();
+ }
+
+ protected static boolean shouldGlow(String name) {
+ if (name == null) return false;
+ return name.contains("-");
+ }
+
+ protected static int getColor() {
+ return Color.RED.getRGB();
+ }
+
+ protected static void onEntitySpawn(Entity entity) {
+ if (entity instanceof ZombieEntity zombie) {
+ zombies.put(zombie, System.currentTimeMillis() + 10100); //they last for 10100 millis ish so this is the time they despawn
+ }
+ }
+ protected static void onEntityDespawn(Entity entity) {
+ if (entity instanceof ZombieEntity zombie) {
+ zombies.remove(zombie);
+ }
+ }
+
+ protected static void render(WorldRenderContext context) {
+ //render times
+ long currentTime = System.currentTimeMillis();
+ for (Map.Entry<ZombieEntity, Long> zombie : zombies.entrySet()) {
+ float secondsTime = Math.max((zombie.getValue() - currentTime) / 1000f, 0);
+ Vec3d lablePos = zombie.getKey().getEyePos();
+ RenderHelper.renderText(context, Text.literal(FORMATTER.format(secondsTime)), lablePos, 1.5f, true);
+
+ }
+ }
+}
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 d373d2e1..182fae77 100644
--- a/src/main/java/de/hysky/skyblocker/skyblock/entity/MobGlow.java
+++ b/src/main/java/de/hysky/skyblocker/skyblock/entity/MobGlow.java
@@ -1,7 +1,7 @@
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.crimson.dojo.DojoManager;
import de.hysky.skyblocker.skyblock.dungeon.LividColor;
import de.hysky.skyblocker.skyblock.end.TheEnd;
import de.hysky.skyblocker.utils.ItemUtils;
@@ -63,7 +63,7 @@ public class MobGlow {
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));
+ case ZombieEntity zombie when Utils.getLocation() == Location.CRIMSON_ISLE && DojoManager.inArena -> DojoManager.shouldGlow(getArmourStandName(zombie));
default -> false;
};
@@ -109,7 +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();
+ case ZombieEntity zombie when Utils.getLocation() == Location.CRIMSON_ISLE && DojoManager.inArena -> DojoManager.getColor();
default -> 0xf57738;
};