diff options
8 files changed, 115 insertions, 65 deletions
diff --git a/src/main/java/de/hysky/skyblocker/skyblock/crimson/dojo/ControlTestHelper.java b/src/main/java/de/hysky/skyblocker/skyblock/crimson/dojo/ControlTestHelper.java index fa3ef4f8..cc37ef64 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/crimson/dojo/ControlTestHelper.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/crimson/dojo/ControlTestHelper.java @@ -23,7 +23,6 @@ public class ControlTestHelper { if (entity instanceof WitherSkeletonEntity witherSkeleton && correctWitherSkeleton == null) { correctWitherSkeleton = witherSkeleton; pingMultiplier = Util.getMeasuringTimeMs() / 100000; - System.out.println(pingMultiplier); } } 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 cce32847..5c7e8c5a 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 @@ -9,12 +9,19 @@ import java.util.HashMap; public class DisciplineTestHelper { private static final MinecraftClient CLIENT = MinecraftClient.getInstance(); + /** + * Stores what sword is needed for the name of a zombie + */ 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"); }); + + /** + * Stores a color related to the color of the sword: wood = brown, iron = silver, gold = gold, diamond = cyan + */ 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); @@ -22,6 +29,12 @@ public class DisciplineTestHelper { map.put("DIAMOND_SWORD", 0x00ffff); }); + /** + * Works out if a zombie should glow based on its name and the currently held item by the player + * + * @param name name of the zombie to see if it should glow + * @return if the zombie should glow + */ protected static boolean shouldGlow(String name) { if (CLIENT == null || CLIENT.player == null) { return false; @@ -34,6 +47,11 @@ public class DisciplineTestHelper { return false; } + /** + * gets the color linked to the currently held sword for zombies to glow + * + * @return color linked to sword + */ protected static int getColor() { if (DojoManager.currentChallenge != DojoManager.DojoChallenges.DISCIPLINE || CLIENT == null || CLIENT.player == null) { 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 bf4bbedd..8cbfca7b 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 @@ -78,12 +78,12 @@ public class DojoManager { private static void reset() { inArena = false; currentChallenge = DojoChallenges.NONE; - SwiftnessTestHelper.reset(); - MasteryTestHelper.reset(); - TenacityTestHelper.reset(); ForceTestHelper.reset(); - ControlTestHelper.reset(); StaminaTestHelper.reset(); + MasteryTestHelper.reset(); + SwiftnessTestHelper.reset(); + ControlTestHelper.reset(); + TenacityTestHelper.reset(); } /** @@ -141,8 +141,8 @@ public class DojoManager { return false; } return switch (currentChallenge) { - case DISCIPLINE -> DisciplineTestHelper.shouldGlow(name); case FORCE -> ForceTestHelper.shouldGlow(name); + case DISCIPLINE -> DisciplineTestHelper.shouldGlow(name); default -> false; }; } @@ -157,8 +157,8 @@ public class DojoManager { return 0xf57738; } return switch (currentChallenge) { - case DISCIPLINE -> DisciplineTestHelper.getColor(); case FORCE -> ForceTestHelper.getColor(); + case DISCIPLINE -> DisciplineTestHelper.getColor(); default -> 0xf57738; }; } @@ -174,8 +174,8 @@ public class DojoManager { return; } switch (currentChallenge) { - case SWIFTNESS -> SwiftnessTestHelper.onBlockUpdate(pos, state); case MASTERY -> MasteryTestHelper.onBlockUpdate(pos, state); + case SWIFTNESS -> SwiftnessTestHelper.onBlockUpdate(pos, state); } } @@ -188,9 +188,9 @@ public class DojoManager { return; } switch (currentChallenge) { - case TENACITY -> TenacityTestHelper.onEntitySpawn(entity); case FORCE -> ForceTestHelper.onEntitySpawn(entity); case CONTROL -> ControlTestHelper.onEntitySpawn(entity); + case TENACITY -> TenacityTestHelper.onEntitySpawn(entity); } } @@ -199,8 +199,8 @@ public class DojoManager { return; } switch (currentChallenge) { - case TENACITY -> TenacityTestHelper.onEntityDespawn(entity); case FORCE -> ForceTestHelper.onEntityDespawn(entity); + case TENACITY -> TenacityTestHelper.onEntityDespawn(entity); } } @@ -230,10 +230,10 @@ public class DojoManager { switch (currentChallenge) { case FORCE -> ForceTestHelper.render(context); case STAMINA -> StaminaTestHelper.render(context); - case SWIFTNESS -> SwiftnessTestHelper.render(context); - case TENACITY -> TenacityTestHelper.render(context); case MASTERY -> MasteryTestHelper.render(context); + case SWIFTNESS -> SwiftnessTestHelper.render(context); case CONTROL -> ControlTestHelper.render(context); + case TENACITY -> TenacityTestHelper.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 index d737146a..e4cff23c 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/crimson/dojo/ForceTestHelper.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/crimson/dojo/ForceTestHelper.java @@ -17,6 +17,7 @@ import java.util.Map; public class ForceTestHelper { private static final DecimalFormat FORMATTER = new DecimalFormat("0.0"); + private static final int ZOMBIE_LIFE_TIME = 10100; private static final Map<ZombieEntity, Long> zombies = new HashMap<>(); @@ -24,6 +25,12 @@ public class ForceTestHelper { zombies.clear(); } + /** + * If a zombie value is negative make it glow + * + * @param name zombies value + * @return if the zombie should glow + */ protected static boolean shouldGlow(String name) { if (name == null) return false; return name.contains("-"); @@ -35,14 +42,14 @@ public class ForceTestHelper { 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 + zombies.put(zombie, System.currentTimeMillis() + ZOMBIE_LIFE_TIME); } } protected static void onEntityAttacked(Entity entity) { if (entity instanceof ZombieEntity zombie) { if (zombies.containsKey(zombie)) { - zombies.put(zombie, System.currentTimeMillis() + 10100); //timer is reset when they are hit + zombies.put(zombie, System.currentTimeMillis() + ZOMBIE_LIFE_TIME); //timer is reset when they are hit } } } @@ -68,8 +75,8 @@ public class ForceTestHelper { text = text.formatted(Formatting.RED); } - Vec3d lablePos = zombie.getKey().getEyePos(); - RenderHelper.renderText(context, text, lablePos, 1.5f, true); + Vec3d labelPos = zombie.getKey().getEyePos(); + RenderHelper.renderText(context, text, labelPos, 1.5f, true); } } } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/crimson/dojo/MasteryTestHelper.java b/src/main/java/de/hysky/skyblocker/skyblock/crimson/dojo/MasteryTestHelper.java index 43af9f29..393e8f06 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/crimson/dojo/MasteryTestHelper.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/crimson/dojo/MasteryTestHelper.java @@ -17,8 +17,8 @@ import java.util.List; public class MasteryTestHelper { - private static final DecimalFormat FORMATTER = new DecimalFormat("0.00"); + private static final int BLOCK_LIFE_TIME = 6850; private static final List<BlockPos> blockOrder = new ArrayList<>(); private static final Map<BlockPos, Long> endTimes = new HashMap<>(); @@ -31,7 +31,7 @@ public class MasteryTestHelper { protected static void onBlockUpdate(BlockPos pos, BlockState state) { if (state.isOf(Blocks.LIME_WOOL)) { blockOrder.add(pos); - endTimes.put(pos, System.currentTimeMillis() + 6850); + endTimes.put(pos, System.currentTimeMillis() + BLOCK_LIFE_TIME); } if (state.isAir()) { blockOrder.remove(pos); @@ -45,7 +45,7 @@ public class MasteryTestHelper { RenderHelper.renderLineFromCursor(context, blockOrder.getFirst().toCenterPos(), Color.LIGHT_GRAY.getColorComponents(new float[]{0, 0, 0}), 1f, 2); } if (blockOrder.size() >= 2) { - RenderHelper.renderLinesFromPoints(context, new Vec3d[]{blockOrder.get(0).toCenterPos(), blockOrder.get(1).toCenterPos()}, new float[]{0f, 1f, 0f}, 1, 2, false); + RenderHelper.renderLinesFromPoints(context, new Vec3d[]{blockOrder.get(0).toCenterPos(), blockOrder.get(1).toCenterPos()}, Color.LIGHT_GRAY.getColorComponents(new float[]{0, 0, 0}), 1, 2, false); } //render times diff --git a/src/main/java/de/hysky/skyblocker/skyblock/crimson/dojo/StaminaTestHelper.java b/src/main/java/de/hysky/skyblocker/skyblock/crimson/dojo/StaminaTestHelper.java index b1126f99..77a202d7 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/crimson/dojo/StaminaTestHelper.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/crimson/dojo/StaminaTestHelper.java @@ -21,10 +21,10 @@ public class StaminaTestHelper { private static final List<BlockPos> wallHoles = new ArrayList<>(); private static final List<BlockPos> lastHoles = new ArrayList<>(); - private static final Map<BlockPos, wallDirections> holeDirections = new HashMap<>(); + private static final Map<BlockPos, holeDirection> holeDirections = new HashMap<>(); private static BlockPos middleBase; - private enum wallDirections { + private enum holeDirection { POSITIVE_X, POSITIVE_Z, NEGATIVE_X, @@ -41,10 +41,45 @@ public class StaminaTestHelper { } protected static void update() { - if (CLIENT == null || CLIENT.player == null || CLIENT.world == null) { + + //search the world around the player for walls 30 x 10 x 30 area centered on player + + List<BlockPos> currentBottomWallLocations = findWallBlocks(); + if (currentBottomWallLocations == null) { //stop here if the center pos has not been found return; } - //search the world around the player for walls 30 x 10 x 30 area centered on player + //find walls + List<Box> walls = findWalls(currentBottomWallLocations); + + //find air then holes and add whole to list + lastHoles.clear(); + lastHoles.addAll(wallHoles); + wallHoles.clear(); + for (Box wall : walls) { + wallHoles.addAll(findAirInBox(wall)); + } + // get direction for the holes + Map<BlockPos, holeDirection> lastHoleDirections = new HashMap<>(holeDirections); + holeDirections.clear(); + for (BlockPos hole : wallHoles) { + holeDirection holeDirection = getWholeDirection(hole); + if (holeDirection == StaminaTestHelper.holeDirection.UNCHANGED) { + holeDirections.put(hole, lastHoleDirections.get(hole)); + continue; + } + holeDirections.put(hole, holeDirection); + } + } + + /** + * Locates the center of the game and once this is found scans the bottom of room for blocks that make up the walls + * + * @return list of blocks that make up the bottom of the walls + */ + private static List<BlockPos> findWallBlocks() { + if (CLIENT == null || CLIENT.player == null || CLIENT.world == null) { + return null; + } BlockPos playerPos = CLIENT.player.getBlockPos(); //find the center first before starting to look for walls if (middleBase == null) { @@ -55,12 +90,12 @@ public class StaminaTestHelper { BlockState state = CLIENT.world.getBlockState(pos); if (state.isOf(Blocks.CHISELED_STONE_BRICKS)) { middleBase = pos; - return; + return null; } } } } - return; + return null; } List<BlockPos> currentBottomWallLocations = new ArrayList<>(); for (int x = middleBase.getX() - 15; x < middleBase.getX() + 15; x++) { @@ -73,48 +108,26 @@ public class StaminaTestHelper { } } } - - //find walls - List<Box> walls = findWalls(currentBottomWallLocations); - - //find air then holes and add whole to list - lastHoles.clear(); - lastHoles.addAll(wallHoles); - wallHoles.clear(); - for (Box wall : walls) { - wallHoles.addAll(findAirInBox(wall)); - } - // get direction for the holes - Map<BlockPos, wallDirections> lastHoleDirections = new HashMap<>(holeDirections); - holeDirections.clear(); - for (BlockPos hole : wallHoles) { - wallDirections holeDirection = getWholeDirection(hole); - if (holeDirection == wallDirections.UNCHANGED) { - holeDirections.put(hole, lastHoleDirections.get(hole)); - continue; - } - holeDirections.put(hole, holeDirection); - } + return currentBottomWallLocations; } private static List<Box> findWalls(List<BlockPos> currentBottomWallLocations) { Map<Integer, List<BlockPos>> possibleWallsX = new HashMap<>(); Map<Integer, List<BlockPos>> possibleWallsZ = new HashMap<>(); - for (BlockPos andesite : currentBottomWallLocations) { + for (BlockPos block : currentBottomWallLocations) { //add to the x walls - int x = andesite.getX(); + int x = block.getX(); if (!possibleWallsX.containsKey(x)) { possibleWallsX.put(x, new ArrayList<>()); } - possibleWallsX.get(x).add(andesite); + possibleWallsX.get(x).add(block); //add to the z walls - int z = andesite.getZ(); + int z = block.getZ(); if (!possibleWallsZ.containsKey(z)) { possibleWallsZ.put(z, new ArrayList<>()); - } - possibleWallsZ.get(z).add(andesite); + possibleWallsZ.get(z).add(block); } //extract only the lines that are long enough to be a wall and not from walls overlapping @@ -188,31 +201,31 @@ public class StaminaTestHelper { return holes; } - private static wallDirections getWholeDirection(BlockPos hole) { + private static holeDirection getWholeDirection(BlockPos hole) { //the value has not changed since last time if (lastHoles.contains(hole)) { - return wallDirections.UNCHANGED; + return holeDirection.UNCHANGED; } //check each direction to work out which way the whole is going BlockPos posX = hole.add(1, 0, 0); if (lastHoles.contains(posX)) { - return wallDirections.POSITIVE_X; + return holeDirection.POSITIVE_X; } BlockPos negX = hole.add(-1, 0, 0); if (lastHoles.contains(negX)) { System.out.println("positiveX"); - return wallDirections.NEGATIVE_X; + return holeDirection.NEGATIVE_X; } BlockPos posZ = hole.add(0, 0, 1); if (lastHoles.contains(posZ)) { - return wallDirections.POSITIVE_Z; + return holeDirection.POSITIVE_Z; } BlockPos negZ = hole.add(0, 0, -1); if (lastHoles.contains(negZ)) { - return wallDirections.NEGATIVE_Z; + return holeDirection.NEGATIVE_Z; } // if pos can not be found mark as new - return wallDirections.NEW; + return holeDirection.NEW; } @@ -222,13 +235,13 @@ public class StaminaTestHelper { } BlockPos playerPos = CLIENT.player.getBlockPos(); for (BlockPos hole : wallHoles) { - float[] color = isHoleIncoming(hole,holeDirections.get(hole),playerPos) ? INCOMING_COLOR : OUTGOING_COLOR; + float[] color = isHoleIncoming(hole, holeDirections.get(hole), playerPos) ? INCOMING_COLOR : OUTGOING_COLOR; RenderHelper.renderFilled(context, hole, color, 0.3f, true); } } - private static boolean isHoleIncoming(BlockPos holePos, wallDirections holeDirection, BlockPos playerPos) { - return switch (holeDirection) { + private static boolean isHoleIncoming(BlockPos holePos, holeDirection holeDirection, BlockPos playerPos) { + return switch (holeDirection) { case POSITIVE_X -> playerPos.getX() < holePos.getX(); case POSITIVE_Z -> playerPos.getZ() < holePos.getZ(); case NEGATIVE_X -> playerPos.getX() > holePos.getX(); 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 index 8e3f2a32..df2c26d5 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/crimson/dojo/SwiftnessTestHelper.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/crimson/dojo/SwiftnessTestHelper.java @@ -24,6 +24,11 @@ public class SwiftnessTestHelper { } } + /** + * Renders a green block around the newest block + * + * @param context render context + */ protected static void render(WorldRenderContext context) { if (lastBlock == null) { return; 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 index 1ca409d8..861b3453 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/crimson/dojo/TenacityTestHelper.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/crimson/dojo/TenacityTestHelper.java @@ -53,11 +53,14 @@ public class TenacityTestHelper { return CLIENT.world.raycast(new RaycastContext(start, end, RaycastContext.ShapeType.OUTLINE, RaycastContext.FluidHandling.ANY, fireball)); } + /** + * If a spawned entity is an armour stand add it to the fireballs map (assuming all armour stands are fireballs) + * + * @param entity spawned entity + */ protected static void onEntitySpawn(Entity entity) { if (entity instanceof ArmorStandEntity armorStand) { - // they should be holding coal block but are not holding anything idk fireBallsWithStartPos.put(armorStand, armorStand.getPos()); - } } @@ -67,6 +70,11 @@ public class TenacityTestHelper { } } + /** + * Uses the particles spawned with the fireballs to offset from the armour stand position to get a mor accurate guess of where its going + * + * @param packet particle packet + */ protected static void onParticle(ParticleS2CPacket packet) { if (!ParticleTypes.FLAME.equals(packet.getParameters().getType())) { return; |