diff --git a/build.gradle.kts b/build.gradle.kts index ae7dcfe..07e8bab 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,10 +1,9 @@ plugins { - id("fabric-loom") version "1.10-SNAPSHOT" + id("net.fabricmc.fabric-loom") version "1.17-SNAPSHOT" } val targetVersion = findProperty("target_version") as String? ?: "1_21_4" val minecraftVersion = properties["minecraft_version_$targetVersion"] as String -val yarnMappings = properties["yarn_mappings_$targetVersion"] as String val loaderVersion = properties["loader_version_$targetVersion"] as String base { @@ -29,14 +28,13 @@ val meteorClientVersion = if (minecraftVersion == "1.21.1") "0.5.8" else minecra dependencies { // Fabric minecraft("com.mojang:minecraft:$minecraftVersion") - mappings("net.fabricmc:yarn:$yarnMappings:v2") - modImplementation("net.fabricmc:fabric-loader:$loaderVersion") + implementation("net.fabricmc:fabric-loader:$loaderVersion") // Meteor - modImplementation("meteordevelopment:meteor-client:$meteorClientVersion-SNAPSHOT") + implementation("meteordevelopment:meteor-client:$meteorClientVersion-SNAPSHOT") // Baritone - modCompileOnly("meteordevelopment:baritone:$minecraftVersion-SNAPSHOT") + compileOnly("meteordevelopment:baritone:$minecraftVersion-SNAPSHOT") } tasks { @@ -66,12 +64,12 @@ tasks { } java { - sourceCompatibility = JavaVersion.VERSION_21 - targetCompatibility = JavaVersion.VERSION_21 + sourceCompatibility = JavaVersion.VERSION_25 + targetCompatibility = JavaVersion.VERSION_25 } withType { options.encoding = "UTF-8" - options.release = 21 + options.release = 25 } } diff --git a/gradle.properties b/gradle.properties index e81c2ff..2f34571 100644 --- a/gradle.properties +++ b/gradle.properties @@ -12,9 +12,9 @@ yarn_mappings_1_21_1=1.21.1+build.3 loader_version_1_21_1=0.16.14 # 1.21.4 Fabric Properties -minecraft_version_1_21_4=1.21.4 -yarn_mappings_1_21_4=1.21.4+build.8 -loader_version_1_21_4=0.16.14 +minecraft_version_1_21_4=26.2 +# yarn_mappings_1_21_4=1.21.4+build.8 +loader_version_1_21_4=0.19.3 # 1.21.5 Fabric Properties minecraft_version_1_21_5=1.21.5 diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index a4b76b9..eddabd2 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index cea7a79..df6a6ad 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,7 +1,9 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.1-bin.zip networkTimeout=10000 +retries=0 +retryBackOffMs=500 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index f3b75f3..379a658 100755 --- a/gradlew +++ b/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ ############################################################################## # -# Gradle start up script for POSIX generated by Gradle. +# gradlew start up script for POSIX generated by Gradle. # # Important for running: # @@ -29,7 +29,7 @@ # bash, then to run this script, type that shell name before the whole # command line, like: # -# ksh Gradle +# ksh gradlew # # Busybox and similar reduced shells will NOT work, because this script # requires all of these POSIX shell features: @@ -57,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob//platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -114,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -172,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -205,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/gradlew.bat b/gradlew.bat index 9d21a21..8508ef6 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,94 +1,82 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem -@rem SPDX-License-Identifier: Apache-2.0 -@rem - -@if "%DEBUG%"=="" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%"=="" set DIRNAME=. -@rem This is normally unused -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if %ERRORLEVEL% equ 0 goto execute - -echo. 1>&2 -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 -echo. 1>&2 -echo Please set the JAVA_HOME variable in your environment to match the 1>&2 -echo location of your Java installation. 1>&2 - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. 1>&2 -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 -echo. 1>&2 -echo Please set the JAVA_HOME variable in your environment to match the 1>&2 -echo location of your Java installation. 1>&2 - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem gradlew startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +"%COMSPEC%" /c exit 1 + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +"%COMSPEC%" /c exit 1 + +:execute +@rem Setup the command line + + + +@rem Execute gradlew +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel + +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/src/main/java/xyz/omegaware/addon/commands/LinkCommand.java b/src/main/java/xyz/omegaware/addon/commands/LinkCommand.java index 859e581..fab1682 100644 --- a/src/main/java/xyz/omegaware/addon/commands/LinkCommand.java +++ b/src/main/java/xyz/omegaware/addon/commands/LinkCommand.java @@ -3,7 +3,7 @@ import com.mojang.brigadier.arguments.StringArgumentType; import com.mojang.brigadier.builder.LiteralArgumentBuilder; import meteordevelopment.meteorclient.commands.Command; -import net.minecraft.command.CommandSource; +import net.minecraft.client.multiplayer.ClientSuggestionProvider; import xyz.omegaware.addon.modules.TSRKitBotModule; public class LinkCommand extends Command { @@ -12,7 +12,7 @@ public LinkCommand() { } @Override - public void build(LiteralArgumentBuilder builder) { + public void build(LiteralArgumentBuilder builder) { builder.then(argument("2FACode", StringArgumentType.word()).executes(context -> { TSRKitBotModule.getIsLinked(StringArgumentType.getString(context, "2FACode")); return SINGLE_SUCCESS; diff --git a/src/main/java/xyz/omegaware/addon/commands/ShulkerQueueCommand.java b/src/main/java/xyz/omegaware/addon/commands/ShulkerQueueCommand.java index 97feb78..a853a8f 100644 --- a/src/main/java/xyz/omegaware/addon/commands/ShulkerQueueCommand.java +++ b/src/main/java/xyz/omegaware/addon/commands/ShulkerQueueCommand.java @@ -2,9 +2,9 @@ import com.mojang.brigadier.builder.LiteralArgumentBuilder; import meteordevelopment.meteorclient.commands.Command; -import net.minecraft.command.CommandSource; -import net.minecraft.item.ItemStack; -import net.minecraft.util.Formatting; +import net.minecraft.ChatFormatting; +import net.minecraft.client.multiplayer.ClientSuggestionProvider; +import net.minecraft.world.item.ItemStack; import xyz.omegaware.addon.modules.ItemFrameDupeModule; import xyz.omegaware.addon.utils.Logger; @@ -14,21 +14,21 @@ public ShulkerQueueCommand() { } @Override - public void build(LiteralArgumentBuilder builder) { + public void build(LiteralArgumentBuilder builder) { builder.then(literal("add").executes(context -> { if (mc.player == null) { Logger.error("Player was somehow null"); return SINGLE_SUCCESS; } - ItemStack stack = mc.player.getMainHandStack(); + ItemStack stack = mc.player.getMainHandItem(); if (stack.isEmpty()) { Logger.error("You must hold an item in your main hand"); return SINGLE_SUCCESS; } ItemFrameDupeModule.shulkerQueue.add(stack.copy()); - Logger.info("%sAdded %s to the shulker queue", Formatting.GREEN, stack.toHoverableText()); + Logger.info("%sAdded %s to the shulker queue", ChatFormatting.GREEN, stack.getDisplayName()); return SINGLE_SUCCESS; })); @@ -39,7 +39,7 @@ public void build(LiteralArgumentBuilder builder) { return SINGLE_SUCCESS; } - ItemStack stack = mc.player.getMainHandStack(); + ItemStack stack = mc.player.getMainHandItem(); if (stack.isEmpty()) { Logger.error("You must hold an item in your main hand"); return SINGLE_SUCCESS; @@ -51,7 +51,7 @@ public void build(LiteralArgumentBuilder builder) { ItemFrameDupeModule.shulkerQueue.remove(stack.copy()); - Logger.info("%sRemoved%s %s from the shulker queue", Formatting.RED, Formatting.WHITE ,stack.toHoverableText()); + Logger.info("%sRemoved%s %s from the shulker queue", ChatFormatting.RED, ChatFormatting.WHITE ,stack.getDisplayName()); return SINGLE_SUCCESS; })); @@ -65,7 +65,7 @@ public void build(LiteralArgumentBuilder builder) { Logger.info("Shulker queue is empty"); } else { StringBuilder sb = new StringBuilder("Shulker queue: "); - ItemFrameDupeModule.shulkerQueue.forEach(itemStack -> sb.append(itemStack.toHoverableText().getString()).append("\n")); + ItemFrameDupeModule.shulkerQueue.forEach(itemStack -> sb.append(itemStack.getDisplayName().getString()).append("\n")); Logger.info(sb.toString()); } diff --git a/src/main/java/xyz/omegaware/addon/hud/ChestCount.java b/src/main/java/xyz/omegaware/addon/hud/ChestCount.java index deb16d5..47143e2 100644 --- a/src/main/java/xyz/omegaware/addon/hud/ChestCount.java +++ b/src/main/java/xyz/omegaware/addon/hud/ChestCount.java @@ -6,11 +6,11 @@ import meteordevelopment.meteorclient.systems.hud.HudRenderer; import meteordevelopment.meteorclient.utils.Utils; import meteordevelopment.meteorclient.utils.render.color.Color; -import net.minecraft.block.BlockState; -import net.minecraft.block.ChestBlock; -import net.minecraft.block.entity.BlockEntity; -import net.minecraft.block.entity.ChestBlockEntity; -import net.minecraft.block.enums.ChestType; +import net.minecraft.world.level.block.ChestBlock; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.entity.ChestBlockEntity; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.ChestType; import xyz.omegaware.addon.OmegawareAddons; import static meteordevelopment.meteorclient.MeteorClient.mc; @@ -24,14 +24,14 @@ public ChestCount() { @Override public void render(HudRenderer renderer) { - if (mc.player == null || mc.world == null) return; + if (mc.player == null || mc.level == null) return; int count = 0; for (BlockEntity blockEntity : Utils.blockEntities()) { if (!(blockEntity instanceof ChestBlockEntity chestBlock)) continue; - BlockState blockState = chestBlock.getCachedState(); - ChestType chestType = blockState.get(ChestBlock.CHEST_TYPE); + BlockState blockState = chestBlock.getBlockState(); + ChestType chestType = blockState.getValue(ChestBlock.TYPE); // Only count left chests to avoid double counting if (chestType.equals(ChestType.SINGLE) || chestType.equals(ChestType.RIGHT)) continue; diff --git a/src/main/java/xyz/omegaware/addon/hud/OnlineTSRMembersHUD.java b/src/main/java/xyz/omegaware/addon/hud/OnlineTSRMembersHUD.java index ff71fc5..734781a 100644 --- a/src/main/java/xyz/omegaware/addon/hud/OnlineTSRMembersHUD.java +++ b/src/main/java/xyz/omegaware/addon/hud/OnlineTSRMembersHUD.java @@ -77,7 +77,7 @@ public void render(HudRenderer renderer) { //renderer.quad(x, y, getWidth(), getHeight(), Color.LIGHT_GRAY); // get all online players from tab list - List onlinePlayers = new ArrayList<>(mc.player.networkHandler.getPlayerList().stream().map(playerInfo -> playerInfo.getProfile().getName()).toList()); + List onlinePlayers = new ArrayList<>(mc.player.connection.getOnlinePlayers().stream().map(playerInfo -> playerInfo.getProfile().name()).toList()); AtomicDouble screenY = new AtomicDouble(y+4); diff --git a/src/main/java/xyz/omegaware/addon/modules/BeaconRangeModule.java b/src/main/java/xyz/omegaware/addon/modules/BeaconRangeModule.java index 0ea92b8..c7495d9 100644 --- a/src/main/java/xyz/omegaware/addon/modules/BeaconRangeModule.java +++ b/src/main/java/xyz/omegaware/addon/modules/BeaconRangeModule.java @@ -5,16 +5,15 @@ import meteordevelopment.meteorclient.settings.*; import meteordevelopment.meteorclient.utils.Utils; import meteordevelopment.meteorclient.utils.render.color.SettingColor; -import net.minecraft.block.Blocks; -import net.minecraft.block.entity.BeaconBlockEntity; -import net.minecraft.block.entity.BlockEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Box; -import net.minecraft.world.World; import xyz.omegaware.addon.OmegawareAddons; import meteordevelopment.meteorclient.systems.modules.Module; import meteordevelopment.orbit.EventHandler; - +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.entity.BeaconBlockEntity; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.phys.AABB; import java.util.ArrayList; import java.util.List; @@ -87,14 +86,14 @@ List subtract(Rect2D o) { @EventHandler private void onRender(Render3DEvent event) { - List renderedBoxes = new ArrayList<>(); + List renderedBoxes = new ArrayList<>(); double epsilon = 0.001; for (BlockEntity blockEntity : Utils.blockEntities()) { if (!(blockEntity instanceof BeaconBlockEntity)) continue; - BlockPos pos = blockEntity.getPos(); - int level = getBeaconLevel(blockEntity.getWorld(), pos); + BlockPos pos = blockEntity.getBlockPos(); + int level = getBeaconLevel(blockEntity.getLevel(), pos); if (level < 1) continue; int range = 10 + (level * 10); @@ -106,13 +105,13 @@ private void onRender(Render3DEvent event) { double y2 = pos.getY() + range; double z2 = pos.getZ() + range; - List toRender = new ArrayList<>(); - toRender.add(new Box(x1, y1, z1, x2, y2, z2)); + List toRender = new ArrayList<>(); + toRender.add(new AABB(x1, y1, z1, x2, y2, z2)); if (cullOverlapping.get()) { - for (Box prev : renderedBoxes) { - List next = new ArrayList<>(); - for (Box box : toRender) { + for (AABB prev : renderedBoxes) { + List next = new ArrayList<>(); + for (AABB box : toRender) { next.addAll(subtractBox(box, prev)); } toRender = next; @@ -120,10 +119,10 @@ private void onRender(Render3DEvent event) { } } - renderedBoxes.add(new Box(x1, y1, z1, x2, y2, z2)); + renderedBoxes.add(new AABB(x1, y1, z1, x2, y2, z2)); // Per-face, per-section rendering - for (Box box : toRender) { + for (AABB box : toRender) { for (int axis = 0; axis < 3; axis++) { for (boolean isMin : new boolean[]{true, false}) { Rect2D faceRect; @@ -145,7 +144,7 @@ private void onRender(Render3DEvent event) { } List visible = new ArrayList<>(); visible.add(faceRect); - for (Box other : renderedBoxes) { + for (AABB other : renderedBoxes) { if (other == box) break; // Only check previous boxes boolean sharesFace = false; Rect2D overlap = null; @@ -216,8 +215,8 @@ private void onRender(Render3DEvent event) { } } - private List subtractBox(Box box, Box subtract) { - List result = new ArrayList<>(); + private List subtractBox(AABB box, AABB subtract) { + List result = new ArrayList<>(); if (!box.intersects(subtract)) { result.add(box); return result; @@ -231,38 +230,38 @@ private List subtractBox(Box box, Box subtract) { // Left if (x1 < sx1) - result.add(new Box(x1, y1, z1, sx1, y2, z2)); + result.add(new AABB(x1, y1, z1, sx1, y2, z2)); // Right if (x2 > sx2) - result.add(new Box(sx2, y1, z1, x2, y2, z2)); + result.add(new AABB(sx2, y1, z1, x2, y2, z2)); // Bottom if (y1 < sy1) - result.add(new Box(Math.max(x1, sx1), y1, z1, Math.min(x2, sx2), sy1, z2)); + result.add(new AABB(Math.max(x1, sx1), y1, z1, Math.min(x2, sx2), sy1, z2)); // Top if (y2 > sy2) - result.add(new Box(Math.max(x1, sx1), sy2, z1, Math.min(x2, sx2), y2, z2)); + result.add(new AABB(Math.max(x1, sx1), sy2, z1, Math.min(x2, sx2), y2, z2)); // Front if (z1 < sz1) - result.add(new Box(Math.max(x1, sx1), Math.max(y1, sy1), z1, Math.min(x2, sx2), Math.min(y2, sy2), sz1)); + result.add(new AABB(Math.max(x1, sx1), Math.max(y1, sy1), z1, Math.min(x2, sx2), Math.min(y2, sy2), sz1)); // Back if (z2 > sz2) - result.add(new Box(Math.max(x1, sx1), Math.max(y1, sy1), sz2, Math.min(x2, sx2), Math.min(y2, sy2), z2)); + result.add(new AABB(Math.max(x1, sx1), Math.max(y1, sy1), sz2, Math.min(x2, sx2), Math.min(y2, sy2), z2)); return result; } - public static int getBeaconLevel(World world, BlockPos beaconPos) { + public static int getBeaconLevel(Level world, BlockPos beaconPos) { int level = 0; for (int y = 1; y <= 4; y++) { int layerY = beaconPos.getY() - y; - if (layerY < world.getBottomY()) break; + if (layerY < world.getMinY()) break; boolean validLayer = true; for (int x = -y; x <= y; x++) { for (int z = -y; z <= y; z++) { - BlockPos checkPos = beaconPos.add(x, -y, z); + BlockPos checkPos = beaconPos.offset(x, -y, z); if (!isValidBeaconBase(world, checkPos)) { validLayer = false; break; @@ -281,12 +280,12 @@ public static int getBeaconLevel(World world, BlockPos beaconPos) { return level; } - private static boolean isValidBeaconBase(World world, BlockPos pos) { - return world.getBlockState(pos).isOf(Blocks.IRON_BLOCK) - || world.getBlockState(pos).isOf(Blocks.GOLD_BLOCK) - || world.getBlockState(pos).isOf(Blocks.EMERALD_BLOCK) - || world.getBlockState(pos).isOf(Blocks.DIAMOND_BLOCK) - || world.getBlockState(pos).isOf(Blocks.NETHERITE_BLOCK); + private static boolean isValidBeaconBase(Level world, BlockPos pos) { + return world.getBlockState(pos).is(Blocks.IRON_BLOCK) + || world.getBlockState(pos).is(Blocks.GOLD_BLOCK) + || world.getBlockState(pos).is(Blocks.EMERALD_BLOCK) + || world.getBlockState(pos).is(Blocks.DIAMOND_BLOCK) + || world.getBlockState(pos).is(Blocks.NETHERITE_BLOCK); } // End of BeaconCache } diff --git a/src/main/java/xyz/omegaware/addon/modules/BetterBaritoneBuild.java b/src/main/java/xyz/omegaware/addon/modules/BetterBaritoneBuild.java index ac7bb38..72fe2c8 100644 --- a/src/main/java/xyz/omegaware/addon/modules/BetterBaritoneBuild.java +++ b/src/main/java/xyz/omegaware/addon/modules/BetterBaritoneBuild.java @@ -29,21 +29,30 @@ import meteordevelopment.meteorclient.utils.player.SlotUtils; import meteordevelopment.meteorclient.utils.render.color.SettingColor; import meteordevelopment.orbit.EventHandler; -import net.minecraft.block.entity.*; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.network.ClientPlayNetworkHandler; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.registry.Registries; -import net.minecraft.screen.ScreenHandler; -import net.minecraft.screen.ScreenHandlerType; -import net.minecraft.text.MutableText; -import net.minecraft.text.Text; +import net.minecraft.ChatFormatting; +import net.minecraft.world.level.block.entity.*; +import net.minecraft.client.Minecraft; +import net.minecraft.client.multiplayer.ClientPacketListener; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.MutableComponent; +import net.minecraft.resources.Identifier; import net.minecraft.util.*; -import net.minecraft.util.hit.BlockHitResult; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.Vec3d; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.inventory.MenuType; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.block.entity.BarrelBlockEntity; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.entity.ChestBlockEntity; +import net.minecraft.world.level.block.entity.EnderChestBlockEntity; +import net.minecraft.world.level.block.entity.ShulkerBoxBlockEntity; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.Vec3; import xyz.omegaware.addon.OmegawareAddons; import xyz.omegaware.addon.utils.Logger; @@ -117,7 +126,7 @@ public static class Storage { public List inventory; public Storage() { - this.blockPos = BlockPos.ORIGIN; + this.blockPos = BlockPos.ZERO; this.inventory = new ArrayList<>(); } @@ -148,15 +157,15 @@ public List getAll() { return new ArrayList<>(storages); } - public Storage indexStorage(ScreenHandler screenHandler, BlockPos blockPos) { + public Storage indexStorage(AbstractContainerMenu screenHandler, BlockPos blockPos) { if (screenHandler == null || blockPos == null) return null; int max = 27; // Default size for most chests, shulker boxes, etc. - if (screenHandler.getType() == ScreenHandlerType.GENERIC_9X6) max = 27 * 2; + if (screenHandler.getType() == MenuType.GENERIC_9x6) max = 27 * 2; List inventory = new ArrayList<>(); for (int i = 0; i < max; i++) { - ItemStack stack = screenHandler.getSlot(i).getStack(); + ItemStack stack = screenHandler.getSlot(i).getItem(); if (!stack.isEmpty()) { inventory.add(stack); } @@ -186,25 +195,25 @@ public Storage findItem(Item item) { public void findItemAndPath(Item item) { Storage storage = findItem(item); if (storage != null) { - Logger.info("%s Navigating to storage containing:%s %s", Formatting.GREEN, Formatting.WHITE, item.getName().getString()); + Logger.info("%s Navigating to storage containing:%s %s", ChatFormatting.GREEN, ChatFormatting.WHITE, item.getName(item.getDefaultInstance()).getString()); EventRegistry.INSTANCE.push(new EventRegistry.Event(EventRegistry.Event.EventType.PathToPos, true, () -> OmegawareAddons.BETTER_BARITONE_BUILD.pathToPos(storage.blockPos))); EventRegistry.INSTANCE.push(new EventRegistry.Event(EventRegistry.Event.EventType.InteractWithBlock, true, () -> { - if (mc.player == null || mc.interactionManager == null) { + if (mc.player == null || mc.gameMode == null) { Logger.error("Player or interaction manager is null!"); return; } - mc.setScreen(null); // Close any open screens to ensure that we can interact with the storage block + mc.gui.setScreen(null); // Close any open screens to ensure that we can interact with the storage block - Vec3d hitPos = Vec3d.ofCenter(storage.blockPos); + Vec3 hitPos = Vec3.atCenterOf(storage.blockPos); BlockHitResult hit = new BlockHitResult(hitPos, Direction.UP, storage.blockPos, false); - ActionResult result = mc.interactionManager.interactBlock(mc.player, Hand.MAIN_HAND, hit); // Attempt to interact with the block + InteractionResult result = mc.gameMode.useItemOn(mc.player, InteractionHand.MAIN_HAND, hit); // Attempt to interact with the block if (OmegawareAddons.BETTER_BARITONE_BUILD.debugMode.get()) { - Logger.info("Attempted interact with block at %s, result: %s", storage.blockPos, result.isAccepted()); + Logger.info("Attempted interact with block at %s, result: %s", storage.blockPos, result.consumesAction()); } - if (result.isAccepted()) // If the interaction was successful, we can then make the player swing their hand - mc.player.swingHand(Hand.MAIN_HAND); + if (result.consumesAction()) // If the interaction was successful, we can then make the player swing their hand + mc.player.swing(InteractionHand.MAIN_HAND); })); } } @@ -212,14 +221,14 @@ public void findItemAndPath(Item item) { public void update() { storages.removeIf(storage -> { if (storage == null || storage.blockPos == null) return true; - assert MinecraftClient.getInstance().world != null; - if (!MinecraftClient.getInstance().world.isPosLoaded(storage.blockPos)) return false; + assert Minecraft.getInstance().level != null; + if (!Minecraft.getInstance().level.isLoaded(storage.blockPos)) return false; if (storage.inventory == null || storage.inventory.isEmpty()) { return true; } - return MinecraftClient.getInstance().world.getBlockState(storage.blockPos).isAir() || MinecraftClient.getInstance().world.getBlockEntity(storage.blockPos) == null; + return Minecraft.getInstance().level.getBlockState(storage.blockPos).isAir() || Minecraft.getInstance().level.getBlockEntity(storage.blockPos) == null; }); } @@ -250,7 +259,7 @@ void save() { JsonObject inventoryJson = new JsonObject(); for (ItemStack stack : storage.inventory) { if (!stack.isEmpty()) { - String itemId = Registries.ITEM.getId(stack.getItem()).toString(); + String itemId = BuiltInRegistries.ITEM.getKey(stack.getItem()).toString(); JsonObject itemData = new JsonObject(); itemData.addProperty("count", stack.getCount()); inventoryJson.add(itemId, itemData); @@ -290,7 +299,7 @@ void load() { Storage storage = new Storage(); if (storageJson.has("blockPos")) { - storage.blockPos = BlockPos.fromLong(storageJson.get("blockPos").getAsLong()); + storage.blockPos = BlockPos.of(storageJson.get("blockPos").getAsLong()); } if (storageJson.has("inventory")) { @@ -298,7 +307,7 @@ void load() { storage.inventory = new ArrayList<>(); for (String itemId : inventoryJson.keySet()) { - Item item = Registries.ITEM.get(Identifier.of(itemId)).asItem(); + Item item = BuiltInRegistries.ITEM.getValue(Identifier.parse(itemId)).asItem(); if (item != null) { JsonObject itemData = inventoryJson.getAsJsonObject(itemId); int count = itemData.get("count").getAsInt(); @@ -362,7 +371,7 @@ void load() { String content = Files.readString(configFile.toPath()); JsonObject payload = new GsonBuilder().setPrettyPrinting().create().fromJson(content, JsonObject.class); if (payload.has("home")) { - pos = BlockPos.fromLong(payload.get("home").getAsLong()); + pos = BlockPos.of(payload.get("home").getAsLong()); } } catch (Exception e) { OmegawareAddons.LOG.error("Failed to load Home from {}: {}", configFile.toPath(), e.getMessage()); @@ -548,7 +557,7 @@ public void onActivate() { return; } - baritone = BaritoneAPI.getProvider().getBaritoneForMinecraft(MinecraftClient.getInstance()); + baritone = BaritoneAPI.getProvider().getBaritoneForMinecraft(Minecraft.getInstance()); currentEvent = null; EventRegistry.INSTANCE.clear(); @@ -594,13 +603,13 @@ public WWidget getWidget(GuiTheme theme) { WButton setHomeBtn = theme.button("Set Home"); setHomeBtn.action = () -> { - if (mc.player == null || mc.world == null) return; + if (mc.player == null || mc.level == null) return; - Home.INSTANCE.setHome(mc.player.getBlockPos()); + Home.INSTANCE.setHome(mc.player.blockPosition()); Home.INSTANCE.save(); BlockPos home = Home.INSTANCE.getPos(); - Logger.info("%sHome point set to:%s X=%s, Y=%s, Z=%s", Formatting.GREEN, Formatting.WHITE, home.getX(), home.getY(), home.getZ()); + Logger.info("%sHome point set to:%s X=%s, Y=%s, Z=%s", ChatFormatting.GREEN, ChatFormatting.WHITE, home.getX(), home.getY(), home.getZ()); }; hList.add(setHomeBtn); @@ -609,7 +618,7 @@ public WWidget getWidget(GuiTheme theme) { printFetchListBtn.action = () -> { StringBuilder sb = new StringBuilder(); FetchRegistry.INSTANCE.get().forEach(material -> { - sb.append(String.format("Item: %s, Stacks: %d\n", material.item.getName().getString(), material.stacks)); + sb.append(String.format("Item: %s, Stacks: %d\n", material.item.getName(material.item.getDefaultInstance()).getString(), material.stacks)); }); Logger.info("Fetch List:\n%s", sb.toString()); @@ -680,11 +689,11 @@ private void onTickPost(TickEvent.Post event) { @EventHandler private void onRender(Render3DEvent event) { - if (!isActive() || mc.world == null || !highlightLinkedStorages.get()) return; + if (!isActive() || mc.level == null || !highlightLinkedStorages.get()) return; if (!invertHighlight.get()) { StorageRegistry.INSTANCE.getAll().forEach(storage -> { - if (storage.blockPos == null || !mc.world.isPosLoaded(storage.blockPos)) return; + if (storage.blockPos == null || !mc.level.isLoaded(storage.blockPos)) return; event.renderer.box(storage.blockPos, sideColor.get(), lineColor.get(), shapeMode.get(), 0); }); @@ -693,8 +702,8 @@ private void onRender(Render3DEvent event) { if (!(blockEntity instanceof ShulkerBoxBlockEntity || blockEntity instanceof ChestBlockEntity || blockEntity instanceof BarrelBlockEntity || blockEntity instanceof EnderChestBlockEntity)) continue; - BlockPos pos = blockEntity.getPos(); - if (!mc.world.isPosLoaded(pos) || StorageRegistry.INSTANCE.find(pos) != null) return; + BlockPos pos = blockEntity.getBlockPos(); + if (!mc.level.isLoaded(pos) || StorageRegistry.INSTANCE.find(pos) != null) return; event.renderer.box(pos, sideColor.get(), lineColor.get(), shapeMode.get(), 0); } @@ -703,9 +712,9 @@ private void onRender(Render3DEvent event) { @EventHandler private void onBlockInteract(InteractBlockEvent event) { - if (!isActive() || mc.world == null) return; + if (!isActive() || mc.level == null) return; - BlockEntity blockEntity = mc.world.getBlockEntity(event.result.getBlockPos()); + BlockEntity blockEntity = mc.level.getBlockEntity(event.result.getBlockPos()); if (!(blockEntity instanceof ShulkerBoxBlockEntity || blockEntity instanceof ChestBlockEntity || blockEntity instanceof BarrelBlockEntity || blockEntity instanceof EnderChestBlockEntity)) { if (debugMode.get()) Logger.error("Block entity is not a valid storage type!"); lastBlockInteractPos = null; @@ -746,11 +755,11 @@ private void onMessageReceive(ReceiveMessageEvent event) { blockName = blockName.substring(0, endIndex); } - Identifier identifier = Identifier.of(blockName); - Item item = Registries.ITEM.get(identifier).asItem(); + Identifier identifier = Identifier.parse(blockName); + Item item = BuiltInRegistries.ITEM.getValue(identifier).asItem(); if (item == null) { - if (debugMode.get()) Logger.error("Item not found: %s%s", Formatting.WHITE, blockName); + if (debugMode.get()) Logger.error("Item not found: %s%s", ChatFormatting.WHITE, blockName); return; } @@ -758,7 +767,7 @@ private void onMessageReceive(ReceiveMessageEvent event) { StorageRegistry.Storage storage = StorageRegistry.INSTANCE.findItem(item); if (storage == null) { - Logger.error("No linked storage contains the item: %s%s", Formatting.WHITE, item.getName().getString()); + Logger.error("No linked storage contains the item: %s%s", ChatFormatting.WHITE, item.getName(item.getDefaultInstance()).getString()); if (disconnectOnError.get()) { AutoReconnect autoReconnect = Modules.get().get(AutoReconnect.class); @@ -767,11 +776,11 @@ private void onMessageReceive(ReceiveMessageEvent event) { } String prefix = Logger.PREFIX.getString(); - MutableText text = Text.literal(String.format("%s%s%s%s %s", Formatting.GRAY, Formatting.BLUE, prefix.substring(0, prefix.length() - 1), Formatting.GRAY, Formatting.RED) + String.format("No linked storage contains the item: %s\n", item.getName().getString())); + MutableComponent text = Component.literal(String.format("%s%s%s%s %s", ChatFormatting.GRAY, ChatFormatting.BLUE, prefix.substring(0, prefix.length() - 1), ChatFormatting.GRAY, ChatFormatting.RED) + String.format("No linked storage contains the item: %s\n", item.getName(item.getDefaultInstance()).getString())); disconnectOnError.set(false); // Disable the setting to prevent infinite disconnects - ClientPlayNetworkHandler networkHandler = mc.getNetworkHandler(); + ClientPacketListener networkHandler = mc.getConnection(); if (networkHandler != null) { networkHandler.getConnection().disconnect(text); } @@ -796,9 +805,9 @@ private void onMessageReceive(ReceiveMessageEvent event) { } String prefix = Logger.PREFIX.getString(); - MutableText text = Text.literal(String.format("%s%s%s%s %s", Formatting.GRAY, Formatting.BLUE, prefix.substring(0, prefix.length() - 1), Formatting.GRAY, Formatting.RED) + "Baritone has finished building!"); + MutableComponent text = Component.literal(String.format("%s%s%s%s %s", ChatFormatting.GRAY, ChatFormatting.BLUE, prefix.substring(0, prefix.length() - 1), ChatFormatting.GRAY, ChatFormatting.RED) + "Baritone has finished building!"); - ClientPlayNetworkHandler networkHandler = mc.getNetworkHandler(); + ClientPacketListener networkHandler = mc.getConnection(); if (networkHandler != null) { networkHandler.getConnection().disconnect(text); } @@ -810,7 +819,7 @@ private void onMessageReceive(ReceiveMessageEvent event) { if (msg.startsWith("build") || msg.startsWith("litematica")) { buildCommand = msg; if (debugMode.get()) { - Logger.info("Build command captured: %s%s", Formatting.WHITE, buildCommand); + Logger.info("Build command captured: %s%s", ChatFormatting.WHITE, buildCommand); } return; } @@ -827,10 +836,10 @@ private void onMessageReceive(ReceiveMessageEvent event) { @EventHandler private void onInventory(InventoryEvent event) { - if (!isActive() || mc.player == null || mc.world == null || mc.currentScreen == null || lastBlockInteractPos == null) return; + if (!isActive() || mc.player == null || mc.level == null || mc.gui.screen() == null || lastBlockInteractPos == null) return; if (StorageRegistry.INSTANCE.find(lastBlockInteractPos) != null) { - StorageRegistry.Storage storage = StorageRegistry.INSTANCE.indexStorage(mc.player.currentScreenHandler, lastBlockInteractPos); + StorageRegistry.Storage storage = StorageRegistry.INSTANCE.indexStorage(mc.player.containerMenu, lastBlockInteractPos); StorageRegistry.INSTANCE.updateStorage(lastBlockInteractPos, storage.inventory); StorageRegistry.INSTANCE.update(); StorageRegistry.INSTANCE.save(); @@ -847,7 +856,7 @@ private void onInventory(InventoryEvent event) { FetchRegistry.INSTANCE.get().forEach(material -> { if (material.item == null || material.stacks <= 0) return; if (!interactionStorage.hasItem(material.item)) return; - ScreenHandler handler = mc.player.currentScreenHandler; + AbstractContainerMenu handler = mc.player.containerMenu; if (handler == null) return; MeteorExecutor.execute(() -> { @@ -855,10 +864,10 @@ private void onInventory(InventoryEvent event) { int count = 0; int max = 27; // Default size for most chests, shulker boxes, etc. - if (handler.getType() == ScreenHandlerType.GENERIC_9X6) max = 27 * 2; + if (handler.getType() == MenuType.GENERIC_9x6) max = 27 * 2; for (int i = 0; i < max; i++) { - if (!handler.getSlot(i).hasStack()) continue; + if (!handler.getSlot(i).hasItem()) continue; int sleep; if (initial) { @@ -873,9 +882,9 @@ private void onInventory(InventoryEvent event) { } // Exit if user closes screen or exit world - if (mc.currentScreen == null || !Utils.canUpdate()) break; + if (mc.gui.screen() == null || !Utils.canUpdate()) break; - Item item = handler.getSlot(i).getStack().getItem(); + Item item = handler.getSlot(i).getItem().getItem(); if (item != material.item) continue; count++; @@ -888,7 +897,7 @@ private void onInventory(InventoryEvent event) { FetchRegistry.Material updatedMaterial = FetchRegistry.INSTANCE.updateMaterial(material, material.stacks - count); if (debugMode.get()) { - Logger.info("Fetched %d stacks of %s%s, %d stacks remaining", count, Formatting.WHITE, material.item.getName().getString(), updatedMaterial != null ? updatedMaterial.stacks : 0); + Logger.info("Fetched %d stacks of %s%s, %d stacks remaining", count, ChatFormatting.WHITE, material.item.getName(material.item.getDefaultInstance()).getString(), updatedMaterial != null ? updatedMaterial.stacks : 0); } FetchRegistry.INSTANCE.update(); @@ -903,7 +912,7 @@ private void onInventory(InventoryEvent event) { if (!storageLinkMode.get() || StorageRegistry.INSTANCE.find(lastBlockInteractPos) != null) return; - StorageRegistry.Storage storage = StorageRegistry.INSTANCE.indexStorage(mc.player.currentScreenHandler, lastBlockInteractPos); + StorageRegistry.Storage storage = StorageRegistry.INSTANCE.indexStorage(mc.player.containerMenu, lastBlockInteractPos); if (storage == null) { if (debugMode.get()) Logger.error("Storage is null for block at %s", lastBlockInteractPos); return; @@ -926,13 +935,13 @@ private void onInventory(InventoryEvent event) { } public void pathToPos(BlockPos blockPos) { - if (mc.player == null || mc.world == null) return; + if (mc.player == null || mc.level == null) return; - if (debugMode.get()) Logger.info("%sNavigating to:%s X=%s, Y=%s, Z=%s", Formatting.GREEN, Formatting.WHITE, blockPos.getX(), blockPos.getY(), blockPos.getZ()); + if (debugMode.get()) Logger.info("%sNavigating to:%s X=%s, Y=%s, Z=%s", ChatFormatting.GREEN, ChatFormatting.WHITE, blockPos.getX(), blockPos.getY(), blockPos.getZ()); if (!ignoreY.get()) { baritone.getCustomGoalProcess().setGoalAndPath(new GoalGetToBlock(blockPos)); - } else baritone.getCustomGoalProcess().setGoalAndPath(new GoalGetToBlock(blockPos.withY(mc.player.getBlockY()))); + } else baritone.getCustomGoalProcess().setGoalAndPath(new GoalGetToBlock(blockPos.atY(mc.player.getBlockY()))); } } diff --git a/src/main/java/xyz/omegaware/addon/modules/BetterStashFinderModule.java b/src/main/java/xyz/omegaware/addon/modules/BetterStashFinderModule.java index a45e47a..84c1039 100644 --- a/src/main/java/xyz/omegaware/addon/modules/BetterStashFinderModule.java +++ b/src/main/java/xyz/omegaware/addon/modules/BetterStashFinderModule.java @@ -19,18 +19,28 @@ import meteordevelopment.meteorclient.systems.modules.world.StashFinder; import meteordevelopment.meteorclient.utils.render.MeteorToast; import meteordevelopment.orbit.EventHandler; -import net.minecraft.block.entity.*; -import net.minecraft.client.network.ClientPlayNetworkHandler; -import net.minecraft.item.Items; -import net.minecraft.text.MutableText; -import net.minecraft.text.Text; -import net.minecraft.util.Formatting; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.ChunkPos; +import net.minecraft.ChatFormatting; +import net.minecraft.world.level.block.entity.*; +import net.minecraft.client.multiplayer.ClientPacketListener; +import net.minecraft.core.BlockPos; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.MutableComponent; +import net.minecraft.world.item.Items; +import net.minecraft.world.level.ChunkPos; +import net.minecraft.world.level.block.entity.AbstractFurnaceBlockEntity; +import net.minecraft.world.level.block.entity.BarrelBlockEntity; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.world.level.block.entity.ChestBlockEntity; +import net.minecraft.world.level.block.entity.DispenserBlockEntity; +import net.minecraft.world.level.block.entity.EnderChestBlockEntity; +import net.minecraft.world.level.block.entity.HopperBlockEntity; +import net.minecraft.world.level.block.entity.ShulkerBoxBlockEntity; import xyz.omegaware.addon.OmegawareAddons; import xyz.omegaware.addon.utils.Logger; import java.io.*; +import java.nio.file.Files; import java.util.ArrayList; import java.util.Comparator; import java.util.List; @@ -103,8 +113,8 @@ public void onActivate() { @EventHandler private void onChunkData(ChunkDataEvent event) { // Check the distance. - double chunkXAbs = Math.abs(event.chunk().getPos().x * 16); - double chunkZAbs = Math.abs(event.chunk().getPos().z * 16); + double chunkXAbs = Math.abs(event.chunk().getPos().x() * 16); + double chunkZAbs = Math.abs(event.chunk().getPos().z() * 16); if (Math.sqrt(chunkXAbs * chunkXAbs + chunkZAbs * chunkZAbs) < minimumDistance.get()) return; StashFinder.Chunk chunk = new StashFinder.Chunk(event.chunk().getPos()); @@ -134,11 +144,11 @@ private void onChunkData(ChunkDataEvent event) { if (sendNotifications.get() && (!chunk.equals(prevChunk) || !chunk.countsEqual(prevChunk))) { switch (notificationMode.get()) { - case Chat -> info("Found stash at (highlight)%s(default), (highlight)%s(default).", chunk.x, chunk.z); - case Toast -> mc.getToastManager().add(new MeteorToast(Items.CHEST, title, "Found Stash!")); + case Chat -> info("Found stash at (highlight)%s(default), (highlight)%s(default).", chunk.chunkPos.getMiddleBlockX(), chunk.chunkPos.getMiddleBlockZ()); + case Toast -> mc.gui.toastManager().addToast(new MeteorToast.Builder(title).icon(Items.CHEST).text("Found Stash!").build()); case Both -> { - info("Found stash at (highlight)%s(default), (highlight)%s(default).", chunk.x, chunk.z); - mc.getToastManager().add(new MeteorToast(Items.CHEST, title, "Found Stash!")); + info("Found stash at (highlight)%s(default), (highlight)%s(default).", chunk.chunkPos.getMiddleBlockX(), chunk.chunkPos.getMiddleBlockX()); + mc.gui.toastManager().addToast(new MeteorToast.Builder(title).icon(Items.CHEST).text("Found Stash!").build()); } } } @@ -150,11 +160,11 @@ private void onChunkData(ChunkDataEvent event) { } String prefix = Logger.PREFIX.getString(); - MutableText text = Text.literal(String.format("%s%s%s%s %s", Formatting.GRAY, Formatting.BLUE, prefix.substring(0, prefix.length() - 1), Formatting.GRAY, Formatting.RED) + String.format("Found stash at %s, %s.", chunk.x, chunk.z)).append("\n"); + MutableComponent text = Component.literal(String.format("%s%s%s%s %s", ChatFormatting.GRAY, ChatFormatting.BLUE, prefix.substring(0, prefix.length() - 1), ChatFormatting.GRAY, ChatFormatting.RED) + String.format("Found stash at %s, %s.", chunk.chunkPos.getMiddleBlockX(), chunk.chunkPos.getMiddleBlockZ())).append("\n"); disconnectOnStashFound.set(false); // Disable the setting to prevent infinite disconnects - ClientPlayNetworkHandler networkHandler = mc.getNetworkHandler(); + ClientPacketListener networkHandler = mc.getConnection(); if (networkHandler != null) { networkHandler.getConnection().disconnect(text); } @@ -188,14 +198,14 @@ public WWidget getWidget(GuiTheme theme) { private void fillTable(GuiTheme theme, WTable table) { for (StashFinder.Chunk chunk : chunks) { - table.add(theme.label("Pos: " + chunk.x + ", " + chunk.z)); + table.add(theme.label("Pos: " + chunk.chunkPos.getMiddleBlockX() + ", " + chunk.chunkPos.getMiddleBlockZ())); table.add(theme.label("Total: " + chunk.getTotal())); WButton open = table.add(theme.button("Open")).widget(); - open.action = () -> mc.setScreen(new ChunkScreen(theme, chunk)); + open.action = () -> mc.gui.setScreen(new ChunkScreen(theme, chunk)); WButton gotoBtn = table.add(theme.button("Goto")).widget(); - gotoBtn.action = () -> PathManagers.get().moveTo(new BlockPos(chunk.x, 0, chunk.z), true); + gotoBtn.action = () -> PathManagers.get().moveTo(new BlockPos(chunk.chunkPos.getMiddleBlockX(), 0, chunk.chunkPos.getMiddleBlockZ()), true); WMinus delete = table.add(theme.minus()).widget(); delete.action = () -> { @@ -217,7 +227,7 @@ private void saveCsv() { File file = OmegawareAddons.GetConfigFile("better-stash-finder", "stashes.csv"); //noinspection ResultOfMethodCallIgnored file.getParentFile().mkdirs(); - Writer writer = new FileWriter(file); + BufferedWriter writer = Files.newBufferedWriter(file.toPath()); writer.write("X,Z,Chests,Barrels,Shulkers,EnderChests,Furnaces,DispensersDroppers,Hoppers\n"); for (StashFinder.Chunk chunk : chunks) chunk.write(writer); @@ -252,8 +262,6 @@ private void load() { chunks = GSON.fromJson(reader, new TypeToken>() {}.getType()); reader.close(); - for (StashFinder.Chunk chunk : chunks) chunk.calculatePos(); - loaded = true; } catch (Exception ignored) { if (chunks == null) chunks = new ArrayList<>(); @@ -298,7 +306,7 @@ private static class ChunkScreen extends WindowScreen { private final StashFinder.Chunk chunk; public ChunkScreen(GuiTheme theme, StashFinder.Chunk chunk) { - super(theme, "Chunk at " + chunk.x + ", " + chunk.z); + super(theme, "Chunk at " + chunk.chunkPos.getMiddleBlockX() + ", " + chunk.chunkPos.getMiddleBlockZ()); this.chunk = chunk; } diff --git a/src/main/java/xyz/omegaware/addon/modules/ChatFilterModule.java b/src/main/java/xyz/omegaware/addon/modules/ChatFilterModule.java index 111c362..6d78c42 100644 --- a/src/main/java/xyz/omegaware/addon/modules/ChatFilterModule.java +++ b/src/main/java/xyz/omegaware/addon/modules/ChatFilterModule.java @@ -8,12 +8,12 @@ import meteordevelopment.meteorclient.gui.widgets.containers.WVerticalList; import meteordevelopment.meteorclient.gui.widgets.pressable.WButton; import meteordevelopment.meteorclient.settings.*; -import net.minecraft.text.Text; -import net.minecraft.util.Formatting; import xyz.omegaware.addon.OmegawareAddons; import meteordevelopment.meteorclient.events.game.ReceiveMessageEvent; import meteordevelopment.meteorclient.systems.modules.Module; import meteordevelopment.orbit.EventHandler; +import net.minecraft.ChatFormatting; +import net.minecraft.network.chat.Component; import xyz.omegaware.addon.utils.Logger; import java.io.File; @@ -165,7 +165,7 @@ private void onMessageReceive(ReceiveMessageEvent event) { if (!message.contains("»")) return; String username = message.split(" » ")[0]; - if (username.equals(mc.player.getNameForScoreboard())) return; + if (username.equals(mc.player.getScoreboardName())) return; boolean isRanked = false; if (message.startsWith("[")) { @@ -209,12 +209,12 @@ private void onMessageReceive(ReceiveMessageEvent event) { // Little thing for me as the Developer :) if (username.equals("LostEmotions") || username.equals("LostFriendships")) { - Text msg = Text.literal("[").formatted(Formatting.WHITE) - .append(Text.literal("OmegaWare").formatted(Formatting.AQUA)) - .append(Text.literal("] ")) - .append(username).formatted(Formatting.AQUA) - .append(Text.literal(" » ").formatted(Formatting.WHITE)) - .append(Text.literal(message).formatted(Formatting.AQUA)); + Component msg = Component.literal("[").withStyle(ChatFormatting.WHITE) + .append(Component.literal("OmegaWare").withStyle(ChatFormatting.AQUA)) + .append(Component.literal("] ")) + .append(username).withStyle(ChatFormatting.AQUA) + .append(Component.literal(" » ").withStyle(ChatFormatting.WHITE)) + .append(Component.literal(message).withStyle(ChatFormatting.AQUA)); event.setMessage(msg); } } @@ -226,7 +226,7 @@ public WWidget getWidget(GuiTheme theme) { WButton btn = theme.button("Print number of filtered messages"); btn.action = () -> { - Logger.info("%sTotal Filtered Messages: %s%d", Formatting.GREEN, Formatting.WHITE, filteredCount); + Logger.info("%sTotal Filtered Messages: %s%d", ChatFormatting.GREEN, ChatFormatting.WHITE, filteredCount); }; hList.add(btn); diff --git a/src/main/java/xyz/omegaware/addon/modules/ItemFrameDupeModule.java b/src/main/java/xyz/omegaware/addon/modules/ItemFrameDupeModule.java index 7343d1f..d9dfb94 100644 --- a/src/main/java/xyz/omegaware/addon/modules/ItemFrameDupeModule.java +++ b/src/main/java/xyz/omegaware/addon/modules/ItemFrameDupeModule.java @@ -9,18 +9,20 @@ import meteordevelopment.meteorclient.utils.player.FindItemResult; import meteordevelopment.meteorclient.utils.player.InvUtils; import meteordevelopment.orbit.EventHandler; -import net.minecraft.entity.Entity; -import net.minecraft.entity.decoration.ItemFrameEntity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.util.Hand; -import net.minecraft.util.hit.BlockHitResult; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Box; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.Vec3d; -import net.minecraft.world.GameMode; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.tags.ItemTags; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.decoration.ItemFrame; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.level.GameType; +import net.minecraft.world.phys.AABB; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.phys.EntityHitResult; import org.jetbrains.annotations.NotNull; import xyz.omegaware.addon.OmegawareAddons; import xyz.omegaware.addon.utils.Logger; @@ -133,13 +135,13 @@ private void onTickPost(TickEvent.Post event) { return; } - if (mc.player == null || mc.world == null || mc.interactionManager == null) return; - if (mc.world.getBlockState(mc.player.getBlockPos().up(3)).isAir()) return; - if (mc.interactionManager.getCurrentGameMode() != GameMode.SURVIVAL) return; + if (mc.player == null || mc.level == null || mc.gameMode == null) return; + if (mc.level.getBlockState(mc.player.blockPosition().above(3)).isAir()) return; + if (mc.gameMode.getPlayerMode() != GameType.SURVIVAL) return; - Box blockAbovePlayer = new Box(mc.player.getBlockPos().up(2)); - List entitiesAbovePlayer = mc.world.getOtherEntities(null, blockAbovePlayer); - entitiesAbovePlayer.removeIf(entity -> !(entity instanceof ItemFrameEntity)); + AABB blockAbovePlayer = new AABB(mc.player.blockPosition().above(2)); + List entitiesAbovePlayer = mc.level.getEntities(null, blockAbovePlayer); + entitiesAbovePlayer.removeIf(entity -> !(entity instanceof ItemFrame)); if (entitiesAbovePlayer.isEmpty()) { if (!getItemFrame()) return; @@ -153,10 +155,10 @@ private void onTickPost(TickEvent.Post event) { for (ItemStack queuedShulker : shulkerQueue) { int count = 0; List indices = new ArrayList<>(); - for (int i = 0; i < mc.player.getInventory().size(); i++) { - ItemStack invStack = mc.player.getInventory().getStack(i); + for (int i = 0; i < mc.player.getInventory().getContainerSize(); i++) { + ItemStack invStack = mc.player.getInventory().getItem(i); if (!invStack.isEmpty() && - invStack.toHoverableText().equals(queuedShulker.toHoverableText()) && + invStack.getDisplayName().equals(queuedShulker.getDisplayName()) && invStack.getItem() == queuedShulker.getItem() && isShulkerBox(invStack.getItem())) { count++; @@ -171,7 +173,7 @@ private void onTickPost(TickEvent.Post event) { for (int index : indices) { if (dropCount <= 0) break; int containerIndex = (index < 9) ? index + 36 : index; - if (!isShulkerBox(mc.player.getInventory().getStack(containerIndex).getItem())) continue; + if (!isShulkerBox(mc.player.getInventory().getItem(containerIndex).getItem())) continue; InvUtils.drop().slot(containerIndex); dropCount--; @@ -181,8 +183,8 @@ private void onTickPost(TickEvent.Post event) { } } - ItemFrameEntity frame = (ItemFrameEntity)entitiesAbovePlayer.getFirst(); - if (frame.getHeldItemStack().isEmpty()) { + ItemFrame frame = (ItemFrame)entitiesAbovePlayer.getFirst(); + if (frame.getItem().isEmpty()) { if (!getShulker()) return; interactItemFrame(frame); forceDelay = insertToRotateDelay.get(); @@ -204,8 +206,8 @@ private void onTickPost(TickEvent.Post event) { private boolean getItemFrame() { if (mc.player == null) return false; - int selectedSlot = mc.player.getInventory().selectedSlot; - if (mc.player.getInventory().getStack(selectedSlot).getItem() == Items.ITEM_FRAME) return true; + int selectedSlot = mc.player.getInventory().getSelectedSlot(); + if (mc.player.getInventory().getItem(selectedSlot).getItem() == Items.ITEM_FRAME) return true; FindItemResult res = InvUtils.findInHotbar(Items.ITEM_FRAME); FindItemResult resInv = InvUtils.find(Items.ITEM_FRAME); @@ -221,33 +223,33 @@ private boolean getItemFrame() { } public void placeItemFrame() { - if (mc.world == null || mc.player == null || mc.interactionManager == null) return; + if (mc.level == null || mc.player == null || mc.gameMode == null) return; - BlockPos targetPos = mc.player.getBlockPos().up(3); + BlockPos targetPos = mc.player.blockPosition().above(3); - if (mc.world.getBlockState(targetPos).isAir()) return; + if (mc.level.getBlockState(targetPos).isAir()) return; Direction face = Direction.DOWN; - Vec3d hitPos = Vec3d.ofCenter(targetPos); + Vec3 hitPos = Vec3.atCenterOf(targetPos); BlockHitResult hit = new BlockHitResult(hitPos, face, targetPos, false); - mc.interactionManager.interactBlock(mc.player, Hand.MAIN_HAND, hit); - mc.player.swingHand(Hand.MAIN_HAND); + mc.gameMode.useItemOn(mc.player, InteractionHand.MAIN_HAND, hit); + mc.player.swing(InteractionHand.MAIN_HAND); } - public void interactItemFrame(ItemFrameEntity frame) { - if (mc.player == null || mc.interactionManager == null) return; + public void interactItemFrame(ItemFrame frame) { + if (mc.player == null || mc.gameMode == null) return; - mc.interactionManager.interactEntity(mc.player, frame, Hand.MAIN_HAND); - mc.player.swingHand(Hand.MAIN_HAND); + mc.gameMode.interact(mc.player, frame, new EntityHitResult(frame), InteractionHand.MAIN_HAND); + mc.player.swing(InteractionHand.MAIN_HAND); } - public void attackItemFrame(ItemFrameEntity frame) { - if (mc.player == null || mc.interactionManager == null) return; + public void attackItemFrame(ItemFrame frame) { + if (mc.player == null || mc.gameMode == null) return; - mc.interactionManager.attackEntity(mc.player, frame); - mc.player.swingHand(Hand.MAIN_HAND); + mc.gameMode.attack(mc.player, frame); + mc.player.swing(InteractionHand.MAIN_HAND); } private boolean getShulker() { @@ -265,14 +267,14 @@ private boolean getShulker() { FindItemResult hotbarRes = InvUtils.findInHotbar(itemStack -> { Item item = itemStack.getItem(); - return isShulkerBox(item) && itemStack.getCount() > 0 && itemStack.isOf(shulkerStack.getItem()); + return isShulkerBox(item) && itemStack.getCount() > 0 && itemStack.is(shulkerStack.getItem()); }); if (hotbarRes.count() > 0) { - ItemStack itemStack = mc.player.getInventory().getStack(hotbarRes.slot()); + ItemStack itemStack = mc.player.getInventory().getItem(hotbarRes.slot()); if (itemStack.isEmpty()) return false; - if (itemStack.toHoverableText().equals(shulkerStack.toHoverableText()) && itemStack.getItem() == shulkerStack.getItem()) { + if (itemStack.getDisplayName().equals(shulkerStack.getDisplayName()) && itemStack.getItem() == shulkerStack.getItem()) { mc.player.getInventory().setSelectedSlot(hotbarRes.slot()); return true; } @@ -281,14 +283,14 @@ private boolean getShulker() { FindItemResult invRes = InvUtils.find(itemStack -> { Item item = itemStack.getItem(); - return isShulkerBox(item) && itemStack.getCount() > 0 && itemStack.isOf(shulkerStack.getItem()); + return isShulkerBox(item) && itemStack.getCount() > 0 && itemStack.is(shulkerStack.getItem()); }); if (invRes.count() > 0) { for (int i = 0; i < invRes.count(); i++) { - ItemStack itemStack = mc.player.getInventory().getStack(invRes.slot()); - if (itemStack.toHoverableText().equals(shulkerStack.toHoverableText()) && itemStack.getItem() == shulkerStack.getItem()) { - InvUtils.move().fromId(invRes.slot()).to(mc.player.getInventory().selectedSlot); + ItemStack itemStack = mc.player.getInventory().getItem(invRes.slot()); + if (itemStack.getDisplayName().equals(shulkerStack.getDisplayName()) && itemStack.getItem() == shulkerStack.getItem()) { + InvUtils.move().fromId(invRes.slot()).to(mc.player.getInventory().getSelectedSlot()); return true; } } @@ -314,31 +316,11 @@ private boolean getShulker() { return true; } - InvUtils.move().fromId(invRes.slot()).to(mc.player.getInventory().selectedSlot); + InvUtils.move().fromId(invRes.slot()).to(mc.player.getInventory().getSelectedSlot()); return true; } private boolean isShulkerBox(Item item) { - List<@NotNull Item> SHULKERS = List.of( - Items.SHULKER_BOX, - Items.WHITE_SHULKER_BOX, - Items.ORANGE_SHULKER_BOX, - Items.MAGENTA_SHULKER_BOX, - Items.LIGHT_BLUE_SHULKER_BOX, - Items.YELLOW_SHULKER_BOX, - Items.LIME_SHULKER_BOX, - Items.PINK_SHULKER_BOX, - Items.GRAY_SHULKER_BOX, - Items.LIGHT_GRAY_SHULKER_BOX, - Items.CYAN_SHULKER_BOX, - Items.PURPLE_SHULKER_BOX, - Items.BLUE_SHULKER_BOX, - Items.BROWN_SHULKER_BOX, - Items.GREEN_SHULKER_BOX, - Items.RED_SHULKER_BOX, - Items.BLACK_SHULKER_BOX - ); - - return SHULKERS.contains(item); + return item.builtInRegistryHolder().is(ItemTags.SHULKER_BOXES); } } diff --git a/src/main/java/xyz/omegaware/addon/modules/TPAAutomationModule.java b/src/main/java/xyz/omegaware/addon/modules/TPAAutomationModule.java index f14b15e..bbe6924 100644 --- a/src/main/java/xyz/omegaware/addon/modules/TPAAutomationModule.java +++ b/src/main/java/xyz/omegaware/addon/modules/TPAAutomationModule.java @@ -3,11 +3,11 @@ import meteordevelopment.meteorclient.settings.*; import meteordevelopment.meteorclient.systems.friends.Friends; import meteordevelopment.meteorclient.utils.player.ChatUtils; -import net.minecraft.util.Formatting; import xyz.omegaware.addon.OmegawareAddons; import meteordevelopment.meteorclient.events.game.ReceiveMessageEvent; import meteordevelopment.meteorclient.systems.modules.Module; import meteordevelopment.orbit.EventHandler; +import net.minecraft.ChatFormatting; import xyz.omegaware.addon.utils.Logger; import java.util.List; @@ -135,17 +135,17 @@ private void onMessageReceive(ReceiveMessageEvent event) { String username = matcher.group(1); - if (printTpaDetected.get()) Logger.info("%sTPA Detected:%s %s!", Formatting.RED, Formatting.WHITE, username); + if (printTpaDetected.get()) Logger.info("%sTPA Detected:%s %s!", ChatFormatting.RED, ChatFormatting.WHITE, username); if (approvedUsers.get().contains(username) || (acceptFriends.get() && Friends.get().get(username) != null) || (acceptTSRBots.get() && TSR_KIT_BOT_USERS.contains(username))) { ChatUtils.sendPlayerMsg("/tpy " + username); - if (printTpaAccepted.get()) Logger.info("%sAuto Accepted:%s %s!", Formatting.GREEN, Formatting.WHITE, username); + if (printTpaAccepted.get()) Logger.info("%sAuto Accepted:%s %s!", ChatFormatting.GREEN, ChatFormatting.WHITE, username); } else if (autoDeny.get()){ ChatUtils.sendPlayerMsg("/tpn " + username); - if (printTpaIgnored.get()) Logger.info("%sIgnored:%s %s!", Formatting.RED, Formatting.WHITE, username); + if (printTpaIgnored.get()) Logger.info("%sIgnored:%s %s!", ChatFormatting.RED, ChatFormatting.WHITE, username); } if (filterTpaMessages.get() && printTpaDetected.get()) event.cancel(); diff --git a/src/main/java/xyz/omegaware/addon/modules/TSRKitBotModule.java b/src/main/java/xyz/omegaware/addon/modules/TSRKitBotModule.java index b65de65..0a3b8bb 100644 --- a/src/main/java/xyz/omegaware/addon/modules/TSRKitBotModule.java +++ b/src/main/java/xyz/omegaware/addon/modules/TSRKitBotModule.java @@ -14,8 +14,8 @@ import meteordevelopment.meteorclient.settings.SettingGroup; import meteordevelopment.meteorclient.systems.modules.Module; import meteordevelopment.meteorclient.utils.network.Http; -import net.minecraft.client.MinecraftClient; -import net.minecraft.util.Formatting; +import net.minecraft.ChatFormatting; +import net.minecraft.client.Minecraft; import xyz.omegaware.addon.OmegawareAddons; import xyz.omegaware.addon.utils.Logger; @@ -198,8 +198,8 @@ public static boolean getIsLinked(String... code) { } JsonObject payload = new JsonObject(); - assert MinecraftClient.getInstance().player != null; - payload.addProperty("minecraft_username", MinecraftClient.getInstance().player.getName().getString()); + assert Minecraft.getInstance().player != null; + payload.addProperty("minecraft_username", Minecraft.getInstance().player.getName().getString()); payload.addProperty("discord_id", DiscordIPC.getUser().id); payload.addProperty("retrieve_code", code.length > 0 ? code[0] : ""); @@ -211,14 +211,14 @@ public static boolean getIsLinked(String... code) { if (response.statusCode() == 200) { String message = response.body().get("message").getAsString(); if (message != null && message.equals("Retrieval code sent to your Discord DMs.")) { - Logger.info("%sMessage: %s%sGrab the code and use the command .auth ", Formatting.GREEN, Formatting.WHITE, message); + Logger.info("%sMessage: %s%sGrab the code and use the command .auth ", ChatFormatting.GREEN, ChatFormatting.WHITE, message); return false; } // print api key to chat if (response.body().has("api_key")) { apiKey = response.body().get("api_key").getAsString(); - Logger.info("%sSet API Key:%s %s", Formatting.GREEN, Formatting.WHITE, apiKey); + Logger.info("%sSet API Key:%s %s", ChatFormatting.GREEN, ChatFormatting.WHITE, apiKey); saveApiKey(apiKey); } else { @@ -240,8 +240,8 @@ public static boolean getIsLinked(String... code) { private static void conditionallyPrintOrders(String... statusFlag) { if (!getIsLinked()) return; - assert MinecraftClient.getInstance().player != null; - Http.Request request = Http.get(apiUrl + "/order/history?minecraft_username=" + MinecraftClient.getInstance().player.getName().getString()) + assert Minecraft.getInstance().player != null; + Http.Request request = Http.get(apiUrl + "/order/history?minecraft_username=" + Minecraft.getInstance().player.getName().getString()) .header("Content-Type", "application/json") .header("x-api-key", apiKey); @@ -250,7 +250,7 @@ private static void conditionallyPrintOrders(String... statusFlag) { if (response.statusCode() == 200) { JsonArray orders = response.body().getAsJsonArray("orders"); if (orders.isEmpty()) { - Logger.info("%sNo order history.", Formatting.GREEN); + Logger.info("%sNo order history.", ChatFormatting.GREEN); return; } @@ -275,8 +275,8 @@ private static void conditionallyPrintOrders(String... statusFlag) { if (!isValidStatus) continue; Logger.info("%sOrder ID:%s %s\n | %sStatus:%s %s\n | %sRequest Type:%s %s\n | %sQuantity:%s %s", - Formatting.GREEN, Formatting.WHITE, orderId, Formatting.GREEN, Formatting.WHITE, status, - Formatting.GREEN, Formatting.WHITE, requestType, Formatting.GREEN, Formatting.WHITE, quantity); + ChatFormatting.GREEN, ChatFormatting.WHITE, orderId, ChatFormatting.GREEN, ChatFormatting.WHITE, status, + ChatFormatting.GREEN, ChatFormatting.WHITE, requestType, ChatFormatting.GREEN, ChatFormatting.WHITE, quantity); } } else { if (response.body() == null) { @@ -321,7 +321,7 @@ public WWidget getWidget(GuiTheme theme) { HttpResponse response = request.sendJsonResponse(JsonObject.class); if (response.statusCode() == 200) { - Logger.info("%sBalance:%s %s ",Formatting.GREEN, Formatting.WHITE, response.body().get("credits").getAsString()); + Logger.info("%sBalance:%s %s ",ChatFormatting.GREEN, ChatFormatting.WHITE, response.body().get("credits").getAsString()); } else { if (response.body() == null) { Logger.error("No response from server."); @@ -346,9 +346,9 @@ public WWidget getWidget(GuiTheme theme) { if (response.statusCode() == 200) { if (response.body().has("message")) { - Logger.info("%sMessage:%s %s", Formatting.WHITE, Formatting.GREEN, response.body().get("message").getAsString()); + Logger.info("%sMessage:%s %s", ChatFormatting.WHITE, ChatFormatting.GREEN, response.body().get("message").getAsString()); } else { - Logger.info("%sQueue Position:%s %s", Formatting.GREEN, Formatting.WHITE, response.body().get("position").getAsString()); + Logger.info("%sQueue Position:%s %s", ChatFormatting.GREEN, ChatFormatting.WHITE, response.body().get("position").getAsString()); } } else { if (response.body() == null) { @@ -531,21 +531,21 @@ public WWidget getWidget(GuiTheme theme) { HttpResponse response = request.sendJsonResponse(JsonObject.class); if (response.statusCode() == 200) { if (response.body().has("message")) { - Logger.info("%sMessage:%s %s", Formatting.GREEN, Formatting.WHITE,response.body().get("message").getAsString()); + Logger.info("%sMessage:%s %s", ChatFormatting.GREEN, ChatFormatting.WHITE,response.body().get("message").getAsString()); return; } else if (response.body().has("error")) { Logger.error("%s", response.body().get("error").getAsString()); return; } - Logger.info("%sOrder Placed:%s %s | %sPriority:%s %s", Formatting.GREEN, Formatting.WHITE, response.body().get("order_id").getAsString(), Formatting.GREEN, Formatting.WHITE, response.body().get("priority").getAsString()); + Logger.info("%sOrder Placed:%s %s | %sPriority:%s %s", ChatFormatting.GREEN, ChatFormatting.WHITE, response.body().get("order_id").getAsString(), ChatFormatting.GREEN, ChatFormatting.WHITE, response.body().get("priority").getAsString()); } else { if (response.body() == null) { Logger.error("No response from server."); return; } - Logger.error("%s", Formatting.WHITE, response.body().get("error").getAsString()); + Logger.error("%s", ChatFormatting.WHITE, response.body().get("error").getAsString()); } }; hList2.add(orderButton); @@ -580,14 +580,14 @@ public WWidget getWidget(GuiTheme theme) { HttpResponse response = request.sendJsonResponse(JsonObject.class); if (response.statusCode() == 200) { - Logger.info("%sCancel All Orders:%s %s", Formatting.GREEN, Formatting.WHITE, response.body().get("message").getAsString()); + Logger.info("%sCancel All Orders:%s %s", ChatFormatting.GREEN, ChatFormatting.WHITE, response.body().get("message").getAsString()); } else { if (response.body() == null) { Logger.error("No response from server."); return; } - Logger.error("%s", Formatting.WHITE, response.body().get("error").getAsString()); + Logger.error("%s", ChatFormatting.WHITE, response.body().get("error").getAsString()); } }; hList3.add(cancelAllButton); @@ -621,7 +621,7 @@ public WWidget getWidget(GuiTheme theme) { HttpResponse response = request.sendJsonResponse(JsonObject.class); if (response.statusCode() == 200) { - Logger.info("%sOrder Cancelled:%s %s", Formatting.GREEN, Formatting.WHITE, response.body().get("order_id").getAsString()); + Logger.info("%sOrder Cancelled:%s %s", ChatFormatting.GREEN, ChatFormatting.WHITE, response.body().get("order_id").getAsString()); } else { if (response.body() == null) { Logger.error("No response from server"); @@ -684,8 +684,8 @@ public WWidget getWidget(GuiTheme theme) { } Logger.info("%sTokens Sent:%s %s | %sNew Balance:%s %s", - Formatting.GREEN, Formatting.WHITE, response.body().get("message").getAsString(), - Formatting.GREEN, Formatting.WHITE, response.body().get("from_balance").getAsString()); + ChatFormatting.GREEN, ChatFormatting.WHITE, response.body().get("message").getAsString(), + ChatFormatting.GREEN, ChatFormatting.WHITE, response.body().get("from_balance").getAsString()); } else { if (response.body() == null) { Logger.error("No response from server."); diff --git a/src/main/java/xyz/omegaware/addon/utils/Logger.java b/src/main/java/xyz/omegaware/addon/utils/Logger.java index 3a5ba96..2368003 100644 --- a/src/main/java/xyz/omegaware/addon/utils/Logger.java +++ b/src/main/java/xyz/omegaware/addon/utils/Logger.java @@ -1,25 +1,25 @@ package xyz.omegaware.addon.utils; import meteordevelopment.meteorclient.utils.player.ChatUtils; -import net.minecraft.text.Text; -import net.minecraft.util.Formatting; +import net.minecraft.ChatFormatting; +import net.minecraft.network.chat.Component; public class Logger { - public static final Text PREFIX = Text.empty() - .append(Text.literal("[").formatted(Formatting.WHITE)) - .append(Text.literal("OmegaWare").formatted(Formatting.AQUA)) - .append(Text.literal("] ").formatted(Formatting.WHITE)); + public static final Component PREFIX = Component.empty() + .append(Component.literal("[").withStyle(ChatFormatting.WHITE)) + .append(Component.literal("OmegaWare").withStyle(ChatFormatting.AQUA)) + .append(Component.literal("] ").withStyle(ChatFormatting.WHITE)); - private static final Text WARN = Text.empty() - .append(Text.literal("[").formatted(Formatting.WHITE)) - .append(Text.literal("WARNING").formatted(Formatting.YELLOW)) - .append(Text.literal("] ").formatted(Formatting.WHITE)); + private static final Component WARN = Component.empty() + .append(Component.literal("[").withStyle(ChatFormatting.WHITE)) + .append(Component.literal("WARNING").withStyle(ChatFormatting.YELLOW)) + .append(Component.literal("] ").withStyle(ChatFormatting.WHITE)); - private static final Text ERROR = Text.empty() - .append(Text.literal("[").formatted(Formatting.WHITE)) - .append(Text.literal("ERROR").formatted(Formatting.RED)) - .append(Text.literal("] ").formatted(Formatting.WHITE)); + private static final Component ERROR = Component.empty() + .append(Component.literal("[").withStyle(ChatFormatting.WHITE)) + .append(Component.literal("ERROR").withStyle(ChatFormatting.RED)) + .append(Component.literal("] ").withStyle(ChatFormatting.WHITE)); /** * Sends a message to the chat with the given format string and arguments, prefixed with the OmegaWare prefix. @@ -29,7 +29,7 @@ public class Logger { * */ public static void info(String message, Object... args) { - ChatUtils.sendMsg(PREFIX.copy().append(Text.literal(String.format(message, args)))); + ChatUtils.sendMsg(PREFIX.copy().append(Component.literal(String.format(message, args)))); } /** @@ -41,7 +41,7 @@ public static void info(String message, Object... args) { * */ public static void warn(String message, Object... args) { - ChatUtils.sendMsg(PREFIX.copy().append(WARN).append(Text.literal(String.format(message, args))).formatted(Formatting.YELLOW)); + ChatUtils.sendMsg(PREFIX.copy().append(WARN).append(Component.literal(String.format(message, args))).withStyle(ChatFormatting.YELLOW)); } /** @@ -53,6 +53,6 @@ public static void warn(String message, Object... args) { * */ public static void error(String message, Object... args) { - ChatUtils.sendMsg(PREFIX.copy().append(ERROR).append(Text.literal(String.format(message, args))).formatted(Formatting.RED)); + ChatUtils.sendMsg(PREFIX.copy().append(ERROR).append(Component.literal(String.format(message, args))).withStyle(ChatFormatting.RED)); } } diff --git a/src/main/java/xyz/omegaware/addon/utils/ServerCheck.java b/src/main/java/xyz/omegaware/addon/utils/ServerCheck.java index 398394a..5069216 100644 --- a/src/main/java/xyz/omegaware/addon/utils/ServerCheck.java +++ b/src/main/java/xyz/omegaware/addon/utils/ServerCheck.java @@ -1,17 +1,18 @@ package xyz.omegaware.addon.utils; import net.fabricmc.loader.api.FabricLoader; -import net.minecraft.client.network.ServerInfo; +import net.minecraft.client.multiplayer.ServerData; + import static meteordevelopment.meteorclient.MeteorClient.mc; public class ServerCheck { public static boolean isNot6B6T() { if (FabricLoader.getInstance().isDevelopmentEnvironment()) return false; // Bypass check in dev environment - if (mc.isIntegratedServerRunning()) return true; - ServerInfo server = mc.getCurrentServerEntry(); + if (mc.hasSingleplayerServer()) return true; + ServerData server = mc.getCurrentServer(); if (server == null) return false; - return !server.address.endsWith("6b6t.org"); + return !server.ip.endsWith("6b6t.org"); } // Idk how to turn off the module from here diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 790dca2..185bb2a 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -7,6 +7,15 @@ "authors": [ "Omega172" ], + "contributors": [ + { + "name": "Abelpro678", + "contact": { + "homepage": "https://github.com/Abelkrijgtalles", + "modrinth": "https://modrinth.com/user/Abelpro678" + } + } + ], "contact": { "repo": "https://github.com/Omega172/OmegaWare-Addons" }, @@ -25,7 +34,7 @@ "omegaware-addons:commit": "${commit}" }, "depends": { - "java": ">=21", + "java": ">=25", "minecraft": ["${mc_version}"], "meteor-client": "*" } diff --git a/src/main/resources/omegaware-addons.mixins.json b/src/main/resources/omegaware-addons.mixins.json index 966ee2f..a8a6ae4 100644 --- a/src/main/resources/omegaware-addons.mixins.json +++ b/src/main/resources/omegaware-addons.mixins.json @@ -1,7 +1,7 @@ { "required": true, "package": "xyz.omegaware.addon.mixin", - "compatibilityLevel": "JAVA_21", + "compatibilityLevel": "JAVA_25", "client": [], "injectors": { "defaultRequire": 1