diff options
author | olim <bobq4582@gmail.com> | 2024-05-01 21:37:06 +0100 |
---|---|---|
committer | olim <bobq4582@gmail.com> | 2024-07-01 14:26:13 +0100 |
commit | b69fb532750981808b3632aa84851de0ed539b1a (patch) | |
tree | 3bf90e297b30733604a9e53f0d08111ab22c9091 /src/main/java/de/hysky/skyblocker/skyblock/crimson | |
parent | d23f2f42e9fc57e06341a372c319fec54f510899 (diff) | |
download | Skyblocker-b69fb532750981808b3632aa84851de0ed539b1a.tar.gz Skyblocker-b69fb532750981808b3632aa84851de0ed539b1a.tar.bz2 Skyblocker-b69fb532750981808b3632aa84851de0ed539b1a.zip |
fix formatting and add some comments
Diffstat (limited to 'src/main/java/de/hysky/skyblocker/skyblock/crimson')
6 files changed, 46 insertions, 42 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 6312bbdc..2350ea97 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 @@ -11,7 +11,6 @@ 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<>(); @@ -20,16 +19,16 @@ public class DisciplineTestHelper { } 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"); + 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); + map.put("WOOD_SWORD", 0xa52a2a); + map.put("IRON_SWORD", 0xc0c0c0); + map.put("GOLD_SWORD", 0xffd700); + map.put("DIAMOND_SWORD", 0x00ffff); }); protected static boolean shouldGlow(String name) { 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 dd2df117..b24d3d49 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 @@ -8,12 +8,15 @@ 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.fabricmc.fabric.api.event.player.AttackEntityCallback; +import net.fabricmc.fabric.api.event.player.PlayerBlockBreakEvents; import net.minecraft.client.MinecraftClient; +import net.minecraft.client.session.telemetry.WorldLoadedEvent; import net.minecraft.client.world.ClientWorld; import net.minecraft.entity.Entity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.network.packet.s2c.play.BlockUpdateS2CPacket; import net.minecraft.network.packet.s2c.play.ParticleS2CPacket; +import net.minecraft.server.world.BlockEvent; import net.minecraft.text.Text; import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; @@ -61,7 +64,6 @@ public class DojoManager { ClientEntityEvents.ENTITY_LOAD.register(DojoManager::onEntitySpawn); ClientEntityEvents.ENTITY_UNLOAD.register(DojoManager::onEntityDespawn); AttackEntityCallback.EVENT.register(DojoManager::onEntityAttacked); - } private static void reset() { @@ -73,6 +75,11 @@ public class DojoManager { ForceTestHelper.reset(); } + /** + * works out if the player is in dojo and if so what challenge based on chat messages + * @param text message + * @param overlay is overlay + */ private static void onMessage(Text text, Boolean overlay) { if (Utils.getLocation() != Location.CRIMSON_ISLE || overlay) { return; @@ -99,6 +106,11 @@ public class DojoManager { } } + /** + * called from the {@link de.hysky.skyblocker.skyblock.entity.MobGlow} class and checks the current challenge to see if zombies should be glowing + * @param name name of the zombie + * @return if the zombie should glow + */ public static boolean shouldGlow(String name) { if (Utils.getLocation() != Location.CRIMSON_ISLE || !inArena) { return false; @@ -110,6 +122,10 @@ public class DojoManager { }; } + /** + * called from the {@link de.hysky.skyblocker.skyblock.entity.MobGlow} class and checks the current challenge to see zombie outline color + * @return if the zombie should glow + */ public static int getColor() { if (Utils.getLocation() != Location.CRIMSON_ISLE || !inArena) { return 0xf57738; @@ -121,6 +137,10 @@ public class DojoManager { }; } + /** + * when a block is updated check the current challenge and send the packet to correct helper + * @param packet block update packet + */ public static void onBlockUpdate(BlockUpdateS2CPacket packet) { if (Utils.getLocation() != Location.CRIMSON_ISLE || !inArena) { return; @@ -130,12 +150,13 @@ public class DojoManager { case MASTERY -> MasteryTestHelper.onBlockUpdate(packet); } } + private static void onEntitySpawn(Entity entity, ClientWorld clientWorld) { if (Utils.getLocation() != Location.CRIMSON_ISLE || !inArena || CLIENT == null || CLIENT.player == null) { return; } //check close by - if (entity.distanceTo(CLIENT.player) > 50 || Math.abs(entity.getBlockY() - CLIENT.player.getBlockY()) > 5){ + if (entity.distanceTo(CLIENT.player) > 50 || Math.abs(entity.getBlockY() - CLIENT.player.getBlockY()) > 5) { return; } switch (currentChallenge) { @@ -158,8 +179,8 @@ public class DojoManager { if (Utils.getLocation() != Location.CRIMSON_ISLE || !inArena) { return null; } - switch (currentChallenge) { - case FORCE -> ForceTestHelper.onEntityAttacked(entity); + if (currentChallenge == DojoChallenges.FORCE) { + ForceTestHelper.onEntityAttacked(entity); } return ActionResult.PASS; } @@ -184,6 +205,4 @@ public class DojoManager { 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 index c709f64a..1f29f634 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 @@ -2,7 +2,6 @@ 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.ZombieEntity; import net.minecraft.text.Text; @@ -42,7 +41,7 @@ public class ForceTestHelper { 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() + 10100); //timer is reset when they are hit } } } @@ -50,7 +49,6 @@ public class ForceTestHelper { protected static void onEntityDespawn(Entity entity) { if (entity instanceof ZombieEntity zombie) { zombies.remove(zombie); - } } @@ -59,21 +57,18 @@ public class ForceTestHelper { long currentTime = System.currentTimeMillis(); for (Map.Entry<ZombieEntity, Long> zombie : zombies.entrySet()) { float secondsTime = Math.max((zombie.getValue() - currentTime) / 1000f, 0); - + Text text; if (secondsTime > 1) { text = Text.literal(FORMATTER.format(secondsTime)).formatted(Formatting.GREEN); - } - else if (secondsTime > 0) { + } else if (secondsTime > 0) { text = Text.literal(FORMATTER.format(secondsTime)).formatted(Formatting.YELLOW); - } - else { + } else { text = Text.literal("Soon").formatted(Formatting.RED); //todo translate } Vec3d lablePos = zombie.getKey().getEyePos(); RenderHelper.renderText(context, text, lablePos, 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 2bbe4255..76aa5209 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 @@ -13,23 +13,22 @@ import java.util.*; public class MasteryTestHelper { - private static final float[] LIGHT_GRAY = { 192 / 255f, 192 / 255f, 192 / 255f }; + private static final float[] LIGHT_GRAY = {192 / 255f, 192 / 255f, 192 / 255f}; private static final DecimalFormat FORMATTER = new DecimalFormat("0.00"); private static final List<BlockPos> blockOrder = new ArrayList<>(); - private static final Map<BlockPos, Long> endTimes =new HashMap<>(); + private static final Map<BlockPos, Long> endTimes = new HashMap<>(); protected static void reset() { blockOrder.clear(); endTimes.clear(); } - public static void onBlockUpdate(BlockUpdateS2CPacket packet) { BlockPos pos = packet.getPos(); if (packet.getState().isOf(Blocks.LIME_WOOL)) { blockOrder.add(pos); - endTimes.put(pos,System.currentTimeMillis()+6850); + endTimes.put(pos, System.currentTimeMillis() + 6850); } if (packet.getState().isAir()) { blockOrder.remove(pos); @@ -40,7 +39,7 @@ public class MasteryTestHelper { protected static void render(WorldRenderContext context) { //render connecting lines if (!blockOrder.isEmpty()) { - RenderHelper.renderLineFromCursor(context, blockOrder.getFirst().toCenterPos(),LIGHT_GRAY,1f, 2); + RenderHelper.renderLineFromCursor(context, blockOrder.getFirst().toCenterPos(), LIGHT_GRAY, 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); @@ -50,10 +49,8 @@ public class MasteryTestHelper { long currentTime = System.currentTimeMillis(); for (BlockPos pos : blockOrder) { long blockEndTime = endTimes.get(pos); - float secondsTime = Math.max((blockEndTime - currentTime) / 1000f, 0); + float secondsTime = Math.max((blockEndTime - currentTime) / 1000f, 0); RenderHelper.renderText(context, Text.literal(FORMATTER.format(secondsTime)), pos.add(0, 1, 0).toCenterPos(), 3, 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 5d5f3bab..7243b45b 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 @@ -18,10 +18,6 @@ public class SwiftnessTestHelper { lastBlock = null; } - //dojo cwords: - //-189 99 -580 - //-223 99 -614 - public static void onBlockUpdate(BlockUpdateS2CPacket packet) { if (packet.getState().isOf(Blocks.LIME_WOOL)) { lastBlock = packet.getPos(); @@ -32,7 +28,6 @@ public class SwiftnessTestHelper { if (lastBlock == null) { return; } - RenderHelper.renderOutline(context,new Box(lastBlock),new float[]{0f,1f,0f},3,true); - + RenderHelper.renderOutline(context, new Box(lastBlock), new float[]{0f, 1f, 0f}, 3, true); } } 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 b2f99d2e..37ba84d2 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 @@ -26,7 +26,6 @@ public class TenacityTestHelper { particleOffsets.clear(); } - protected static void render(WorldRenderContext context) { for (ArmorStandEntity fireball : fireBallsWithStartPos.keySet()) { Vec3d lineStart = fireBallsWithStartPos.get(fireball).add(particleOffsets.getOrDefault(fireball, Vec3d.ZERO)); @@ -37,12 +36,12 @@ public class TenacityTestHelper { distance = distance.multiply(100); Vec3d lineEnd = lineStart.add(distance); - RenderHelper.renderLinesFromPoints(context, new Vec3d[]{lineStart, lineEnd},new float[]{1f, 0f, 0f}, 1, 3, false); + RenderHelper.renderLinesFromPoints(context, new Vec3d[]{lineStart, lineEnd}, new float[]{1f, 0f, 0f}, 1, 3, false); //get highlighted block HitResult hitResult = raycast(lineStart, lineEnd, fireball); if (hitResult != null && hitResult.getType() == HitResult.Type.BLOCK && hitResult instanceof BlockHitResult blockHitResult) { - RenderHelper.renderFilled(context, blockHitResult.getBlockPos(),new float[]{1f, 0f, 0f}, 0.5f, false); + RenderHelper.renderFilled(context, blockHitResult.getBlockPos(), new float[]{1f, 0f, 0f}, 0.5f, false); } } } @@ -58,7 +57,7 @@ public class TenacityTestHelper { public 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()); + fireBallsWithStartPos.put(armorStand, armorStand.getPos()); } } |