diff options
author | Aaron <51387595+AzureAaron@users.noreply.github.com> | 2024-04-24 11:54:49 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-24 11:54:49 -0400 |
commit | cca9c9a13c3c92f06f567cb8467b525a32cdfd2a (patch) | |
tree | b02a0c286ddd91bc66a97bc653adcb4a0f16be25 /src/main/java/de | |
parent | 38e1057e08afcfe2912a19183ab70de97476d902 (diff) | |
parent | acd7d7225f8685ab9374899628b367936f082c81 (diff) | |
download | Skyblocker-cca9c9a13c3c92f06f567cb8467b525a32cdfd2a.tar.gz Skyblocker-cca9c9a13c3c92f06f567cb8467b525a32cdfd2a.tar.bz2 Skyblocker-cca9c9a13c3c92f06f567cb8467b525a32cdfd2a.zip |
Merge pull request #667 from viciscat/end-hud-changes
fix and things for end hud
Diffstat (limited to 'src/main/java/de')
4 files changed, 88 insertions, 32 deletions
diff --git a/src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java b/src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java index 912636d6..2d113361 100644 --- a/src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java +++ b/src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java @@ -1095,6 +1095,12 @@ public class SkyblockerConfig { public boolean hudEnabled = true; @SerialEntry + public boolean zealotKillsEnabled = true; + + @SerialEntry + public boolean protectorLocationEnabled = true; + + @SerialEntry public boolean waypoint = true; @SerialEntry diff --git a/src/main/java/de/hysky/skyblocker/config/categories/LocationsCategory.java b/src/main/java/de/hysky/skyblocker/config/categories/LocationsCategory.java index 46f3067c..e56c9eb0 100644 --- a/src/main/java/de/hysky/skyblocker/config/categories/LocationsCategory.java +++ b/src/main/java/de/hysky/skyblocker/config/categories/LocationsCategory.java @@ -3,6 +3,7 @@ package de.hysky.skyblocker.config.categories; import de.hysky.skyblocker.config.ConfigUtils; import de.hysky.skyblocker.config.SkyblockerConfig; import de.hysky.skyblocker.skyblock.end.EndHudConfigScreen; +import de.hysky.skyblocker.skyblock.end.EndHudWidget; import de.hysky.skyblocker.skyblock.end.TheEnd; import de.hysky.skyblocker.skyblock.garden.FarmingHudConfigScreen; import dev.isxander.yacl3.api.*; @@ -99,6 +100,26 @@ public class LocationsCategory { .controller(ConfigUtils::createBooleanController) .build()) .option(Option.<Boolean>createBuilder() + .name(Text.translatable("text.autoconfig.skyblocker.option.locations.end.zealotKillsEnabled")) + .binding(defaults.locations.end.zealotKillsEnabled, + () -> config.locations.end.zealotKillsEnabled, + newValue -> { + config.locations.end.zealotKillsEnabled = newValue; + EndHudWidget.INSTANCE.update(); + }) + .controller(ConfigUtils::createBooleanController) + .build()) + .option(Option.<Boolean>createBuilder() + .name(Text.translatable("text.autoconfig.skyblocker.option.locations.end.protectorLocationEnable")) + .binding(defaults.locations.end.protectorLocationEnabled, + () -> config.locations.end.protectorLocationEnabled, + newValue -> { + config.locations.end.protectorLocationEnabled = newValue; + EndHudWidget.INSTANCE.update(); + }) + .controller(ConfigUtils::createBooleanController) + .build()) + .option(Option.<Boolean>createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.locations.end.waypoint")) .binding(defaults.locations.end.waypoint, () -> config.locations.end.waypoint, diff --git a/src/main/java/de/hysky/skyblocker/skyblock/end/EndHudWidget.java b/src/main/java/de/hysky/skyblocker/skyblock/end/EndHudWidget.java index 59a637dd..30de9a48 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/end/EndHudWidget.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/end/EndHudWidget.java @@ -40,26 +40,30 @@ public class EndHudWidget extends Widget { @Override public void updateContent() { // Zealots - addComponent(new IcoTextComponent(ENDERMAN_HEAD, Text.literal("Zealots").formatted(Formatting.BOLD))); - addComponent(new PlainTextComponent(Text.translatable("skyblocker.end.hud.zealotsSinceLastEye", TheEnd.zealotsSinceLastEye))); - addComponent(new PlainTextComponent(Text.translatable("skyblocker.end.hud.zealotsTotalKills", TheEnd.zealotsKilled))); - NumberFormat instance = NumberFormat.getInstance(); - instance.setMinimumFractionDigits(0); - instance.setMaximumFractionDigits(2); - String avg = TheEnd.eyes == 0 ? "???" : instance.format((float)TheEnd.zealotsKilled / TheEnd.eyes); - addComponent(new PlainTextComponent(Text.translatable("skyblocker.end.hud.avgKillsPerEye", avg))); + if (SkyblockerConfigManager.get().locations.end.zealotKillsEnabled) { + addComponent(new IcoTextComponent(ENDERMAN_HEAD, Text.literal("Zealots").formatted(Formatting.BOLD))); + addComponent(new PlainTextComponent(Text.translatable("skyblocker.end.hud.zealotsSinceLastEye", TheEnd.zealotsSinceLastEye))); + addComponent(new PlainTextComponent(Text.translatable("skyblocker.end.hud.zealotsTotalKills", TheEnd.zealotsKilled))); + NumberFormat instance = NumberFormat.getInstance(); + instance.setMinimumFractionDigits(0); + instance.setMaximumFractionDigits(2); + String avg = TheEnd.eyes == 0 ? "???" : instance.format((float) TheEnd.zealotsKilled / TheEnd.eyes); + addComponent(new PlainTextComponent(Text.translatable("skyblocker.end.hud.avgKillsPerEye", avg))); + } // Endstone protector - addComponent(new IcoTextComponent(POPPY, Text.literal("Endstone Protector").formatted(Formatting.BOLD))); - if (TheEnd.stage == 5) { - addComponent(new PlainTextComponent(Text.translatable("skyblocker.end.hud.stage", "IMMINENT"))); - } else { - addComponent(new PlainTextComponent(Text.translatable("skyblocker.end.hud.stage", String.valueOf(TheEnd.stage)))); - } - if (TheEnd.currentProtectorLocation == null) { - addComponent(new PlainTextComponent(Text.translatable("skyblocker.end.hud.location", "?"))); - } else { - addComponent(new PlainTextComponent(Text.translatable("skyblocker.end.hud.location", TheEnd.currentProtectorLocation.name()))); + if (SkyblockerConfigManager.get().locations.end.protectorLocationEnabled) { + addComponent(new IcoTextComponent(POPPY, Text.literal("Endstone Protector").formatted(Formatting.BOLD))); + if (TheEnd.stage == 5) { + addComponent(new PlainTextComponent(Text.translatable("skyblocker.end.hud.stage", "IMMINENT"))); + } else { + addComponent(new PlainTextComponent(Text.translatable("skyblocker.end.hud.stage", String.valueOf(TheEnd.stage)))); + } + if (TheEnd.currentProtectorLocation == null) { + addComponent(new PlainTextComponent(Text.translatable("skyblocker.end.hud.location", "?"))); + } else { + addComponent(new PlainTextComponent(Text.translatable("skyblocker.end.hud.location", TheEnd.currentProtectorLocation.name()))); + } } } } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/end/TheEnd.java b/src/main/java/de/hysky/skyblocker/skyblock/end/TheEnd.java index 10672bde..a093f598 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/end/TheEnd.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/end/TheEnd.java @@ -16,6 +16,7 @@ import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents; import net.fabricmc.fabric.api.event.player.AttackEntityCallback; import net.minecraft.block.Blocks; import net.minecraft.client.MinecraftClient; +import net.minecraft.client.world.ClientWorld; import net.minecraft.entity.Entity; import net.minecraft.entity.decoration.ArmorStandEntity; import net.minecraft.entity.mob.EndermanEntity; @@ -84,18 +85,11 @@ public class TheEnd { if (Utils.isInTheEnd() || lowerCase.contains("the end") || lowerCase.contains("dragon's nest")) { ChunkPos pos = chunk.getPos(); // - Box box = new Box(pos.getStartX(), 0, pos.getStartZ(), pos.getEndX(), 1, pos.getEndZ()); - locationsLoop: for (ProtectorLocation protectorLocation : protectorLocations) { - if (box.contains(protectorLocation.x, 0.5, protectorLocation.z)) { - //MinecraftClient.getInstance().player.sendMessage(Text.literal("Checking: ").append(protectorLocation.name));//MinecraftClient.getInstance().player.sendMessage(Text.literal(pos.getStartX() + " " + pos.getStartZ() + " " + pos.getEndX() + " " + pos.getEndZ())); - for (int i = 0; i < 5; i++) { - if (world.getBlockState(new BlockPos(protectorLocation.x, i+5, protectorLocation.z)).isOf(Blocks.PLAYER_HEAD)) { - stage = i + 1; - currentProtectorLocation = protectorLocation; - EndHudWidget.INSTANCE.update(); - break locationsLoop; - } - } + Box box = new Box(pos.getStartX(), 0, pos.getStartZ(), pos.getEndX() + 1, 1, pos.getEndZ() + 1); + for (ProtectorLocation protectorLocation : protectorLocations) { + if (box.contains(protectorLocation.x(), 0.5, protectorLocation.z())) { + // MinecraftClient.getInstance().player.sendMessage(Text.literal("Checking: ").append(protectorLocation.name));//MinecraftClient.getInstance().player.sendMessage(Text.literal(pos.getStartX() + " " + pos.getStartZ() + " " + pos.getEndX() + " " + pos.getEndZ())); + if (isProtectorHere(world, protectorLocation)) break; } } if (currentProfile.isEmpty()) load(); // Wacky fix for when you join skyblock, and you are directly in the end (profile id isn't parsed yet most of the time) @@ -109,14 +103,18 @@ public class TheEnd { resetLocation(); save(); load(); + EndHudWidget.INSTANCE.update(); }); // Save when leaving as well ClientLifecycleEvents.CLIENT_STOPPING.register((client) -> save()); ClientReceiveMessageEvents.GAME.register((message, overlay) -> { - if (Utils.isInTheEnd()) return; + if (!Utils.isInTheEnd() || overlay) return; String lowerCase = message.getString().toLowerCase(); - if (lowerCase.contains("tremor") && stage != 0) stage += 1; // TODO: If stage is 0 re-scan. + if (lowerCase.contains("tremor")) { + if (stage == 0) checkAllProtectorLocations(); + else stage += 1; + } else if (lowerCase.contains("rises from below")) stage = 5; else if (lowerCase.contains("protector down") || lowerCase.contains("has risen")) resetLocation(); else return; @@ -127,6 +125,33 @@ public class TheEnd { ClientLifecycleEvents.CLIENT_STARTED.register((client -> loadFile())); } + private static void checkAllProtectorLocations() { + ClientWorld world = MinecraftClient.getInstance().world; + if (world == null) return; + for (ProtectorLocation protectorLocation : protectorLocations) { + if (!world.isChunkLoaded(protectorLocation.x() >> 4, protectorLocation.z() >> 4)) continue; + if (isProtectorHere(world, protectorLocation)) break; + } + } + + /** + * Checks a bunch of Ys to see if a player head is there, if it's there it returns true and updates the hud accordingly + * @param world le world to check + * @param protectorLocation protectorLocation to check + * @return if found + */ + private static boolean isProtectorHere(ClientWorld world, ProtectorLocation protectorLocation) { + for (int i = 0; i < 5; i++) { + if (world.getBlockState(new BlockPos(protectorLocation.x, i + 5, protectorLocation.z)).isOf(Blocks.PLAYER_HEAD)) { + stage = i + 1; + currentProtectorLocation = protectorLocation; + EndHudWidget.INSTANCE.update(); + return true; + } + } + return false; + } + private static void resetLocation() { stage = 0; currentProtectorLocation = null; |