diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 6ffca898cc..42b083d4b9 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -35,7 +35,7 @@ body: label: Minecraft Version description: What version of Minecraft are you running? If you do not know what version you are using, look in the bottom left corner of the main menu in game. options: - - "1.20.4" + - "1.20.6" validations: required: true - type: input @@ -43,7 +43,7 @@ body: attributes: label: Skyblocker Version description: What version of Skyblocker are you running? Every part is important! If you do not know what version you are using, look at the file name in your "mods" folder. - placeholder: ex. skyblocker-1.19.0+1.20.4.jar + placeholder: ex. skyblocker-1.20.3+1.20.6.jar validations: required: true - type: textarea diff --git a/.github/ISSUE_TEMPLATE/crash_report.yml b/.github/ISSUE_TEMPLATE/crash_report.yml index 7135848d18..142e131451 100644 --- a/.github/ISSUE_TEMPLATE/crash_report.yml +++ b/.github/ISSUE_TEMPLATE/crash_report.yml @@ -16,7 +16,7 @@ body: label: Minecraft Version description: What version of Minecraft are you running? If you do not know what version you are using, look in the bottom left corner of the main menu in game. options: - - "1.20.4" + - "1.20.6" validations: required: true - type: input @@ -24,7 +24,7 @@ body: attributes: label: Skyblocker Version description: What version of Skyblocker are you running? Every part is important! If you do not know what version you are using, look at the file name in your "mods" folder. - placeholder: ex. skyblocker-1.19.0+1.20.4.jar + placeholder: ex. skyblocker-1.20.3+1.20.6.jar validations: required: true - type: textarea diff --git a/.github/workflows/beta.yml b/.github/workflows/beta.yml index 7100e2e268..e1d3427cfb 100644 --- a/.github/workflows/beta.yml +++ b/.github/workflows/beta.yml @@ -59,6 +59,15 @@ jobs: - name: Build with Gradle run: ./gradlew build + - name: Store reports + if: failure() + uses: actions/upload-artifact@v4 + with: + name: reports + path: | + **/build/reports/ + **/build/test-results/ + - uses: actions/github-script@v7 id: fname with: diff --git a/README.md b/README.md index b7e8327214..a65125d379 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ [![Ko-fi](https://img.shields.io/badge/buy%20me%20coffee-skyblocker?color=434B57&logo=kofi)](https://ko-fi.com/wohlhabend) [![Translated](https://translate.hysky.de/widgets/Skyblocker/-/skyblocker/svg-badge.svg)](https://translate.hysky.de/projects/Skyblocker/skyblocker/) -Hypixel Skyblock Mod for Minecraft 1.20.4 +Hypixel Skyblock Mod for Minecraft 1.20.6 Installation guide is [here](https://github.com/SkyblockerMod/Skyblocker/wiki/installation) or use our [Modpack](https://modrinth.com/modpack/skyblocker-modpack) ## Features diff --git a/build.gradle b/build.gradle index d7b37bfe25..fd21ebd5fe 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'fabric-loom' version '1.5-SNAPSHOT' + id 'fabric-loom' version '1.6-SNAPSHOT' id 'maven-publish' id "me.modmuss50.mod-publish-plugin" version "0.5.1" } @@ -36,14 +36,19 @@ dependencies { testImplementation "net.fabricmc:fabric-loader-junit:${project.loader_version}" // To change the versions see the gradle.properties file minecraft "com.mojang:minecraft:${project.minecraft_version}" - mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" + //Layered Yarn & Mojmap - used to fill in intermediary names + mappings loom.layered { + //Using Mojmap breaks runClient, so uncomment only for snapshots when temp mappings are needed + //officialMojangMappings() + mappings("net.fabricmc:yarn:${project.yarn_mappings}:v2") + } modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" // Fabric API modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}" // YACL - include modImplementation("dev.isxander.yacl:yet-another-config-lib-fabric:${project.yacl_version}") + include modImplementation("dev.isxander:yet-another-config-lib:${project.yacl_version}-fabric") // Mod Menu modImplementation "com.terraformersmc:modmenu:${project.mod_menu_version}" @@ -92,17 +97,12 @@ processResources { } tasks.withType(JavaCompile).configureEach { - it.options.release = 17 + it.options.release = 21 } java { - // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task - // if it is present. - // If you remove this line, sources will not be generated. - withSourcesJar() - - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 + sourceCompatibility = JavaVersion.VERSION_21 + targetCompatibility = JavaVersion.VERSION_21 } jar { diff --git a/gradle.properties b/gradle.properties index ce2fbd8900..ceb86ac8e8 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,19 +3,19 @@ org.gradle.parallel=true # Fabric Properties (https://fabricmc.net/versions.html) ## 1.20 -minecraft_version=1.20.4 -yarn_mappings=1.20.4+build.1 -loader_version=0.15.1 +minecraft_version=1.20.6 +yarn_mappings=1.20.6+build.1 +loader_version=0.15.10 #Fabric api ## 1.20 -fabric_api_version=0.92.0+1.20.4 +fabric_api_version=0.97.8+1.20.6 # Minecraft Mods ## YACL (https://github.com/isXander/YetAnotherConfigLib) -yacl_version=3.3.2+1.20.4 +yacl_version=3.4.1+1.20.5 ## Mod Menu (https://modrinth.com/mod/modmenu/versions) -mod_menu_version = 9.0.0-alpha.3 +mod_menu_version = 10.0.0-beta.1 ## REI (https://modrinth.com/mod/rei/versions?l=fabric) rei_version = 13.0.666 ## EMI (https://modrinth.com/mod/emi/versions) @@ -25,11 +25,11 @@ emi_version = 1.0.22+1.20.2 ## Occlusion Culling (https://github.com/LogisticsCraft/OcclusionCulling) occlusionculling_version = 0.0.8-SNAPSHOT ## neu repoparser (https://repo.nea.moe/#/releases/moe/nea/neurepoparser/) -repoparser_version = 1.4.0 +repoparser_version = 1.5.0 # Other Libraries ## JGit (https://mvnrepository.com/artifact/org.eclipse.jgit/org.eclipse.jgit) -jgit_version = 6.8.0.202311291450-r +jgit_version = 6.9.0.202403050737-r ## Apache Commons Math (https://mvnrepository.com/artifact/org.apache.commons/commons-math3) commons_math_version = 3.6.1 diff --git a/src/main/java/de/hysky/skyblocker/SkyblockerMod.java b/src/main/java/de/hysky/skyblocker/SkyblockerMod.java index e0815eee66..3336cefb75 100644 --- a/src/main/java/de/hysky/skyblocker/SkyblockerMod.java +++ b/src/main/java/de/hysky/skyblocker/SkyblockerMod.java @@ -136,6 +136,7 @@ public void onInitializeClient() { LividColor.init(); FishingHelper.init(); DungeonMap.init(); + DungeonScoreHUD.init(); DungeonManager.init(); DungeonBlaze.init(); Waterboard.init(); diff --git a/src/main/java/de/hysky/skyblocker/config/HudConfigScreen.java b/src/main/java/de/hysky/skyblocker/config/HudConfigScreen.java index 07109b460a..4151173270 100644 --- a/src/main/java/de/hysky/skyblocker/config/HudConfigScreen.java +++ b/src/main/java/de/hysky/skyblocker/config/HudConfigScreen.java @@ -6,7 +6,6 @@ import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.screen.Screen; import net.minecraft.text.Text; -import net.minecraft.util.math.MathHelper; import java.awt.*; import java.util.List; @@ -70,8 +69,8 @@ protected void renderWidget(DrawContext context, List widgets) { @Override public final boolean mouseDragged(double mouseX, double mouseY, int button, double deltaX, double deltaY) { if (button == 0 && draggingWidget != null) { - draggingWidget.setX((int) MathHelper.clamp(mouseX - mouseClickRelativeX, 0, this.width - draggingWidget.getWidth())); - draggingWidget.setY((int) MathHelper.clamp(mouseY - mouseClickRelativeY, 0, this.height - draggingWidget.getHeight())); + draggingWidget.setX((int) Math.clamp(mouseX - mouseClickRelativeX, 0, this.width - draggingWidget.getWidth())); + draggingWidget.setY((int) Math.clamp(mouseY - mouseClickRelativeY, 0, this.height - draggingWidget.getHeight())); } return super.mouseDragged(mouseX, mouseY, button, deltaX, deltaY); } diff --git a/src/main/java/de/hysky/skyblocker/config/ImageRepoLoader.java b/src/main/java/de/hysky/skyblocker/config/ImageRepoLoader.java index 584b79e70d..77dd2f6189 100644 --- a/src/main/java/de/hysky/skyblocker/config/ImageRepoLoader.java +++ b/src/main/java/de/hysky/skyblocker/config/ImageRepoLoader.java @@ -8,6 +8,7 @@ import java.nio.file.Path; import java.nio.file.StandardCopyOption; import java.util.concurrent.CompletableFuture; +import java.util.concurrent.Executors; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; @@ -85,7 +86,7 @@ private static void update(int retries) { update(retries + 1); } } - }); + }, Executors.newVirtualThreadPerTaskExecutor()); } /** @@ -96,7 +97,7 @@ private static String checkSavedCommitData() throws IOException { if (Files.exists(file)) { try (BufferedReader reader = Files.newBufferedReader(file)) { - CommitData commitData = CommitData.CODEC.parse(JsonOps.INSTANCE, JsonParser.parseReader(reader)).result().orElseThrow(); + CommitData commitData = CommitData.CODEC.parse(JsonOps.INSTANCE, JsonParser.parseReader(reader)).getOrThrow(); return commitData.commit(); } @@ -115,7 +116,7 @@ private static void writeCommitData(String newHash) throws IOException { CommitData commitData = new CommitData(newHash, System.currentTimeMillis()); try (BufferedWriter writer = Files.newBufferedWriter(file)) { - SkyblockerMod.GSON.toJson(CommitData.CODEC.encodeStart(JsonOps.INSTANCE, commitData).result().orElseThrow(), writer); + SkyblockerMod.GSON.toJson(CommitData.CODEC.encodeStart(JsonOps.INSTANCE, commitData).getOrThrow(), writer); } } diff --git a/src/main/java/de/hysky/skyblocker/config/SkyblockerConfigManager.java b/src/main/java/de/hysky/skyblocker/config/SkyblockerConfigManager.java index 70578822d6..31f1357d96 100644 --- a/src/main/java/de/hysky/skyblocker/config/SkyblockerConfigManager.java +++ b/src/main/java/de/hysky/skyblocker/config/SkyblockerConfigManager.java @@ -4,7 +4,7 @@ import com.mojang.brigadier.builder.LiteralArgumentBuilder; import de.hysky.skyblocker.SkyblockerMod; import de.hysky.skyblocker.config.categories.*; -import de.hysky.skyblocker.mixin.accessor.HandledScreenAccessor; +import de.hysky.skyblocker.mixins.accessors.HandledScreenAccessor; import de.hysky.skyblocker.utils.scheduler.Scheduler; import dev.isxander.yacl3.api.YetAnotherConfigLib; import dev.isxander.yacl3.config.v2.api.ConfigClassHandler; diff --git a/src/main/java/de/hysky/skyblocker/config/categories/QuickNavigationCategory.java b/src/main/java/de/hysky/skyblocker/config/categories/QuickNavigationCategory.java index e26841155d..4b3c0dfdf0 100644 --- a/src/main/java/de/hysky/skyblocker/config/categories/QuickNavigationCategory.java +++ b/src/main/java/de/hysky/skyblocker/config/categories/QuickNavigationCategory.java @@ -4,6 +4,7 @@ import de.hysky.skyblocker.config.SkyblockerConfig; import dev.isxander.yacl3.api.ConfigCategory; import dev.isxander.yacl3.api.Option; +import dev.isxander.yacl3.api.OptionDescription; import dev.isxander.yacl3.api.OptionGroup; import dev.isxander.yacl3.api.controller.IntegerFieldControllerBuilder; import dev.isxander.yacl3.api.controller.StringControllerBuilder; @@ -51,6 +52,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.quickNav.button.item.nbt")) + .description(OptionDescription.of(Text.translatable("text.autoconfig.skyblocker.option.quickNav.button.item.nbt.@Tooltip"))) .binding(defaults.quickNav.button1.item.nbt, () -> config.quickNav.button1.item.nbt, newValue -> config.quickNav.button1.item.nbt = newValue) @@ -99,6 +101,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.quickNav.button.item.nbt")) + .description(OptionDescription.of(Text.translatable("text.autoconfig.skyblocker.option.quickNav.button.item.nbt.@Tooltip"))) .binding(defaults.quickNav.button2.item.nbt, () -> config.quickNav.button2.item.nbt, newValue -> config.quickNav.button2.item.nbt = newValue) @@ -147,6 +150,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.quickNav.button.item.nbt")) + .description(OptionDescription.of(Text.translatable("text.autoconfig.skyblocker.option.quickNav.button.item.nbt.@Tooltip"))) .binding(defaults.quickNav.button3.item.nbt, () -> config.quickNav.button3.item.nbt, newValue -> config.quickNav.button3.item.nbt = newValue) @@ -195,6 +199,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.quickNav.button.item.nbt")) + .description(OptionDescription.of(Text.translatable("text.autoconfig.skyblocker.option.quickNav.button.item.nbt.@Tooltip"))) .binding(defaults.quickNav.button4.item.nbt, () -> config.quickNav.button4.item.nbt, newValue -> config.quickNav.button4.item.nbt = newValue) @@ -243,6 +248,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.quickNav.button.item.nbt")) + .description(OptionDescription.of(Text.translatable("text.autoconfig.skyblocker.option.quickNav.button.item.nbt.@Tooltip"))) .binding(defaults.quickNav.button5.item.nbt, () -> config.quickNav.button5.item.nbt, newValue -> config.quickNav.button5.item.nbt = newValue) @@ -291,6 +297,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.quickNav.button.item.nbt")) + .description(OptionDescription.of(Text.translatable("text.autoconfig.skyblocker.option.quickNav.button.item.nbt.@Tooltip"))) .binding(defaults.quickNav.button6.item.nbt, () -> config.quickNav.button6.item.nbt, newValue -> config.quickNav.button6.item.nbt = newValue) @@ -339,6 +346,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.quickNav.button.item.nbt")) + .description(OptionDescription.of(Text.translatable("text.autoconfig.skyblocker.option.quickNav.button.item.nbt.@Tooltip"))) .binding(defaults.quickNav.button7.item.nbt, () -> config.quickNav.button7.item.nbt, newValue -> config.quickNav.button7.item.nbt = newValue) @@ -387,6 +395,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.quickNav.button.item.nbt")) + .description(OptionDescription.of(Text.translatable("text.autoconfig.skyblocker.option.quickNav.button.item.nbt.@Tooltip"))) .binding(defaults.quickNav.button8.item.nbt, () -> config.quickNav.button8.item.nbt, newValue -> config.quickNav.button8.item.nbt = newValue) @@ -435,6 +444,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.quickNav.button.item.nbt")) + .description(OptionDescription.of(Text.translatable("text.autoconfig.skyblocker.option.quickNav.button.item.nbt.@Tooltip"))) .binding(defaults.quickNav.button9.item.nbt, () -> config.quickNav.button9.item.nbt, newValue -> config.quickNav.button9.item.nbt = newValue) @@ -483,6 +493,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.quickNav.button.item.nbt")) + .description(OptionDescription.of(Text.translatable("text.autoconfig.skyblocker.option.quickNav.button.item.nbt.@Tooltip"))) .binding(defaults.quickNav.button10.item.nbt, () -> config.quickNav.button10.item.nbt, newValue -> config.quickNav.button10.item.nbt = newValue) @@ -531,6 +542,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.quickNav.button.item.nbt")) + .description(OptionDescription.of(Text.translatable("text.autoconfig.skyblocker.option.quickNav.button.item.nbt.@Tooltip"))) .binding(defaults.quickNav.button11.item.nbt, () -> config.quickNav.button11.item.nbt, newValue -> config.quickNav.button11.item.nbt = newValue) @@ -579,6 +591,7 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig .build()) .option(Option.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.quickNav.button.item.nbt")) + .description(OptionDescription.of(Text.translatable("text.autoconfig.skyblocker.option.quickNav.button.item.nbt.@Tooltip"))) .binding(defaults.quickNav.button12.item.nbt, () -> config.quickNav.button12.item.nbt, newValue -> config.quickNav.button12.item.nbt = newValue) diff --git a/src/main/java/de/hysky/skyblocker/debug/Debug.java b/src/main/java/de/hysky/skyblocker/debug/Debug.java index 86adcac652..8c883b30e9 100644 --- a/src/main/java/de/hysky/skyblocker/debug/Debug.java +++ b/src/main/java/de/hysky/skyblocker/debug/Debug.java @@ -3,26 +3,37 @@ import com.mojang.brigadier.Command; import com.mojang.brigadier.builder.LiteralArgumentBuilder; import de.hysky.skyblocker.SkyblockerMod; +import de.hysky.skyblocker.utils.Constants; import de.hysky.skyblocker.utils.ItemUtils; import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback; import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; import net.fabricmc.loader.api.FabricLoader; +import net.minecraft.entity.decoration.ArmorStandEntity; +import net.minecraft.item.ItemStack; +import net.minecraft.predicate.entity.EntityPredicates; import net.minecraft.text.Text; import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.literal; +import java.util.List; + public class Debug { private static final boolean DEBUG_ENABLED = Boolean.parseBoolean(System.getProperty("skyblocker.debug", "false")); + private static boolean showInvisibleArmorStands = false; + public static boolean debugEnabled() { return DEBUG_ENABLED || FabricLoader.getInstance().isDevelopmentEnvironment(); } public static void init() { if (debugEnabled()) { + SnapshotDebug.init(); ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> dispatcher.register(literal(SkyblockerMod.NAMESPACE).then(literal("debug") .then(dumpPlayersCommand()) - .then(ItemUtils.dumpHeldItemNbtCommand()) + .then(ItemUtils.dumpHeldItemCommand()) + .then(toggleShowingInvisibleArmorStands()) + .then(dumpArmorStandHeadTextures()) ))); } } @@ -34,4 +45,36 @@ private static LiteralArgumentBuilder dumpPlayersComm return Command.SINGLE_SUCCESS; }); } + + private static LiteralArgumentBuilder toggleShowingInvisibleArmorStands() { + return literal("toggleShowingInvisibleArmorStands") + .executes(context -> { + showInvisibleArmorStands = !showInvisibleArmorStands; + context.getSource().sendFeedback(Constants.PREFIX.get().append(Text.translatable("skyblocker.debug.toggledShowingInvisibleArmorStands", showInvisibleArmorStands))); + return Command.SINGLE_SUCCESS; + }); + } + + private static LiteralArgumentBuilder dumpArmorStandHeadTextures() { + return literal("dumpArmorStandHeadTextures") + .executes(context -> { + List armorStands = context.getSource().getWorld().getEntitiesByClass(ArmorStandEntity.class, context.getSource().getPlayer().getBoundingBox().expand(8d), EntityPredicates.NOT_MOUNTED); + + for (ArmorStandEntity armorStand : armorStands) { + Iterable equippedItems = armorStand.getEquippedItems(); + + for (ItemStack stack : equippedItems) { + String texture = ItemUtils.getHeadTexture(stack); + + if (!texture.isEmpty()) context.getSource().sendFeedback(Text.of(texture)); + } + } + + return Command.SINGLE_SUCCESS; + }); + } + + public static boolean shouldShowInvisibleArmorStands() { + return showInvisibleArmorStands; + } } diff --git a/src/main/java/de/hysky/skyblocker/debug/SnapshotDebug.java b/src/main/java/de/hysky/skyblocker/debug/SnapshotDebug.java new file mode 100644 index 0000000000..bd4abd2c5c --- /dev/null +++ b/src/main/java/de/hysky/skyblocker/debug/SnapshotDebug.java @@ -0,0 +1,32 @@ +package de.hysky.skyblocker.debug; + +import de.hysky.skyblocker.utils.render.RenderHelper; +import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext; +import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents; +import net.minecraft.SharedConstants; +import net.minecraft.text.Text; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Vec3d; + +public class SnapshotDebug { + private static final float[] RED = { 1.0f, 0.0f, 0.0f }; + private static final float ALPHA = 0.5f; + private static final float LINE_WIDTH = 8f; + + private static boolean isInSnapshot() { + return !SharedConstants.getGameVersion().isStable(); + } + + static void init() { + if (isInSnapshot()) { + WorldRenderEvents.AFTER_TRANSLUCENT.register(SnapshotDebug::renderTest); + } + } + + private static void renderTest(WorldRenderContext wrc) { + RenderHelper.renderFilledWithBeaconBeam(wrc, new BlockPos(175, 63, -14), RED, ALPHA, true); + RenderHelper.renderLinesFromPoints(wrc, new Vec3d[] { new Vec3d(173, 66, -7.5), new Vec3d(178, 66, -7.5) }, RED, ALPHA, LINE_WIDTH, false); + RenderHelper.renderQuad(wrc, new Vec3d[] { new Vec3d(183, 66, -16), new Vec3d(183, 63, -16), new Vec3d(183, 63, -14), new Vec3d(183, 66, -14) }, RED, ALPHA, false); + RenderHelper.renderText(wrc, Text.of("Skyblocker on " + SharedConstants.getGameVersion().getName() + "!"), new Vec3d(175.5, 67.5, -7.5), false); + } +} diff --git a/src/main/java/de/hysky/skyblocker/events/HudRenderEvents.java b/src/main/java/de/hysky/skyblocker/events/HudRenderEvents.java new file mode 100644 index 0000000000..13e70498dc --- /dev/null +++ b/src/main/java/de/hysky/skyblocker/events/HudRenderEvents.java @@ -0,0 +1,50 @@ +package de.hysky.skyblocker.events; + +import net.fabricmc.fabric.api.event.Event; +import net.fabricmc.fabric.api.event.EventFactory; +import net.minecraft.client.gui.DrawContext; + +/** + * HUD render events that allow for proper layering between different HUD elements. + * This should always be preferred over Fabric's {@link net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback}. + * + * Perhaps in the future this system could be PR'd to Fabric. + */ +public class HudRenderEvents { + /** + * Called after the hotbar, status bars, and experience bar have been rendered. + */ + public static final Event AFTER_MAIN_HUD = createEventForStage(); + + /** + * Called before the {@link net.minecraft.client.gui.hud.ChatHud} is rendered. + */ + public static final Event BEFORE_CHAT = createEventForStage(); + + /** + * Called after the entire HUD is rendered. + */ + public static final Event LAST = createEventForStage(); + + private static Event createEventForStage() { + return EventFactory.createArrayBacked(HudRenderStage.class, listeners -> (context, tickDelta) -> { + for (HudRenderStage listener : listeners) { + listener.onRender(context, tickDelta); + } + }); + } + + /** + * @implNote Similar to Fabric's {@link net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback} + */ + @FunctionalInterface + public interface HudRenderStage { + /** + * Called sometime during a specific HUD render stage. + * + * @param drawContext The {@link DrawContext} instance + * @param tickDelta Progress for linearly interpolating between the previous and current game state + */ + void onRender(DrawContext context, float tickDelta); + } +} diff --git a/src/main/java/de/hysky/skyblocker/mixin/ArmorTrimMixin.java b/src/main/java/de/hysky/skyblocker/mixin/ArmorTrimMixin.java deleted file mode 100644 index b9bdb52385..0000000000 --- a/src/main/java/de/hysky/skyblocker/mixin/ArmorTrimMixin.java +++ /dev/null @@ -1,34 +0,0 @@ -package de.hysky.skyblocker.mixin; - -import com.llamalad7.mixinextras.injector.ModifyReturnValue; -import com.llamalad7.mixinextras.sugar.Local; -import de.hysky.skyblocker.config.SkyblockerConfigManager; -import de.hysky.skyblocker.skyblock.item.CustomArmorTrims; -import de.hysky.skyblocker.utils.ItemUtils; -import de.hysky.skyblocker.utils.Utils; -import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; -import net.minecraft.item.ItemStack; -import net.minecraft.item.trim.ArmorTrim; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; - -import java.util.Optional; - -@Mixin(ArmorTrim.class) -public class ArmorTrimMixin { - - @ModifyReturnValue(method = "getTrim", at = @At("RETURN")) - private static Optional skyblocker$customArmorTrims(@SuppressWarnings("OptionalUsedAsFieldOrParameterType") Optional original, @Local ItemStack stack) { - if (Utils.isOnSkyblock()) { - Object2ObjectOpenHashMap customTrims = SkyblockerConfigManager.get().general.customArmorTrims; - String itemUuid = ItemUtils.getItemUuid(stack); - - if (customTrims.containsKey(itemUuid)) { - CustomArmorTrims.ArmorTrimId trimKey = customTrims.get(itemUuid); - return CustomArmorTrims.TRIMS_CACHE.getOrDefault(trimKey, original); - } - } - - return original; - } -} diff --git a/src/main/java/de/hysky/skyblocker/mixin/HandledScreenProviderMixin.java b/src/main/java/de/hysky/skyblocker/mixin/HandledScreenProviderMixin.java deleted file mode 100644 index bf330d8099..0000000000 --- a/src/main/java/de/hysky/skyblocker/mixin/HandledScreenProviderMixin.java +++ /dev/null @@ -1,82 +0,0 @@ -package de.hysky.skyblocker.mixin; - - -import de.hysky.skyblocker.config.SkyblockerConfigManager; -import de.hysky.skyblocker.skyblock.auction.AuctionBrowserScreen; -import de.hysky.skyblocker.skyblock.auction.AuctionHouseScreenHandler; -import de.hysky.skyblocker.skyblock.auction.AuctionViewScreen; -import de.hysky.skyblocker.skyblock.dungeon.partyfinder.PartyFinderScreen; -import de.hysky.skyblocker.skyblock.item.SkyblockCraftingTableScreenHandler; -import de.hysky.skyblocker.skyblock.item.SkyblockCraftingTableScreen; -import de.hysky.skyblocker.utils.Utils; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.screen.ingame.HandledScreens; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.screen.GenericContainerScreenHandler; -import net.minecraft.screen.ScreenHandler; -import net.minecraft.screen.ScreenHandlerType; -import net.minecraft.text.Text; -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(HandledScreens.Provider.class) -public interface HandledScreenProviderMixin { - @Inject(method = "open", at = @At("HEAD"), cancellable = true) - default void skyblocker$open(Text name, ScreenHandlerType type, MinecraftClient client, int id, CallbackInfo ci) { - ClientPlayerEntity player = client.player; - if (player == null) return; - if (!Utils.isOnSkyblock()) return; - T screenHandler = type.create(id, player.getInventory()); - if (!(screenHandler instanceof GenericContainerScreenHandler containerScreenHandler)) return; - String nameLowercase = name.getString().toLowerCase(); - // Better party finder - if (SkyblockerConfigManager.get().general.betterPartyFinder && PartyFinderScreen.possibleInventoryNames.contains(nameLowercase)) { - if (client.currentScreen != null) { - String lowerCase = client.currentScreen.getTitle().getString().toLowerCase(); - if (lowerCase.contains("group builder")) return; - if (lowerCase.contains("select tier")) { - PartyFinderScreen.isInKuudraPartyFinder = true; - } else if (lowerCase.contains("catacombs")) { - PartyFinderScreen.isInKuudraPartyFinder = false; - } - } - if (PartyFinderScreen.isInKuudraPartyFinder) return; - client.player.currentScreenHandler = containerScreenHandler; - if (client.currentScreen instanceof PartyFinderScreen screen) { - screen.updateHandler(containerScreenHandler, name); - } else { - client.setScreen(new PartyFinderScreen(containerScreenHandler, player.getInventory(), name)); - } - - ci.cancel(); - // Fancy AH - } else if (SkyblockerConfigManager.get().general.fancyAuctionHouse.enabled && (nameLowercase.contains("auctions browser") || nameLowercase.contains("auctions: "))) { - AuctionHouseScreenHandler auctionHouseScreenHandler = AuctionHouseScreenHandler.of(containerScreenHandler, false); - client.player.currentScreenHandler = auctionHouseScreenHandler; - if (client.currentScreen instanceof AuctionBrowserScreen auctionBrowserScreen) { - auctionBrowserScreen.changeHandler(auctionHouseScreenHandler); - } else client.setScreen(new AuctionBrowserScreen(auctionHouseScreenHandler, client.player.getInventory())); - ci.cancel(); - } else if (SkyblockerConfigManager.get().general.fancyAuctionHouse.enabled && nameLowercase.contains("auction view")) { - AuctionHouseScreenHandler auctionHouseScreenHandler = AuctionHouseScreenHandler.of(containerScreenHandler, true); - client.player.currentScreenHandler = auctionHouseScreenHandler; - if (client.currentScreen instanceof AuctionViewScreen auctionViewScreen) { - auctionViewScreen.changeHandler(auctionHouseScreenHandler); - } else - client.setScreen(new AuctionViewScreen(auctionHouseScreenHandler, client.player.getInventory(), name)); - ci.cancel(); - } else if (SkyblockerConfigManager.get().general.fancyAuctionHouse.enabled && (nameLowercase.contains("confirm purchase") || nameLowercase.contains("confirm bid")) && client.currentScreen instanceof AuctionViewScreen auctionViewScreen) { - client.setScreen(auctionViewScreen.getConfirmPurchasePopup(name)); - client.player.currentScreenHandler = containerScreenHandler; - ci.cancel(); - // Fancy crafting table - } else if (SkyblockerConfigManager.get().general.fancyCraftingTable && name.getString().toLowerCase().contains("craft item")) { - SkyblockCraftingTableScreenHandler skyblockCraftingTableScreenHandler = new SkyblockCraftingTableScreenHandler(containerScreenHandler, player.getInventory()); - client.player.currentScreenHandler = skyblockCraftingTableScreenHandler; - client.setScreen(new SkyblockCraftingTableScreen(skyblockCraftingTableScreenHandler, player.getInventory(), Text.literal("Craft Item"))); - ci.cancel(); - } - } -} diff --git a/src/main/java/de/hysky/skyblocker/mixin/ItemMixin.java b/src/main/java/de/hysky/skyblocker/mixin/ItemMixin.java deleted file mode 100644 index 6b49220bbf..0000000000 --- a/src/main/java/de/hysky/skyblocker/mixin/ItemMixin.java +++ /dev/null @@ -1,19 +0,0 @@ -package de.hysky.skyblocker.mixin; - -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import org.objectweb.asm.Opcodes; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -@Mixin(Item.class) -public abstract class ItemMixin { - @Redirect( - method = {"getItemBarColor", "getItemBarStep"}, - at = @At(value = "FIELD", target = "Lnet/minecraft/item/Item;maxDamage:I", opcode = Opcodes.GETFIELD) - ) - private int skyblocker$handlePickoDrillBar(Item item, ItemStack stack) { - return stack.getMaxDamage(); - } -} diff --git a/src/main/java/de/hysky/skyblocker/mixin/accessor/ItemStackAccessor.java b/src/main/java/de/hysky/skyblocker/mixin/accessor/ItemStackAccessor.java deleted file mode 100644 index e3bd69aa51..0000000000 --- a/src/main/java/de/hysky/skyblocker/mixin/accessor/ItemStackAccessor.java +++ /dev/null @@ -1,14 +0,0 @@ -package de.hysky.skyblocker.mixin.accessor; - -import net.minecraft.item.ItemStack; -import net.minecraft.text.Style; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -@Mixin(ItemStack.class) -public interface ItemStackAccessor { - @Accessor - static Style getLORE_STYLE() { - throw new UnsupportedOperationException(); - } -} diff --git a/src/main/java/de/hysky/skyblocker/mixin/AbstractInventoryScreenMixin.java b/src/main/java/de/hysky/skyblocker/mixins/AbstractInventoryScreenMixin.java similarity index 95% rename from src/main/java/de/hysky/skyblocker/mixin/AbstractInventoryScreenMixin.java rename to src/main/java/de/hysky/skyblocker/mixins/AbstractInventoryScreenMixin.java index d0d4b9f75c..5315182633 100644 --- a/src/main/java/de/hysky/skyblocker/mixin/AbstractInventoryScreenMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixins/AbstractInventoryScreenMixin.java @@ -1,4 +1,4 @@ -package de.hysky.skyblocker.mixin; +package de.hysky.skyblocker.mixins; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; diff --git a/src/main/java/de/hysky/skyblocker/mixin/BatEntityMixin.java b/src/main/java/de/hysky/skyblocker/mixins/BatEntityMixin.java similarity index 94% rename from src/main/java/de/hysky/skyblocker/mixin/BatEntityMixin.java rename to src/main/java/de/hysky/skyblocker/mixins/BatEntityMixin.java index fa97e5467c..7ee59be1b4 100644 --- a/src/main/java/de/hysky/skyblocker/mixin/BatEntityMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixins/BatEntityMixin.java @@ -1,4 +1,4 @@ -package de.hysky.skyblocker.mixin; +package de.hysky.skyblocker.mixins; import de.hysky.skyblocker.skyblock.dungeon.secrets.DungeonManager; import net.minecraft.entity.EntityType; diff --git a/src/main/java/de/hysky/skyblocker/mixin/ClientPlayNetworkHandlerMixin.java b/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java similarity index 98% rename from src/main/java/de/hysky/skyblocker/mixin/ClientPlayNetworkHandlerMixin.java rename to src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java index 743f949f6e..0a5ebc6487 100644 --- a/src/main/java/de/hysky/skyblocker/mixin/ClientPlayNetworkHandlerMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java @@ -1,7 +1,7 @@ -package de.hysky.skyblocker.mixin; +package de.hysky.skyblocker.mixins; import com.llamalad7.mixinextras.injector.ModifyExpressionValue; -import com.llamalad7.mixinextras.injector.WrapWithCondition; +import com.llamalad7.mixinextras.injector.v2.WrapWithCondition; import com.llamalad7.mixinextras.sugar.Local; import de.hysky.skyblocker.skyblock.FishingHelper; import de.hysky.skyblocker.skyblock.dungeon.DungeonScore; diff --git a/src/main/java/de/hysky/skyblocker/mixin/ClientPlayerEntityMixin.java b/src/main/java/de/hysky/skyblocker/mixins/ClientPlayerEntityMixin.java similarity index 99% rename from src/main/java/de/hysky/skyblocker/mixin/ClientPlayerEntityMixin.java rename to src/main/java/de/hysky/skyblocker/mixins/ClientPlayerEntityMixin.java index 8fb2fda4b6..d4c930d27c 100644 --- a/src/main/java/de/hysky/skyblocker/mixin/ClientPlayerEntityMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixins/ClientPlayerEntityMixin.java @@ -1,4 +1,4 @@ -package de.hysky.skyblocker.mixin; +package de.hysky.skyblocker.mixins; import com.mojang.authlib.GameProfile; import de.hysky.skyblocker.config.SkyblockerConfigManager; diff --git a/src/main/java/de/hysky/skyblocker/mixin/CommandTreeS2CPacketMixin.java b/src/main/java/de/hysky/skyblocker/mixins/CommandTreeS2CPacketMixin.java similarity index 96% rename from src/main/java/de/hysky/skyblocker/mixin/CommandTreeS2CPacketMixin.java rename to src/main/java/de/hysky/skyblocker/mixins/CommandTreeS2CPacketMixin.java index 1cc1b8de59..289923c843 100644 --- a/src/main/java/de/hysky/skyblocker/mixin/CommandTreeS2CPacketMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixins/CommandTreeS2CPacketMixin.java @@ -1,4 +1,4 @@ -package de.hysky.skyblocker.mixin; +package de.hysky.skyblocker.mixins; import com.llamalad7.mixinextras.injector.ModifyExpressionValue; import com.mojang.brigadier.tree.CommandNode; diff --git a/src/main/java/de/hysky/skyblocker/mixins/ComponentHolderMixin.java b/src/main/java/de/hysky/skyblocker/mixins/ComponentHolderMixin.java new file mode 100644 index 0000000000..8fa03cdc14 --- /dev/null +++ b/src/main/java/de/hysky/skyblocker/mixins/ComponentHolderMixin.java @@ -0,0 +1,39 @@ +package de.hysky.skyblocker.mixins; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; + +import com.llamalad7.mixinextras.injector.ModifyReturnValue; + +import de.hysky.skyblocker.config.SkyblockerConfigManager; +import de.hysky.skyblocker.skyblock.item.CustomArmorTrims; +import de.hysky.skyblocker.utils.ItemUtils; +import de.hysky.skyblocker.utils.Utils; +import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; +import net.minecraft.component.ComponentHolder; +import net.minecraft.component.DataComponentType; +import net.minecraft.component.DataComponentTypes; +import net.minecraft.item.ItemStack; +import net.minecraft.item.trim.ArmorTrim; + +@Mixin(ComponentHolder.class) +public interface ComponentHolderMixin { + + @SuppressWarnings("unchecked") + @ModifyReturnValue(method = "get", at = @At("RETURN")) + private T skyblocker$customArmorTrims(T original, DataComponentType dataComponentType) { + if (Utils.isOnSkyblock() && ((Object) this) instanceof ItemStack stack) { + if (dataComponentType == DataComponentTypes.TRIM) { + Object2ObjectOpenHashMap customTrims = SkyblockerConfigManager.get().general.customArmorTrims; + String itemUuid = ItemUtils.getItemUuid(stack); + + if (customTrims.containsKey(itemUuid)) { + CustomArmorTrims.ArmorTrimId trimKey = customTrims.get(itemUuid); + return (T) CustomArmorTrims.TRIMS_CACHE.getOrDefault(trimKey, (ArmorTrim) original); + } + } + } + + return original; + } +} diff --git a/src/main/java/de/hysky/skyblocker/mixin/DataTrackerMixin.java b/src/main/java/de/hysky/skyblocker/mixins/DataTrackerMixin.java similarity index 86% rename from src/main/java/de/hysky/skyblocker/mixin/DataTrackerMixin.java rename to src/main/java/de/hysky/skyblocker/mixins/DataTrackerMixin.java index d9db5dae70..77bb09bbd1 100644 --- a/src/main/java/de/hysky/skyblocker/mixin/DataTrackerMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixins/DataTrackerMixin.java @@ -1,14 +1,15 @@ -package de.hysky.skyblocker.mixin; +package de.hysky.skyblocker.mixins; import com.llamalad7.mixinextras.sugar.Local; import de.hysky.skyblocker.config.SkyblockerConfigManager; -import de.hysky.skyblocker.mixin.accessor.EndermanEntityAccessor; +import de.hysky.skyblocker.mixins.accessors.EndermanEntityAccessor; import de.hysky.skyblocker.skyblock.entity.MobGlow; import de.hysky.skyblocker.utils.Utils; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.client.MinecraftClient; import net.minecraft.entity.Entity; +import net.minecraft.entity.data.DataTracked; import net.minecraft.entity.data.DataTracker; import net.minecraft.sound.SoundEvents; import net.minecraft.text.Text; @@ -26,14 +27,14 @@ public abstract class DataTrackerMixin { @Shadow @Final - private Entity trackedEntity; + private DataTracked trackedEntity; @SuppressWarnings("ConstantValue") @Inject(method = "writeUpdatedEntries", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/data/DataTracker;copyToFrom(Lnet/minecraft/entity/data/DataTracker$Entry;Lnet/minecraft/entity/data/DataTracker$SerializedEntry;)V")) private void skyblocker$onWriteUpdatedEntries(CallbackInfo ci, @Local DataTracker.Entry entry, @Local DataTracker.SerializedEntry serializedEntry) { if (Utils.isInTheEnd() && SkyblockerConfigManager.get().slayer.endermanSlayer.enableYangGlyphsNotification && entry.getData() == EndermanEntityAccessor.getCARRIED_BLOCK() && entry.get() instanceof Optional value && value.isPresent() && value.get() instanceof BlockState state && state.isOf(Blocks.BEACON) && ((Optional) serializedEntry.value()).isEmpty()) { MinecraftClient client = MinecraftClient.getInstance(); - if (MobGlow.getArmorStands(trackedEntity).stream().anyMatch(armorStand -> armorStand.getName().getString().contains(client.getSession().getUsername()))) { + if (trackedEntity instanceof Entity entity && MobGlow.getArmorStands(entity).stream().anyMatch(armorStand -> armorStand.getName().getString().contains(client.getSession().getUsername()))) { client.inGameHud.setTitleTicks(5, 20, 10); client.inGameHud.setTitle(Text.literal("Yang Glyph!").formatted(Formatting.RED)); client.player.playSound(SoundEvents.BLOCK_NOTE_BLOCK_PLING.value(), 100f, 0.1f); @@ -41,7 +42,6 @@ public abstract class DataTrackerMixin { } } - @SuppressWarnings({"MixinAnnotationTarget", "UnresolvedMixinReference"}) @Inject(method = "copyToFrom", at = @At(value = "NEW", target = "Ljava/lang/IllegalStateException;"), cancellable = true) public void skyblocker$ignoreInvalidDataExceptions(CallbackInfo ci) { //These exceptions cause annoying small lag spikes for some reason diff --git a/src/main/java/de/hysky/skyblocker/mixin/DrawContextMixin.java b/src/main/java/de/hysky/skyblocker/mixins/DrawContextMixin.java similarity index 90% rename from src/main/java/de/hysky/skyblocker/mixin/DrawContextMixin.java rename to src/main/java/de/hysky/skyblocker/mixins/DrawContextMixin.java index b33a8b23a9..7964b11476 100644 --- a/src/main/java/de/hysky/skyblocker/mixin/DrawContextMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixins/DrawContextMixin.java @@ -1,4 +1,4 @@ -package de.hysky.skyblocker.mixin; +package de.hysky.skyblocker.mixins; import com.llamalad7.mixinextras.injector.ModifyExpressionValue; import com.llamalad7.mixinextras.sugar.Local; @@ -36,10 +36,10 @@ public abstract class DrawContextMixin { if (!SkyblockerConfigManager.get().general.itemInfoDisplay.attributeShardInfo) return; if (Utils.isOnSkyblock()) { - NbtCompound extraAttributes = ItemUtils.getExtraAttributes(stack); + NbtCompound customData = ItemUtils.getCustomData(stack); - if (extraAttributes != null && extraAttributes.getString(ItemUtils.ID).equals("ATTRIBUTE_SHARD")) { - NbtCompound attributesTag = extraAttributes.getCompound("attributes"); + if (ItemUtils.getItemId(stack).equals("ATTRIBUTE_SHARD")) { + NbtCompound attributesTag = customData.getCompound("attributes"); String[] attributes = attributesTag.getKeys().toArray(String[]::new); if (attributes.length != 0) { @@ -65,7 +65,7 @@ public abstract class DrawContextMixin { @ModifyExpressionValue(method = "drawItemInSlot(Lnet/minecraft/client/font/TextRenderer;Lnet/minecraft/item/ItemStack;IILjava/lang/String;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/ItemCooldownManager;getCooldownProgress(Lnet/minecraft/item/Item;F)F")) - private float skyblocker$modifyItemCooldown(float cooldownProgress, @Local ItemStack stack) { + private float skyblocker$modifyItemCooldown(float cooldownProgress, @Local(argsOnly = true) ItemStack stack) { return Utils.isOnSkyblock() && ItemCooldowns.isOnCooldown(stack) ? ItemCooldowns.getItemCooldownEntry(stack).getRemainingCooldownPercent() : cooldownProgress; } } diff --git a/src/main/java/de/hysky/skyblocker/mixin/DyeableItemMixin.java b/src/main/java/de/hysky/skyblocker/mixins/DyedColorComponentMixin.java similarity index 50% rename from src/main/java/de/hysky/skyblocker/mixin/DyeableItemMixin.java rename to src/main/java/de/hysky/skyblocker/mixins/DyedColorComponentMixin.java index 64f6a4525f..0fd4f8a09f 100644 --- a/src/main/java/de/hysky/skyblocker/mixin/DyeableItemMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixins/DyedColorComponentMixin.java @@ -1,27 +1,32 @@ -package de.hysky.skyblocker.mixin; +package de.hysky.skyblocker.mixins; import com.llamalad7.mixinextras.injector.ModifyReturnValue; +import com.llamalad7.mixinextras.sugar.Local; + import de.hysky.skyblocker.config.SkyblockerConfigManager; import de.hysky.skyblocker.skyblock.item.CustomArmorAnimatedDyes; import de.hysky.skyblocker.utils.ItemUtils; import de.hysky.skyblocker.utils.Utils; -import net.minecraft.item.DyeableItem; +import net.minecraft.component.type.DyedColorComponent; import net.minecraft.item.ItemStack; +import net.minecraft.util.math.ColorHelper; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; -@Mixin(DyeableItem.class) -public interface DyeableItemMixin { +@Mixin(DyedColorComponent.class) +public record DyedColorComponentMixin() { + @ModifyReturnValue(method = "getColor", at = @At("RETURN")) - private int skyblocker$customDyeColor(int originalColor, ItemStack stack) { + private static int skyblocker$customDyeColor(int originalColor, @Local(argsOnly = true) ItemStack stack) { if (Utils.isOnSkyblock()) { String itemUuid = ItemUtils.getItemUuid(stack); if (SkyblockerConfigManager.get().general.customAnimatedDyes.containsKey(itemUuid)) { - return CustomArmorAnimatedDyes.animateColorTransition(SkyblockerConfigManager.get().general.customAnimatedDyes.get(itemUuid)); + return ColorHelper.Argb.fullAlpha(CustomArmorAnimatedDyes.animateColorTransition(SkyblockerConfigManager.get().general.customAnimatedDyes.get(itemUuid))); } - return SkyblockerConfigManager.get().general.customDyeColors.getOrDefault(itemUuid, originalColor); + return ColorHelper.Argb.fullAlpha(SkyblockerConfigManager.get().general.customDyeColors.getOrDefault(itemUuid, originalColor)); } return originalColor; diff --git a/src/main/java/de/hysky/skyblocker/mixin/EntityRenderDispatcherMixin.java b/src/main/java/de/hysky/skyblocker/mixins/EntityRenderDispatcherMixin.java similarity index 85% rename from src/main/java/de/hysky/skyblocker/mixin/EntityRenderDispatcherMixin.java rename to src/main/java/de/hysky/skyblocker/mixins/EntityRenderDispatcherMixin.java index 5cf88588ee..79d1306813 100644 --- a/src/main/java/de/hysky/skyblocker/mixin/EntityRenderDispatcherMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixins/EntityRenderDispatcherMixin.java @@ -1,4 +1,4 @@ -package de.hysky.skyblocker.mixin; +package de.hysky.skyblocker.mixins; import com.llamalad7.mixinextras.injector.ModifyExpressionValue; import de.hysky.skyblocker.debug.Debug; @@ -13,6 +13,6 @@ public class EntityRenderDispatcherMixin { @ModifyExpressionValue(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;isInvisible()Z", ordinal = 1)) private boolean skyblocker$armorStandHitboxVisible(boolean invisible, E entity) { - return (!(entity instanceof ArmorStandEntity) || !Utils.isOnHypixel() || !Debug.debugEnabled()) && invisible; + return (!(entity instanceof ArmorStandEntity) || !Utils.isOnHypixel() || !Debug.debugEnabled() || !Debug.shouldShowInvisibleArmorStands()) && invisible; } } diff --git a/src/main/java/de/hysky/skyblocker/mixin/FarmlandBlockMixin.java b/src/main/java/de/hysky/skyblocker/mixins/FarmlandBlockMixin.java similarity index 94% rename from src/main/java/de/hysky/skyblocker/mixin/FarmlandBlockMixin.java rename to src/main/java/de/hysky/skyblocker/mixins/FarmlandBlockMixin.java index dfa886c4ed..4c981d9a2c 100644 --- a/src/main/java/de/hysky/skyblocker/mixin/FarmlandBlockMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixins/FarmlandBlockMixin.java @@ -1,4 +1,4 @@ -package de.hysky.skyblocker.mixin; +package de.hysky.skyblocker.mixins; import com.llamalad7.mixinextras.injector.ModifyReturnValue; import de.hysky.skyblocker.config.SkyblockerConfigManager; @@ -30,7 +30,6 @@ protected FarmlandBlockMixin(Settings settings) { return Utils.isOnSkyblock() && SkyblockerConfigManager.get().general.hitbox.oldFarmlandHitbox ? VoxelShapes.fullCube() : original; } - @SuppressWarnings("deprecation") @Override public VoxelShape getCullingShape(BlockState state, BlockView world, BlockPos pos) { return SHAPE; diff --git a/src/main/java/de/hysky/skyblocker/mixin/GenericContainerScreenHandlerMixin.java b/src/main/java/de/hysky/skyblocker/mixins/GenericContainerScreenHandlerMixin.java similarity index 97% rename from src/main/java/de/hysky/skyblocker/mixin/GenericContainerScreenHandlerMixin.java rename to src/main/java/de/hysky/skyblocker/mixins/GenericContainerScreenHandlerMixin.java index a7843ba2ec..f75af09a20 100644 --- a/src/main/java/de/hysky/skyblocker/mixin/GenericContainerScreenHandlerMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixins/GenericContainerScreenHandlerMixin.java @@ -1,4 +1,4 @@ -package de.hysky.skyblocker.mixin; +package de.hysky.skyblocker.mixins; import de.hysky.skyblocker.SkyblockerMod; import de.hysky.skyblocker.skyblock.dungeon.partyfinder.PartyFinderScreen; diff --git a/src/main/java/de/hysky/skyblocker/mixin/HandledScreenMixin.java b/src/main/java/de/hysky/skyblocker/mixins/HandledScreenMixin.java similarity index 85% rename from src/main/java/de/hysky/skyblocker/mixin/HandledScreenMixin.java rename to src/main/java/de/hysky/skyblocker/mixins/HandledScreenMixin.java index 7d2f849ed6..9ae25d85e2 100644 --- a/src/main/java/de/hysky/skyblocker/mixin/HandledScreenMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixins/HandledScreenMixin.java @@ -1,4 +1,4 @@ -package de.hysky.skyblocker.mixin; +package de.hysky.skyblocker.mixins; import com.llamalad7.mixinextras.sugar.Local; import com.mojang.blaze3d.systems.RenderSystem; @@ -97,7 +97,7 @@ protected HandledScreenMixin(Text title) { public void skyblocker$keyPressed(int keyCode, int scanCode, int modifiers, CallbackInfoReturnable cir) { if (this.client != null && this.focusedSlot != null && keyCode != 256) { //wiki lookup - if (!this.client.options.inventoryKey.matchesKey(keyCode, scanCode) && WikiLookup.wikiLookup.matchesKey(keyCode, scanCode)) { + if (!this.client.options.inventoryKey.matchesKey(keyCode, scanCode) && WikiLookup.wikiLookup.matchesKey(keyCode, scanCode) && client.player != null) { WikiLookup.openWiki(this.focusedSlot, client.player); } //item protection @@ -165,6 +165,8 @@ protected HandledScreenMixin(Text title) { /** * The naming of this method in yarn is half true, its mostly to handle slot/item interactions (which are mouse or keyboard clicks) * For example, using the drop key bind while hovering over an item will invoke this method to drop the players item + * + * @implNote This runs before {@link ScreenHandler#onSlotClick(int, int, SlotActionType, net.minecraft.entity.player.PlayerEntity)} */ @Inject(method = "onMouseClick(Lnet/minecraft/screen/slot/Slot;IILnet/minecraft/screen/slot/SlotActionType;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerInteractionManager;clickSlot(IIILnet/minecraft/screen/slot/SlotActionType;Lnet/minecraft/entity/player/PlayerEntity;)V"), cancellable = true) private void skyblocker$onSlotClick(Slot slot, int slotId, int button, SlotActionType actionType, CallbackInfo ci) { @@ -201,11 +203,11 @@ protected HandledScreenMixin(Text title) { return; } if (this.handler instanceof GenericContainerScreenHandler genericContainerScreenHandler && genericContainerScreenHandler.getRows() == 6) { - VisitorHelper.onSlotClick(slot, slotId, title); + VisitorHelper.onSlotClick(slot, slotId, title, genericContainerScreenHandler.getSlot(13).getStack()); // Prevent selling to NPC shops ItemStack sellStack = this.handler.slots.get(49).getStack(); - if (sellStack.getName().getString().equals("Sell Item") || ItemUtils.getNbtTooltip(sellStack, text -> text.contains("buyback")) != null) { + if (sellStack.getName().getString().equals("Sell Item") || ItemUtils.getLoreLineIf(sellStack, text -> text.contains("buyback")) != null) { if (slotId != 49 && ItemProtection.isItemProtected(stack)) { ci.cancel(); return; @@ -213,21 +215,32 @@ protected HandledScreenMixin(Text title) { } } + if (currentSolver != null) { + SkyblockerMod.getInstance().containerSolverManager.onSlotClick(slotId, stack); + } + // Experiment Solvers if (currentSolver instanceof ExperimentSolver experimentSolver && experimentSolver.getState() == ExperimentSolver.State.SHOW && slot.inventory instanceof SimpleInventory) { - if (experimentSolver instanceof ChronomatronSolver chronomatronSolver) { - Item item = chronomatronSolver.getChronomatronSlots().get(chronomatronSolver.getChronomatronCurrentOrdinal()); - if ((stack.isOf(item) || ChronomatronSolver.TERRACOTTA_TO_GLASS.get(stack.getItem()) == item) && chronomatronSolver.incrementChronomatronCurrentOrdinal() >= chronomatronSolver.getChronomatronSlots().size()) { - chronomatronSolver.setState(ExperimentSolver.State.END); + switch (experimentSolver) { + case ChronomatronSolver chronomatronSolver -> { + Item item = chronomatronSolver.getChronomatronSlots().get(chronomatronSolver.getChronomatronCurrentOrdinal()); + if ((stack.isOf(item) || ChronomatronSolver.TERRACOTTA_TO_GLASS.get(stack.getItem()) == item) && chronomatronSolver.incrementChronomatronCurrentOrdinal() >= chronomatronSolver.getChronomatronSlots().size()) { + chronomatronSolver.setState(ExperimentSolver.State.END); + } + } + + case SuperpairsSolver superpairsSolver -> { + superpairsSolver.setSuperpairsPrevClickedSlot(slot.getIndex()); + superpairsSolver.setSuperpairsCurrentSlot(ItemStack.EMPTY); } - } else if (experimentSolver instanceof SuperpairsSolver superpairsSolver) { - superpairsSolver.setSuperpairsPrevClickedSlot(slot.getIndex()); - superpairsSolver.setSuperpairsCurrentSlot(ItemStack.EMPTY); - } else if (experimentSolver instanceof UltrasequencerSolver ultrasequencerSolver && slot.getIndex() == ultrasequencerSolver.getUltrasequencerNextSlot()) { - int count = ultrasequencerSolver.getSlots().get(ultrasequencerSolver.getUltrasequencerNextSlot()).getCount() + 1; - ultrasequencerSolver.getSlots().entrySet().stream().filter(entry -> entry.getValue().getCount() == count).findAny().map(Map.Entry::getKey).ifPresentOrElse(ultrasequencerSolver::setUltrasequencerNextSlot, () -> ultrasequencerSolver.setState(ExperimentSolver.State.END)); + + case UltrasequencerSolver ultrasequencerSolver when slot.getIndex() == ultrasequencerSolver.getUltrasequencerNextSlot() -> { + int count = ultrasequencerSolver.getSlots().get(ultrasequencerSolver.getUltrasequencerNextSlot()).getCount() + 1; + ultrasequencerSolver.getSlots().entrySet().stream().filter(entry -> entry.getValue().getCount() == count).findAny().map(Map.Entry::getKey).ifPresentOrElse(ultrasequencerSolver::setUltrasequencerNextSlot, () -> ultrasequencerSolver.setState(ExperimentSolver.State.END)); + } + + default -> { /*Do Nothing*/ } } - return; } } diff --git a/src/main/java/de/hysky/skyblocker/mixins/HandledScreenProviderMixin.java b/src/main/java/de/hysky/skyblocker/mixins/HandledScreenProviderMixin.java new file mode 100644 index 0000000000..da87c2a3f7 --- /dev/null +++ b/src/main/java/de/hysky/skyblocker/mixins/HandledScreenProviderMixin.java @@ -0,0 +1,99 @@ +package de.hysky.skyblocker.mixins; + + +import de.hysky.skyblocker.config.SkyblockerConfigManager; +import de.hysky.skyblocker.skyblock.auction.AuctionBrowserScreen; +import de.hysky.skyblocker.skyblock.auction.AuctionHouseScreenHandler; +import de.hysky.skyblocker.skyblock.auction.AuctionViewScreen; +import de.hysky.skyblocker.skyblock.dungeon.partyfinder.PartyFinderScreen; +import de.hysky.skyblocker.skyblock.item.SkyblockCraftingTableScreenHandler; +import de.hysky.skyblocker.skyblock.item.SkyblockCraftingTableScreen; +import de.hysky.skyblocker.utils.Utils; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.screen.ingame.HandledScreens; +import net.minecraft.client.network.ClientPlayerEntity; +import net.minecraft.screen.GenericContainerScreenHandler; +import net.minecraft.screen.ScreenHandler; +import net.minecraft.screen.ScreenHandlerType; +import net.minecraft.text.Text; +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(HandledScreens.Provider.class) +public interface HandledScreenProviderMixin { + + @Inject(method = "open", at = @At("HEAD"), cancellable = true) + default void skyblocker$open(Text name, ScreenHandlerType type, MinecraftClient client, int id, CallbackInfo ci) { + ClientPlayerEntity player = client.player; + if (player == null) return; + if (!Utils.isOnSkyblock()) return; + T screenHandler = type.create(id, player.getInventory()); + String nameLowercase = name.getString().toLowerCase(); + + switch (screenHandler) { + // Better party finder + case GenericContainerScreenHandler ignored when SkyblockerConfigManager.get().general.betterPartyFinder && nameLowercase.contains("select tier") -> PartyFinderScreen.isInKuudraPartyFinder = true; + case GenericContainerScreenHandler ignored when SkyblockerConfigManager.get().general.betterPartyFinder && nameLowercase.contains("catacombs") -> PartyFinderScreen.isInKuudraPartyFinder = false; + + case GenericContainerScreenHandler containerScreenHandler when SkyblockerConfigManager.get().general.betterPartyFinder && PartyFinderScreen.possibleInventoryNames.contains(nameLowercase) -> { + if (client.currentScreen != null) { + String lowerCase = client.currentScreen.getTitle().getString().toLowerCase(); + if (lowerCase.contains("group builder")) return; + } + + if (PartyFinderScreen.isInKuudraPartyFinder) return; + client.player.currentScreenHandler = containerScreenHandler; + + switch (client.currentScreen) { + case PartyFinderScreen screen -> screen.updateHandler(containerScreenHandler, name); + case null, default -> client.setScreen(new PartyFinderScreen(containerScreenHandler, player.getInventory(), name)); + } + + ci.cancel(); + } + + // Fancy AH + case GenericContainerScreenHandler containerScreenHandler when SkyblockerConfigManager.get().general.fancyAuctionHouse.enabled && (nameLowercase.contains("auctions browser") || nameLowercase.contains("auctions: ")) -> { + AuctionHouseScreenHandler auctionHouseScreenHandler = AuctionHouseScreenHandler.of(containerScreenHandler, false); + client.player.currentScreenHandler = auctionHouseScreenHandler; + + switch (client.currentScreen) { + case AuctionBrowserScreen auctionBrowserScreen -> auctionBrowserScreen.changeHandler(auctionHouseScreenHandler); + case null, default -> client.setScreen(new AuctionBrowserScreen(auctionHouseScreenHandler, client.player.getInventory())); + } + + ci.cancel(); + } + + case GenericContainerScreenHandler containerScreenHandler when SkyblockerConfigManager.get().general.fancyAuctionHouse.enabled && nameLowercase.contains("auction view") -> { + AuctionHouseScreenHandler auctionHouseScreenHandler = AuctionHouseScreenHandler.of(containerScreenHandler, true); + client.player.currentScreenHandler = auctionHouseScreenHandler; + + switch (client.currentScreen) { + case AuctionViewScreen auctionViewScreen -> auctionViewScreen.changeHandler(auctionHouseScreenHandler); + case null, default -> client.setScreen(new AuctionViewScreen(auctionHouseScreenHandler, client.player.getInventory(), name)); + } + + ci.cancel(); + } + + case GenericContainerScreenHandler containerScreenHandler when SkyblockerConfigManager.get().general.fancyAuctionHouse.enabled && (nameLowercase.contains("confirm purchase") || nameLowercase.contains("confirm bid")) && client.currentScreen instanceof AuctionViewScreen auctionViewScreen -> { + client.setScreen(auctionViewScreen.getConfirmPurchasePopup(name)); + client.player.currentScreenHandler = containerScreenHandler; + ci.cancel(); + } + + // Fancy crafting table + case GenericContainerScreenHandler containerScreenHandler when SkyblockerConfigManager.get().general.fancyCraftingTable && name.getString().toLowerCase().contains("craft item") -> { + SkyblockCraftingTableScreenHandler skyblockCraftingTableScreenHandler = new SkyblockCraftingTableScreenHandler(containerScreenHandler, player.getInventory()); + client.player.currentScreenHandler = skyblockCraftingTableScreenHandler; + client.setScreen(new SkyblockCraftingTableScreen(skyblockCraftingTableScreenHandler, player.getInventory(), Text.literal("Craft Item"))); + ci.cancel(); + } + + case null, default -> {} + } + } +} diff --git a/src/main/java/de/hysky/skyblocker/mixin/InGameHudMixin.java b/src/main/java/de/hysky/skyblocker/mixins/InGameHudMixin.java similarity index 70% rename from src/main/java/de/hysky/skyblocker/mixin/InGameHudMixin.java rename to src/main/java/de/hysky/skyblocker/mixins/InGameHudMixin.java index b0970b4bc2..897b98b30c 100644 --- a/src/main/java/de/hysky/skyblocker/mixin/InGameHudMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixins/InGameHudMixin.java @@ -1,4 +1,4 @@ -package de.hysky.skyblocker.mixin; +package de.hysky.skyblocker.mixins; import com.llamalad7.mixinextras.injector.ModifyExpressionValue; import com.llamalad7.mixinextras.sugar.Local; @@ -6,10 +6,7 @@ import de.hysky.skyblocker.SkyblockerMod; import de.hysky.skyblocker.config.SkyblockerConfigManager; import de.hysky.skyblocker.skyblock.fancybars.FancyStatusBars; -import de.hysky.skyblocker.skyblock.dungeon.DungeonMap; -import de.hysky.skyblocker.skyblock.dungeon.DungeonScore; -import de.hysky.skyblocker.skyblock.dungeon.DungeonScoreHUD; -import de.hysky.skyblocker.skyblock.dungeon.secrets.DungeonManager; +import de.hysky.skyblocker.events.HudRenderEvents; import de.hysky.skyblocker.skyblock.item.HotbarSlotLock; import de.hysky.skyblocker.skyblock.item.ItemCooldowns; import de.hysky.skyblocker.skyblock.item.ItemProtection; @@ -19,6 +16,7 @@ import net.fabricmc.api.Environment; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.DrawContext; +import net.minecraft.client.gui.LayeredDrawer; import net.minecraft.client.gui.hud.InGameHud; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; @@ -34,6 +32,8 @@ import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.ModifyArg; +import org.spongepowered.asm.mixin.injection.Slice; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Environment(EnvType.CLIENT) @@ -51,16 +51,15 @@ public abstract class InGameHudMixin { private final FancyStatusBars statusBars = new FancyStatusBars(); @Shadow - private int scaledHeight; - @Shadow - private int scaledWidth; + @Final + private MinecraftClient client; @Shadow @Final - private MinecraftClient client; + private LayeredDrawer layeredDrawer; @Inject(method = "renderHotbar", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/InGameHud;renderHotbarItem(Lnet/minecraft/client/gui/DrawContext;IIFLnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/item/ItemStack;I)V", ordinal = 0)) - public void skyblocker$renderHotbarItemLockOrRarityBg(float tickDelta, DrawContext context, CallbackInfo ci, @Local(ordinal = 4, name = "m") int index, @Local(ordinal = 5, name = "n") int x, @Local(ordinal = 6, name = "o") int y, @Local PlayerEntity player) { + public void skyblocker$renderHotbarItemLockOrRarityBg(CallbackInfo ci, @Local(argsOnly = true) DrawContext context, @Local(ordinal = 4, name = "m") int index, @Local(ordinal = 5, name = "n") int x, @Local(ordinal = 6, name = "o") int y, @Local PlayerEntity player) { if (Utils.isOnSkyblock()) { // slot lock if (SkyblockerConfigManager.get().general.itemInfoDisplay.itemRarityBackgrounds) ItemRarityBackgrounds.tryDraw(player.getInventory().main.get(index), context, x, y); @@ -70,7 +69,7 @@ public abstract class InGameHudMixin { RenderSystem.disableBlend(); } //item protection - if (ItemProtection.isItemProtected(player.getInventory().main.get(index))){ + if (ItemProtection.isItemProtected(player.getInventory().main.get(index))) { RenderSystem.enableBlend(); context.drawTexture(ITEM_PROTECTION, x, y, 0, 0, 16, 16, 16, 16); RenderSystem.disableBlend(); @@ -78,7 +77,7 @@ public abstract class InGameHudMixin { } } - @Inject(method = "renderExperienceBar", at = @At("HEAD"), cancellable = true) + @Inject(method = { "renderExperienceBar", "renderExperienceLevel" }, at = @At("HEAD"), cancellable = true) private void skyblocker$renderExperienceBar(CallbackInfo ci) { if (Utils.isOnSkyblock() && SkyblockerConfigManager.get().general.bars.enableBars && !Utils.isInTheRift()) ci.cancel(); @@ -88,13 +87,8 @@ public abstract class InGameHudMixin { private void skyblocker$renderStatusBars(DrawContext context, CallbackInfo ci) { if (!Utils.isOnSkyblock()) return; - if (statusBars.render(context, scaledWidth, scaledHeight)) + if (statusBars.render(context, context.getScaledWindowWidth(), context.getScaledWindowHeight())) ci.cancel(); - - if (Utils.isInDungeons() && DungeonScore.isDungeonStarted()) { - if (SkyblockerConfigManager.get().locations.dungeons.enableMap && !DungeonManager.isInBoss()) DungeonMap.render(context.getMatrices()); - if (SkyblockerConfigManager.get().locations.dungeons.dungeonScore.enableScoreHUD) DungeonScoreHUD.render(context); - } } @Inject(method = "renderMountHealth", at = @At("HEAD"), cancellable = true) @@ -126,4 +120,25 @@ public abstract class InGameHudMixin { ci.cancel(); } } + + @ModifyArg(method = "", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/LayeredDrawer;addLayer(Lnet/minecraft/client/gui/LayeredDrawer$Layer;)Lnet/minecraft/client/gui/LayeredDrawer;", ordinal = 2)) + private LayeredDrawer.Layer skyblocker$afterMainHud(LayeredDrawer.Layer mainHudLayer) { + return (context, tickDelta) -> { + mainHudLayer.render(context, tickDelta); + HudRenderEvents.AFTER_MAIN_HUD.invoker().onRender(context, tickDelta); + }; + } + + @ModifyArg(method = "", slice = @Slice(from = @At(value = "NEW", target = "Lnet/minecraft/client/gui/LayeredDrawer;", ordinal = 1)), at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/LayeredDrawer;addLayer(Lnet/minecraft/client/gui/LayeredDrawer$Layer;)Lnet/minecraft/client/gui/LayeredDrawer;", ordinal = 5)) + private LayeredDrawer.Layer skyblocker$beforeChat(LayeredDrawer.Layer beforeChatLayer) { + return (context, tickDelta) -> { + HudRenderEvents.BEFORE_CHAT.invoker().onRender(context, tickDelta); + beforeChatLayer.render(context, tickDelta); + }; + } + + @Inject(method = "", at = @At("TAIL")) + private void skyblocker$afterDrawersInitialized(CallbackInfo ci) { + this.layeredDrawer.addLayer(HudRenderEvents.LAST.invoker()::onRender); + } } diff --git a/src/main/java/de/hysky/skyblocker/mixin/InGameOverlayRendererMixin.java b/src/main/java/de/hysky/skyblocker/mixins/InGameOverlayRendererMixin.java similarity index 96% rename from src/main/java/de/hysky/skyblocker/mixin/InGameOverlayRendererMixin.java rename to src/main/java/de/hysky/skyblocker/mixins/InGameOverlayRendererMixin.java index 4775ce2d5c..c770455868 100644 --- a/src/main/java/de/hysky/skyblocker/mixin/InGameOverlayRendererMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixins/InGameOverlayRendererMixin.java @@ -1,4 +1,4 @@ -package de.hysky.skyblocker.mixin; +package de.hysky.skyblocker.mixins; import de.hysky.skyblocker.config.SkyblockerConfigManager; import net.minecraft.client.gui.hud.InGameOverlayRenderer; diff --git a/src/main/java/de/hysky/skyblocker/mixin/InventoryScreenMixin.java b/src/main/java/de/hysky/skyblocker/mixins/InventoryScreenMixin.java similarity index 96% rename from src/main/java/de/hysky/skyblocker/mixin/InventoryScreenMixin.java rename to src/main/java/de/hysky/skyblocker/mixins/InventoryScreenMixin.java index 8e6b9230ff..0d833c22fc 100644 --- a/src/main/java/de/hysky/skyblocker/mixin/InventoryScreenMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixins/InventoryScreenMixin.java @@ -1,4 +1,4 @@ -package de.hysky.skyblocker.mixin; +package de.hysky.skyblocker.mixins; import com.llamalad7.mixinextras.injector.ModifyExpressionValue; import de.hysky.skyblocker.config.SkyblockerConfigManager; diff --git a/src/main/java/de/hysky/skyblocker/mixin/ItemStackMixin.java b/src/main/java/de/hysky/skyblocker/mixins/ItemStackMixin.java similarity index 81% rename from src/main/java/de/hysky/skyblocker/mixin/ItemStackMixin.java rename to src/main/java/de/hysky/skyblocker/mixins/ItemStackMixin.java index 2a1ed125a6..3ebfc439a5 100644 --- a/src/main/java/de/hysky/skyblocker/mixin/ItemStackMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixins/ItemStackMixin.java @@ -1,17 +1,20 @@ -package de.hysky.skyblocker.mixin; +package de.hysky.skyblocker.mixins; import com.llamalad7.mixinextras.injector.ModifyReturnValue; import de.hysky.skyblocker.config.SkyblockerConfigManager; import de.hysky.skyblocker.utils.ItemUtils; import de.hysky.skyblocker.utils.Utils; import it.unimi.dsi.fastutil.ints.IntIntPair; +import net.minecraft.component.type.ItemEnchantmentsComponent; import net.minecraft.item.ItemStack; +import net.minecraft.item.TooltipAppender; import net.minecraft.text.Text; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.ModifyVariable; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(ItemStack.class) @@ -35,6 +38,11 @@ public abstract class ItemStackMixin { return original; } + @ModifyVariable(method = "appendTooltip", at = @At("STORE")) + private TooltipAppender skyblocker$hideVanillaEnchants(TooltipAppender original) { + return Utils.isOnSkyblock() && original instanceof ItemEnchantmentsComponent component ? component.withShowInTooltip(false) : original; + } + /** * Updates the durability of this item stack every tick when in the inventory. */ @@ -72,6 +80,11 @@ public abstract class ItemStackMixin { return skyblocker$shouldProcess() || original; } + @ModifyReturnValue(method = "isDamaged", at = @At("RETURN")) + private boolean skyblocker$handleDamaged(boolean original) { + return skyblocker$shouldProcess() || original; + } + @Unique private boolean skyblocker$shouldProcess() { return Utils.isOnSkyblock() && SkyblockerConfigManager.get().locations.dwarvenMines.enableDrillFuel && ItemUtils.hasCustomDurability((ItemStack) (Object) this); diff --git a/src/main/java/de/hysky/skyblocker/mixin/LeverBlockMixin.java b/src/main/java/de/hysky/skyblocker/mixins/LeverBlockMixin.java similarity index 96% rename from src/main/java/de/hysky/skyblocker/mixin/LeverBlockMixin.java rename to src/main/java/de/hysky/skyblocker/mixins/LeverBlockMixin.java index a1cfe44b65..eb8c6bf672 100644 --- a/src/main/java/de/hysky/skyblocker/mixin/LeverBlockMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixins/LeverBlockMixin.java @@ -1,4 +1,4 @@ -package de.hysky.skyblocker.mixin; +package de.hysky.skyblocker.mixins; import de.hysky.skyblocker.skyblock.dungeon.OldLever; import de.hysky.skyblocker.utils.Utils; diff --git a/src/main/java/de/hysky/skyblocker/mixin/LivingEntityRendererMixin.java b/src/main/java/de/hysky/skyblocker/mixins/LivingEntityRendererMixin.java similarity index 88% rename from src/main/java/de/hysky/skyblocker/mixin/LivingEntityRendererMixin.java rename to src/main/java/de/hysky/skyblocker/mixins/LivingEntityRendererMixin.java index cf927f0cec..60fa7decbc 100644 --- a/src/main/java/de/hysky/skyblocker/mixin/LivingEntityRendererMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixins/LivingEntityRendererMixin.java @@ -1,4 +1,4 @@ -package de.hysky.skyblocker.mixin; +package de.hysky.skyblocker.mixins; import com.llamalad7.mixinextras.injector.ModifyExpressionValue; import de.hysky.skyblocker.debug.Debug; @@ -13,6 +13,6 @@ public class LivingEntityRendererMixin { @ModifyExpressionValue(method = "render(Lnet/minecraft/entity/LivingEntity;FFLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/entity/LivingEntityRenderer;isVisible(Lnet/minecraft/entity/LivingEntity;)Z")) private boolean skyblocker$armorStandVisible(boolean visible, T entity) { - return entity instanceof ArmorStandEntity && Utils.isOnHypixel() && Debug.debugEnabled() || visible; + return entity instanceof ArmorStandEntity && Utils.isOnHypixel() && Debug.debugEnabled() && Debug.shouldShowInvisibleArmorStands() || visible; } } diff --git a/src/main/java/de/hysky/skyblocker/mixin/MinecraftClientMixin.java b/src/main/java/de/hysky/skyblocker/mixins/MinecraftClientMixin.java similarity index 83% rename from src/main/java/de/hysky/skyblocker/mixin/MinecraftClientMixin.java rename to src/main/java/de/hysky/skyblocker/mixins/MinecraftClientMixin.java index dd671b2ecf..b04f958f5b 100644 --- a/src/main/java/de/hysky/skyblocker/mixin/MinecraftClientMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixins/MinecraftClientMixin.java @@ -1,4 +1,4 @@ -package de.hysky.skyblocker.mixin; +package de.hysky.skyblocker.mixins; import de.hysky.skyblocker.skyblock.item.HotbarSlotLock; import de.hysky.skyblocker.skyblock.item.ItemProtection; @@ -42,14 +42,12 @@ public abstract class MinecraftClientMixin { //Remove Downloading Terrain Screen and Reconfiguring Screen @ModifyVariable(at = @At("HEAD"), method = "setScreen", ordinal = 0, argsOnly = true) public Screen modifySetScreen(Screen screen) { - if (Utils.isOnSkyblock()) { - if (screen instanceof DownloadingTerrainScreen) { - return null; - } else if (screen instanceof ReconfiguringScreen && this.getNetworkHandler() != null) { - return new ReconfiguringPlaceholderScreen(this.getNetworkHandler().getConnection()); - } - } - return screen; + return switch (screen) { + case DownloadingTerrainScreen _s when Utils.isOnHypixel() -> null; + case ReconfiguringScreen _s when Utils.isOnHypixel() && this.getNetworkHandler() != null -> new ReconfiguringPlaceholderScreen(this.getNetworkHandler().getConnection()); + + case null, default -> screen; + }; } @ModifyArg(method = "joinWorld", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;reset(Lnet/minecraft/client/gui/screen/Screen;)V"), index = 0) diff --git a/src/main/java/de/hysky/skyblocker/mixin/MouseMixin.java b/src/main/java/de/hysky/skyblocker/mixins/MouseMixin.java similarity index 94% rename from src/main/java/de/hysky/skyblocker/mixin/MouseMixin.java rename to src/main/java/de/hysky/skyblocker/mixins/MouseMixin.java index 33c3f48749..fb156af2bd 100644 --- a/src/main/java/de/hysky/skyblocker/mixin/MouseMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixins/MouseMixin.java @@ -1,4 +1,4 @@ -package de.hysky.skyblocker.mixin; +package de.hysky.skyblocker.mixins; import com.llamalad7.mixinextras.injector.ModifyExpressionValue; import de.hysky.skyblocker.skyblock.garden.LowerSensitivity; diff --git a/src/main/java/de/hysky/skyblocker/mixin/PlayerInventoryMixin.java b/src/main/java/de/hysky/skyblocker/mixins/PlayerInventoryMixin.java similarity index 94% rename from src/main/java/de/hysky/skyblocker/mixin/PlayerInventoryMixin.java rename to src/main/java/de/hysky/skyblocker/mixins/PlayerInventoryMixin.java index 4795a28b0c..35747267db 100644 --- a/src/main/java/de/hysky/skyblocker/mixin/PlayerInventoryMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixins/PlayerInventoryMixin.java @@ -1,4 +1,4 @@ -package de.hysky.skyblocker.mixin; +package de.hysky.skyblocker.mixins; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; diff --git a/src/main/java/de/hysky/skyblocker/mixin/PlayerListHudMixin.java b/src/main/java/de/hysky/skyblocker/mixins/PlayerListHudMixin.java similarity index 98% rename from src/main/java/de/hysky/skyblocker/mixin/PlayerListHudMixin.java rename to src/main/java/de/hysky/skyblocker/mixins/PlayerListHudMixin.java index 88ca7c6738..a1a9116c9a 100644 --- a/src/main/java/de/hysky/skyblocker/mixin/PlayerListHudMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixins/PlayerListHudMixin.java @@ -1,4 +1,4 @@ -package de.hysky.skyblocker.mixin; +package de.hysky.skyblocker.mixins; import de.hysky.skyblocker.skyblock.tabhud.screenbuilder.ScreenMaster; import de.hysky.skyblocker.config.SkyblockerConfigManager; diff --git a/src/main/java/de/hysky/skyblocker/mixin/PlayerSkinProviderMixin.java b/src/main/java/de/hysky/skyblocker/mixins/PlayerSkinProviderMixin.java similarity index 85% rename from src/main/java/de/hysky/skyblocker/mixin/PlayerSkinProviderMixin.java rename to src/main/java/de/hysky/skyblocker/mixins/PlayerSkinProviderMixin.java index dd38e15a6c..9cd2ef1421 100644 --- a/src/main/java/de/hysky/skyblocker/mixin/PlayerSkinProviderMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixins/PlayerSkinProviderMixin.java @@ -1,10 +1,10 @@ -package de.hysky.skyblocker.mixin; +package de.hysky.skyblocker.mixins; import org.slf4j.Logger; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; -import com.llamalad7.mixinextras.injector.WrapWithCondition; +import com.llamalad7.mixinextras.injector.v2.WrapWithCondition; import de.hysky.skyblocker.utils.Utils; diff --git a/src/main/java/de/hysky/skyblocker/mixin/PlayerSkinTextureMixin.java b/src/main/java/de/hysky/skyblocker/mixins/PlayerSkinTextureMixin.java similarity index 93% rename from src/main/java/de/hysky/skyblocker/mixin/PlayerSkinTextureMixin.java rename to src/main/java/de/hysky/skyblocker/mixins/PlayerSkinTextureMixin.java index 50f478b822..f9e2c8cd47 100644 --- a/src/main/java/de/hysky/skyblocker/mixin/PlayerSkinTextureMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixins/PlayerSkinTextureMixin.java @@ -1,4 +1,4 @@ -package de.hysky.skyblocker.mixin; +package de.hysky.skyblocker.mixins; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; @@ -8,7 +8,7 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import com.llamalad7.mixinextras.injector.WrapWithCondition; +import com.llamalad7.mixinextras.injector.v2.WrapWithCondition; import de.hysky.skyblocker.config.SkyblockerConfigManager; import de.hysky.skyblocker.skyblock.item.PlayerHeadHashCache; diff --git a/src/main/java/de/hysky/skyblocker/mixin/RenderFishMixin.java b/src/main/java/de/hysky/skyblocker/mixins/RenderFishMixin.java similarity index 97% rename from src/main/java/de/hysky/skyblocker/mixin/RenderFishMixin.java rename to src/main/java/de/hysky/skyblocker/mixins/RenderFishMixin.java index e74bbaead6..71e7f56f0f 100644 --- a/src/main/java/de/hysky/skyblocker/mixin/RenderFishMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixins/RenderFishMixin.java @@ -1,4 +1,4 @@ -package de.hysky.skyblocker.mixin; +package de.hysky.skyblocker.mixins; import de.hysky.skyblocker.config.SkyblockerConfigManager; diff --git a/src/main/java/de/hysky/skyblocker/mixin/ScoreboardMixin.java b/src/main/java/de/hysky/skyblocker/mixins/ScoreboardMixin.java similarity index 85% rename from src/main/java/de/hysky/skyblocker/mixin/ScoreboardMixin.java rename to src/main/java/de/hysky/skyblocker/mixins/ScoreboardMixin.java index 2cfb658aa3..94b39c0cc0 100644 --- a/src/main/java/de/hysky/skyblocker/mixin/ScoreboardMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixins/ScoreboardMixin.java @@ -1,6 +1,6 @@ -package de.hysky.skyblocker.mixin; +package de.hysky.skyblocker.mixins; -import com.llamalad7.mixinextras.injector.WrapWithCondition; +import com.llamalad7.mixinextras.injector.v2.WrapWithCondition; import de.hysky.skyblocker.utils.Utils; import net.minecraft.scoreboard.Scoreboard; import org.slf4j.Logger; diff --git a/src/main/java/de/hysky/skyblocker/mixin/SocialInteractionsPlayerListWidgetMixin.java b/src/main/java/de/hysky/skyblocker/mixins/SocialInteractionsPlayerListWidgetMixin.java similarity index 96% rename from src/main/java/de/hysky/skyblocker/mixin/SocialInteractionsPlayerListWidgetMixin.java rename to src/main/java/de/hysky/skyblocker/mixins/SocialInteractionsPlayerListWidgetMixin.java index cad7cf387e..121e3045dc 100644 --- a/src/main/java/de/hysky/skyblocker/mixin/SocialInteractionsPlayerListWidgetMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixins/SocialInteractionsPlayerListWidgetMixin.java @@ -1,4 +1,4 @@ -package de.hysky.skyblocker.mixin; +package de.hysky.skyblocker.mixins; import java.util.Map; diff --git a/src/main/java/de/hysky/skyblocker/mixin/WindowMixin.java b/src/main/java/de/hysky/skyblocker/mixins/WindowMixin.java similarity index 93% rename from src/main/java/de/hysky/skyblocker/mixin/WindowMixin.java rename to src/main/java/de/hysky/skyblocker/mixins/WindowMixin.java index 481a70a635..d9df4b74a7 100644 --- a/src/main/java/de/hysky/skyblocker/mixin/WindowMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixins/WindowMixin.java @@ -1,4 +1,4 @@ -package de.hysky.skyblocker.mixin; +package de.hysky.skyblocker.mixins; import de.hysky.skyblocker.skyblock.fancybars.FancyStatusBars; import net.minecraft.client.util.Window; diff --git a/src/main/java/de/hysky/skyblocker/mixin/WorldRendererMixin.java b/src/main/java/de/hysky/skyblocker/mixins/WorldRendererMixin.java similarity index 98% rename from src/main/java/de/hysky/skyblocker/mixin/WorldRendererMixin.java rename to src/main/java/de/hysky/skyblocker/mixins/WorldRendererMixin.java index a24daa80f1..2959d4b5d1 100644 --- a/src/main/java/de/hysky/skyblocker/mixin/WorldRendererMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixins/WorldRendererMixin.java @@ -1,4 +1,4 @@ -package de.hysky.skyblocker.mixin; +package de.hysky.skyblocker.mixins; import de.hysky.skyblocker.skyblock.dungeon.LividColor; import org.spongepowered.asm.mixin.Mixin; diff --git a/src/main/java/de/hysky/skyblocker/mixin/YggdrasilMinecraftSessionServiceMixin.java b/src/main/java/de/hysky/skyblocker/mixins/YggdrasilMinecraftSessionServiceMixin.java similarity index 88% rename from src/main/java/de/hysky/skyblocker/mixin/YggdrasilMinecraftSessionServiceMixin.java rename to src/main/java/de/hysky/skyblocker/mixins/YggdrasilMinecraftSessionServiceMixin.java index 47c8780f34..17dbbb71e2 100644 --- a/src/main/java/de/hysky/skyblocker/mixin/YggdrasilMinecraftSessionServiceMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixins/YggdrasilMinecraftSessionServiceMixin.java @@ -1,10 +1,10 @@ -package de.hysky.skyblocker.mixin; +package de.hysky.skyblocker.mixins; import org.slf4j.Logger; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; -import com.llamalad7.mixinextras.injector.WrapWithCondition; +import com.llamalad7.mixinextras.injector.v2.WrapWithCondition; import com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService; import de.hysky.skyblocker.utils.Utils; diff --git a/src/main/java/de/hysky/skyblocker/mixin/YggdrasilServicesKeyInfoMixin.java b/src/main/java/de/hysky/skyblocker/mixins/YggdrasilServicesKeyInfoMixin.java similarity index 96% rename from src/main/java/de/hysky/skyblocker/mixin/YggdrasilServicesKeyInfoMixin.java rename to src/main/java/de/hysky/skyblocker/mixins/YggdrasilServicesKeyInfoMixin.java index 78c4bac141..12621894b8 100644 --- a/src/main/java/de/hysky/skyblocker/mixin/YggdrasilServicesKeyInfoMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixins/YggdrasilServicesKeyInfoMixin.java @@ -1,6 +1,6 @@ -package de.hysky.skyblocker.mixin; +package de.hysky.skyblocker.mixins; -import com.llamalad7.mixinextras.injector.WrapWithCondition; +import com.llamalad7.mixinextras.injector.v2.WrapWithCondition; import com.llamalad7.mixinextras.injector.wrapoperation.Operation; import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import com.mojang.authlib.yggdrasil.YggdrasilServicesKeyInfo; diff --git a/src/main/java/de/hysky/skyblocker/mixin/accessor/BeaconBlockEntityRendererInvoker.java b/src/main/java/de/hysky/skyblocker/mixins/accessors/BeaconBlockEntityRendererInvoker.java similarity index 93% rename from src/main/java/de/hysky/skyblocker/mixin/accessor/BeaconBlockEntityRendererInvoker.java rename to src/main/java/de/hysky/skyblocker/mixins/accessors/BeaconBlockEntityRendererInvoker.java index e470cdaed9..833cfc2286 100644 --- a/src/main/java/de/hysky/skyblocker/mixin/accessor/BeaconBlockEntityRendererInvoker.java +++ b/src/main/java/de/hysky/skyblocker/mixins/accessors/BeaconBlockEntityRendererInvoker.java @@ -1,4 +1,4 @@ -package de.hysky.skyblocker.mixin.accessor; +package de.hysky.skyblocker.mixins.accessors; import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.render.block.entity.BeaconBlockEntityRenderer; diff --git a/src/main/java/de/hysky/skyblocker/mixin/accessor/DrawContextInvoker.java b/src/main/java/de/hysky/skyblocker/mixins/accessors/DrawContextInvoker.java similarity index 94% rename from src/main/java/de/hysky/skyblocker/mixin/accessor/DrawContextInvoker.java rename to src/main/java/de/hysky/skyblocker/mixins/accessors/DrawContextInvoker.java index 9c14fdc667..7a04630dbd 100644 --- a/src/main/java/de/hysky/skyblocker/mixin/accessor/DrawContextInvoker.java +++ b/src/main/java/de/hysky/skyblocker/mixins/accessors/DrawContextInvoker.java @@ -1,4 +1,4 @@ -package de.hysky.skyblocker.mixin.accessor; +package de.hysky.skyblocker.mixins.accessors; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.DrawContext; diff --git a/src/main/java/de/hysky/skyblocker/mixin/accessor/EndermanEntityAccessor.java b/src/main/java/de/hysky/skyblocker/mixins/accessors/EndermanEntityAccessor.java similarity index 90% rename from src/main/java/de/hysky/skyblocker/mixin/accessor/EndermanEntityAccessor.java rename to src/main/java/de/hysky/skyblocker/mixins/accessors/EndermanEntityAccessor.java index b7bcd95ccd..4dfed6dc46 100644 --- a/src/main/java/de/hysky/skyblocker/mixin/accessor/EndermanEntityAccessor.java +++ b/src/main/java/de/hysky/skyblocker/mixins/accessors/EndermanEntityAccessor.java @@ -1,4 +1,4 @@ -package de.hysky.skyblocker.mixin.accessor; +package de.hysky.skyblocker.mixins.accessors; import net.minecraft.block.BlockState; import net.minecraft.entity.data.TrackedData; diff --git a/src/main/java/de/hysky/skyblocker/mixin/accessor/FrustumInvoker.java b/src/main/java/de/hysky/skyblocker/mixins/accessors/FrustumInvoker.java similarity index 92% rename from src/main/java/de/hysky/skyblocker/mixin/accessor/FrustumInvoker.java rename to src/main/java/de/hysky/skyblocker/mixins/accessors/FrustumInvoker.java index dd4f5ef1f8..e4d04ddebd 100644 --- a/src/main/java/de/hysky/skyblocker/mixin/accessor/FrustumInvoker.java +++ b/src/main/java/de/hysky/skyblocker/mixins/accessors/FrustumInvoker.java @@ -1,4 +1,4 @@ -package de.hysky.skyblocker.mixin.accessor; +package de.hysky.skyblocker.mixins.accessors; import net.minecraft.client.render.Frustum; import org.spongepowered.asm.mixin.Mixin; diff --git a/src/main/java/de/hysky/skyblocker/mixin/accessor/HandledScreenAccessor.java b/src/main/java/de/hysky/skyblocker/mixins/accessors/HandledScreenAccessor.java similarity index 92% rename from src/main/java/de/hysky/skyblocker/mixin/accessor/HandledScreenAccessor.java rename to src/main/java/de/hysky/skyblocker/mixins/accessors/HandledScreenAccessor.java index 5b84072d18..447031d471 100644 --- a/src/main/java/de/hysky/skyblocker/mixin/accessor/HandledScreenAccessor.java +++ b/src/main/java/de/hysky/skyblocker/mixins/accessors/HandledScreenAccessor.java @@ -1,4 +1,4 @@ -package de.hysky.skyblocker.mixin.accessor; +package de.hysky.skyblocker.mixins.accessors; import net.minecraft.client.gui.screen.ingame.HandledScreen; import net.minecraft.screen.ScreenHandler; diff --git a/src/main/java/de/hysky/skyblocker/mixin/accessor/MessageHandlerAccessor.java b/src/main/java/de/hysky/skyblocker/mixins/accessors/MessageHandlerAccessor.java similarity index 88% rename from src/main/java/de/hysky/skyblocker/mixin/accessor/MessageHandlerAccessor.java rename to src/main/java/de/hysky/skyblocker/mixins/accessors/MessageHandlerAccessor.java index 6e5793e359..bf4f9bae0e 100644 --- a/src/main/java/de/hysky/skyblocker/mixin/accessor/MessageHandlerAccessor.java +++ b/src/main/java/de/hysky/skyblocker/mixins/accessors/MessageHandlerAccessor.java @@ -1,4 +1,4 @@ -package de.hysky.skyblocker.mixin.accessor; +package de.hysky.skyblocker.mixins.accessors; import net.minecraft.client.network.message.MessageHandler; import net.minecraft.text.Text; diff --git a/src/main/java/de/hysky/skyblocker/mixin/accessor/PlayerListHudAccessor.java b/src/main/java/de/hysky/skyblocker/mixins/accessors/PlayerListHudAccessor.java similarity index 90% rename from src/main/java/de/hysky/skyblocker/mixin/accessor/PlayerListHudAccessor.java rename to src/main/java/de/hysky/skyblocker/mixins/accessors/PlayerListHudAccessor.java index c982249abe..d1fd1c4697 100644 --- a/src/main/java/de/hysky/skyblocker/mixin/accessor/PlayerListHudAccessor.java +++ b/src/main/java/de/hysky/skyblocker/mixins/accessors/PlayerListHudAccessor.java @@ -1,4 +1,4 @@ -package de.hysky.skyblocker.mixin.accessor; +package de.hysky.skyblocker.mixins.accessors; import net.minecraft.client.gui.hud.PlayerListHud; import net.minecraft.client.network.PlayerListEntry; diff --git a/src/main/java/de/hysky/skyblocker/mixin/accessor/RecipeBookWidgetAccessor.java b/src/main/java/de/hysky/skyblocker/mixins/accessors/RecipeBookWidgetAccessor.java similarity index 89% rename from src/main/java/de/hysky/skyblocker/mixin/accessor/RecipeBookWidgetAccessor.java rename to src/main/java/de/hysky/skyblocker/mixins/accessors/RecipeBookWidgetAccessor.java index 30aad00cdc..555a0d8a1c 100644 --- a/src/main/java/de/hysky/skyblocker/mixin/accessor/RecipeBookWidgetAccessor.java +++ b/src/main/java/de/hysky/skyblocker/mixins/accessors/RecipeBookWidgetAccessor.java @@ -1,4 +1,4 @@ -package de.hysky.skyblocker.mixin.accessor; +package de.hysky.skyblocker.mixins.accessors; import net.minecraft.client.gui.screen.recipebook.RecipeBookWidget; import net.minecraft.client.gui.widget.TextFieldWidget; diff --git a/src/main/java/de/hysky/skyblocker/mixin/accessor/ScreenAccessor.java b/src/main/java/de/hysky/skyblocker/mixins/accessors/ScreenAccessor.java similarity index 87% rename from src/main/java/de/hysky/skyblocker/mixin/accessor/ScreenAccessor.java rename to src/main/java/de/hysky/skyblocker/mixins/accessors/ScreenAccessor.java index c0196e5f04..c354430276 100644 --- a/src/main/java/de/hysky/skyblocker/mixin/accessor/ScreenAccessor.java +++ b/src/main/java/de/hysky/skyblocker/mixins/accessors/ScreenAccessor.java @@ -1,4 +1,4 @@ -package de.hysky.skyblocker.mixin.accessor; +package de.hysky.skyblocker.mixins.accessors; import net.minecraft.client.gui.screen.Screen; import net.minecraft.text.Text; diff --git a/src/main/java/de/hysky/skyblocker/mixin/accessor/SkullBlockEntityAccessor.java b/src/main/java/de/hysky/skyblocker/mixins/accessors/SkullBlockEntityAccessor.java similarity index 86% rename from src/main/java/de/hysky/skyblocker/mixin/accessor/SkullBlockEntityAccessor.java rename to src/main/java/de/hysky/skyblocker/mixins/accessors/SkullBlockEntityAccessor.java index dfe544bc6c..34c196b3f0 100644 --- a/src/main/java/de/hysky/skyblocker/mixin/accessor/SkullBlockEntityAccessor.java +++ b/src/main/java/de/hysky/skyblocker/mixins/accessors/SkullBlockEntityAccessor.java @@ -1,7 +1,8 @@ -package de.hysky.skyblocker.mixin.accessor; +package de.hysky.skyblocker.mixins.accessors; import com.mojang.authlib.GameProfile; import net.minecraft.block.entity.SkullBlockEntity; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Invoker; @@ -11,7 +12,7 @@ @Mixin(SkullBlockEntity.class) public interface SkullBlockEntityAccessor { @Invoker - static CompletableFuture> invokeFetchProfile(String name) { + static CompletableFuture> invokeFetchProfileByName(String name) { throw new UnsupportedOperationException(); } } diff --git a/src/main/java/de/hysky/skyblocker/mixin/accessor/SlotAccessor.java b/src/main/java/de/hysky/skyblocker/mixins/accessors/SlotAccessor.java similarity index 88% rename from src/main/java/de/hysky/skyblocker/mixin/accessor/SlotAccessor.java rename to src/main/java/de/hysky/skyblocker/mixins/accessors/SlotAccessor.java index ef11006c95..7c261458ed 100644 --- a/src/main/java/de/hysky/skyblocker/mixin/accessor/SlotAccessor.java +++ b/src/main/java/de/hysky/skyblocker/mixins/accessors/SlotAccessor.java @@ -1,4 +1,4 @@ -package de.hysky.skyblocker.mixin.accessor; +package de.hysky.skyblocker.mixins.accessors; import net.minecraft.screen.slot.Slot; import org.spongepowered.asm.mixin.Mixin; diff --git a/src/main/java/de/hysky/skyblocker/mixin/accessor/WorldRendererAccessor.java b/src/main/java/de/hysky/skyblocker/mixins/accessors/WorldRendererAccessor.java similarity index 86% rename from src/main/java/de/hysky/skyblocker/mixin/accessor/WorldRendererAccessor.java rename to src/main/java/de/hysky/skyblocker/mixins/accessors/WorldRendererAccessor.java index f1b3158d0b..e52b1c855e 100644 --- a/src/main/java/de/hysky/skyblocker/mixin/accessor/WorldRendererAccessor.java +++ b/src/main/java/de/hysky/skyblocker/mixins/accessors/WorldRendererAccessor.java @@ -1,4 +1,4 @@ -package de.hysky.skyblocker.mixin.accessor; +package de.hysky.skyblocker.mixins.accessors; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; diff --git a/src/main/java/de/hysky/skyblocker/mixin/discordipc/ConnectionMixin.java b/src/main/java/de/hysky/skyblocker/mixins/discordipc/ConnectionMixin.java similarity index 94% rename from src/main/java/de/hysky/skyblocker/mixin/discordipc/ConnectionMixin.java rename to src/main/java/de/hysky/skyblocker/mixins/discordipc/ConnectionMixin.java index 47f1cadce6..79a93e69b4 100644 --- a/src/main/java/de/hysky/skyblocker/mixin/discordipc/ConnectionMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixins/discordipc/ConnectionMixin.java @@ -1,4 +1,4 @@ -package de.hysky.skyblocker.mixin.discordipc; +package de.hysky.skyblocker.mixins.discordipc; import de.hysky.skyblocker.utils.discord.DiscordRPCManager; import meteordevelopment.discordipc.DiscordIPC; diff --git a/src/main/java/de/hysky/skyblocker/skyblock/ChestValue.java b/src/main/java/de/hysky/skyblocker/skyblock/ChestValue.java index 5cdca21631..e04a30ef8e 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/ChestValue.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/ChestValue.java @@ -3,10 +3,11 @@ import com.google.gson.JsonObject; import de.hysky.skyblocker.config.SkyblockerConfig; import de.hysky.skyblocker.config.SkyblockerConfigManager; -import de.hysky.skyblocker.mixin.accessor.HandledScreenAccessor; -import de.hysky.skyblocker.mixin.accessor.ScreenAccessor; +import de.hysky.skyblocker.mixins.accessors.HandledScreenAccessor; +import de.hysky.skyblocker.mixins.accessors.ScreenAccessor; import de.hysky.skyblocker.skyblock.item.tooltip.ItemTooltip; import de.hysky.skyblocker.skyblock.item.tooltip.TooltipInfoType; +import de.hysky.skyblocker.utils.ItemUtils; import de.hysky.skyblocker.utils.Utils; import it.unimi.dsi.fastutil.longs.LongBooleanPair; import net.fabricmc.fabric.api.client.screen.v1.ScreenEvents; @@ -15,7 +16,6 @@ import net.minecraft.client.gui.screen.ingame.GenericContainerScreen; import net.minecraft.client.gui.tooltip.Tooltip; import net.minecraft.client.gui.widget.ButtonWidget; -import net.minecraft.client.item.TooltipContext; import net.minecraft.item.ItemStack; import net.minecraft.screen.GenericContainerScreenHandler; import net.minecraft.screen.slot.Slot; @@ -206,7 +206,7 @@ private static LongBooleanPair getItemPrice(String id) { * Searches for a specific string of characters in the name and lore of an item */ private static String searchLoreFor(ItemStack stack, MinecraftClient client, String searchString) { - return stack.getTooltip(client.player, TooltipContext.BASIC).stream().map(Text::getString).filter(line -> line.contains(searchString)).findAny().orElse(null); + return ItemUtils.getLoreLineIf(stack, line -> line.contains(searchString)); } static Text getProfitText(long profit, boolean hasIncompleteData) { diff --git a/src/main/java/de/hysky/skyblocker/skyblock/StatusBarTracker.java b/src/main/java/de/hysky/skyblocker/skyblock/StatusBarTracker.java index c3483102b3..c31e210734 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/StatusBarTracker.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/StatusBarTracker.java @@ -21,6 +21,7 @@ public class StatusBarTracker { private int defense = 0; public void init() { + ClientReceiveMessageEvents.ALLOW_GAME.register(this::allowOverlayMessage); ClientReceiveMessageEvents.MODIFY_GAME.register(this::onOverlayMessage); } @@ -65,6 +66,11 @@ private String reset(String str, Matcher m) { return str; } + private boolean allowOverlayMessage(Text text, boolean overlay) { + onOverlayMessage(text, overlay); + return true; + } + private Text onOverlayMessage(Text text, boolean overlay) { if (!overlay || !Utils.isOnSkyblock() || !SkyblockerConfigManager.get().general.bars.enableBars || Utils.isInTheRift()) { return text; diff --git a/src/main/java/de/hysky/skyblocker/skyblock/TeleportOverlay.java b/src/main/java/de/hysky/skyblocker/skyblock/TeleportOverlay.java index e572d9dcf2..f7f9836cef 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/TeleportOverlay.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/TeleportOverlay.java @@ -9,6 +9,7 @@ import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents; import net.minecraft.block.BlockState; import net.minecraft.client.MinecraftClient; +import net.minecraft.entity.attribute.EntityAttributes; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NbtCompound; import net.minecraft.util.hit.BlockHitResult; @@ -27,7 +28,7 @@ private static void render(WorldRenderContext wrc) { if (Utils.isOnSkyblock() && SkyblockerConfigManager.get().general.teleportOverlay.enableTeleportOverlays && client.player != null && client.world != null) { ItemStack heldItem = client.player.getMainHandStack(); String itemId = ItemTooltip.getInternalNameFromNBT(heldItem, true); - NbtCompound extraAttributes = ItemUtils.getExtraAttributes(heldItem); + NbtCompound customData = ItemUtils.getCustomData(heldItem); if (itemId != null) { switch (itemId) { @@ -42,20 +43,20 @@ private static void render(WorldRenderContext wrc) { } } case "ASPECT_OF_THE_END", "ASPECT_OF_THE_VOID" -> { - if (SkyblockerConfigManager.get().general.teleportOverlay.enableEtherTransmission && client.options.sneakKey.isPressed() && extraAttributes != null && extraAttributes.getInt("ethermerge") == 1) { - render(wrc, extraAttributes, 57); + if (SkyblockerConfigManager.get().general.teleportOverlay.enableEtherTransmission && client.options.sneakKey.isPressed() && customData != null && customData.getInt("ethermerge") == 1) { + render(wrc, customData, 57); } else if (SkyblockerConfigManager.get().general.teleportOverlay.enableInstantTransmission) { - render(wrc, extraAttributes, 8); + render(wrc, customData, 8); } } case "ETHERWARP_CONDUIT" -> { if (SkyblockerConfigManager.get().general.teleportOverlay.enableEtherTransmission) { - render(wrc, extraAttributes, 57); + render(wrc, customData, 57); } } case "SINSEEKER_SCYTHE" -> { if (SkyblockerConfigManager.get().general.teleportOverlay.enableSinrecallTransmission) { - render(wrc, extraAttributes, 4); + render(wrc, customData, 4); } } case "NECRON_BLADE", "ASTRAEA", "HYPERION", "SCYLLA", "VALKYRIE" -> { @@ -71,8 +72,8 @@ private static void render(WorldRenderContext wrc) { /** * Renders the teleport overlay with a given base range and the tuned transmission stat. */ - private static void render(WorldRenderContext wrc, NbtCompound extraAttributes, int baseRange) { - render(wrc, extraAttributes != null && extraAttributes.contains("tuned_transmission") ? baseRange + extraAttributes.getInt("tuned_transmission") : baseRange); + private static void render(WorldRenderContext wrc, NbtCompound customData, int baseRange) { + render(wrc, customData != null && customData.contains("tuned_transmission") ? baseRange + customData.getInt("tuned_transmission") : baseRange); } /** @@ -83,7 +84,7 @@ private static void render(WorldRenderContext wrc, NbtCompound extraAttributes, private static void render(WorldRenderContext wrc, int range) { if (client.crosshairTarget != null && client.crosshairTarget.getType() == HitResult.Type.BLOCK && client.crosshairTarget instanceof BlockHitResult blockHitResult && client.crosshairTarget.squaredDistanceTo(client.player) < range * range) { render(wrc, blockHitResult); - } else if (client.interactionManager != null && range > client.interactionManager.getReachDistance()) { + } else if (client.interactionManager != null && range > client.player.getAttributeInstance(EntityAttributes.PLAYER_BLOCK_INTERACTION_RANGE).getValue()) { @SuppressWarnings("DataFlowIssue") HitResult result = client.player.raycast(range, wrc.tickDelta(), false); if (result.getType() == HitResult.Type.BLOCK && result instanceof BlockHitResult blockHitResult) { diff --git a/src/main/java/de/hysky/skyblocker/skyblock/WarpAutocomplete.java b/src/main/java/de/hysky/skyblocker/skyblock/WarpAutocomplete.java index 8862185f14..a44a31026b 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/WarpAutocomplete.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/WarpAutocomplete.java @@ -20,7 +20,7 @@ import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.literal; /** - * the mixin {@link de.hysky.skyblocker.mixin.CommandTreeS2CPacketMixin} + * the mixin {@link de.hysky.skyblocker.mixins.CommandTreeS2CPacketMixin} */ public class WarpAutocomplete { private static final Logger LOGGER = LoggerFactory.getLogger(WarpAutocomplete.class); diff --git a/src/main/java/de/hysky/skyblocker/skyblock/accessories/newyearcakes/NewYearCakeBagHelper.java b/src/main/java/de/hysky/skyblocker/skyblock/accessories/newyearcakes/NewYearCakeBagHelper.java index e0d67fbe09..9b2080a3e8 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/accessories/newyearcakes/NewYearCakeBagHelper.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/accessories/newyearcakes/NewYearCakeBagHelper.java @@ -3,12 +3,12 @@ import de.hysky.skyblocker.config.SkyblockerConfigManager; import de.hysky.skyblocker.utils.render.gui.ColorHighlight; import de.hysky.skyblocker.utils.render.gui.ContainerSolver; +import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import net.minecraft.client.MinecraftClient; import net.minecraft.item.ItemStack; import net.minecraft.screen.slot.Slot; import java.util.List; -import java.util.Map; public class NewYearCakeBagHelper extends ContainerSolver { public NewYearCakeBagHelper() { @@ -21,7 +21,7 @@ protected boolean isEnabled() { } @Override - protected List getColors(String[] groups, Map slots) { + protected List getColors(String[] groups, Int2ObjectMap slots) { MinecraftClient client = MinecraftClient.getInstance(); if (client.player != null) { for (Slot slot : client.player.currentScreenHandler.slots) { diff --git a/src/main/java/de/hysky/skyblocker/skyblock/accessories/newyearcakes/NewYearCakesHelper.java b/src/main/java/de/hysky/skyblocker/skyblock/accessories/newyearcakes/NewYearCakesHelper.java index b722849b70..2fdcf3b4aa 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/accessories/newyearcakes/NewYearCakesHelper.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/accessories/newyearcakes/NewYearCakesHelper.java @@ -4,6 +4,7 @@ import de.hysky.skyblocker.utils.Utils; import de.hysky.skyblocker.utils.render.gui.ColorHighlight; import de.hysky.skyblocker.utils.render.gui.ContainerSolver; +import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.IntOpenHashSet; import it.unimi.dsi.fastutil.ints.IntSet; import net.fabricmc.fabric.api.client.message.v1.ClientReceiveMessageEvents; @@ -64,14 +65,14 @@ private void onChatMessage(Text message, boolean overlay) { } @Override - protected List getColors(String[] groups, Map slots) { + protected List getColors(String[] groups, Int2ObjectMap slots) { String profile = Utils.getProfile(); if (cakes.isEmpty() || !cakes.containsKey(profile) || cakes.containsKey(profile) && cakes.get(profile).isEmpty()) return List.of(); List highlights = new ArrayList<>(); - for (Map.Entry entry : slots.entrySet()) { + for (Int2ObjectMap.Entry entry : slots.int2ObjectEntrySet()) { int year = getCakeYear(entry.getValue()); if (year >= 0 && cakes.containsKey(profile)) { - highlights.add(cakes.get(profile).contains(year) ? ColorHighlight.red(entry.getKey()) : ColorHighlight.green(entry.getKey())); + highlights.add(cakes.get(profile).contains(year) ? ColorHighlight.red(entry.getIntKey()) : ColorHighlight.green(entry.getIntKey())); } } return highlights; diff --git a/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionBrowserScreen.java b/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionBrowserScreen.java index c8bc1f13ac..1082341875 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionBrowserScreen.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionBrowserScreen.java @@ -34,6 +34,7 @@ import org.slf4j.LoggerFactory; import java.awt.*; +import java.time.Duration; import java.util.ArrayList; import java.util.List; import java.util.function.Supplier; @@ -93,7 +94,7 @@ protected void init() { resetFiltersButton = new ScaledTextButtonWidget(x + 10, y + 77, 12, 12, Text.literal("↻"), this::onResetPressed); addDrawableChild(resetFiltersButton); resetFiltersButton.setTooltip(Tooltip.of(Text.literal("Reset Filters"))); - resetFiltersButton.setTooltipDelay(500); + resetFiltersButton.setTooltipDelay(Duration.ofMillis(500)); addDrawableChild(new ButtonWidget.Builder(Text.literal("<"), button -> this.clickSlot(BACK_BUTTON_SLOT)) .position(x + 98, y + 4) @@ -240,11 +241,11 @@ public void onSlotChange(AuctionHouseScreenHandler handler, int slotId, ItemStac } } case SORT_BUTTON_SLOT -> - sortWidget.setCurrent(SortWidget.Option.get(getOrdinal(ItemUtils.getNbtTooltips(stack)))); + sortWidget.setCurrent(SortWidget.Option.get(getOrdinal(ItemUtils.getLore(stack)))); case AUCTION_TYPE_BUTTON_SLOT -> - auctionTypeWidget.setCurrent(AuctionTypeWidget.Option.get(getOrdinal(ItemUtils.getNbtTooltips(stack)))); + auctionTypeWidget.setCurrent(AuctionTypeWidget.Option.get(getOrdinal(ItemUtils.getLore(stack)))); case RARITY_BUTTON_SLOT -> { - List tooltip = ItemUtils.getNbtTooltips(stack); + List tooltip = ItemUtils.getLore(stack); int ordinal = getOrdinal(tooltip); String split = tooltip.get(ordinal + 1).getString().substring(2); rarityWidget.setText(tooltip.subList(1, tooltip.size() - 3), split); @@ -254,7 +255,7 @@ public void onSlotChange(AuctionHouseScreenHandler handler, int slotId, ItemStac resetFiltersButton.active = handler.getSlot(slotId).getStack().isOf(Items.ANVIL); } case SEARCH_BUTTON_SLOT -> { - List tooltipSearch = ItemUtils.getNbtTooltips(stack); + List tooltipSearch = ItemUtils.getLore(stack); for (Text text : tooltipSearch) { String string = text.getString(); if (string.contains("Filtered:")) { @@ -271,7 +272,7 @@ public void onSlotChange(AuctionHouseScreenHandler handler, int slotId, ItemStac CategoryTabWidget categoryTabWidget = categoryTabWidgets.get(slotId / 9); categoryTabWidget.setSlotId(slotId); categoryTabWidget.setIcon(handler.getSlot(slotId).getStack()); - List tooltipDefault = ItemUtils.getNbtTooltips(handler.getSlot(slotId).getStack()); + List tooltipDefault = ItemUtils.getLore(handler.getSlot(slotId).getStack()); for (int j = tooltipDefault.size() - 1; j >= 0; j--) { String lowerCase = tooltipDefault.get(j).getString().toLowerCase(); if (lowerCase.contains("currently")) { @@ -284,7 +285,7 @@ public void onSlotChange(AuctionHouseScreenHandler handler, int slotId, ItemStac } } else if (slotId > 9 && slotId < (handler.getRows() - 1) * 9 && slotId % 9 > 1 && slotId % 9 < 8) { if (!SkyblockerConfigManager.get().general.fancyAuctionHouse.highlightCheapBIN) return; - List tooltip = ItemUtils.getNbtTooltips(stack); + List tooltip = ItemUtils.getLore(stack); for (int k = tooltip.size() - 1; k >= 0; k--) { Text text = tooltip.get(k); String string = text.getString(); @@ -349,7 +350,7 @@ private static int getOrdinal(List tooltip) { private void parsePage(ItemStack stack) { assert client != null; try { - List tooltip = ItemUtils.getNbtTooltips(stack); + List tooltip = ItemUtils.getLore(stack); String str = tooltip.get(0).getString().trim(); str = str.substring(1, str.length() - 1); // remove parentheses String[] parts = str.split("/"); // split the string diff --git a/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionHouseScreenHandler.java b/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionHouseScreenHandler.java index 28898cdc76..4c4e1c0fb7 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionHouseScreenHandler.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionHouseScreenHandler.java @@ -1,6 +1,6 @@ package de.hysky.skyblocker.skyblock.auction; -import de.hysky.skyblocker.mixin.accessor.SlotAccessor; +import de.hysky.skyblocker.mixins.accessors.SlotAccessor; import net.minecraft.client.MinecraftClient; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.inventory.Inventory; diff --git a/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionViewScreen.java b/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionViewScreen.java index a8b30a50c1..af931eb140 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionViewScreen.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionViewScreen.java @@ -198,18 +198,18 @@ public void onSlotChange(AuctionHouseScreenHandler handler, int slotId, ItemStac if (priceParsed) return; if (stack.isOf(Items.POISONOUS_POTATO)) { changeState(BuyState.CANT_AFFORD); - getPriceFromTooltip(ItemUtils.getNbtTooltips(stack)); + getPriceFromTooltip(ItemUtils.getLore(stack)); buySlotID = slotId; } else if (stack.isOf(Items.GOLD_NUGGET)) { changeState(BuyState.AFFORD); - getPriceFromTooltip(ItemUtils.getNbtTooltips(stack)); + getPriceFromTooltip(ItemUtils.getLore(stack)); buySlotID = slotId; } else if (stack.isOf(Items.GOLD_BLOCK)) { changeState(BuyState.TOP_BID); - getPriceFromTooltip(ItemUtils.getNbtTooltips(stack)); + getPriceFromTooltip(ItemUtils.getLore(stack)); buySlotID = slotId; } else if (stack.isOf(Items.NAME_TAG)) { - getPriceFromTooltip(ItemUtils.getNbtTooltips(stack)); + getPriceFromTooltip(ItemUtils.getLore(stack)); changeProfile = true; buySlotID = slotId; } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/auction/widgets/AuctionTypeWidget.java b/src/main/java/de/hysky/skyblocker/skyblock/auction/widgets/AuctionTypeWidget.java index 4334fc58de..2204d39c3d 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/auction/widgets/AuctionTypeWidget.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/auction/widgets/AuctionTypeWidget.java @@ -4,7 +4,6 @@ import de.hysky.skyblocker.skyblock.auction.SlotClickHandler; import net.minecraft.text.Text; import net.minecraft.util.Identifier; -import net.minecraft.util.math.MathHelper; public class AuctionTypeWidget extends SliderWidget { @@ -34,7 +33,7 @@ public enum Option implements SliderWidget.OptionInfo { private static final AuctionTypeWidget.Option[] values = values(); public static AuctionTypeWidget.Option get(int ordinal) { - return values[MathHelper.clamp(ordinal, 0, values.length - 1)]; + return values[Math.clamp(ordinal, 0, values.length - 1)]; } @Override diff --git a/src/main/java/de/hysky/skyblocker/skyblock/auction/widgets/CategoryTabWidget.java b/src/main/java/de/hysky/skyblocker/skyblock/auction/widgets/CategoryTabWidget.java index 03d91780b5..02dbc1329e 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/auction/widgets/CategoryTabWidget.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/auction/widgets/CategoryTabWidget.java @@ -5,7 +5,8 @@ import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.screen.ButtonTextures; import net.minecraft.client.gui.widget.ToggleButtonWidget; -import net.minecraft.client.item.TooltipContext; +import net.minecraft.client.item.TooltipType; +import net.minecraft.item.Item.TooltipContext; import net.minecraft.item.ItemStack; import net.minecraft.util.Identifier; import org.jetbrains.annotations.NotNull; @@ -39,7 +40,7 @@ public void renderWidget(DrawContext context, int mouseX, int mouseY, float delt if (isMouseOver(mouseX, mouseY)) { context.getMatrices().push(); - context.drawTooltip(MinecraftClient.getInstance().textRenderer, icon.getTooltip(MinecraftClient.getInstance().player, TooltipContext.BASIC), mouseX, mouseY); + context.drawTooltip(MinecraftClient.getInstance().textRenderer, icon.getTooltip(TooltipContext.DEFAULT, MinecraftClient.getInstance().player, TooltipType.BASIC), mouseX, mouseY); context.getMatrices().pop(); } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/auction/widgets/SortWidget.java b/src/main/java/de/hysky/skyblocker/skyblock/auction/widgets/SortWidget.java index b2450b596b..84b8ae4dc6 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/auction/widgets/SortWidget.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/auction/widgets/SortWidget.java @@ -4,7 +4,6 @@ import de.hysky.skyblocker.skyblock.auction.SlotClickHandler; import net.minecraft.text.Text; import net.minecraft.util.Identifier; -import net.minecraft.util.math.MathHelper; public class SortWidget extends SliderWidget { @@ -39,7 +38,7 @@ public Identifier getOptionTexture() { private static final Option[] values = values(); public static Option get(int ordinal) { - return values[MathHelper.clamp(ordinal, 0, values.length - 1)]; + return values[Math.clamp(ordinal, 0, values.length - 1)]; } @Override diff --git a/src/main/java/de/hysky/skyblocker/skyblock/barn/HungryHiker.java b/src/main/java/de/hysky/skyblocker/skyblock/barn/HungryHiker.java index abb4a76da3..4a0213c122 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/barn/HungryHiker.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/barn/HungryHiker.java @@ -1,6 +1,7 @@ package de.hysky.skyblocker.skyblock.barn; import de.hysky.skyblocker.config.SkyblockerConfigManager; +import de.hysky.skyblocker.utils.Utils; import de.hysky.skyblocker.utils.chat.ChatFilterResult; import de.hysky.skyblocker.utils.chat.ChatPatternListener; import net.minecraft.client.MinecraftClient; @@ -14,7 +15,7 @@ public class HungryHiker extends ChatPatternListener { private static final Map foods; - public HungryHiker() { super("^§e\\[NPC] Hungry Hiker§f: (The food I want is|(I asked for) food that is) ([a-zA-Z, '\\-]*\\.)$"); } + public HungryHiker() { super("^\\[NPC] Hungry Hiker: (The food I want is|(I asked for) food that is) ([a-zA-Z, '\\-]*\\.)$"); } @Override public ChatFilterResult state() { @@ -29,7 +30,7 @@ public boolean onMatch(Text message, Matcher matcher) { String food = foods.get(foodDescription); if (food == null) return false; String middlePartOfTheMessageToSend = matcher.group(2) != null ? matcher.group(2) : matcher.group(1); - client.player.sendMessage(Text.of("§e[NPC] Hungry Hiker§f: " + middlePartOfTheMessageToSend + " " + food + "."), false); + Utils.sendMessageToBypassEvents(Text.of("§e[NPC] Hungry Hiker§f: " + middlePartOfTheMessageToSend + " " + food + ".")); return true; } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/barn/TreasureHunter.java b/src/main/java/de/hysky/skyblocker/skyblock/barn/TreasureHunter.java index 191014d5f1..032c7df90f 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/barn/TreasureHunter.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/barn/TreasureHunter.java @@ -14,7 +14,7 @@ public class TreasureHunter extends ChatPatternListener { private static final Map locations; - public TreasureHunter() { super("^§e\\[NPC] Treasure Hunter§f: ([a-zA-Z, '\\-\\.]*)$"); } + public TreasureHunter() { super("^\\[NPC] Treasure Hunter: ([a-zA-Z, '\\-\\.]*)$"); } @Override public ChatFilterResult state() { diff --git a/src/main/java/de/hysky/skyblocker/skyblock/chat/ChatRuleAnnouncementScreen.java b/src/main/java/de/hysky/skyblocker/skyblock/chat/ChatRuleAnnouncementScreen.java index bafada27cd..d61a0b5978 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/chat/ChatRuleAnnouncementScreen.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/chat/ChatRuleAnnouncementScreen.java @@ -1,7 +1,7 @@ package de.hysky.skyblocker.skyblock.chat; import de.hysky.skyblocker.config.SkyblockerConfigManager; -import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback; +import de.hysky.skyblocker.events.HudRenderEvents; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.DrawContext; import net.minecraft.client.util.math.MatrixStack; @@ -13,7 +13,7 @@ public class ChatRuleAnnouncementScreen { private static Text text = null; public static void init() { - HudRenderCallback.EVENT.register((context, tickDelta) -> { + HudRenderEvents.BEFORE_CHAT.register((context, tickDelta) -> { if (timer <= 0 || text == null) { return; } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/chat/ChatRulesConfigListWidget.java b/src/main/java/de/hysky/skyblocker/skyblock/chat/ChatRulesConfigListWidget.java index a1b9317af6..747e826ba3 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/chat/ChatRulesConfigListWidget.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/chat/ChatRulesConfigListWidget.java @@ -39,8 +39,8 @@ public int getRowWidth() { } @Override - protected int getScrollbarPositionX() { - return super.getScrollbarPositionX() + 50; + protected int getScrollbarX() { + return super.getScrollbarX() + 50; } protected void addRuleAfterSelected() { diff --git a/src/main/java/de/hysky/skyblocker/skyblock/chat/ChatRulesHandler.java b/src/main/java/de/hysky/skyblocker/skyblock/chat/ChatRulesHandler.java index 2a103d13e9..d1c7f4fd8a 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/chat/ChatRulesHandler.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/chat/ChatRulesHandler.java @@ -6,7 +6,7 @@ import com.mojang.serialization.Codec; import com.mojang.serialization.JsonOps; import de.hysky.skyblocker.SkyblockerMod; -import de.hysky.skyblocker.mixin.accessor.MessageHandlerAccessor; +import de.hysky.skyblocker.mixins.accessors.MessageHandlerAccessor; import de.hysky.skyblocker.utils.Http; import de.hysky.skyblocker.utils.Utils; import net.fabricmc.fabric.api.client.message.v1.ClientReceiveMessageEvents; @@ -52,7 +52,7 @@ public static void init() { private static void loadChatRules() { try (BufferedReader reader = Files.newBufferedReader(CHAT_RULE_FILE)) { - Map> chatRules = MAP_CODEC.parse(JsonOps.INSTANCE, JsonParser.parseReader(reader)).result().orElseThrow(); + Map> chatRules = MAP_CODEC.parse(JsonOps.INSTANCE, JsonParser.parseReader(reader)).getOrThrow(); LOGGER.info("[Skyblocker Chat Rules]: {}", chatRules); chatRuleList.addAll(chatRules.get("rules")); @@ -98,7 +98,7 @@ private static void loadLocations() { protected static void saveChatRules() { JsonObject chatRuleJson = new JsonObject(); - chatRuleJson.add("rules", ChatRule.LIST_CODEC.encodeStart(JsonOps.INSTANCE, chatRuleList).result().orElseThrow()); + chatRuleJson.add("rules", ChatRule.LIST_CODEC.encodeStart(JsonOps.INSTANCE, chatRuleList).getOrThrow()); try (BufferedWriter writer = Files.newBufferedWriter(CHAT_RULE_FILE)) { SkyblockerMod.GSON.toJson(chatRuleJson, writer); LOGGER.info("[Skyblocker Chat Rules] Saved chat rules file"); @@ -139,9 +139,7 @@ private static boolean checkMessage(Text message, boolean overlay) { //show replacement message in chat //bypass MessageHandler#onGameMessage to avoid activating chat rules again if (!rule.getHideMessage() && CLIENT.player != null) { - CLIENT.inGameHud.getChatHud().addMessage(newMessage); - ((MessageHandlerAccessor) CLIENT.getMessageHandler()).invokeAddToChatLog(newMessage, Instant.now()); - CLIENT.getNarratorManager().narrateSystemMessage(newMessage); + Utils.sendMessageToBypassEvents(newMessage); } //play sound diff --git a/src/main/java/de/hysky/skyblocker/skyblock/crimson/kuudra/KuudraWaypoints.java b/src/main/java/de/hysky/skyblocker/skyblock/crimson/kuudra/KuudraWaypoints.java index 790d434ad3..00cd85a076 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/crimson/kuudra/KuudraWaypoints.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/crimson/kuudra/KuudraWaypoints.java @@ -60,7 +60,7 @@ static void load(MinecraftClient client) { private static CompletableFuture loadWaypoints(MinecraftClient client, Identifier file, ObjectArrayList list, float[] colorComponents) { return CompletableFuture.supplyAsync(() -> { try (BufferedReader reader = client.getResourceManager().openAsReader(file)) { - return CODEC.apply(colorComponents).parse(JsonOps.INSTANCE, getWaypoints(reader)).result().orElseThrow(); + return CODEC.apply(colorComponents).parse(JsonOps.INSTANCE, getWaypoints(reader)).getOrThrow(); } catch (Exception e) { LOGGER.error("[Skyblocker Kuudra Waypoints] Failed to load kuudra waypoints from: {}", file, e); diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/CroesusHelper.java b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/CroesusHelper.java index 01422770ac..0bc34c5780 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/CroesusHelper.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/CroesusHelper.java @@ -1,13 +1,15 @@ package de.hysky.skyblocker.skyblock.dungeon; import de.hysky.skyblocker.config.SkyblockerConfigManager; +import de.hysky.skyblocker.utils.ItemUtils; import de.hysky.skyblocker.utils.render.gui.ColorHighlight; import de.hysky.skyblocker.utils.render.gui.ContainerSolver; +import it.unimi.dsi.fastutil.ints.Int2ObjectMap; +import net.minecraft.component.DataComponentTypes; import net.minecraft.item.ItemStack; import java.util.ArrayList; import java.util.List; -import java.util.Map; public class CroesusHelper extends ContainerSolver { @@ -21,15 +23,15 @@ protected boolean isEnabled() { } @Override - protected List getColors(String[] groups, Map slots) { + protected List getColors(String[] groups, Int2ObjectMap slots) { List highlights = new ArrayList<>(); - for (Map.Entry entry : slots.entrySet()) { + for (Int2ObjectMap.Entry entry : slots.int2ObjectEntrySet()) { ItemStack stack = entry.getValue(); - if (stack != null && stack.getNbt() != null) { - if (stack.getNbt().toString().contains("Opened Chest:")) { - highlights.add(ColorHighlight.gray(entry.getKey())); - } else if (stack.getNbt().toString().contains("No more Chests to open!")) { - highlights.add(ColorHighlight.red(entry.getKey())); + if (stack != null && stack.contains(DataComponentTypes.LORE)) { + if (ItemUtils.getLoreLineIf(stack, s -> s.contains("Opened Chest:")) != null) { + highlights.add(ColorHighlight.gray(entry.getIntKey())); + } else if (ItemUtils.getLoreLineIf(stack, s -> s.contains("No more Chests to open!")) != null) { + highlights.add(ColorHighlight.red(entry.getIntKey())); } } } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/CroesusProfit.java b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/CroesusProfit.java index ca166915ab..c6cbe2ce6a 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/CroesusProfit.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/CroesusProfit.java @@ -6,8 +6,11 @@ import de.hysky.skyblocker.utils.ItemUtils; import de.hysky.skyblocker.utils.render.gui.ColorHighlight; import de.hysky.skyblocker.utils.render.gui.ContainerSolver; +import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import net.minecraft.item.ItemStack; import net.minecraft.text.Text; +import net.minecraft.util.Util; + import org.jetbrains.annotations.NotNull; import java.util.ArrayList; @@ -29,15 +32,15 @@ protected boolean isEnabled() { } @Override - protected List getColors(String[] groups, Map slots) { + protected List getColors(String[] groups, Int2ObjectMap slots) { List highlights = new ArrayList<>(); ItemStack bestChest = null, secondBestChest = null; long bestValue = 0, secondBestValue = 0; // If negative value of chest - it is out of the question long dungeonKeyPriceData = getItemPrice("DUNGEON_CHEST_KEY") * 2; // lesser ones don't worth the hassle - for (Map.Entry entry : slots.entrySet()) { + for (Int2ObjectMap.Entry entry : slots.int2ObjectEntrySet()) { ItemStack stack = entry.getValue(); - if (stack != null && stack.getNbt() != null && stack.getName().toString().contains("Chest")) { + if (stack.getName().getString().contains("Chest")) { long value = valueChest(stack); if (value > bestValue) { secondBestChest = bestChest; @@ -51,13 +54,13 @@ protected List getColors(String[] groups, Map entry : slots.entrySet()) { + for (Int2ObjectMap.Entry entry : slots.int2ObjectEntrySet()) { ItemStack stack = entry.getValue(); - if (stack != null && stack.getNbt() != null) { + if (stack != null) { if (stack.equals(bestChest)) { - highlights.add(ColorHighlight.green(entry.getKey())); + highlights.add(ColorHighlight.green(entry.getIntKey())); } else if (stack.equals(secondBestChest) && secondBestValue > dungeonKeyPriceData) { - highlights.add(ColorHighlight.yellow(entry.getKey())); + highlights.add(ColorHighlight.yellow(entry.getIntKey())); } } } @@ -71,7 +74,7 @@ private long valueChest(@NotNull ItemStack chest) { List chestItems = new ArrayList<>(); boolean processingContents = false; - for (Text line : ItemUtils.getNbtTooltips(chest)) { + for (Text line : ItemUtils.getLore(chest)) { String lineString = line.getString(); if (lineString.contains("Contents")) { processingContents = true; @@ -124,144 +127,144 @@ private long getItemPrice(String itemDisplayName) { // I did a thing :( - final Map dungeonDropsNameToId = new HashMap<>() {{ - put("Enchanted Book (Ultimate Jerry I)", "ENCHANTMENT_ULTIMATE_JERRY_1"); // ultimate books start - put("Enchanted Book (Ultimate Jerry II)", "ENCHANTMENT_ULTIMATE_JERRY_2"); - put("Enchanted Book (Ultimate Jerry III)", "ENCHANTMENT_ULTIMATE_JERRY_3"); - put("Enchanted Book (Bank I)", "ENCHANTMENT_ULTIMATE_BANK_1"); - put("Enchanted Book (Bank II)", "ENCHANTMENT_ULTIMATE_BANK_2"); - put("Enchanted Book (Bank III)", "ENCHANTMENT_ULTIMATE_BANK_3"); - put("Enchanted Book (Combo I)", "ENCHANTMENT_ULTIMATE_COMBO_1"); - put("Enchanted Book (Combo II)", "ENCHANTMENT_ULTIMATE_COMBO_2"); - put("Enchanted Book (No Pain No Gain I)", "ENCHANTMENT_ULTIMATE_NO_PAIN_NO_GAIN_1"); - put("Enchanted Book (No Pain No Gain II)", "ENCHANTMENT_ULTIMATE_NO_PAIN_NO_GAIN_2"); - put("Enchanted Book (Ultimate Wise I)", "ENCHANTMENT_ULTIMATE_WISE_1"); - put("Enchanted Book (Ultimate Wise II)", "ENCHANTMENT_ULTIMATE_WISE_2"); - put("Enchanted Book (Wisdom I)", "ENCHANTMENT_ULTIMATE_WISDOM_1"); - put("Enchanted Book (Wisdom II)", "ENCHANTMENT_ULTIMATE_WISDOM_2"); - put("Enchanted Book (Last Stand I)", "ENCHANTMENT_ULTIMATE_LAST_STAND_1"); - put("Enchanted Book (Last Stand II)", "ENCHANTMENT_ULTIMATE_LAST_STAND_2"); - put("Enchanted Book (Rend I)", "ENCHANTMENT_ULTIMATE_REND_1"); - put("Enchanted Book (Rend II)", "ENCHANTMENT_ULTIMATE_REND_2"); - put("Enchanted Book (Legion I)", "ENCHANTMENT_ULTIMATE_LEGION_1"); - put("Enchanted Book (Swarm I)", "ENCHANTMENT_ULTIMATE_SWARM_1"); - put("Enchanted Book (One For All I)", "ENCHANTMENT_ULTIMATE_ONE_FOR_ALL_1"); - put("Enchanted Book (Soul Eater I)", "ENCHANTMENT_ULTIMATE_SOUL_EATER_1"); // ultimate books end - put("Enchanted Book (Infinite Quiver VI)", "ENCHANTMENT_INFINITE_QUIVER_6"); // enchanted books start - put("Enchanted Book (Infinite Quiver VII)", "ENCHANTMENT_INFINITE_QUIVER_7"); - put("Enchanted Book (Feather Falling VI)", "ENCHANTMENT_FEATHER_FALLING_6"); - put("Enchanted Book (Feather Falling VII)", "ENCHANTMENT_FEATHER_FALLING_7"); - put("Enchanted Book (Rejuvenate I)", "ENCHANTMENT_REJUVENATE_1"); - put("Enchanted Book (Rejuvenate II)", "ENCHANTMENT_REJUVENATE_2"); - put("Enchanted Book (Rejuvenate III)", "ENCHANTMENT_REJUVENATE_3"); - put("Enchanted Book (Overload)", "ENCHANTMENT_OVERLOAD_1"); - put("Enchanted Book (Lethality VI)", "ENCHANTMENT_LETHALITY_6"); - put("Enchanted Book (Thunderlord VII)", "ENCHANTMENT_THUNDERLORD_7"); // enchanted books end + private final Map dungeonDropsNameToId = Util.make(new HashMap<>(), map -> { + map.put("Enchanted Book (Ultimate Jerry I)", "ENCHANTMENT_ULTIMATE_JERRY_1"); // ultimate books start + map.put("Enchanted Book (Ultimate Jerry II)", "ENCHANTMENT_ULTIMATE_JERRY_2"); + map.put("Enchanted Book (Ultimate Jerry III)", "ENCHANTMENT_ULTIMATE_JERRY_3"); + map.put("Enchanted Book (Bank I)", "ENCHANTMENT_ULTIMATE_BANK_1"); + map.put("Enchanted Book (Bank II)", "ENCHANTMENT_ULTIMATE_BANK_2"); + map.put("Enchanted Book (Bank III)", "ENCHANTMENT_ULTIMATE_BANK_3"); + map.put("Enchanted Book (Combo I)", "ENCHANTMENT_ULTIMATE_COMBO_1"); + map.put("Enchanted Book (Combo II)", "ENCHANTMENT_ULTIMATE_COMBO_2"); + map.put("Enchanted Book (No Pain No Gain I)", "ENCHANTMENT_ULTIMATE_NO_PAIN_NO_GAIN_1"); + map.put("Enchanted Book (No Pain No Gain II)", "ENCHANTMENT_ULTIMATE_NO_PAIN_NO_GAIN_2"); + map.put("Enchanted Book (Ultimate Wise I)", "ENCHANTMENT_ULTIMATE_WISE_1"); + map.put("Enchanted Book (Ultimate Wise II)", "ENCHANTMENT_ULTIMATE_WISE_2"); + map.put("Enchanted Book (Wisdom I)", "ENCHANTMENT_ULTIMATE_WISDOM_1"); + map.put("Enchanted Book (Wisdom II)", "ENCHANTMENT_ULTIMATE_WISDOM_2"); + map.put("Enchanted Book (Last Stand I)", "ENCHANTMENT_ULTIMATE_LAST_STAND_1"); + map.put("Enchanted Book (Last Stand II)", "ENCHANTMENT_ULTIMATE_LAST_STAND_2"); + map.put("Enchanted Book (Rend I)", "ENCHANTMENT_ULTIMATE_REND_1"); + map.put("Enchanted Book (Rend II)", "ENCHANTMENT_ULTIMATE_REND_2"); + map.put("Enchanted Book (Legion I)", "ENCHANTMENT_ULTIMATE_LEGION_1"); + map.put("Enchanted Book (Swarm I)", "ENCHANTMENT_ULTIMATE_SWARM_1"); + map.put("Enchanted Book (One For All I)", "ENCHANTMENT_ULTIMATE_ONE_FOR_ALL_1"); + map.put("Enchanted Book (Soul Eater I)", "ENCHANTMENT_ULTIMATE_SOUL_EATER_1"); // ultimate books end + map.put("Enchanted Book (Infinite Quiver VI)", "ENCHANTMENT_INFINITE_QUIVER_6"); // enchanted books start + map.put("Enchanted Book (Infinite Quiver VII)", "ENCHANTMENT_INFINITE_QUIVER_7"); + map.put("Enchanted Book (Feather Falling VI)", "ENCHANTMENT_FEATHER_FALLING_6"); + map.put("Enchanted Book (Feather Falling VII)", "ENCHANTMENT_FEATHER_FALLING_7"); + map.put("Enchanted Book (Rejuvenate I)", "ENCHANTMENT_REJUVENATE_1"); + map.put("Enchanted Book (Rejuvenate II)", "ENCHANTMENT_REJUVENATE_2"); + map.put("Enchanted Book (Rejuvenate III)", "ENCHANTMENT_REJUVENATE_3"); + map.put("Enchanted Book (Overload)", "ENCHANTMENT_OVERLOAD_1"); + map.put("Enchanted Book (Lethality VI)", "ENCHANTMENT_LETHALITY_6"); + map.put("Enchanted Book (Thunderlord VII)", "ENCHANTMENT_THUNDERLORD_7"); // enchanted books end - put("Hot Potato Book", "HOT_POTATO_BOOK"); // HPB, FPB, Recomb (universal drops) - put("Fuming Potato Book", "FUMING_POTATO_BOOK"); - put("Recombobulator 3000", "RECOMBOBULATOR_3000"); - put("Necromancer's Brooch", "NECROMANCER_BROOCH"); - put("ESSENCE_WITHER","ESSENCE_WITHER"); // Essences. Really stupid way of doing this - put("ESSENCE_UNDEAD", "ESSENCE_UNDEAD"); - put("ESSENCE_DRAGON", "ESSENCE_DRAGON"); - put("ESSENCE_SPIDER", "ESSENCE_SPIDER"); - put("ESSENCE_ICE", "ESSENCE_ICE"); - put("ESSENCE_DIAMOND", "ESSENCE_DIAMOND"); - put("ESSENCE_GOLD", "ESSENCE_GOLD"); - put("ESSENCE_CRIMSON", "ESSENCE_CRIMSON"); - put("DUNGEON_CHEST_KEY", "DUNGEON_CHEST_KEY"); + map.put("Hot Potato Book", "HOT_POTATO_BOOK"); // HPB, FPB, Recomb (universal drops) + map.put("Fuming Potato Book", "FUMING_POTATO_BOOK"); + map.put("Recombobulator 3000", "RECOMBOBULATOR_3000"); + map.put("Necromancer's Brooch", "NECROMANCER_BROOCH"); + map.put("ESSENCE_WITHER","ESSENCE_WITHER"); // Essences. Really stupid way of doing this + map.put("ESSENCE_UNDEAD", "ESSENCE_UNDEAD"); + map.put("ESSENCE_DRAGON", "ESSENCE_DRAGON"); + map.put("ESSENCE_SPIDER", "ESSENCE_SPIDER"); + map.put("ESSENCE_ICE", "ESSENCE_ICE"); + map.put("ESSENCE_DIAMOND", "ESSENCE_DIAMOND"); + map.put("ESSENCE_GOLD", "ESSENCE_GOLD"); + map.put("ESSENCE_CRIMSON", "ESSENCE_CRIMSON"); + map.put("DUNGEON_CHEST_KEY", "DUNGEON_CHEST_KEY"); - put("Bonzo's Staff", "BONZO_STAFF"); // F1 M1 - put("Master Skull - Tier 1", "MASTER_SKULL_TIER_1"); - put("Bonzo's Mask", "BONZO_MASK"); - put("Balloon Snake", "BALLOON_SNAKE"); - put("Red Nose", "RED_NOSE"); + map.put("Bonzo's Staff", "BONZO_STAFF"); // F1 M1 + map.put("Master Skull - Tier 1", "MASTER_SKULL_TIER_1"); + map.put("Bonzo's Mask", "BONZO_MASK"); + map.put("Balloon Snake", "BALLOON_SNAKE"); + map.put("Red Nose", "RED_NOSE"); - put("Red Scarf", "RED_SCARF"); // F2 M2 - put("Adaptive Blade", "STONE_BLADE"); - put("Master Skull - Tier 2", "MASTER_SKULL_TIER_2"); - put("Adaptive Belt", "ADAPTIVE_BELT"); - put("Scarf's Studies", "SCARF_STUDIES"); + map.put("Red Scarf", "RED_SCARF"); // F2 M2 + map.put("Adaptive Blade", "STONE_BLADE"); + map.put("Master Skull - Tier 2", "MASTER_SKULL_TIER_2"); + map.put("Adaptive Belt", "ADAPTIVE_BELT"); + map.put("Scarf's Studies", "SCARF_STUDIES"); - put("First Master Star", "FIRST_MASTER_STAR"); // F3 M3 - put("Adaptive Helmet", "ADAPTIVE_HELMET"); - put("Adaptive Chestplate", "ADAPTIVE_CHESTPLATE"); - put("Adaptive Leggings", "ADAPTIVE_LEGGINGS"); - put("Adaptive Boots", "ADAPTIVE_BOOTS"); - put("Master Skull - Tier 3", "MASTER_SKULL_TIER_3"); - put("Suspicious Vial", "SUSPICIOUS_VIAL"); + map.put("First Master Star", "FIRST_MASTER_STAR"); // F3 M3 + map.put("Adaptive Helmet", "ADAPTIVE_HELMET"); + map.put("Adaptive Chestplate", "ADAPTIVE_CHESTPLATE"); + map.put("Adaptive Leggings", "ADAPTIVE_LEGGINGS"); + map.put("Adaptive Boots", "ADAPTIVE_BOOTS"); + map.put("Master Skull - Tier 3", "MASTER_SKULL_TIER_3"); + map.put("Suspicious Vial", "SUSPICIOUS_VIAL"); - put("Spirit Sword", "SPIRIT_SWORD"); // F4 M4 - put("Spirit Shortbow", "ITEM_SPIRIT_BOW"); - put("Spirit Boots", "THORNS_BOOTS"); - put("Spirit", "LVL_1_LEGENDARY_SPIRIT"); // Spirit pet (Legendary) - put("Spirit Epic", "LVL_1_EPIC_SPIRIT"); + map.put("Spirit Sword", "SPIRIT_SWORD"); // F4 M4 + map.put("Spirit Shortbow", "ITEM_SPIRIT_BOW"); + map.put("Spirit Boots", "THORNS_BOOTS"); + map.put("Spirit", "LVL_1_LEGENDARY_SPIRIT"); // Spirit pet (Legendary) + map.put("Spirit Epic", "LVL_1_EPIC_SPIRIT"); - put("Second Master Star", "SECOND_MASTER_STAR"); - put("Spirit Wing", "SPIRIT_WING"); - put("Spirit Bone", "SPIRIT_BONE"); - put("Spirit Stone", "SPIRIT_DECOY"); + map.put("Second Master Star", "SECOND_MASTER_STAR"); + map.put("Spirit Wing", "SPIRIT_WING"); + map.put("Spirit Bone", "SPIRIT_BONE"); + map.put("Spirit Stone", "SPIRIT_DECOY"); - put("Shadow Fury", "SHADOW_FURY"); // F5 M5 - put("Last Breath", "LAST_BREATH"); - put("Third Master Star", "THIRD_MASTER_STAR"); - put("Warped Stone", "AOTE_STONE"); - put("Livid Dagger", "LIVID_DAGGER"); - put("Shadow Assassin Helmet", "SHADOW_ASSASSIN_HELMET"); - put("Shadow Assassin Chestplate", "SHADOW_ASSASSIN_CHESTPLATE"); - put("Shadow Assassin Leggings", "SHADOW_ASSASSIN_LEGGINGS"); - put("Shadow Assassin Boots", "SHADOW_ASSASSIN_BOOTS"); - put("Shadow Assassin Cloak", "SHADOW_ASSASSIN_CLOAK"); - put("Master Skull - Tier 4", "MASTER_SKULL_TIER_4"); - put("Dark Orb", "DARK_ORB"); + map.put("Shadow Fury", "SHADOW_FURY"); // F5 M5 + map.put("Last Breath", "LAST_BREATH"); + map.put("Third Master Star", "THIRD_MASTER_STAR"); + map.put("Warped Stone", "AOTE_STONE"); + map.put("Livid Dagger", "LIVID_DAGGER"); + map.put("Shadow Assassin Helmet", "SHADOW_ASSASSIN_HELMET"); + map.put("Shadow Assassin Chestplate", "SHADOW_ASSASSIN_CHESTPLATE"); + map.put("Shadow Assassin Leggings", "SHADOW_ASSASSIN_LEGGINGS"); + map.put("Shadow Assassin Boots", "SHADOW_ASSASSIN_BOOTS"); + map.put("Shadow Assassin Cloak", "SHADOW_ASSASSIN_CLOAK"); + map.put("Master Skull - Tier 4", "MASTER_SKULL_TIER_4"); + map.put("Dark Orb", "DARK_ORB"); - put("Precursor Eye", "PRECURSOR_EYE"); // F6 M6 - put("Giant's Sword", "GIANTS_SWORD"); - put("Necromancer Lord Helmet", "NECROMANCER_LORD_HELMET"); - put("Necromancer Lord Chestplate", "NECROMANCER_LORD_CHESTPLATE"); - put("Necromancer Lord Leggings", "NECROMANCER_LORD_LEGGINGS"); - put("Necromancer Lord Boots", "NECROMANCER_LORD_BOOTS"); - put("Fourth Master Star", "FOURTH_MASTER_STAR"); - put("Summoning Ring", "SUMMONING_RING"); - put("Fel Skull", "FEL_SKULL"); - put("Necromancer Sword", "NECROMANCER_SWORD"); - put("Soulweaver Gloves", "SOULWEAVER_GLOVES"); - put("Sadan's Brooch", "SADAN_BROOCH"); - put("Giant Tooth", "GIANT_TOOTH"); + map.put("Precursor Eye", "PRECURSOR_EYE"); // F6 M6 + map.put("Giant's Sword", "GIANTS_SWORD"); + map.put("Necromancer Lord Helmet", "NECROMANCER_LORD_HELMET"); + map.put("Necromancer Lord Chestplate", "NECROMANCER_LORD_CHESTPLATE"); + map.put("Necromancer Lord Leggings", "NECROMANCER_LORD_LEGGINGS"); + map.put("Necromancer Lord Boots", "NECROMANCER_LORD_BOOTS"); + map.put("Fourth Master Star", "FOURTH_MASTER_STAR"); + map.put("Summoning Ring", "SUMMONING_RING"); + map.put("Fel Skull", "FEL_SKULL"); + map.put("Necromancer Sword", "NECROMANCER_SWORD"); + map.put("Soulweaver Gloves", "SOULWEAVER_GLOVES"); + map.put("Sadan's Brooch", "SADAN_BROOCH"); + map.put("Giant Tooth", "GIANT_TOOTH"); - put("Precursor Gear", "PRECURSOR_GEAR"); // F7 M7 - put("Necron Dye", "DYE_NECRON"); - put("Storm the Fish", "STORM_THE_FISH"); - put("Maxor the Fish", "MAXOR_THE_FISH"); - put("Goldor the Fish", "GOLDOR_THE_FISH"); - put("Dark Claymore", "DARK_CLAYMORE"); - put("Necron's Handle", "NECRON_HANDLE"); - put("Master Skull - Tier 5", "MASTER_SKULL_TIER_5"); - put("Shadow Warp", "SHADOW_WARP_SCROLL"); - put("Wither Shield", "WITHER_SHIELD_SCROLL"); - put("Implosion", "IMPLOSION_SCROLL"); - put("Fifth Master Star", "FIFTH_MASTER_STAR"); - put("Auto Recombobulator", "AUTO_RECOMBOBULATOR"); - put("Wither Helmet", "WITHER_HELMET"); - put("Wither Chestplate", "WITHER_CHESTPLATE"); - put("Wither Leggings", "WITHER_LEGGINGS"); - put("Wither Boots", "WITHER_BOOTS"); - put("Wither Catalyst", "WITHER_CATALYST"); - put("Wither Cloak Sword", "WITHER_CLOAK"); - put("Wither Blood", "WITHER_BLOOD"); + map.put("Precursor Gear", "PRECURSOR_GEAR"); // F7 M7 + map.put("Necron Dye", "DYE_NECRON"); + map.put("Storm the Fish", "STORM_THE_FISH"); + map.put("Maxor the Fish", "MAXOR_THE_FISH"); + map.put("Goldor the Fish", "GOLDOR_THE_FISH"); + map.put("Dark Claymore", "DARK_CLAYMORE"); + map.put("Necron's Handle", "NECRON_HANDLE"); + map.put("Master Skull - Tier 5", "MASTER_SKULL_TIER_5"); + map.put("Shadow Warp", "SHADOW_WARP_SCROLL"); + map.put("Wither Shield", "WITHER_SHIELD_SCROLL"); + map.put("Implosion", "IMPLOSION_SCROLL"); + map.put("Fifth Master Star", "FIFTH_MASTER_STAR"); + map.put("Auto Recombobulator", "AUTO_RECOMBOBULATOR"); + map.put("Wither Helmet", "WITHER_HELMET"); + map.put("Wither Chestplate", "WITHER_CHESTPLATE"); + map.put("Wither Leggings", "WITHER_LEGGINGS"); + map.put("Wither Boots", "WITHER_BOOTS"); + map.put("Wither Catalyst", "WITHER_CATALYST"); + map.put("Wither Cloak Sword", "WITHER_CLOAK"); + map.put("Wither Blood", "WITHER_BLOOD"); - put("Shiny Wither Helmet", "SHINY_WITHER_HELMET"); // M7 shiny drops - put("Shiny Wither Chestplate", "SHINY_WITHER_CHESTPLATE"); - put("Shiny Wither Leggings", "SHINY_WITHER_LEGGINGS"); - put("Shiny Wither Boots", "SHINY_WITHER_BOOTS"); - put("Shiny Necron's Handle", "SHINY_NECRON_HANDLE"); // cool thing + map.put("Shiny Wither Helmet", "SHINY_WITHER_HELMET"); // M7 shiny drops + map.put("Shiny Wither Chestplate", "SHINY_WITHER_CHESTPLATE"); + map.put("Shiny Wither Leggings", "SHINY_WITHER_LEGGINGS"); + map.put("Shiny Wither Boots", "SHINY_WITHER_BOOTS"); + map.put("Shiny Necron's Handle", "SHINY_NECRON_HANDLE"); // cool thing - put("Dungeon Disc", "DUNGEON_DISC_1"); - put("Clown Disc", "DUNGEON_DISC_2"); - put("Watcher Disc", "DUNGEON_DISC_3"); - put("Old Disc", "DUNGEON_DISC_4"); - put("Necron Disc", "DUNGEON_DISC_5"); - }}; + map.put("Dungeon Disc", "DUNGEON_DISC_1"); + map.put("Clown Disc", "DUNGEON_DISC_2"); + map.put("Watcher Disc", "DUNGEON_DISC_3"); + map.put("Old Disc", "DUNGEON_DISC_4"); + map.put("Necron Disc", "DUNGEON_DISC_5"); + }); } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/DungeonMap.java b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/DungeonMap.java index f2986ec0ec..7a6cdcd042 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/DungeonMap.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/DungeonMap.java @@ -1,25 +1,32 @@ package de.hysky.skyblocker.skyblock.dungeon; import de.hysky.skyblocker.config.SkyblockerConfigManager; +import de.hysky.skyblocker.events.HudRenderEvents; +import de.hysky.skyblocker.skyblock.dungeon.secrets.DungeonManager; +import de.hysky.skyblocker.utils.Utils; import de.hysky.skyblocker.utils.scheduler.Scheduler; import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager; import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback; import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents; import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.render.LightmapTextureManager; import net.minecraft.client.render.MapRenderer; import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.component.DataComponentTypes; +import net.minecraft.component.type.MapIdComponent; import net.minecraft.item.FilledMapItem; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.item.map.MapState; public class DungeonMap { - private static final int DEFAULT_MAP_ID = 1024; - private static Integer cachedMapId = null; + private static final MapIdComponent DEFAULT_MAP_ID_COMPONENT = new MapIdComponent(1024); + private static MapIdComponent cachedMapIdComponent = null; public static void init() { + HudRenderEvents.AFTER_MAIN_HUD.register((context, tickDelta) -> render(context)); ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> dispatcher.register(ClientCommandManager.literal("skyblocker") .then(ClientCommandManager.literal("hud") .then(ClientCommandManager.literal("dungeon") @@ -34,7 +41,7 @@ public static void render(MatrixStack matrices) { MinecraftClient client = MinecraftClient.getInstance(); if (client.player == null || client.world == null) return; - int mapId = getMapId(client.player.getInventory().main.get(8)); + MapIdComponent mapId = getMapIdComponent(client.player.getInventory().main.get(8)); MapState state = FilledMapItem.getMapState(mapId, client.world); if (state == null) return; @@ -53,16 +60,21 @@ public static void render(MatrixStack matrices) { matrices.pop(); } - public static int getMapId(ItemStack stack) { - if (stack.isOf(Items.FILLED_MAP)) { - @SuppressWarnings("DataFlowIssue") - int mapId = FilledMapItem.getMapId(stack); - cachedMapId = mapId; - return mapId; - } else return cachedMapId != null ? cachedMapId : DEFAULT_MAP_ID; + public static MapIdComponent getMapIdComponent(ItemStack stack) { + if (stack.isOf(Items.FILLED_MAP) && stack.contains(DataComponentTypes.MAP_ID)) { + MapIdComponent mapIdComponent = stack.get(DataComponentTypes.MAP_ID); + cachedMapIdComponent = mapIdComponent; + return mapIdComponent; + } else return cachedMapIdComponent != null ? cachedMapIdComponent : DEFAULT_MAP_ID_COMPONENT; + } + + private static void render(DrawContext context) { + if (Utils.isInDungeons() && DungeonScore.isDungeonStarted() && !DungeonManager.isInBoss() && SkyblockerConfigManager.get().locations.dungeons.enableMap) { + render(context.getMatrices()); + } } private static void reset() { - cachedMapId = null; + cachedMapIdComponent = null; } } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/DungeonScoreHUD.java b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/DungeonScoreHUD.java index 1dfb1b9571..8d40217231 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/DungeonScoreHUD.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/DungeonScoreHUD.java @@ -1,6 +1,8 @@ package de.hysky.skyblocker.skyblock.dungeon; import de.hysky.skyblocker.config.SkyblockerConfigManager; +import de.hysky.skyblocker.events.HudRenderEvents; +import de.hysky.skyblocker.utils.Utils; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.DrawContext; import net.minecraft.client.util.math.MatrixStack; @@ -11,13 +13,19 @@ public class DungeonScoreHUD { private DungeonScoreHUD() { } + public static void init() { + HudRenderEvents.AFTER_MAIN_HUD.register((context, tickDelta) -> render(context)); + } + //This is 4+5 wide, needed to offset the extra width from bold numbers (3×1 wide) in S+ and the "+" (6 wide) so that it doesn't go off the screen if the score is S+ and the hud element is at the right edge of the screen private static final Text extraSpace = Text.literal(" ").append(Text.literal(" ").formatted(Formatting.BOLD)); - public static void render(DrawContext context) { - int x = SkyblockerConfigManager.get().locations.dungeons.dungeonScore.scoreX; - int y = SkyblockerConfigManager.get().locations.dungeons.dungeonScore.scoreY; - render(context, x, y); + private static void render(DrawContext context) { + if (Utils.isInDungeons() && DungeonScore.isDungeonStarted() && SkyblockerConfigManager.get().locations.dungeons.dungeonScore.enableScoreHUD) { + int x = SkyblockerConfigManager.get().locations.dungeons.dungeonScore.scoreX; + int y = SkyblockerConfigManager.get().locations.dungeons.dungeonScore.scoreY; + render(context, x, y); + } } public static void render(DrawContext context, int x, int y) { diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/FireFreezeStaffTimer.java b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/FireFreezeStaffTimer.java index e5d4f078e2..7c0aab4c50 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/FireFreezeStaffTimer.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/FireFreezeStaffTimer.java @@ -1,9 +1,9 @@ package de.hysky.skyblocker.skyblock.dungeon; import de.hysky.skyblocker.config.SkyblockerConfigManager; +import de.hysky.skyblocker.events.HudRenderEvents; import net.fabricmc.fabric.api.client.message.v1.ClientReceiveMessageEvents; import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents; -import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.DrawContext; @@ -14,7 +14,7 @@ public class FireFreezeStaffTimer { private static long fireFreezeTimer; public static void init() { - HudRenderCallback.EVENT.register(FireFreezeStaffTimer::onDraw); + HudRenderEvents.BEFORE_CHAT.register(FireFreezeStaffTimer::onDraw); ClientReceiveMessageEvents.GAME.register(FireFreezeStaffTimer::onChatMessage); ClientPlayConnectionEvents.JOIN.register((handler, sender, client) -> FireFreezeStaffTimer.reset()); } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/LividColor.java b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/LividColor.java index 15efe6e4b3..ee9791d542 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/LividColor.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/LividColor.java @@ -16,6 +16,7 @@ import net.minecraft.util.math.BlockPos; import java.util.Map; +import java.util.Set; public class LividColor { private static final Map WOOL_TO_FORMATTING = Map.of( @@ -40,6 +41,7 @@ public class LividColor { "Doctor Livid", Formatting.GRAY, "Vendetta Livid", Formatting.WHITE ); + public static final Set LIVID_NAMES = Set.copyOf(LIVID_TO_FORMATTING.keySet()); public static final SkyblockerConfig.LividColor CONFIG = SkyblockerConfigManager.get().locations.dungeons.lividColor; private static int tenTicks = 0; private static Formatting color; diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/partyfinder/FinderSettingsContainer.java b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/partyfinder/FinderSettingsContainer.java index 0a04877569..70902a17bc 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/partyfinder/FinderSettingsContainer.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/partyfinder/FinderSettingsContainer.java @@ -5,7 +5,6 @@ import net.minecraft.client.gui.Element; import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder; import net.minecraft.client.gui.widget.ContainerWidget; -import net.minecraft.client.item.TooltipContext; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.screen.GenericContainerScreenHandler; @@ -15,6 +14,8 @@ import java.util.ArrayList; import java.util.List; +import de.hysky.skyblocker.utils.ItemUtils; + public class FinderSettingsContainer extends ContainerWidget { private boolean isInitialized = false; private OptionDropdownWidget floorSelector; @@ -161,7 +162,7 @@ private int findBackSlotId(GenericContainerScreenHandler handler) { * @return true if all goes well */ private boolean setRangeFromTooltip(ItemStack stack, RangedValueWidget widget) { - for (Text text : stack.getTooltip(null, TooltipContext.BASIC)) { + for (Text text : ItemUtils.getLore(stack)) { String textLowerCase = text.getString().toLowerCase(); if (textLowerCase.contains("selected:")) { String[] split = text.getString().split(":"); @@ -186,7 +187,7 @@ private boolean setRangeFromTooltip(ItemStack stack, RangedValueWidget widget) { * @return true if all goes well */ private boolean setSelectedElementFromTooltip(Slot slot, ItemStack stack, OptionDropdownWidget dropdownWidget) { - for (Text text : stack.getTooltip(null, TooltipContext.BASIC)) { + for (Text text : ItemUtils.getLore(stack)) { String textLowerCase = text.getString().toLowerCase(); if (textLowerCase.contains("selected:")) { String[] split = text.getString().split(":"); diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/partyfinder/OptionDropdownWidget.java b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/partyfinder/OptionDropdownWidget.java index 64e45283a5..d2159751bf 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/partyfinder/OptionDropdownWidget.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/partyfinder/OptionDropdownWidget.java @@ -29,7 +29,6 @@ public OptionDropdownWidget(PartyFinderScreen screen, Text name, @Nullable Optio this.screen = screen; this.slotId = slotId; setX(x); - setRenderBackground(false); setRenderHeader(true, 25); this.name = name; this.selectedOption = selectedOption; @@ -55,7 +54,7 @@ public int getRowLeft() { } @Override - protected int getScrollbarPositionX() { + protected int getScrollbarX() { return getRowLeft() + getRowWidth(); } @@ -120,6 +119,14 @@ public void renderWidget(DrawContext context, int mouseX, int mouseY, float delt matrices.pop(); } } + + @Override + protected void drawHeaderAndFooterSeparators(DrawContext context) { + } + + @Override + protected void drawMenuListBackground(DrawContext context) { + } public void open(List