From b98415d1c5439d3862a55ca7e943ca3e578c6f6e Mon Sep 17 00:00:00 2001 From: olim Date: Fri, 17 May 2024 13:14:55 +0100 Subject: fix to align with new config --- src/main/resources/assets/skyblocker/lang/en_us.json | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/main/resources/assets/skyblocker/lang/en_us.json') diff --git a/src/main/resources/assets/skyblocker/lang/en_us.json b/src/main/resources/assets/skyblocker/lang/en_us.json index a814718e..f2d0db46 100644 --- a/src/main/resources/assets/skyblocker/lang/en_us.json +++ b/src/main/resources/assets/skyblocker/lang/en_us.json @@ -866,6 +866,20 @@ "skyblocker.fancyAuctionHouse.yourAuction": "This is your auction!", "skyblocker.fancyAuctionHouse.youPay": "You pay: %s", + "skyblocker.crimson.dojo": "Dojo", + "skyblocker.crimson.dojo.forceHelper": "Enable Force Helper", + "skyblocker.crimson.dojo.forceHelper.@Tooltip": "Shows timer showing how long until a zombie despawns and outlines negative zombies.", + "skyblocker.crimson.dojo.masteryHelper": "Enable Mastery Helper", + "skyblocker.crimson.dojo.masteryHelper.@Tooltip": "Shows timer for how long a block has left and a path to follow.", + "skyblocker.crimson.dojo.disciplineHelper": "Enable Discipline Helper", + "skyblocker.crimson.dojo.disciplineHelper.@Tooltip": "Outlines the zombies to attack with currently held sword.", + "skyblocker.crimson.dojo.swiftnessHelper": "Enable Swiftness Helper", + "skyblocker.crimson.dojo.swiftnessHelper.@Tooltip": "highlights the newest wool block to go to.", + "skyblocker.crimson.dojo.controlHelper": "Enable Control Helper", + "skyblocker.crimson.dojo.controlHelper.@Tooltip": "Creates a line from cursor to where to aim (this is not exact and is guessed of ping).", + "skyblocker.crimson.dojo.tenacityHelper": "Enable Tenacity Helper", + "skyblocker.crimson.dojo.tenacityHelper.@Tooltip": "Shows a path for each fireball and predicted block they are going to hit.", + "skyblocker.crimson.kuudra.noArrowPoison": "No Arrow Poison!", "skyblocker.crimson.kuudra.lowArrowPoison": "Low on Arrow Poison!", -- cgit From 9bcd5488b023091a8168ab2ae8eefa2fd27827c6 Mon Sep 17 00:00:00 2001 From: olim Date: Fri, 17 May 2024 21:42:46 +0100 Subject: add helper for stamina add higlighting of holes in walls for stanima chalange --- .../config/categories/CrimsonIsleCategory.java | 8 + .../config/configs/CrimsonIsleConfig.java | 3 + .../skyblock/crimson/dojo/DojoManager.java | 15 +- .../skyblock/crimson/dojo/StaminaTestHelper.java | 240 +++++++++++++++++++++ .../skyblock/crimson/dojo/SwiftnessTestHelper.java | 1 - .../resources/assets/skyblocker/lang/en_us.json | 2 + 6 files changed, 267 insertions(+), 2 deletions(-) create mode 100644 src/main/java/de/hysky/skyblocker/skyblock/crimson/dojo/StaminaTestHelper.java (limited to 'src/main/resources/assets/skyblocker/lang/en_us.json') diff --git a/src/main/java/de/hysky/skyblocker/config/categories/CrimsonIsleCategory.java b/src/main/java/de/hysky/skyblocker/config/categories/CrimsonIsleCategory.java index 49850403..e8127a0e 100644 --- a/src/main/java/de/hysky/skyblocker/config/categories/CrimsonIsleCategory.java +++ b/src/main/java/de/hysky/skyblocker/config/categories/CrimsonIsleCategory.java @@ -93,6 +93,14 @@ public class CrimsonIsleCategory { newValue -> config.crimsonIsle.dojo.enableForceHelper = newValue) .controller(ConfigUtils::createBooleanController) .build()) + .option(Option.createBuilder() + .name(Text.translatable("skyblocker.crimson.dojo.staminaHelper")) + .description(OptionDescription.of(Text.translatable("skyblocker.crimson.dojo.staminaHelper.@Tooltip"))) + .binding(config.crimsonIsle.dojo.enableStaminaHelper, + () -> config.crimsonIsle.dojo.enableStaminaHelper, + newValue -> config.crimsonIsle.dojo.enableStaminaHelper = newValue) + .controller(ConfigUtils::createBooleanController) + .build()) .option(Option.createBuilder() .name(Text.translatable("skyblocker.crimson.dojo.masteryHelper")) .description(OptionDescription.of(Text.translatable("skyblocker.crimson.dojo.masteryHelper.@Tooltip"))) diff --git a/src/main/java/de/hysky/skyblocker/config/configs/CrimsonIsleConfig.java b/src/main/java/de/hysky/skyblocker/config/configs/CrimsonIsleConfig.java index 0bf334a1..451d1983 100644 --- a/src/main/java/de/hysky/skyblocker/config/configs/CrimsonIsleConfig.java +++ b/src/main/java/de/hysky/skyblocker/config/configs/CrimsonIsleConfig.java @@ -41,6 +41,9 @@ public class CrimsonIsleConfig { @SerialEntry public boolean enableForceHelper = true; + @SerialEntry + public boolean enableStaminaHelper = true; + @SerialEntry public boolean enableMasteryHelper = true; 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 22bfe8c3..bf4bbedd 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 @@ -3,6 +3,7 @@ package de.hysky.skyblocker.skyblock.crimson.dojo; import de.hysky.skyblocker.config.SkyblockerConfigManager; import de.hysky.skyblocker.utils.Location; import de.hysky.skyblocker.utils.Utils; +import de.hysky.skyblocker.utils.scheduler.Scheduler; import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientEntityEvents; import net.fabricmc.fabric.api.client.message.v1.ClientReceiveMessageEvents; import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents; @@ -41,6 +42,7 @@ public class DojoManager { protected enum DojoChallenges { NONE("none", enabled -> false), FORCE("Force", enabled -> SkyblockerConfigManager.get().crimsonIsle.dojo.enableForceHelper), + STAMINA("Stamina", enabled -> SkyblockerConfigManager.get().crimsonIsle.dojo.enableStaminaHelper), MASTERY("Mastery", enabled -> SkyblockerConfigManager.get().crimsonIsle.dojo.enableMasteryHelper), DISCIPLINE("Discipline", enabled -> SkyblockerConfigManager.get().crimsonIsle.dojo.enableDisciplineHelper), SWIFTNESS("Swiftness", enabled -> SkyblockerConfigManager.get().crimsonIsle.dojo.enableSwiftnessHelper), @@ -70,6 +72,7 @@ public class DojoManager { ClientEntityEvents.ENTITY_LOAD.register(DojoManager::onEntitySpawn); ClientEntityEvents.ENTITY_UNLOAD.register(DojoManager::onEntityDespawn); AttackEntityCallback.EVENT.register(DojoManager::onEntityAttacked); + Scheduler.INSTANCE.scheduleCyclic(DojoManager::update, 3); } private static void reset() { @@ -80,6 +83,7 @@ public class DojoManager { TenacityTestHelper.reset(); ForceTestHelper.reset(); ControlTestHelper.reset(); + StaminaTestHelper.reset(); } /** @@ -92,7 +96,6 @@ public class DojoManager { if (Utils.getLocation() != Location.CRIMSON_ISLE || overlay) { return; } - System.out.println(Formatting.strip(text.getString())); if (Objects.equals(Formatting.strip(text.getString()), START_MESSAGE)) { inArena = true; return; @@ -118,6 +121,15 @@ public class DojoManager { } } + private static void update() { + if (Utils.getLocation() != Location.CRIMSON_ISLE || !inArena) { + return; + } + if (currentChallenge == DojoChallenges.STAMINA) { + StaminaTestHelper.update(); + } + } + /** * called from the {@link de.hysky.skyblocker.skyblock.entity.MobGlow} class and checks the current challenge to see if zombies should be glowing * @@ -217,6 +229,7 @@ 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); 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 new file mode 100644 index 00000000..b1126f99 --- /dev/null +++ b/src/main/java/de/hysky/skyblocker/skyblock/crimson/dojo/StaminaTestHelper.java @@ -0,0 +1,240 @@ +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.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.client.MinecraftClient; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Box; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class StaminaTestHelper { + private static final MinecraftClient CLIENT = MinecraftClient.getInstance(); + private static final int WALL_THRESHOLD_VALUE = 13; + private static final float[] INCOMING_COLOR = new float[]{0f, 1f, 0f, 0f}; + private static final float[] OUTGOING_COLOR = new float[]{1f, 0.64f, 0f, 0f}; + + private static final List wallHoles = new ArrayList<>(); + private static final List lastHoles = new ArrayList<>(); + private static final Map holeDirections = new HashMap<>(); + private static BlockPos middleBase; + + private enum wallDirections { + POSITIVE_X, + POSITIVE_Z, + NEGATIVE_X, + NEGATIVE_Z, + NEW, + UNCHANGED; + } + + protected static void reset() { + wallHoles.clear(); + lastHoles.clear(); + holeDirections.clear(); + middleBase = null; + } + + protected static void update() { + if (CLIENT == null || CLIENT.player == null || CLIENT.world == null) { + return; + } + //search the world around the player for walls 30 x 10 x 30 area centered on player + BlockPos playerPos = CLIENT.player.getBlockPos(); + //find the center first before starting to look for walls + if (middleBase == null) { + for (int x = playerPos.getX() - 10; x < playerPos.getX() + 10; x++) { + for (int y = playerPos.getY() - 5; y < playerPos.getY(); y++) { + for (int z = playerPos.getZ() - 10; z < playerPos.getZ() + 10; z++) { + BlockPos pos = new BlockPos(x, y, z); + BlockState state = CLIENT.world.getBlockState(pos); + if (state.isOf(Blocks.CHISELED_STONE_BRICKS)) { + middleBase = pos; + return; + } + } + } + } + return; + } + List currentBottomWallLocations = new ArrayList<>(); + for (int x = middleBase.getX() - 15; x < middleBase.getX() + 15; x++) { + for (int z = middleBase.getZ() - 15; z < middleBase.getZ() + 15; z++) { + BlockPos pos = new BlockPos(x, middleBase.getY() + 1, z); + BlockState state = CLIENT.world.getBlockState(pos); + //find the bottom of walls + if (!state.isAir()) { + currentBottomWallLocations.add(pos); + } + } + } + + //find walls + List 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 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); + } + } + + private static List findWalls(List currentBottomWallLocations) { + Map> possibleWallsX = new HashMap<>(); + Map> possibleWallsZ = new HashMap<>(); + for (BlockPos andesite : currentBottomWallLocations) { + //add to the x walls + int x = andesite.getX(); + if (!possibleWallsX.containsKey(x)) { + possibleWallsX.put(x, new ArrayList<>()); + + } + possibleWallsX.get(x).add(andesite); + //add to the z walls + int z = andesite.getZ(); + if (!possibleWallsZ.containsKey(z)) { + possibleWallsZ.put(z, new ArrayList<>()); + + } + possibleWallsZ.get(z).add(andesite); + } + + //extract only the lines that are long enough to be a wall and not from walls overlapping + List> walls = new ArrayList<>(); + for (List line : possibleWallsX.values()) { + if (line.size() >= WALL_THRESHOLD_VALUE) { + walls.add(line); + } + } + for (List line : possibleWallsZ.values()) { + if (line.size() >= WALL_THRESHOLD_VALUE) { + walls.add(line); + } + } + + //final find the maximum values for each wall to output a box for them + List wallBoxes = new ArrayList<>(); + for (List wall : walls) { + BlockPos minPos = wall.getFirst(); + BlockPos maxPos = wall.getFirst(); + for (BlockPos pos : wall) { + if (pos.getX() < minPos.getX()) { + minPos = new BlockPos(pos.getX(), minPos.getY(), minPos.getZ()); + } + if (pos.getZ() < minPos.getZ()) { + minPos = new BlockPos(minPos.getX(), minPos.getY(), pos.getZ()); + } + + if (pos.getX() > maxPos.getX()) { + maxPos = new BlockPos(pos.getX(), maxPos.getY(), maxPos.getZ()); + } + if (pos.getZ() > maxPos.getZ()) { + maxPos = new BlockPos(maxPos.getX(), maxPos.getY(), pos.getZ()); + } + } + //expand wall to top + maxPos = new BlockPos(maxPos.getX(), maxPos.getY() + 5, maxPos.getZ()); + + wallBoxes.add(Box.enclosing(minPos, maxPos)); + } + + return wallBoxes; + } + + private static List findAirInBox(Box box) { + List air = new ArrayList<>(); + if (CLIENT == null || CLIENT.player == null || CLIENT.world == null) { + return air; + } + for (int x = (int) box.minX; x < box.maxX; x++) { + for (int y = (int) box.minY; y < box.maxY; y++) { + for (int z = (int) box.minZ; z < box.maxZ; z++) { + BlockPos pos = new BlockPos(x, y, z); + BlockState state = CLIENT.world.getBlockState(pos); + if (state.isAir()) { + air.add(pos); + } + } + } + } + return air; + } + + private static List combineAir(List airLocations) { + //todo + List holes = new ArrayList<>(); + //check if air is conected to existing whole and if so + for (BlockPos airLocation : airLocations) { + holes.add(Box.enclosing(airLocation, airLocation)); + } + return holes; + } + + private static wallDirections getWholeDirection(BlockPos hole) { + //the value has not changed since last time + if (lastHoles.contains(hole)) { + return wallDirections.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; + } + BlockPos negX = hole.add(-1, 0, 0); + if (lastHoles.contains(negX)) { + System.out.println("positiveX"); + return wallDirections.NEGATIVE_X; + } + BlockPos posZ = hole.add(0, 0, 1); + if (lastHoles.contains(posZ)) { + return wallDirections.POSITIVE_Z; + } + BlockPos negZ = hole.add(0, 0, -1); + if (lastHoles.contains(negZ)) { + return wallDirections.NEGATIVE_Z; + } + // if pos can not be found mark as new + return wallDirections.NEW; + + } + + protected static void render(WorldRenderContext context) { + if (wallHoles.isEmpty() || CLIENT == null || CLIENT.player == null) { + return; + } + BlockPos playerPos = CLIENT.player.getBlockPos(); + for (BlockPos hole : wallHoles) { + 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) { + case POSITIVE_X -> playerPos.getX() < holePos.getX(); + case POSITIVE_Z -> playerPos.getZ() < holePos.getZ(); + case NEGATIVE_X -> playerPos.getX() > holePos.getX(); + case NEGATIVE_Z -> playerPos.getZ() > holePos.getZ(); + + default -> true; + }; + } +} 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 fd2364d1..8e3f2a32 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 @@ -28,7 +28,6 @@ public class SwiftnessTestHelper { if (lastBlock == null) { return; } - System.out.println("render" + lastBlock); RenderHelper.renderFilled(context, lastBlock, new float[]{0f, 1f, 0f}, 0.5f, true); } } diff --git a/src/main/resources/assets/skyblocker/lang/en_us.json b/src/main/resources/assets/skyblocker/lang/en_us.json index f2d0db46..a0a83897 100644 --- a/src/main/resources/assets/skyblocker/lang/en_us.json +++ b/src/main/resources/assets/skyblocker/lang/en_us.json @@ -869,6 +869,8 @@ "skyblocker.crimson.dojo": "Dojo", "skyblocker.crimson.dojo.forceHelper": "Enable Force Helper", "skyblocker.crimson.dojo.forceHelper.@Tooltip": "Shows timer showing how long until a zombie despawns and outlines negative zombies.", + "skyblocker.crimson.dojo.staminaHelper": "Enable Stamina Helper", + "skyblocker.crimson.dojo.staminaHelper.@Tooltip": "Highlights the holes in the walls turning orange once you have been through a wall.", "skyblocker.crimson.dojo.masteryHelper": "Enable Mastery Helper", "skyblocker.crimson.dojo.masteryHelper.@Tooltip": "Shows timer for how long a block has left and a path to follow.", "skyblocker.crimson.dojo.disciplineHelper": "Enable Discipline Helper", -- cgit From 27b242b1d0d40d5b107a09718833400a14395fe1 Mon Sep 17 00:00:00 2001 From: olim Date: Mon, 3 Jun 2024 21:18:55 +0100 Subject: add ping measure and improve mastery mastery now counts down to when to release the bow --- .../hysky/skyblocker/mixins/PingMeasureMixin.java | 23 ++++++++++++++++++++++ .../skyblock/crimson/dojo/DojoManager.java | 16 +++++++++++++++ .../skyblock/crimson/dojo/MasteryTestHelper.java | 16 ++++++++++++--- .../resources/assets/skyblocker/lang/en_us.json | 2 +- src/main/resources/skyblocker.mixins.json | 1 + 5 files changed, 54 insertions(+), 4 deletions(-) create mode 100644 src/main/java/de/hysky/skyblocker/mixins/PingMeasureMixin.java (limited to 'src/main/resources/assets/skyblocker/lang/en_us.json') diff --git a/src/main/java/de/hysky/skyblocker/mixins/PingMeasureMixin.java b/src/main/java/de/hysky/skyblocker/mixins/PingMeasureMixin.java new file mode 100644 index 00000000..0e9c5e13 --- /dev/null +++ b/src/main/java/de/hysky/skyblocker/mixins/PingMeasureMixin.java @@ -0,0 +1,23 @@ +package de.hysky.skyblocker.mixins; + +import de.hysky.skyblocker.skyblock.crimson.dojo.DojoManager; +import de.hysky.skyblocker.utils.Location; +import de.hysky.skyblocker.utils.Utils; +import net.minecraft.client.network.PingMeasurer; +import net.minecraft.network.packet.s2c.query.PingResultS2CPacket; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(PingMeasurer.class) +public class PingMeasureMixin { + + @Inject(method = "onPingResult", at = @At("RETURN")) + private void skyblocker$onPingResult(PingResultS2CPacket packet, CallbackInfo ci) { + if (Utils.getLocation() == Location.CRIMSON_ISLE) { + long ping = System.currentTimeMillis() - packet.startTime(); + DojoManager.onPingResult(ping); + } + } +} 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 3de425ec..8278f089 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 @@ -12,9 +12,11 @@ import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents; import net.fabricmc.fabric.api.event.player.AttackEntityCallback; import net.minecraft.block.BlockState; import net.minecraft.client.MinecraftClient; +import net.minecraft.client.network.ClientPlayNetworkHandler; import net.minecraft.client.world.ClientWorld; import net.minecraft.entity.Entity; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.network.packet.c2s.query.QueryPingC2SPacket; import net.minecraft.network.packet.s2c.play.ParticleS2CPacket; import net.minecraft.text.Text; import net.minecraft.util.ActionResult; @@ -64,6 +66,7 @@ public class DojoManager { protected static DojoChallenges currentChallenge = DojoChallenges.NONE; public static boolean inArena = false; + protected static long ping = -1; public static void init() { ClientReceiveMessageEvents.GAME.register(DojoManager::onMessage); @@ -98,6 +101,8 @@ public class DojoManager { } if (Objects.equals(Formatting.strip(text.getString()), START_MESSAGE)) { inArena = true; + //update the players ping + getPing(); return; } if (!inArena) { @@ -121,6 +126,16 @@ public class DojoManager { } } + private static void getPing() { + ClientPlayNetworkHandler networkHandler = CLIENT.getNetworkHandler(); + if (networkHandler != null) { + networkHandler.sendPacket(new QueryPingC2SPacket(System.currentTimeMillis())); + } + } + public static void onPingResult(long ping) { + DojoManager.ping = ping; + } + private static void update() { if (Utils.getLocation() != Location.CRIMSON_ISLE || !inArena) { return; @@ -237,4 +252,5 @@ public class DojoManager { case TENACITY -> TenacityTestHelper.render(context); } } + } 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 393e8f06..172de7f5 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 @@ -7,6 +7,7 @@ import net.minecraft.block.Blocks; import net.minecraft.client.MinecraftClient; import net.minecraft.network.packet.s2c.play.BlockUpdateS2CPacket; import net.minecraft.text.Text; +import net.minecraft.util.Util; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; @@ -16,9 +17,12 @@ import java.util.*; import java.util.List; public class MasteryTestHelper { - + private static final MinecraftClient CLIENT = MinecraftClient.getInstance(); private static final DecimalFormat FORMATTER = new DecimalFormat("0.00"); - private static final int BLOCK_LIFE_TIME = 6850; + /** + * How long it takes for a block to turn red + */ + private static final int BLOCK_LIFE_TIME = 6550; private static final List blockOrder = new ArrayList<>(); private static final Map endTimes = new HashMap<>(); @@ -29,9 +33,15 @@ public class MasteryTestHelper { } protected static void onBlockUpdate(BlockPos pos, BlockState state) { + if (CLIENT == null || CLIENT.player == null) { + return; + } if (state.isOf(Blocks.LIME_WOOL)) { blockOrder.add(pos); - endTimes.put(pos, System.currentTimeMillis() + BLOCK_LIFE_TIME); + //add lifetime of a block to the time to get time when block expires + // work out how long it will take between the player firing and arrow hitting the block and to subtract from time + long travelTime = (long) (CLIENT.player.getPos().distanceTo(pos.toCenterPos()) * (1000 / 60)); //an arrow speed is about 60 blocks a second from a full draw + endTimes.put(pos, System.currentTimeMillis() + BLOCK_LIFE_TIME - DojoManager.ping - travelTime); } if (state.isAir()) { blockOrder.remove(pos); diff --git a/src/main/resources/assets/skyblocker/lang/en_us.json b/src/main/resources/assets/skyblocker/lang/en_us.json index a0a83897..c19a352d 100644 --- a/src/main/resources/assets/skyblocker/lang/en_us.json +++ b/src/main/resources/assets/skyblocker/lang/en_us.json @@ -872,7 +872,7 @@ "skyblocker.crimson.dojo.staminaHelper": "Enable Stamina Helper", "skyblocker.crimson.dojo.staminaHelper.@Tooltip": "Highlights the holes in the walls turning orange once you have been through a wall.", "skyblocker.crimson.dojo.masteryHelper": "Enable Mastery Helper", - "skyblocker.crimson.dojo.masteryHelper.@Tooltip": "Shows timer for how long a block has left and a path to follow.", + "skyblocker.crimson.dojo.masteryHelper.@Tooltip": "Shows count down to when to relase the bow and a path to follow.", "skyblocker.crimson.dojo.disciplineHelper": "Enable Discipline Helper", "skyblocker.crimson.dojo.disciplineHelper.@Tooltip": "Outlines the zombies to attack with currently held sword.", "skyblocker.crimson.dojo.swiftnessHelper": "Enable Swiftness Helper", diff --git a/src/main/resources/skyblocker.mixins.json b/src/main/resources/skyblocker.mixins.json index 25c813cf..f173467d 100644 --- a/src/main/resources/skyblocker.mixins.json +++ b/src/main/resources/skyblocker.mixins.json @@ -27,6 +27,7 @@ "LivingEntityRendererMixin", "MinecraftClientMixin", "MouseMixin", + "PingMeasureMixin", "PlayerInventoryMixin", "PlayerListHudMixin", "PlayerSkinProviderMixin", -- cgit From e92cd753c695772371cf79636f011834a8518634 Mon Sep 17 00:00:00 2001 From: olim Date: Mon, 3 Jun 2024 22:45:07 +0100 Subject: fix control helper make it actually based off ping and not just how long the games has been open and change the line to a block outline --- .../skyblock/crimson/dojo/ControlTestHelper.java | 46 ++++++++++++---------- .../skyblock/crimson/dojo/StaminaTestHelper.java | 2 +- .../resources/assets/skyblocker/lang/en_us.json | 2 +- 3 files changed, 27 insertions(+), 23 deletions(-) (limited to 'src/main/resources/assets/skyblocker/lang/en_us.json') 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 d2b0b8aa..dfc3ae2a 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 @@ -2,27 +2,29 @@ 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.client.MinecraftClient; import net.minecraft.entity.Entity; import net.minecraft.entity.mob.WitherSkeletonEntity; -import net.minecraft.util.Util; +import net.minecraft.util.math.Box; import net.minecraft.util.math.Vec3d; import java.awt.*; public class ControlTestHelper { + private static final MinecraftClient CLIENT = MinecraftClient.getInstance(); private static WitherSkeletonEntity correctWitherSkeleton; - private static long ping; - private static Vec3d lastTargetPos; private static Vec3d lastPos; - private static Vec3d aimOffset; + private static long lastUpdate; + private static Vec3d pingOffset; + private static Vec3d lastPingOffset; protected static void reset() { correctWitherSkeleton = null; - ping = 0; - lastTargetPos = null; lastPos = null; - aimOffset = null; + lastUpdate = -1; + pingOffset = null; + lastPingOffset = null; } /** @@ -33,41 +35,43 @@ public class ControlTestHelper { protected static void onEntitySpawn(Entity entity) { if (entity instanceof WitherSkeletonEntity witherSkeleton && correctWitherSkeleton == null) { correctWitherSkeleton = witherSkeleton; - ping = Util.getMeasuringTimeMs(); - aimOffset = new Vec3d(0, 0, 0); } } /** - * update the aim offset for the wither skeleton based on ping + * Finds where to look in 3 ticks effected by ping */ protected static void update() { if (correctWitherSkeleton != null) { //smoothly adjust the ping throughout the test - ping = (ping + Util.getMeasuringTimeMs()) / 2; if (lastPos != null) { - lastTargetPos = aimOffset; - double ping = (double) ControlTestHelper.ping / 1000000; + lastPingOffset = pingOffset; + double ping = (double) DojoManager.ping / 1000; //find distance between last position and current position of skeleton Vec3d movementVector = correctWitherSkeleton.getPos().subtract(lastPos).multiply(1, 0.1, 1); - //adjust the vector to current ping (20 / 3 is used because that is how many times this is updated a second. Every 3 ticks) - movementVector = movementVector.multiply((double) 20 / 3 * ping); - //smoothly adjust the aim offset based on the new value - aimOffset = (aimOffset.add(movementVector)).multiply(0.5); + //adjust the vector to current ping + pingOffset = movementVector.multiply((double) 23 / 20 + ping); } lastPos = correctWitherSkeleton.getPos(); + lastUpdate = System.currentTimeMillis(); } } /** - * Renders a line from the cursor where the player should aim + * Renders an outline around where the player should aim (assumes values are updated every 3 ticks) * * @param context render context */ protected static void render(WorldRenderContext context) { - if (correctWitherSkeleton != null && aimOffset != null && lastTargetPos != null) { - Vec3d aimPos = correctWitherSkeleton.getEyePos().add(aimOffset); - RenderHelper.renderLineFromCursor(context, aimPos, Color.LIGHT_GRAY.getColorComponents(new float[]{0, 0, 0}), 1, 3); + if (CLIENT.player != null && correctWitherSkeleton != null && pingOffset != null && lastPingOffset != null) { + float tickDelta = context.tickDelta(); + //how long until net update + double updatePercent = (double) (System.currentTimeMillis() - lastUpdate) / 150; + Vec3d aimPos = correctWitherSkeleton.getEyePos().add(pingOffset.multiply(updatePercent)).add(lastPingOffset.multiply(1 - updatePercent)); + Box targetBox = new Box(aimPos.add(-0.5, -0.5, -0.5), aimPos.add(0.5, 0.5, 0.5)); + boolean playerLookingAtBox = targetBox.raycast(CLIENT.player.getCameraPosVec(tickDelta),CLIENT.player.getCameraPosVec(tickDelta).add(CLIENT.player.getRotationVec(tickDelta).multiply(30))).isPresent(); + float[] boxColor = playerLookingAtBox ? Color.GREEN.getColorComponents(new float[]{0, 0, 0}) : Color.LIGHT_GRAY.getColorComponents(new float[]{0, 0, 0}); + RenderHelper.renderOutline(context, targetBox, boxColor, 3, true); } } } 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 77a202d7..dc9bbb2c 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 @@ -236,7 +236,7 @@ public class StaminaTestHelper { BlockPos playerPos = CLIENT.player.getBlockPos(); for (BlockPos hole : wallHoles) { float[] color = isHoleIncoming(hole, holeDirections.get(hole), playerPos) ? INCOMING_COLOR : OUTGOING_COLOR; - RenderHelper.renderFilled(context, hole, color, 0.3f, true); + RenderHelper.renderFilled(context, hole, color, 0.3f, false); } } diff --git a/src/main/resources/assets/skyblocker/lang/en_us.json b/src/main/resources/assets/skyblocker/lang/en_us.json index c19a352d..cd8fff39 100644 --- a/src/main/resources/assets/skyblocker/lang/en_us.json +++ b/src/main/resources/assets/skyblocker/lang/en_us.json @@ -878,7 +878,7 @@ "skyblocker.crimson.dojo.swiftnessHelper": "Enable Swiftness Helper", "skyblocker.crimson.dojo.swiftnessHelper.@Tooltip": "highlights the newest wool block to go to.", "skyblocker.crimson.dojo.controlHelper": "Enable Control Helper", - "skyblocker.crimson.dojo.controlHelper.@Tooltip": "Creates a line from cursor to where to aim (this is not exact and is guessed of ping).", + "skyblocker.crimson.dojo.controlHelper.@Tooltip": "enders an outline around where to aim.", "skyblocker.crimson.dojo.tenacityHelper": "Enable Tenacity Helper", "skyblocker.crimson.dojo.tenacityHelper.@Tooltip": "Shows a path for each fireball and predicted block they are going to hit.", -- cgit