diff --git a/README.md b/README.md index c98745c..3055d53 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@

Genyo Addon

❤꧁ღ⊱♥ I have brain damge ♥⊱ღ꧂❤

-

Shoreline port into Meteor 1.21.4 plus other GENYO magic :D

+

Shoreline port into Meteor 1.21.11 plus other GENYO magic :D

@@ -31,7 +31,8 @@ You don't need anything more, we have everything you've ever wanted. Also things [Check out the website.](https://genyo.dev) International version: **Genyo Addon**
-*written for **Meteor 1.21.4*** +*written for **Meteor 1.21.11***
+Thank you [Sleeepyv](https://github.com/Sleeepyv) for updating Genyo. ## Features ✨ @@ -53,5 +54,6 @@ International version: **Genyo Addon**
- meteor for being awesome
- Credit to "John Genyo", the founder of Genyo Corporations
- also Shoreline for being shorelineistic
+
- Sleeepyv for updating to 1.21.11
- and other clients lol
diff --git a/build.gradle b/build.gradle index ecc5bfd..480b084 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,6 @@ plugins { id 'base' - id "fabric-loom" version "1.11-SNAPSHOT" + id "fabric-loom" version "1.14-SNAPSHOT" } version = project.mod_version @@ -35,7 +35,7 @@ dependencies { minecraft "com.mojang:minecraft:${project.minecraft_version}" mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" - modImplementation fabricApi.module("fabric-registry-sync-v0", "0.119.4+1.21.4") + modImplementation fabricApi.module("fabric-registry-sync-v0", "0.139.5+1.21.11") // Meteor modImplementation "meteordevelopment:meteor-client:${project.minecraft_version}-SNAPSHOT" @@ -46,6 +46,12 @@ dependencies { implementation "com.ferra13671:discord-ipc:1.2" include 'com.ferra13671:discord-ipc:1.2' + + // Jackson + implementation 'com.fasterxml.jackson.core:jackson-databind:2.15.2' + include 'com.fasterxml.jackson.core:jackson-databind:2.15.2' + + } tasks { diff --git a/gradle.properties b/gradle.properties index 33572a3..d33ba4c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,12 +1,13 @@ org.gradle.jvmargs=-Xmx2G +org.gradle.configuration-cache=false # Fabric Properties (https://fabricmc.net/develop) -minecraft_version=1.21.4 -yarn_mappings=1.21.4+build.8 -loader_version=0.16.4 +minecraft_version=1.21.11 +yarn_mappings=1.21.11+build.3 +loader_version=0.18.2 # Mod Properties -mod_version=1.1.1 +mod_version=2.0.0 maven_group=com.genyo archives_base_name=genyo-addon diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 943f0cb..f8e1ee3 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 ca025c8..bad7c24 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.0-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index 65dcd68..adff685 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. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/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/. @@ -83,10 +85,8 @@ done # This is normally unused # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -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. @@ -133,10 +132,13 @@ location of your Java installation." fi else JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. @@ -144,7 +146,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac @@ -152,7 +154,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then '' | soft) :;; #( *) # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -169,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" ) @@ -197,16 +198,19 @@ if "$cygwin" || "$msys" ; then done fi -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * 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 93e3f59..c4bdd3a 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -13,6 +13,8 @@ @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 ########################################################################## @@ -43,11 +45,11 @@ set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 if %ERRORLEVEL% equ 0 goto execute -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +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 @@ -57,22 +59,21 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto execute -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +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 %* +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* :end @rem End local scope for the variables with windows NT shell diff --git a/src/main/java/com/genyo/Genyo.java b/src/main/java/com/genyo/Genyo.java index bf10dda..422f1a3 100644 --- a/src/main/java/com/genyo/Genyo.java +++ b/src/main/java/com/genyo/Genyo.java @@ -134,7 +134,6 @@ private void initSystems() { private void initModules(Modules modules) { modules.add(new GenyoAutoEZ()); - modules.add(new AngelSexHulkenberg()); modules.add(new GenyoSurround()); modules.add(new GenyoWelcome()); modules.add(new GenyoSkinBlink()); @@ -156,6 +155,7 @@ private void initModules(Modules modules) { modules.add(new CombatBrainrot()); modules.add(new PacketDebug()); modules.add(new GenyoAutoMine()); + modules.add(new GenyoAutoMineV2()); modules.add(new GenyoAutoXP()); modules.add(new GenyoAutoArmor()); modules.add(new GenyoAutoTrap()); @@ -193,6 +193,7 @@ private void initHUD(Hud hud) { hud.register(BetterPlayerRadarHud.INFO); hud.register(LogoHud.INFO); hud.register(PingHud.INFO); + hud.register(GenyoTargetHud.INFO); HUD_ELEMENTS.add(PvPNeccessaryHud.INFO); HUD_ELEMENTS.add(ActiveGenyoHud.INFO); @@ -201,6 +202,7 @@ private void initHUD(Hud hud) { HUD_ELEMENTS.add(BetterPlayerRadarHud.INFO); HUD_ELEMENTS.add(LogoHud.INFO); HUD_ELEMENTS.add(PingHud.INFO); + HUD_ELEMENTS.add(GenyoTargetHud.INFO); } @Override diff --git a/src/main/java/com/genyo/commands/EnemiesCommand.java b/src/main/java/com/genyo/commands/EnemiesCommand.java index 705c8bb..d99ad13 100644 --- a/src/main/java/com/genyo/commands/EnemiesCommand.java +++ b/src/main/java/com/genyo/commands/EnemiesCommand.java @@ -23,12 +23,12 @@ public void build(LiteralArgumentBuilder builder) { .then((argument("player", PlayerListEntryArgumentTypeEx.create()) .executes(context -> { GameProfile profile = PlayerListEntryArgumentTypeEx.get(context).getProfile(); - if (profile.getName().equals(mc.player.getGameProfile().getName())) { + if (profile.name().equals(mc.player.getGameProfile().name())) { GenyoChatUtils.sendError("You can't add yourself as enemy."); return SINGLE_SUCCESS; } - Enemy enemy = new Enemy(profile.getName(), profile.getId()); + Enemy enemy = new Enemy(profile.name(), profile.id()); if (Enemies.get().add(enemy)) { GenyoChatUtils.sendMessage(Formatting.GRAY + "Added %s to enemies.".formatted(enemy.getName())); diff --git a/src/main/java/com/genyo/commands/arguments/PlayerListEntryArgumentTypeEx.java b/src/main/java/com/genyo/commands/arguments/PlayerListEntryArgumentTypeEx.java index 8e1ce20..19b2e77 100644 --- a/src/main/java/com/genyo/commands/arguments/PlayerListEntryArgumentTypeEx.java +++ b/src/main/java/com/genyo/commands/arguments/PlayerListEntryArgumentTypeEx.java @@ -39,7 +39,7 @@ public PlayerListEntry parse(StringReader reader) throws CommandSyntaxException PlayerListEntry playerListEntry = null; for (PlayerListEntry p : mc.getNetworkHandler().getPlayerList()) { - if (p.getProfile().getName().equalsIgnoreCase(argument)) { + if (p.getProfile().name().equalsIgnoreCase(argument)) { playerListEntry = p; break; } @@ -52,12 +52,12 @@ public PlayerListEntry parse(StringReader reader) throws CommandSyntaxException @Override public CompletableFuture listSuggestions(CommandContext context, SuggestionsBuilder builder) { Collection playerListEntries = mc.getNetworkHandler().getPlayerList(); - PlayerListEntry clientEntry = mc.getNetworkHandler().getPlayerListEntry(mc.player.getGameProfile().getName()); + PlayerListEntry clientEntry = mc.getNetworkHandler().getPlayerListEntry(mc.player.getGameProfile().name()); if (playerListEntries.contains(clientEntry)) playerListEntries.remove(clientEntry); // just made this to exclude yourself from the list, it was kinda annoying. - return CommandSource.suggestMatching(playerListEntries.stream().map(playerListEntry -> playerListEntry.getProfile().getName()), builder); + return CommandSource.suggestMatching(playerListEntries.stream().map(playerListEntry -> playerListEntry.getProfile().name()), builder); } @Override diff --git a/src/main/java/com/genyo/core/exporter/InfoExporter.java b/src/main/java/com/genyo/core/exporter/InfoExporter.java index 804e82a..acc54fe 100644 --- a/src/main/java/com/genyo/core/exporter/InfoExporter.java +++ b/src/main/java/com/genyo/core/exporter/InfoExporter.java @@ -34,6 +34,8 @@ public static void acquireInfo() { return; } + //asd + // Modules for (String category : categories) { List currentModules = acquireModules(category); diff --git a/src/main/java/com/genyo/core/render/Interpolation.java b/src/main/java/com/genyo/core/render/Interpolation.java index fbc86b2..173b600 100644 --- a/src/main/java/com/genyo/core/render/Interpolation.java +++ b/src/main/java/com/genyo/core/render/Interpolation.java @@ -38,9 +38,9 @@ public static Vec3d getRenderPosition(Entity entity, float tickDelta) */ public static Vec3d getInterpolatedPosition(Entity entity, float tickDelta) { - return new Vec3d(entity.prevX + ((entity.getX() - entity.prevX) * tickDelta), - entity.prevY + ((entity.getY() - entity.prevY) * tickDelta), - entity.prevZ + ((entity.getZ() - entity.prevZ) * tickDelta)); + return new Vec3d(entity.lastX + ((entity.getX() - entity.lastX) * tickDelta), + entity.lastY + ((entity.getY() - entity.lastY) * tickDelta), + entity.lastZ + ((entity.getZ() - entity.lastZ) * tickDelta)); } /** @@ -73,7 +73,7 @@ public static double interpolateDouble(double prev, double value, double factor) public static Box getInterpolatedBox(Box prevBox, Box box) { - double delta = mc.isPaused() ? 1f : mc.getRenderTickCounter().getTickDelta(true); + double delta = mc.isPaused() ? 1f : mc.getRenderTickCounter().getTickProgress(true); return new Box(interpolateDouble(prevBox.minX, box.minX, delta), interpolateDouble(prevBox.minY, box.minY, delta), @@ -90,7 +90,7 @@ public static Box getInterpolatedBox(Box prevBox, Box box) public static Box getInterpolatedEntityBox(Entity entity) { Box box = entity.getBoundingBox(); - Box prevBox = entity.getBoundingBox().offset(entity.prevX - entity.getX(), entity.prevY - entity.getY(), entity.prevZ - entity.getZ()); + Box prevBox = entity.getBoundingBox().offset(entity.lastX - entity.getX(), entity.lastY - entity.getY(), entity.lastZ - entity.getZ()); return getInterpolatedBox(prevBox, box); } diff --git a/src/main/java/com/genyo/core/sound/SoundManager.java b/src/main/java/com/genyo/core/sound/SoundManager.java index 718a65d..64039a7 100644 --- a/src/main/java/com/genyo/core/sound/SoundManager.java +++ b/src/main/java/com/genyo/core/sound/SoundManager.java @@ -10,6 +10,15 @@ public class SoundManager { + public static final Identifier GUI_HOVER_ID = Identifier.of("genyo:gui_hover"); + public static final SoundEvent GUI_HOVER = SoundEvent.of(GUI_HOVER_ID); + + public static final Identifier GUI_CLICK_LEFT_ID = Identifier.of("genyo:gui_click_left"); + public static final SoundEvent GUI_CLICK_LEFT = SoundEvent.of(GUI_CLICK_LEFT_ID); + + public static final Identifier GUI_CLICK_RIGHT_ID = Identifier.of("genyo:gui_click_right"); + public static final SoundEvent GUI_CLICK_RIGHT = SoundEvent.of(GUI_CLICK_RIGHT_ID); + public static final Identifier VINE_ID = Identifier.of("genyo:vine"); public static final SoundEvent VINE = SoundEvent.of(VINE_ID); @@ -31,6 +40,11 @@ public class SoundManager { public static final Identifier KIWI_ID = Identifier.of("genyo:kiwi"); public static final SoundEvent KIWI = SoundEvent.of(KIWI_ID); + public void playUISound(SoundEvent sound, float volume, float pitch) { + mc.getSoundManager().play( + net.minecraft.client.sound.PositionedSoundInstance.master(sound, pitch, volume) + ); + } public void playSound(SoundEvent sound) { if (mc.player != null && mc.world != null && GenyoConfig.get() != null) { mc.player.playSound(sound, (float) GenyoConfig.get().globalVolume.get() / 100f, 1f); @@ -57,6 +71,9 @@ public static void init() { Registry.register(Registries.SOUND_EVENT, BLACK_ID, BLACK); Registry.register(Registries.SOUND_EVENT, KEYPRESS_ID, KEYPRESS); Registry.register(Registries.SOUND_EVENT, KIWI_ID, KIWI); + Registry.register(Registries.SOUND_EVENT, GUI_HOVER_ID, GUI_HOVER); + Registry.register(Registries.SOUND_EVENT, GUI_CLICK_LEFT_ID, GUI_CLICK_LEFT); + Registry.register(Registries.SOUND_EVENT, GUI_CLICK_RIGHT_ID, GUI_CLICK_RIGHT); } } diff --git a/src/main/java/com/genyo/managers/network/NetworkManager.java b/src/main/java/com/genyo/managers/network/NetworkManager.java index cb906d3..2fbad9e 100644 --- a/src/main/java/com/genyo/managers/network/NetworkManager.java +++ b/src/main/java/com/genyo/managers/network/NetworkManager.java @@ -8,6 +8,7 @@ import meteordevelopment.meteorclient.events.packets.PacketEvent; import meteordevelopment.orbit.EventHandler; import net.minecraft.client.network.*; +import net.minecraft.client.world.ClientChunkLoadProgress; import net.minecraft.network.listener.ServerPlayPacketListener; import net.minecraft.network.packet.Packet; @@ -51,14 +52,23 @@ public void onPacketReceive(PacketEvent.Receive event) incomingCounter.updateCounter(); } - public void connect(final ServerAddress address, final ServerInfo info) - { - if (mc.getNetworkHandler() == null) - { - return; - } - mc.getNetworkHandler().getConnection().connect(address.getAddress(), address.getPort(), - new ClientLoginNetworkHandler(mc.getNetworkHandler().getConnection(), mc, info, null, false, null, null, null)); + public void connect(final ServerAddress address, final ServerInfo info) { + if (mc.getNetworkHandler() == null) return; + mc.getNetworkHandler().getConnection().connect( + address.getAddress(), + address.getPort(), + new ClientLoginNetworkHandler( + mc.getNetworkHandler().getConnection(), + mc, + info, + null, + false, + null, + text -> {}, + new ClientChunkLoadProgress(), + null + ) + ); } public void sendQuietPacket(final Packet p) @@ -129,7 +139,7 @@ public int getClientLatency() if (mc.getNetworkHandler() != null) { final PlayerListEntry playerEntry = - mc.getNetworkHandler().getPlayerListEntry(mc.player.getGameProfile().getId()); + mc.getNetworkHandler().getPlayerListEntry(mc.player.getGameProfile().id()); if (playerEntry != null) { return playerEntry.getLatency(); diff --git a/src/main/java/com/genyo/managers/player/InventoryManager.java b/src/main/java/com/genyo/managers/player/InventoryManager.java index 6bf5d1e..fbd52f3 100644 --- a/src/main/java/com/genyo/managers/player/InventoryManager.java +++ b/src/main/java/com/genyo/managers/player/InventoryManager.java @@ -23,6 +23,8 @@ import net.minecraft.screen.ScreenHandler; import net.minecraft.screen.slot.Slot; import net.minecraft.screen.slot.SlotActionType; +import net.minecraft.screen.sync.ComponentChangesHash; +import net.minecraft.screen.sync.ItemStackHash; import net.minecraft.util.collection.DefaultedList; import java.util.ArrayList; @@ -176,7 +178,7 @@ public void setSlotAlt(final int barSlot) */ public void setClientSlot(final int barSlot) { - if (mc.player.getInventory().selectedSlot != barSlot + if (mc.player.getInventory().getSelectedSlot() != barSlot && PlayerInventory.isValidHotbarIndex(barSlot)) { mc.player.getInventory().setSelectedSlot(barSlot); @@ -201,7 +203,7 @@ public void syncToClient() { if (isDesynced()) { - setSlotForced(mc.player.getInventory().selectedSlot); + setSlotForced(mc.player.getInventory().getSelectedSlot()); for (PreSwapData swapData : swapData) { @@ -212,7 +214,7 @@ public void syncToClient() public boolean isDesynced() { - return mc.player.getInventory().selectedSlot != slot; + return mc.player.getInventory().getSelectedSlot() != slot; } // @@ -260,57 +262,68 @@ public int findEmptySlot() * @param button * @param type */ - public int click(int slot, int button, SlotActionType type) - { - if (slot < 0) - { - return -1; - } + public int click(int slot, int button, SlotActionType type) { + if (slot < 0) return -1; + ScreenHandler screenHandler = mc.player.currentScreenHandler; DefaultedList defaultedList = screenHandler.slots; int i = defaultedList.size(); ArrayList list = Lists.newArrayListWithCapacity(i); - for (Slot slot1 : defaultedList) - { + for (Slot slot1 : defaultedList) { list.add(slot1.getStack().copy()); } screenHandler.onSlotClick(slot, button, type, mc.player); - Int2ObjectOpenHashMap int2ObjectMap = new Int2ObjectOpenHashMap<>(); - for (int j = 0; j < i; ++j) - { - ItemStack itemStack2; + + ComponentChangesHash.ComponentHasher hasher = component -> component.value().hashCode(); + Int2ObjectOpenHashMap int2ObjectMap = new Int2ObjectOpenHashMap<>(); + for (int j = 0; j < i; ++j) { ItemStack itemStack = list.get(j); - if (ItemStack.areEqual(itemStack, itemStack2 = defaultedList.get(j).getStack())) continue; - int2ObjectMap.put(j, itemStack2.copy()); + ItemStack itemStack2 = defaultedList.get(j).getStack(); + if (ItemStack.areEqual(itemStack, itemStack2)) continue; + int2ObjectMap.put(j, ItemStackHash.fromItemStack(itemStack2, hasher)); } - mc.player.networkHandler.sendPacket(new ClickSlotC2SPacket(screenHandler.syncId, screenHandler.getRevision(), slot, button, type, screenHandler.getCursorStack().copy(), int2ObjectMap)); + + mc.player.networkHandler.sendPacket(new ClickSlotC2SPacket( + screenHandler.syncId, + screenHandler.getRevision(), + (short) slot, + (byte) button, + type, + int2ObjectMap, + ItemStackHash.fromItemStack(screenHandler.getCursorStack(), hasher) + )); return screenHandler.getRevision(); } - public int click2(int slot, int button, SlotActionType type) - { - if (slot < 0) - { - return -1; - } + public int click2(int slot, int button, SlotActionType type) { + if (slot < 0) return -1; + ScreenHandler screenHandler = mc.player.currentScreenHandler; DefaultedList defaultedList = screenHandler.slots; int i = defaultedList.size(); ArrayList list = Lists.newArrayListWithCapacity(i); - for (Slot slot1 : defaultedList) - { + for (Slot slot1 : defaultedList) { list.add(slot1.getStack().copy()); } - // screenHandler.onSlotClick(slot, button, type, mc.player); - Int2ObjectOpenHashMap int2ObjectMap = new Int2ObjectOpenHashMap<>(); - for (int j = 0; j < i; ++j) - { - ItemStack itemStack2; + + ComponentChangesHash.ComponentHasher hasher = component -> component.value().hashCode(); + Int2ObjectOpenHashMap int2ObjectMap = new Int2ObjectOpenHashMap<>(); + for (int j = 0; j < i; ++j) { ItemStack itemStack = list.get(j); - if (ItemStack.areEqual(itemStack, itemStack2 = defaultedList.get(j).getStack())) continue; - int2ObjectMap.put(j, itemStack2.copy()); + ItemStack itemStack2 = defaultedList.get(j).getStack(); + if (ItemStack.areEqual(itemStack, itemStack2)) continue; + int2ObjectMap.put(j, ItemStackHash.fromItemStack(itemStack2, hasher)); } - mc.player.networkHandler.sendPacket(new ClickSlotC2SPacket(screenHandler.syncId, screenHandler.getRevision(), slot, button, type, screenHandler.getCursorStack().copy(), int2ObjectMap)); + + mc.player.networkHandler.sendPacket(new ClickSlotC2SPacket( + screenHandler.syncId, + screenHandler.getRevision(), + (short) slot, + (byte) button, + type, + int2ObjectMap, + ItemStackHash.fromItemStack(screenHandler.getCursorStack(), hasher) + )); return screenHandler.getRevision(); } @@ -324,7 +337,7 @@ public int getServerSlot() public int getClientSlot() { - return mc.player.getInventory().selectedSlot; + return mc.player.getInventory().getSelectedSlot(); } /** diff --git a/src/main/java/com/genyo/managers/player/MovementManager.java b/src/main/java/com/genyo/managers/player/MovementManager.java index 77a2339..26828e8 100644 --- a/src/main/java/com/genyo/managers/player/MovementManager.java +++ b/src/main/java/com/genyo/managers/player/MovementManager.java @@ -1,62 +1,37 @@ package com.genyo.managers.player; import com.genyo.events.network.PacketSneakingEvent; -import com.genyo.managers.Managers; import meteordevelopment.orbit.EventHandler; -import net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket; import static meteordevelopment.meteorclient.MeteorClient.mc; -import static net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket.Mode.PRESS_SHIFT_KEY; -import static net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket.Mode.RELEASE_SHIFT_KEY; public class MovementManager { private boolean packetSneaking; - /** - * @param y - */ - public void setMotionY(double y) - { + public void setMotionY(double y) { mc.player.setVelocity(mc.player.getVelocity().getX(), y, mc.player.getVelocity().getZ()); } - /** - * @param x - * @param z - */ - public void setMotionXZ(double x, double z) - { + public void setMotionXZ(double x, double z) { mc.player.setVelocity(x, mc.player.getVelocity().y, z); } - public void setMotionX(double x) - { + public void setMotionX(double x) { mc.player.setVelocity(x, mc.player.getVelocity().y, mc.player.getVelocity().z); } - public void setMotionZ(double z) - { + public void setMotionZ(double z) { mc.player.setVelocity(mc.player.getVelocity().x, mc.player.getVelocity().y, z); } - - public void setPacketSneaking(final boolean packetSneaking) - { + public void setPacketSneaking(final boolean packetSneaking) { this.packetSneaking = packetSneaking; - if (packetSneaking) - { - Managers.NETWORK.sendPacket(new ClientCommandC2SPacket(mc.player, PRESS_SHIFT_KEY)); - } - else - { - Managers.NETWORK.sendPacket(new ClientCommandC2SPacket(mc.player, RELEASE_SHIFT_KEY)); - } + mc.player.setSneaking(packetSneaking); } @EventHandler - public void onPacketSneak(PacketSneakingEvent event) - { + public void onPacketSneak(PacketSneakingEvent event) { event.setCancelled(packetSneaking); } diff --git a/src/main/java/com/genyo/managers/player/PositionManager.java b/src/main/java/com/genyo/managers/player/PositionManager.java index b89a511..c9712de 100644 --- a/src/main/java/com/genyo/managers/player/PositionManager.java +++ b/src/main/java/com/genyo/managers/player/PositionManager.java @@ -18,7 +18,7 @@ public class PositionManager { private double x, y, z; private BlockPos blockPos; // - private boolean sneaking, sprinting; + private boolean sprinting; // private boolean onGround; private boolean horizontalCollision; @@ -102,10 +102,10 @@ public Vec3d getEyePos() */ public final Vec3d getCameraPosVec(float tickDelta) { - double d = MathHelper.lerp(tickDelta, mc.player.prevX, getX()); - double e = MathHelper.lerp(tickDelta, mc.player.prevY, getY()) + double d = MathHelper.lerp(tickDelta, mc.player.lastX, getX()); + double e = MathHelper.lerp(tickDelta, mc.player.lastY, getY()) + (double) mc.player.getStandingEyeHeight(); - double f = MathHelper.lerp(tickDelta, mc.player.prevZ, getZ()); + double f = MathHelper.lerp(tickDelta, mc.player.lastZ, getZ()); return new Vec3d(d, e, f); } @@ -160,8 +160,6 @@ else if (event.packet instanceof ClientCommandC2SPacket packet) { case START_SPRINTING -> sprinting = true; case STOP_SPRINTING -> sprinting = false; - case PRESS_SHIFT_KEY -> sneaking = true; - case RELEASE_SHIFT_KEY -> sneaking = false; } } } @@ -190,13 +188,12 @@ public BlockPos getBlockPos() return blockPos; } + public boolean isSneaking() { + return mc.player != null && mc.player.isSneaking(); + } + /** * @return - */ - public boolean isSneaking() - { - return sneaking; - } /** * @return diff --git a/src/main/java/com/genyo/mixin/accessor/AccessorClientConnection.java b/src/main/java/com/genyo/mixin/accessor/AccessorClientConnection.java index a3e9be2..1491794 100644 --- a/src/main/java/com/genyo/mixin/accessor/AccessorClientConnection.java +++ b/src/main/java/com/genyo/mixin/accessor/AccessorClientConnection.java @@ -1,16 +1,15 @@ package com.genyo.mixin.accessor; +import io.netty.channel.ChannelFutureListener; import net.minecraft.network.ClientConnection; -import net.minecraft.network.PacketCallbacks; import net.minecraft.network.packet.Packet; +import org.jspecify.annotations.Nullable; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Invoker; -import javax.annotation.Nullable; - @Mixin(ClientConnection.class) public interface AccessorClientConnection { @Invoker("sendInternal") - void hookSendInternal(Packet packet, @Nullable PacketCallbacks callbacks, boolean flush); + void hookSendInternal(Packet packet, @Nullable ChannelFutureListener listener, boolean flush); } diff --git a/src/main/java/com/genyo/mixin/accessor/AccessorEntityVelocityUpdateS2CPacket.java b/src/main/java/com/genyo/mixin/accessor/AccessorEntityVelocityUpdateS2CPacket.java index 240d66d..2e92b64 100644 --- a/src/main/java/com/genyo/mixin/accessor/AccessorEntityVelocityUpdateS2CPacket.java +++ b/src/main/java/com/genyo/mixin/accessor/AccessorEntityVelocityUpdateS2CPacket.java @@ -1,6 +1,7 @@ package com.genyo.mixin.accessor; import net.minecraft.network.packet.s2c.play.EntityVelocityUpdateS2CPacket; +import net.minecraft.util.math.Vec3d; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mutable; import org.spongepowered.asm.mixin.gen.Accessor; @@ -8,15 +9,10 @@ @Mixin(EntityVelocityUpdateS2CPacket.class) public interface AccessorEntityVelocityUpdateS2CPacket { - @Accessor("velocityX") - @Mutable - void setVelocityX(int velocityX); - - @Accessor("velocityY") - @Mutable - void setVelocityY(int velocityY); + @Accessor("velocity") + Vec3d getVelocity(); - @Accessor("velocityZ") + @Accessor("velocity") @Mutable - void setVelocityZ(int velocityZ); + void setVelocity(Vec3d velocity); } diff --git a/src/main/java/com/genyo/mixin/accessor/AccessorInput.java b/src/main/java/com/genyo/mixin/accessor/AccessorInput.java new file mode 100644 index 0000000..427e777 --- /dev/null +++ b/src/main/java/com/genyo/mixin/accessor/AccessorInput.java @@ -0,0 +1,18 @@ +package com.genyo.mixin.accessor; + +import net.minecraft.client.input.Input; +import net.minecraft.util.math.Vec2f; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Mutable; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Mixin(Input.class) +public interface AccessorInput { + @Accessor("movementVector") + Vec2f getMovementVector(); + + @Mutable + @Accessor("movementVector") + void setMovementVector(Vec2f vec); +} + diff --git a/src/main/java/com/genyo/mixin/entity/MixinEntity.java b/src/main/java/com/genyo/mixin/entity/MixinEntity.java index 8a9a7f0..b4e28c5 100644 --- a/src/main/java/com/genyo/mixin/entity/MixinEntity.java +++ b/src/main/java/com/genyo/mixin/entity/MixinEntity.java @@ -22,7 +22,7 @@ public class MixinEntity { @Shadow - public float fallDistance; + public double fallDistance; @Shadow protected Vec3d movementMultiplier; @@ -55,7 +55,7 @@ private void hookSlowMovement(BlockState state, Vec3d multiplier, CallbackInfo c MeteorClient.EVENT_BUS.post(slowMovementEvent); if (slowMovementEvent.isCancelled()) { ci.cancel(); - this.fallDistance = 0.0f; + this.fallDistance = 0.0; this.movementMultiplier = multiplier.multiply(slowMovementEvent.multiplier); } } diff --git a/src/main/java/com/genyo/mixin/entity/player/MixinPlayerListEntry.java b/src/main/java/com/genyo/mixin/entity/player/MixinPlayerListEntry.java index f037eda..f7414a8 100644 --- a/src/main/java/com/genyo/mixin/entity/player/MixinPlayerListEntry.java +++ b/src/main/java/com/genyo/mixin/entity/player/MixinPlayerListEntry.java @@ -4,7 +4,8 @@ import com.mojang.authlib.GameProfile; import meteordevelopment.meteorclient.systems.modules.Modules; import net.minecraft.client.network.PlayerListEntry; -import net.minecraft.client.util.SkinTextures; +import net.minecraft.entity.player.SkinTextures; +import net.minecraft.util.AssetInfo; import net.minecraft.util.Identifier; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; @@ -24,16 +25,37 @@ public abstract class MixinPlayerListEntry { @Inject(method = "getSkinTextures", at = @At("TAIL"), cancellable = true) private void getSkinTextures(CallbackInfoReturnable info) { - if (((profile.getName().equals(mc.player.getGameProfile().getName()) - && profile.getId().equals(mc.player.getGameProfile().getId()))) - && Modules.get().isActive(GenyoCapes.class) - && Modules.get().get(GenyoCapes.class).getCapeTexture() != null) - { - Identifier identifier = Modules.get().get(GenyoCapes.class).getCapeTexture(); - SkinTextures texture = info.getReturnValue(); - - info.setReturnValue(new SkinTextures(texture.texture(), texture.textureUrl(), identifier, identifier, texture.model(), texture.secure())); + if (!Modules.get().isActive(GenyoCapes.class)) return; + + GenyoCapes mod = Modules.get().get(GenyoCapes.class); + String name = profile.name(); + + boolean isSelf = name.equals(mc.player.getGameProfile().name()) + && profile.id().equals(mc.player.getGameProfile().id()); + boolean isDev = mod.isDev(name); + + if (!isDev && !isSelf && !mod.everyoneConfig.get()) return; + + Identifier textureId; + Identifier texturePath; + + if (isDev) { + textureId = Identifier.of("genyo", "cape_dev"); + texturePath = Identifier.of("genyo", "textures/cape_dev.png"); + } else { + textureId = Identifier.of("genyo", "cape"); + texturePath = Identifier.of("genyo", "textures/cape.png"); } - } + SkinTextures original = info.getReturnValue(); + AssetInfo.TextureAssetInfo capeAsset = new AssetInfo.TextureAssetInfo(textureId, texturePath); + + info.setReturnValue(new SkinTextures( + original.body(), + capeAsset, + capeAsset, + original.model(), + original.secure() + )); + } } diff --git a/src/main/java/com/genyo/mixin/game/MixinSplashTextResourceSupplier.java b/src/main/java/com/genyo/mixin/game/MixinSplashTextResourceSupplier.java index b219ea0..2e65a4d 100644 --- a/src/main/java/com/genyo/mixin/game/MixinSplashTextResourceSupplier.java +++ b/src/main/java/com/genyo/mixin/game/MixinSplashTextResourceSupplier.java @@ -3,6 +3,7 @@ import com.genyo.systems.config.GenyoConfig; import net.minecraft.client.gui.screen.SplashTextRenderer; import net.minecraft.client.resource.SplashTextResourceSupplier; +import net.minecraft.text.Text; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; @@ -26,7 +27,7 @@ public abstract class MixinSplashTextResourceSupplier { private void onApply(CallbackInfoReturnable cir) { if (GenyoConfig.get() == null || !GenyoConfig.get().useGenyoSplashes.get()) return; - if (override) cir.setReturnValue(new SplashTextRenderer(splashes.get(random.nextInt(splashes.size())))); + if (override) cir.setReturnValue(new SplashTextRenderer(Text.literal(splashes.get(random.nextInt(splashes.size()))))); override = !override; } diff --git a/src/main/java/com/genyo/mixin/game/MixinTitleScreen.java b/src/main/java/com/genyo/mixin/game/MixinTitleScreen.java index 9e1a20d..2e57726 100644 --- a/src/main/java/com/genyo/mixin/game/MixinTitleScreen.java +++ b/src/main/java/com/genyo/mixin/game/MixinTitleScreen.java @@ -1,11 +1,11 @@ package com.genyo.mixin.game; import com.genyo.core.Changelog; +import net.minecraft.client.gui.Click; import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.screen.TitleScreen; import net.minecraft.text.Text; -import org.lwjgl.glfw.GLFW; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -25,9 +25,9 @@ private void onRender(DrawContext context, int mouseX, int mouseY, float delta, } @Inject(method = "mouseClicked", at = @At("HEAD"), cancellable = true) - private void onMouseClicked(double mouseX, double mouseY, int button, CallbackInfoReturnable info) { - if (button == GLFW.GLFW_MOUSE_BUTTON_LEFT) { - if (Changelog.onClicked(mouseX, mouseY)) info.setReturnValue(true); + private void onMouseClicked(Click click, boolean bl, CallbackInfoReturnable info) { + if (click.button() == 0) { // 0 = left mouse button + if (Changelog.onClicked(click.x(), click.y())) info.setReturnValue(true); } } } diff --git a/src/main/java/com/genyo/mixin/meteor/MixinBetterTab.java b/src/main/java/com/genyo/mixin/meteor/MixinBetterTab.java index c2fe0c3..4ba255c 100644 --- a/src/main/java/com/genyo/mixin/meteor/MixinBetterTab.java +++ b/src/main/java/com/genyo/mixin/meteor/MixinBetterTab.java @@ -24,7 +24,7 @@ private void injectGetPlayerName(PlayerListEntry playerListEntry, CallbackInfoRe Color enemyColor = Enemies.get().getEnemyColor(); enemyName = playerListEntry.getDisplayName(); - if (enemyName == null) enemyName = Text.literal(playerListEntry.getProfile().getName()); + if (enemyName == null) enemyName = Text.literal(playerListEntry.getProfile().name()); String nameString = enemyName.getString(); diff --git a/src/main/java/com/genyo/mixin/meteor/MixinWWidget.java b/src/main/java/com/genyo/mixin/meteor/MixinWWidget.java new file mode 100644 index 0000000..0a23237 --- /dev/null +++ b/src/main/java/com/genyo/mixin/meteor/MixinWWidget.java @@ -0,0 +1,57 @@ +package com.genyo.mixin.meteor; + +import com.genyo.managers.Managers; +import com.genyo.core.sound.SoundManager; +import com.genyo.systems.config.GenyoConfig; +import meteordevelopment.meteorclient.gui.themes.meteor.widgets.WMeteorModule; +import meteordevelopment.meteorclient.gui.widgets.WWidget; +import net.minecraft.client.gui.Click; +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.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(value = WWidget.class, remap = false) +public class MixinWWidget { + + @Shadow public boolean mouseOver; + @Unique private boolean genyo_wasOver = false; + + @Inject(method = "mouseMoved", at = @At("TAIL")) + private void onMouseMoved(double mouseX, double mouseY, + double lastMouseX, double lastMouseY, CallbackInfo ci) { + // Only fire on module buttons + if (!(((Object) this) instanceof WMeteorModule)) return; + + if (mouseOver && !genyo_wasOver) { + GenyoConfig cfg = GenyoConfig.get(); + if (cfg != null && cfg.guiSounds.get()) { + float vol = cfg.hoverVolume.get() / 100f; + Managers.SOUND.playUISound(SoundManager.GUI_HOVER, vol, 1f); + } + } + genyo_wasOver = mouseOver; + } + + @Inject(method = "mouseClicked", at = @At("HEAD")) + private void onMouseClicked(Click click, boolean doubled, + CallbackInfoReturnable cir) { + // Only fire on module buttons + if (!(((Object) this) instanceof WMeteorModule)) return; + if (!mouseOver) return; + + GenyoConfig cfg = GenyoConfig.get(); + if (cfg == null || !cfg.guiSounds.get()) return; + + float vol = cfg.clickVolume.get() / 100f; + + if (click.button() == 0) { + Managers.SOUND.playUISound(SoundManager.GUI_CLICK_LEFT, vol, 1f); + } else if (click.button() == 1) { + Managers.SOUND.playUISound(SoundManager.GUI_CLICK_RIGHT, vol, 1f); + } + } +} diff --git a/src/main/java/com/genyo/mixin/network/MixinClientPlayNetworkHandler.java b/src/main/java/com/genyo/mixin/network/MixinClientPlayNetworkHandler.java index dccf5b7..614343e 100644 --- a/src/main/java/com/genyo/mixin/network/MixinClientPlayNetworkHandler.java +++ b/src/main/java/com/genyo/mixin/network/MixinClientPlayNetworkHandler.java @@ -43,7 +43,7 @@ protected MixinClientPlayNetworkHandler(MinecraftClient client, ClientConnection super(client, connection, connectionState); } - @Inject(method = "onExplosion", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/NetworkThreadUtils;forceMainThread(Lnet/minecraft/network/packet/Packet;Lnet/minecraft/network/listener/PacketListener;Lnet/minecraft/util/thread/ThreadExecutor;)V", shift = At.Shift.AFTER)) + @Inject(method = "onExplosion", at = @At("HEAD")) private void onExplosionVelocity(ExplosionS2CPacket packet, CallbackInfo ci) { GenyoVelocity velocity = Modules.get().get(GenyoVelocity.class); if (velocity.explosionConfig.get()) { diff --git a/src/main/java/com/genyo/mixin/network/MixinClientPlayerEntity.java b/src/main/java/com/genyo/mixin/network/MixinClientPlayerEntity.java index 943ac5a..5bd5537 100644 --- a/src/main/java/com/genyo/mixin/network/MixinClientPlayerEntity.java +++ b/src/main/java/com/genyo/mixin/network/MixinClientPlayerEntity.java @@ -4,11 +4,11 @@ import com.genyo.events.entity.SwingEvent; import com.genyo.events.network.*; import com.genyo.events.sync.SyncEvent; -import com.genyo.events.network.*; import com.genyo.imixins.IClientPlayerEntity; import meteordevelopment.meteorclient.MeteorClient; import net.minecraft.client.input.Input; import net.minecraft.client.network.ClientPlayerEntity; +import net.minecraft.entity.Entity; import net.minecraft.util.Hand; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -29,11 +29,6 @@ public abstract class MixinClientPlayerEntity implements IClientPlayerEntity { @Unique private Runnable postAction; - @Shadow - private float lastYaw; - @Shadow - private float lastPitch; - @Shadow protected abstract void sendMovementPackets(); @@ -46,9 +41,6 @@ public abstract class MixinClientPlayerEntity implements IClientPlayerEntity { @Shadow public Input input; - /** - * @param ci - */ @Inject(method = "tick", at = @At(value = "INVOKE", target = "Lnet/" + "minecraft/client/network/AbstractClientPlayerEntity;tick()V", shift = At.Shift.BEFORE, ordinal = 0)) @@ -57,13 +49,9 @@ private void hookTickPre(CallbackInfo ci) MeteorClient.EVENT_BUS.post(new PlayerTickEvent()); } - /** - * @param ci - */ @Inject(method = "sendMovementPackets", at = @At(value = "HEAD"), cancellable = true) private void hookSendMovementPackets(CallbackInfo ci) { - //if (fullNullCheck()) return; - SyncEvent.Pre event = SyncEvent.Pre.get(getYaw(mc.getRenderTickCounter().getTickDelta(true)), getPitch(mc.getRenderTickCounter().getTickDelta(true))); + SyncEvent.Pre event = SyncEvent.Pre.get(getYaw(mc.getRenderTickCounter().getTickProgress(true)), getPitch(mc.getRenderTickCounter().getTickProgress(true))); MeteorClient.EVENT_BUS.post(event); postAction = event.postAction; @@ -80,13 +68,10 @@ private void hookSendMovementPackets(CallbackInfo ci) { @Inject(method = "sendMovementPackets", at = @At("RETURN"), cancellable = true) private void sendMovementPacketsPostHook(CallbackInfo info) { - //if (fullNullCheck()) return; - //mc.player.lastSprinting = pre_sprint_state; - SyncEvent.Post event = SyncEvent.Post.get(); MeteorClient.EVENT_BUS.post(event); - if(postAction != null) { + if (postAction != null) { postAction.run(); postAction = null; } @@ -95,23 +80,13 @@ private void sendMovementPacketsPostHook(CallbackInfo info) { info.cancel(); } - /** - * @param hand - * @param ci - */ @Inject(method = "setCurrentHand", at = @At(value = "HEAD")) private void hookSetCurrentHand(Hand hand, CallbackInfo ci) { MeteorClient.EVENT_BUS.post(SetCurrentHandEvent.get(hand)); } - /** - * @param x - * @param z - * @param ci - */ - @Inject(method = "pushOutOfBlocks", at = @At(value = "HEAD"), - cancellable = true) + @Inject(method = "pushOutOfBlocks", at = @At(value = "HEAD"), cancellable = true) private void onPushOutOfBlocks(double x, double z, CallbackInfo ci) { PushOutOfBlocksEvent pushOutOfBlocksEvent = new PushOutOfBlocksEvent(); @@ -122,19 +97,12 @@ private void onPushOutOfBlocks(double x, double z, CallbackInfo ci) } } - /** - * @param hand - * @param ci - */ @Inject(method = "swingHand", at = @At(value = "RETURN")) private void hookSwingHand(Hand hand, CallbackInfo ci) { MeteorClient.EVENT_BUS.post(SwingEvent.get(hand)); } - /** - * @param ci - */ @Inject(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/input/Input;tick()V", shift = At.Shift.AFTER)) private void hookTickMovementPost(CallbackInfo ci) { @@ -144,13 +112,13 @@ private void hookTickMovementPost(CallbackInfo ci) { @Override public float genyo_addon$getLastSpoofedYaw() { - return lastYaw; + return ((Entity) (Object) this).lastYaw; } @Override public float genyo_addon$getLastSpoofedPitch() { - return lastPitch; + return ((Entity) (Object) this).lastPitch; } } diff --git a/src/main/java/com/genyo/mixin/render/MixinRenderTickCounter.java b/src/main/java/com/genyo/mixin/render/MixinRenderTickCounter.java index 885a36a..0eb8b56 100644 --- a/src/main/java/com/genyo/mixin/render/MixinRenderTickCounter.java +++ b/src/main/java/com/genyo/mixin/render/MixinRenderTickCounter.java @@ -14,22 +14,18 @@ public abstract class MixinRenderTickCounter { @Shadow - private float lastFrameDuration; + private float dynamicDeltaTicks; // ← lastFrameDuration @Shadow - private float tickDelta; + private float tickProgress; // ← tickDelta @Shadow - private long prevTimeMillis; + private long lastTimeMillis; // ← prevTimeMillis @Final @Shadow private float tickTime; - /** - * @param timeMillis - * @param cir - */ @Inject(method = "beginRenderTick(J)I", at = @At(value = "HEAD"), cancellable = true) private void hookBeginRenderTick(long timeMillis, CallbackInfoReturnable cir) { @@ -37,11 +33,11 @@ private void hookBeginRenderTick(long timeMillis, CallbackInfoReturnable mc.getRenderTickCounter().getTickDelta(true) + // getTickDelta() -> mc.getRenderTickCounter().getTickProgress(true) /*@EventHandler public void onRender3D(Render3DEvent event) { @@ -137,125 +138,43 @@ public void onRender3D(Render3DEvent event) { @EventHandler public void onRender3D(Render3DEvent event) { - MatrixStack stack = event.matrices; - Camera camera = mc.getEntityRenderDispatcher().camera; - - // --- FILLED QUEUE --- - if (!FILLED_QUEUE.isEmpty() || !FADE_QUEUE.isEmpty() || !FILLED_SIDE_QUEUE.isEmpty()) { - Tessellator tessellator = Tessellator.getInstance(); - BufferBuilder bufferBuilder = tessellator.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR); - RenderSystem.disableDepthTest(); - setupRender(); - RenderSystem.setShader(ShaderProgramKeys.POSITION_COLOR); - - FILLED_QUEUE.forEach(action -> - setFilledBoxVertexes(bufferBuilder, stack.peek().getPositionMatrix(), action.box(), action.color()) - ); - - FADE_QUEUE.forEach(action -> - setFilledFadePoints(action.box(), bufferBuilder, stack.peek().getPositionMatrix(), action.color(), action.color2()) - ); - - FILLED_SIDE_QUEUE.forEach(action -> - setFilledSidePoints(bufferBuilder, stack.peek().getPositionMatrix(), action.box, action.color(), action.side()) - ); - - Render2DEngine.endBuilding(bufferBuilder); - endRender(); - RenderSystem.enableDepthTest(); - - FADE_QUEUE.clear(); - FILLED_SIDE_QUEUE.clear(); - FILLED_QUEUE.clear(); - } - - // --- OUTLINE QUEUE --- - if (!OUTLINE_QUEUE.isEmpty() || !OUTLINE_SIDE_QUEUE.isEmpty()) { - setupRender(); - Tessellator tessellator = Tessellator.getInstance(); - BufferBuilder buffer = tessellator.begin(VertexFormat.DrawMode.LINES, VertexFormats.LINES); - RenderSystem.disableCull(); - RenderSystem.disableDepthTest(); - RenderSystem.setShader(ShaderProgramKeys.RENDERTYPE_LINES); - RenderSystem.lineWidth(2f); - - OUTLINE_QUEUE.forEach(action -> { - stack.push(); - stack.translate(action.box().minX - camera.getPos().x, action.box().minY - camera.getPos().y, action.box().minZ - camera.getPos().z); - setOutlinePoints(action.box(), stack, buffer, action.color()); - stack.pop(); - }); - - OUTLINE_SIDE_QUEUE.forEach(action -> { - stack.push(); - stack.translate(action.box.minX - camera.getPos().x, action.box.minY - camera.getPos().y, action.box.minZ - camera.getPos().z); - setSideOutlinePoints(action.box, stack, buffer, action.color(), action.side()); - stack.pop(); - }); - - Render2DEngine.endBuilding(buffer); - RenderSystem.enableCull(); - RenderSystem.enableDepthTest(); - endRender(); - OUTLINE_QUEUE.clear(); - OUTLINE_SIDE_QUEUE.clear(); - } - - // --- DEBUG LINE QUEUE --- - if (!DEBUG_LINE_QUEUE.isEmpty()) { - setupRender(); - RenderSystem.disableDepthTest(); - Tessellator tessellator = Tessellator.getInstance(); - BufferBuilder buffer = tessellator.begin(VertexFormat.DrawMode.DEBUG_LINES, VertexFormats.LINES); - RenderSystem.disableCull(); - RenderSystem.setShader(ShaderProgramKeys.RENDERTYPE_LINES); - - DEBUG_LINE_QUEUE.forEach(action -> { - stack.push(); - stack.translate(action.start.getX() - camera.getPos().x, action.start.getY() - camera.getPos().y, action.start.getZ() - camera.getPos().z); - vertexLine(stack, buffer, 0f, 0f, 0f, - (float)(action.end.getX() - action.start.getX()), - (float)(action.end.getY() - action.start.getY()), - (float)(action.end.getZ() - action.start.getZ()), - action.color); - stack.pop(); - }); - - Render2DEngine.endBuilding(buffer); - RenderSystem.enableCull(); - RenderSystem.enableDepthTest(); - endRender(); - DEBUG_LINE_QUEUE.clear(); - } - - // --- LINE QUEUE --- - if (!LINE_QUEUE.isEmpty()) { - setupRender(); - Tessellator tessellator = Tessellator.getInstance(); - RenderSystem.disableCull(); - RenderSystem.setShader(ShaderProgramKeys.RENDERTYPE_LINES); - RenderSystem.lineWidth(2f); - RenderSystem.disableDepthTest(); - BufferBuilder buffer = tessellator.begin(VertexFormat.DrawMode.LINES, VertexFormats.LINES); - - LINE_QUEUE.forEach(action -> { - stack.push(); - stack.translate(action.start.getX() - camera.getPos().x, action.start.getY() - camera.getPos().y, action.start.getZ() - camera.getPos().z); - vertexLine(stack, buffer, 0f, 0f, 0f, - (float)(action.end.getX() - action.start.getX()), - (float)(action.end.getY() - action.start.getY()), - (float)(action.end.getZ() - action.start.getZ()), - action.color); - stack.pop(); - }); - - Render2DEngine.endBuilding(buffer); - RenderSystem.enableCull(); - RenderSystem.lineWidth(1f); - RenderSystem.enableDepthTest(); - endRender(); - LINE_QUEUE.clear(); - } + FILLED_QUEUE.forEach(action -> event.renderer.boxSides( + action.box().minX - event.offsetX, action.box().minY - event.offsetY, action.box().minZ - event.offsetZ, + action.box().maxX - event.offsetX, action.box().maxY - event.offsetY, action.box().maxZ - event.offsetZ, + action.color(), 0)); + FILLED_QUEUE.clear(); + + OUTLINE_QUEUE.forEach(action -> event.renderer.boxLines( + action.box().minX - event.offsetX, action.box().minY - event.offsetY, action.box().minZ - event.offsetZ, + action.box().maxX - event.offsetX, action.box().maxY - event.offsetY, action.box().maxZ - event.offsetZ, + action.color(), 0)); + OUTLINE_QUEUE.clear(); + + FILLED_SIDE_QUEUE.forEach(action -> event.renderer.boxSides( + action.box().minX - event.offsetX, action.box().minY - event.offsetY, action.box().minZ - event.offsetZ, + action.box().maxX - event.offsetX, action.box().maxY - event.offsetY, action.box().maxZ - event.offsetZ, + action.color(), 0)); + FILLED_SIDE_QUEUE.clear(); + + OUTLINE_SIDE_QUEUE.forEach(action -> event.renderer.boxLines( + action.box().minX - event.offsetX, action.box().minY - event.offsetY, action.box().minZ - event.offsetZ, + action.box().maxX - event.offsetX, action.box().maxY - event.offsetY, action.box().maxZ - event.offsetZ, + action.color(), 0)); + OUTLINE_SIDE_QUEUE.clear(); + + LINE_QUEUE.forEach(action -> event.renderer.line( + action.start().x - event.offsetX, action.start().y - event.offsetY, action.start().z - event.offsetZ, + action.end().x - event.offsetX, action.end().y - event.offsetY, action.end().z - event.offsetZ, + action.color())); + LINE_QUEUE.clear(); + + DEBUG_LINE_QUEUE.forEach(action -> event.renderer.line( + action.start().x - event.offsetX, action.start().y - event.offsetY, action.start().z - event.offsetZ, + action.end().x - event.offsetX, action.end().y - event.offsetY, action.end().z - event.offsetZ, + action.color())); + DEBUG_LINE_QUEUE.clear(); + + FADE_QUEUE.clear(); } @Deprecated @@ -264,44 +183,7 @@ public static void drawFilledBox(MatrixStack stack, Box box, Color c) { FILLED_QUEUE.add(new FillAction(box, c)); } - public static void setFilledBoxVertexes(@NotNull BufferBuilder bufferBuilder, Matrix4f m, @NotNull Box box, @NotNull Color c) { - float minX = (float) (box.minX - mc.getEntityRenderDispatcher().camera.getPos().getX()); - float minY = (float) (box.minY - mc.getEntityRenderDispatcher().camera.getPos().getY()); - float minZ = (float) (box.minZ - mc.getEntityRenderDispatcher().camera.getPos().getZ()); - float maxX = (float) (box.maxX - mc.getEntityRenderDispatcher().camera.getPos().getX()); - float maxY = (float) (box.maxY - mc.getEntityRenderDispatcher().camera.getPos().getY()); - float maxZ = (float) (box.maxZ - mc.getEntityRenderDispatcher().camera.getPos().getZ()); - - bufferBuilder.vertex(m, minX, minY, minZ).color(c.getPacked()); - bufferBuilder.vertex(m, maxX, minY, minZ).color(c.getPacked()); - bufferBuilder.vertex(m, maxX, minY, maxZ).color(c.getPacked()); - bufferBuilder.vertex(m, minX, minY, maxZ).color(c.getPacked()); - - bufferBuilder.vertex(m, minX, minY, minZ).color(c.getPacked()); - bufferBuilder.vertex(m, minX, maxY, minZ).color(c.getPacked()); - bufferBuilder.vertex(m, maxX, maxY, minZ).color(c.getPacked()); - bufferBuilder.vertex(m, maxX, minY, minZ).color(c.getPacked()); - - bufferBuilder.vertex(m, maxX, minY, minZ).color(c.getPacked()); - bufferBuilder.vertex(m, maxX, maxY, minZ).color(c.getPacked()); - bufferBuilder.vertex(m, maxX, maxY, maxZ).color(c.getPacked()); - bufferBuilder.vertex(m, maxX, minY, maxZ).color(c.getPacked()); - - bufferBuilder.vertex(m, minX, minY, maxZ).color(c.getPacked()); - bufferBuilder.vertex(m, maxX, minY, maxZ).color(c.getPacked()); - bufferBuilder.vertex(m, maxX, maxY, maxZ).color(c.getPacked()); - bufferBuilder.vertex(m, minX, maxY, maxZ).color(c.getPacked()); - - bufferBuilder.vertex(m, minX, minY, minZ).color(c.getPacked()); - bufferBuilder.vertex(m, minX, minY, maxZ).color(c.getPacked()); - bufferBuilder.vertex(m, minX, maxY, maxZ).color(c.getPacked()); - bufferBuilder.vertex(m, minX, maxY, minZ).color(c.getPacked()); - - bufferBuilder.vertex(m, minX, maxY, minZ).color(c.getPacked()); - bufferBuilder.vertex(m, minX, maxY, maxZ).color(c.getPacked()); - bufferBuilder.vertex(m, maxX, maxY, maxZ).color(c.getPacked()); - bufferBuilder.vertex(m, maxX, maxY, minZ).color(c.getPacked()); - } + public static void setFilledBoxVertexes(@NotNull BufferBuilder bufferBuilder, Matrix4f m, @NotNull Box box, @NotNull Color c) {} public static @NotNull Box interpolateBox(@NotNull Box from, @NotNull Box to, float delta) { double X = Render2DEngine.interpolate(from.maxX, to.maxX, delta); @@ -318,72 +200,20 @@ public static void drawFilledSide(MatrixStack stack, @NotNull Box box, Color c, FILLED_SIDE_QUEUE.add(new FillSideAction(box, c, dir)); } - public static void setFilledSidePoints(BufferBuilder buffer, Matrix4f matrix, Box box, Color c, Direction dir) { - float minX = (float) (box.minX - mc.getEntityRenderDispatcher().camera.getPos().getX()); - float minY = (float) (box.minY - mc.getEntityRenderDispatcher().camera.getPos().getY()); - float minZ = (float) (box.minZ - mc.getEntityRenderDispatcher().camera.getPos().getZ()); - float maxX = (float) (box.maxX - mc.getEntityRenderDispatcher().camera.getPos().getX()); - float maxY = (float) (box.maxY - mc.getEntityRenderDispatcher().camera.getPos().getY()); - float maxZ = (float) (box.maxZ - mc.getEntityRenderDispatcher().camera.getPos().getZ()); - - if (dir == Direction.DOWN) { - buffer.vertex(matrix, minX, minY, minZ).color(c.getPacked()); - buffer.vertex(matrix, maxX, minY, minZ).color(c.getPacked()); - buffer.vertex(matrix, maxX, minY, maxZ).color(c.getPacked()); - buffer.vertex(matrix, minX, minY, maxZ).color(c.getPacked()); - } - - if (dir == Direction.NORTH) { - buffer.vertex(matrix, minX, minY, minZ).color(c.getPacked()); - buffer.vertex(matrix, minX, maxY, minZ).color(c.getPacked()); - buffer.vertex(matrix, maxX, maxY, minZ).color(c.getPacked()); - buffer.vertex(matrix, maxX, minY, minZ).color(c.getPacked()); - } - - if (dir == Direction.EAST) { - buffer.vertex(matrix, maxX, minY, minZ).color(c.getPacked()); - buffer.vertex(matrix, maxX, maxY, minZ).color(c.getPacked()); - buffer.vertex(matrix, maxX, maxY, maxZ).color(c.getPacked()); - buffer.vertex(matrix, maxX, minY, maxZ).color(c.getPacked()); - } - if (dir == Direction.SOUTH) { - buffer.vertex(matrix, minX, minY, maxZ).color(c.getPacked()); - buffer.vertex(matrix, maxX, minY, maxZ).color(c.getPacked()); - buffer.vertex(matrix, maxX, maxY, maxZ).color(c.getPacked()); - buffer.vertex(matrix, minX, maxY, maxZ).color(c.getPacked()); - } - - if (dir == Direction.WEST) { - buffer.vertex(matrix, minX, minY, minZ).color(c.getPacked()); - buffer.vertex(matrix, minX, minY, maxZ).color(c.getPacked()); - buffer.vertex(matrix, minX, maxY, maxZ).color(c.getPacked()); - buffer.vertex(matrix, minX, maxY, minZ).color(c.getPacked()); - } - - if (dir == Direction.UP) { - buffer.vertex(matrix, minX, maxY, minZ).color(c.getPacked()); - buffer.vertex(matrix, minX, maxY, maxZ).color(c.getPacked()); - buffer.vertex(matrix, maxX, maxY, maxZ).color(c.getPacked()); - buffer.vertex(matrix, maxX, maxY, minZ).color(c.getPacked()); - } - } + public static void setFilledSidePoints(BufferBuilder buffer, Matrix4f matrix, Box box, Color c, Direction dir) {} public static void drawTextIn3D(String text, @NotNull Vec3d pos, double offX, double offY, double textOffset, @NotNull Color color) { MatrixStack matrices = new MatrixStack(); Camera camera = mc.gameRenderer.getCamera(); - RenderSystem.disableDepthTest(); - RenderSystem.disableCull(); matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(camera.getPitch())); matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(camera.getYaw() + 180.0F)); - matrices.translate(pos.getX() - camera.getPos().x, pos.getY() - camera.getPos().y, pos.getZ() - camera.getPos().z); + matrices.translate(pos.getX() - camera.getCameraPos().x, pos.getY() - camera.getCameraPos().y, pos.getZ() - camera.getCameraPos().z); matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(-camera.getYaw())); matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(camera.getPitch())); setupRender(); matrices.translate(offX, offY - 0.1, -0.01); matrices.scale(-0.025f, -0.025f, 0); //FontRenderers.sf_medium.drawCenteredString(matrices, text, textOffset, 0f, color.getPacked()); - RenderSystem.enableCull(); - RenderSystem.enableDepthTest(); endRender(); } @@ -394,9 +224,9 @@ public static void drawTextIn3D(String text, @NotNull Vec3d pos, double offX, do GL11.glGetIntegerv(GL11.GL_VIEWPORT, viewport); Vector3f target = new Vector3f(); - double deltaX = pos.x - camera.getPos().x; - double deltaY = pos.y - camera.getPos().y; - double deltaZ = pos.z - camera.getPos().z; + double deltaX = pos.x - camera.getCameraPos().x; + double deltaY = pos.y - camera.getCameraPos().y; + double deltaZ = pos.z - camera.getCameraPos().z; Vector4f transformedCoordinates = new Vector4f((float) deltaX, (float) deltaY, (float) deltaZ, 1.f).mul(lastWorldSpaceMatrix); Matrix4f matrixProj = new Matrix4f(lastProjMat); @@ -417,40 +247,7 @@ public static void drawFilledFadeBox(@NotNull MatrixStack stack, @NotNull Box bo FADE_QUEUE.add(new FadeAction(box, c, c1)); } - public static void setFilledFadePoints(Box box, BufferBuilder buffer, Matrix4f posMatrix, Color c, Color c1) { - float minX = (float) (box.minX - mc.getEntityRenderDispatcher().camera.getPos().getX()); - float minY = (float) (box.minY - mc.getEntityRenderDispatcher().camera.getPos().getY()); - float minZ = (float) (box.minZ - mc.getEntityRenderDispatcher().camera.getPos().getZ()); - float maxX = (float) (box.maxX - mc.getEntityRenderDispatcher().camera.getPos().getX()); - float maxY = (float) (box.maxY - mc.getEntityRenderDispatcher().camera.getPos().getY()); - float maxZ = (float) (box.maxZ - mc.getEntityRenderDispatcher().camera.getPos().getZ()); - - - buffer.vertex(posMatrix, minX, minY, minZ).color(c.getPacked()); - buffer.vertex(posMatrix, minX, maxY, minZ).color(c1.getPacked()); - buffer.vertex(posMatrix, maxX, maxY, minZ).color(c1.getPacked()); - buffer.vertex(posMatrix, maxX, minY, minZ).color(c.getPacked()); - - buffer.vertex(posMatrix, maxX, minY, minZ).color(c.getPacked()); - buffer.vertex(posMatrix, maxX, maxY, minZ).color(c1.getPacked()); - buffer.vertex(posMatrix, maxX, maxY, maxZ).color(c1.getPacked()); - buffer.vertex(posMatrix, maxX, minY, maxZ).color(c.getPacked()); - - buffer.vertex(posMatrix, minX, minY, maxZ).color(c.getPacked()); - buffer.vertex(posMatrix, maxX, minY, maxZ).color(c.getPacked()); - buffer.vertex(posMatrix, maxX, maxY, maxZ).color(c1.getPacked()); - buffer.vertex(posMatrix, minX, maxY, maxZ).color(c1.getPacked()); - - buffer.vertex(posMatrix, minX, minY, minZ).color(c.getPacked()); - buffer.vertex(posMatrix, minX, minY, maxZ).color(c.getPacked()); - buffer.vertex(posMatrix, minX, maxY, maxZ).color(c1.getPacked()); - buffer.vertex(posMatrix, minX, maxY, minZ).color(c1.getPacked()); - - buffer.vertex(posMatrix, minX, maxY, minZ).color(c1.getPacked()); - buffer.vertex(posMatrix, minX, maxY, maxZ).color(c1.getPacked()); - buffer.vertex(posMatrix, maxX, maxY, maxZ).color(c1.getPacked()); - buffer.vertex(posMatrix, maxX, maxY, minZ).color(c1.getPacked()); - } + public static void setFilledFadePoints(Box box, BufferBuilder buffer, Matrix4f posMatrix, Color c, Color c1) {} public static void drawLine(@NotNull Vec3d start, @NotNull Vec3d end, @NotNull Color color) { LINE_QUEUE.add(new LineAction(start, end, color)); @@ -461,126 +258,18 @@ public static void drawBoxOutline(@NotNull Box box, Color color, float lineWidth OUTLINE_QUEUE.add(new OutlineAction(box, color, lineWidth)); } - public static void setOutlinePoints(Box box, MatrixStack matrices, BufferBuilder buffer, Color color) { - box = box.offset(new Vec3d(box.minX, box.minY, box.minZ).negate()); - - float x1 = (float) box.minX; - float y1 = (float) box.minY; - float z1 = (float) box.minZ; - float x2 = (float) box.maxX; - float y2 = (float) box.maxY; - float z2 = (float) box.maxZ; - - vertexLine(matrices, buffer, x1, y1, z1, x2, y1, z1, color); - vertexLine(matrices, buffer, x2, y1, z1, x2, y1, z2, color); - vertexLine(matrices, buffer, x2, y1, z2, x1, y1, z2, color); - vertexLine(matrices, buffer, x1, y1, z2, x1, y1, z1, color); - vertexLine(matrices, buffer, x1, y1, z2, x1, y2, z2, color); - vertexLine(matrices, buffer, x1, y1, z1, x1, y2, z1, color); - vertexLine(matrices, buffer, x2, y1, z2, x2, y2, z2, color); - vertexLine(matrices, buffer, x2, y1, z1, x2, y2, z1, color); - vertexLine(matrices, buffer, x1, y2, z1, x2, y2, z1, color); - vertexLine(matrices, buffer, x2, y2, z1, x2, y2, z2, color); - vertexLine(matrices, buffer, x2, y2, z2, x1, y2, z2, color); - vertexLine(matrices, buffer, x1, y2, z2, x1, y2, z1, color); - } + public static void setOutlinePoints(Box box, MatrixStack matrices, BufferBuilder buffer, Color color) {} @Deprecated public static void drawSideOutline(@NotNull Box box, Color color, float lineWidth, Direction dir) { OUTLINE_SIDE_QUEUE.add(new OutlineSideAction(box, color, lineWidth, dir)); } - public static void setSideOutlinePoints(Box box, MatrixStack matrices, BufferBuilder buffer, Color color, Direction dir) { - box = box.offset(new Vec3d(box.minX, box.minY, box.minZ).negate()); - - float x1 = (float) box.minX; - float y1 = (float) box.minY; - float z1 = (float) box.minZ; - float x2 = (float) box.maxX; - float y2 = (float) box.maxY; - float z2 = (float) box.maxZ; - - switch (dir) { - case UP -> { - vertexLine(matrices, buffer, x1, y2, z1, x2, y2, z1, color); - vertexLine(matrices, buffer, x2, y2, z1, x2, y2, z2, color); - vertexLine(matrices, buffer, x2, y2, z2, x1, y2, z2, color); - vertexLine(matrices, buffer, x1, y2, z2, x1, y2, z1, color); - } - case DOWN -> { - vertexLine(matrices, buffer, x1, y1, z1, x2, y1, z1, color); - vertexLine(matrices, buffer, x2, y1, z1, x2, y1, z2, color); - vertexLine(matrices, buffer, x2, y1, z2, x1, y1, z2, color); - vertexLine(matrices, buffer, x1, y1, z2, x1, y1, z1, color); - } - case EAST -> { - vertexLine(matrices, buffer, x2, y1, z1, x2, y2, z1, color); - vertexLine(matrices, buffer, x2, y1, z2, x2, y2, z2, color); - vertexLine(matrices, buffer, x2, y2, z2, x2, y2, z1, color); - vertexLine(matrices, buffer, x2, y1, z2, x2, y1, z1, color); - } - case WEST -> { - vertexLine(matrices, buffer, x1, y1, z1, x1, y2, z1, color); - vertexLine(matrices, buffer, x1, y1, z2, x1, y2, z2, color); - vertexLine(matrices, buffer, x1, y2, z2, x1, y2, z1, color); - vertexLine(matrices, buffer, x1, y1, z2, x1, y1, z1, color); - } - case NORTH -> { - vertexLine(matrices, buffer, x2, y1, z1, x2, y2, z1, color); - vertexLine(matrices, buffer, x1, y1, z1, x1, y2, z1, color); - vertexLine(matrices, buffer, x2, y1, z1, x1, y1, z1, color); - vertexLine(matrices, buffer, x2, y2, z1, x1, y2, z1, color); - } - case SOUTH -> { - vertexLine(matrices, buffer, x1, y1, z2, x1, y2, z2, color); - vertexLine(matrices, buffer, x2, y1, z2, x2, y2, z2, color); - vertexLine(matrices, buffer, x1, y1, z2, x2, y1, z2, color); - vertexLine(matrices, buffer, x1, y2, z2, x2, y2, z2, color); - } - } - } + public static void setSideOutlinePoints(Box box, MatrixStack matrices, BufferBuilder buffer, Color color, Direction dir) {} - public static void drawHoleOutline(@NotNull Box box, Color color, float lineWidth) { - setupRender(); - MatrixStack matrices = matrixFrom(box.minX, box.minY, box.minZ); - Tessellator tessellator = Tessellator.getInstance(); - BufferBuilder buffer = tessellator.begin(VertexFormat.DrawMode.LINES, VertexFormats.LINES); - - RenderSystem.disableCull(); - RenderSystem.setShader(ShaderProgramKeys.RENDERTYPE_LINES); - RenderSystem.lineWidth(lineWidth); - - box = box.offset(new Vec3d(box.minX, box.minY, box.minZ).negate()); - - float x1 = (float) box.minX; - float y1 = (float) box.minY; - float y2 = (float) box.maxY; - float z1 = (float) box.minZ; - float x2 = (float) box.maxX; - float z2 = (float) box.maxZ; - - vertexLine(matrices, buffer, x1, y1, z1, x2, y1, z1, color); - vertexLine(matrices, buffer, x2, y1, z1, x2, y1, z2, color); - vertexLine(matrices, buffer, x2, y1, z2, x1, y1, z2, color); - vertexLine(matrices, buffer, x1, y1, z2, x1, y1, z1, color); - - vertexLine(matrices, buffer, x1, y1, z1, x1, y2, z1, color); - vertexLine(matrices, buffer, x2, y1, z2, x2, y2, z2, color); - vertexLine(matrices, buffer, x1, y1, z2, x1, y2, z2, color); - vertexLine(matrices, buffer, x2, y1, z1, x2, y2, z1, color); - - Render2DEngine.endBuilding(buffer); - RenderSystem.enableCull(); - endRender(); - } + public static void drawHoleOutline(@NotNull Box box, Color color, float lineWidth) {} - public static void vertexLine(@NotNull MatrixStack matrices, @NotNull VertexConsumer buffer, float x1, float y1, float z1, float x2, float y2, float z2, @NotNull Color lineColor) { - Matrix4f model = matrices.peek().getPositionMatrix(); - MatrixStack.Entry entry = matrices.peek(); - Vector3f normalVec = getNormal(x1, y1, z1, x2, y2, z2); - buffer.vertex(model, x1, y1, z1).color(lineColor.r, lineColor.g, lineColor.b, lineColor.a).normal(entry, normalVec.x(), normalVec.y(), normalVec.z()); - buffer.vertex(model, x2, y2, z2).color(lineColor.r, lineColor.g, lineColor.b, lineColor.a).normal(entry, normalVec.x(), normalVec.y(), normalVec.z()); - } + public static void vertexLine(@NotNull MatrixStack matrices, @NotNull VertexConsumer buffer, float x1, float y1, float z1, float x2, float y2, float z2, @NotNull Color lineColor) {} public static @NotNull Vector3f getNormal(float x1, float y1, float z1, float x2, float y2, float z2) { float xNormal = x2 - x1; @@ -595,7 +284,7 @@ public static void vertexLine(@NotNull MatrixStack matrices, @NotNull VertexCons MatrixStack matrices = new MatrixStack(); Camera camera = MinecraftClient.getInstance().gameRenderer.getCamera(); - matrices.translate(x - camera.getPos().x, y - camera.getPos().y, z - camera.getPos().z); + matrices.translate(x - camera.getCameraPos().x, y - camera.getCameraPos().y, z - camera.getCameraPos().z); matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(-camera.getYaw())); matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(camera.getPitch())); @@ -603,299 +292,30 @@ public static void vertexLine(@NotNull MatrixStack matrices, @NotNull VertexCons } public static void setupRender() { - RenderSystem.enableBlend(); - RenderSystem.defaultBlendFunc(); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); } public static void endRender() { - RenderSystem.disableBlend(); + GL11.glDisable(GL11.GL_BLEND); } - public static void drawTargetEsp(MatrixStack stack, @NotNull Entity target) { - ArrayList vecs = new ArrayList<>(); - ArrayList vecs1 = new ArrayList<>(); - ArrayList vecs2 = new ArrayList<>(); - - double x = target.prevX + (target.getX() - target.prevX) * getTickDelta() - - mc.getEntityRenderDispatcher().camera.getPos().getX(); - double y = target.prevY + (target.getY() - target.prevY) * getTickDelta() - - mc.getEntityRenderDispatcher().camera.getPos().getY(); - double z = target.prevZ + (target.getZ() - target.prevZ) * getTickDelta() - - mc.getEntityRenderDispatcher().camera.getPos().getZ(); - - - double height = target.getHeight(); - - for (int i = 0; i <= 361; ++i) { - double v = Math.sin(Math.toRadians(i)); - double u = Math.cos(Math.toRadians(i)); - Vec3d vec = new Vec3d((float) (u * 0.5f), height, (float) (v * 0.5f)); - vecs.add(vec); - - double v1 = Math.sin(Math.toRadians((i + 120) % 360)); - double u1 = Math.cos(Math.toRadians(i + 120) % 360); - Vec3d vec1 = new Vec3d((float) (u1 * 0.5f), height, (float) (v1 * 0.5f)); - vecs1.add(vec1); - - double v2 = Math.sin(Math.toRadians((i + 240) % 360)); - double u2 = Math.cos(Math.toRadians((i + 240) % 360)); - Vec3d vec2 = new Vec3d((float) (u2 * 0.5f), height, (float) (v2 * 0.5f)); - vecs2.add(vec2); - height -= 0.004f; - } + public static void drawTargetEsp(MatrixStack stack, @NotNull Entity target) {} + public static void renderCrosses(@NotNull Box box, Color color, float lineWidth) {} - stack.push(); - stack.translate(x, y, z); - BufferBuilder bufferBuilder; - setupRender(); - RenderSystem.disableCull(); - RenderSystem.disableDepthTest(); + public static void drawSphere(MatrixStack matrix, float radius, int slices, int stacks, int color) {} - RenderSystem.setShader(ShaderProgramKeys.POSITION_COLOR); - bufferBuilder = Tessellator.getInstance().begin(VertexFormat.DrawMode.TRIANGLE_STRIP, VertexFormats.POSITION_COLOR); + public static void drawCylinder(MatrixStack stack, final float radius, final float height, final int slices, final int stacks, int color) {} - Matrix4f matrix = stack.peek().getPositionMatrix(); - for (int j = 0; j < vecs.size() - 1; ++j) { - float alpha = 1f - (((float) j + ((System.currentTimeMillis() - System.currentTimeMillis()) / 5f)) % 360) / 60f; - bufferBuilder.vertex(matrix, (float) vecs.get(j).x, (float) vecs.get(j).y, (float) vecs.get(j).z).color(Hud.get().textColors.get().getFirst().a((int) (alpha * 255)).getPacked()); - bufferBuilder.vertex(matrix, (float) vecs.get(j + 1).x, (float) vecs.get(j + 1).y + 0.1f, (float) vecs.get(j + 1).z).color(Hud.get().textColors.get().getFirst().a((int) (alpha * 255f)).getPacked()); - } - Render2DEngine.endBuilding(bufferBuilder); - - RenderSystem.setShader(ShaderProgramKeys.POSITION_COLOR); - bufferBuilder = Tessellator.getInstance().begin(VertexFormat.DrawMode.TRIANGLE_STRIP, VertexFormats.POSITION_COLOR); - for (int j = 0; j < vecs1.size() - 1; ++j) { - float alpha = 1f - (((float) j + ((System.currentTimeMillis() - System.currentTimeMillis()) / 5f)) % 360) / 60f; - bufferBuilder.vertex(matrix, (float) vecs1.get(j).x, (float) vecs1.get(j).y, (float) vecs1.get(j).z).color(Hud.get().textColors.get().getFirst().a((int) (alpha * 255)).getPacked()); - bufferBuilder.vertex(matrix, (float) vecs1.get(j + 1).x, (float) vecs1.get(j + 1).y + 0.1f, (float) vecs1.get(j + 1).z).color(Hud.get().textColors.get().getFirst().a((int) (alpha * 255f)).getPacked()); - } - Render2DEngine.endBuilding(bufferBuilder); - - RenderSystem.setShader(ShaderProgramKeys.POSITION_COLOR); - bufferBuilder = Tessellator.getInstance().begin(VertexFormat.DrawMode.TRIANGLE_STRIP, VertexFormats.POSITION_COLOR); - for (int j = 0; j < vecs2.size() - 1; ++j) { - float alpha = 1f - (((float) j + ((System.currentTimeMillis() - System.currentTimeMillis()) / 5f)) % 360) / 60f; - bufferBuilder.vertex(matrix, (float) vecs2.get(j).x, (float) vecs2.get(j).y, (float) vecs2.get(j).z).color(Hud.get().textColors.get().getFirst().a((int) (alpha * 255)).getPacked()); - bufferBuilder.vertex(matrix, (float) vecs2.get(j + 1).x, (float) vecs2.get(j + 1).y + 0.1f, (float) vecs2.get(j + 1).z).color(Hud.get().textColors.get().getFirst().a((int) (alpha * 255f)).getPacked()); - } - Render2DEngine.endBuilding(bufferBuilder); - - RenderSystem.enableCull(); - stack.translate(-x, -y, -z); - endRender(); - RenderSystem.enableDepthTest(); - stack.pop(); - } + public static void drawCircle3D(MatrixStack stack, Entity ent, float radius, int color, int points, boolean hudColor, int colorOffset) {} - public static void renderCrosses(@NotNull Box box, Color color, float lineWidth) { - setupRender(); - MatrixStack matrices = matrixFrom(box.minX, box.minY, box.minZ); - RenderSystem.disableCull(); - RenderSystem.setShader(ShaderProgramKeys.RENDERTYPE_LINES); - RenderSystem.lineWidth(lineWidth); - BufferBuilder buffer = Tessellator.getInstance().begin(VertexFormat.DrawMode.LINES, VertexFormats.LINES); - - box = box.offset(new Vec3d(box.minX, box.minY, box.minZ).negate()); - - vertexLine(matrices, buffer, (float) box.maxX, (float) box.minY, (float) box.minZ, (float) box.minX, (float) box.minY, (float) box.maxZ, color); - vertexLine(matrices, buffer, (float) box.minX, (float) box.minY, (float) box.minZ, (float) box.maxX, (float) box.minY, (float) box.maxZ, color); - - Render2DEngine.endBuilding(buffer); - RenderSystem.enableCull(); - endRender(); - } - - public static void drawSphere(MatrixStack matrix, float radius, int slices, int stacks, int color) { - float drho = 3.1415927F / ((float) stacks); - float dtheta = 6.2831855F / ((float) slices - 1f); - float rho; - float theta; - float x; - float y; - float z; - int i; - int j; - setupRender(); - for (i = 1; i < stacks; ++i) { - rho = (float) i * drho; - - BufferBuilder buffer = Tessellator.getInstance().begin(VertexFormat.DrawMode.DEBUG_LINE_STRIP, VertexFormats.POSITION_COLOR); - RenderSystem.setShader(ShaderProgramKeys.POSITION_COLOR); - - for (j = 0; j < slices; ++j) { - theta = (float) j * dtheta; - x = (float) (Math.cos(theta) * Math.sin(rho)); - y = (float) (Math.sin(theta) * Math.sin(rho)); - z = (float) Math.cos(rho); - buffer.vertex(matrix.peek().getPositionMatrix(), x * radius, y * radius, z * radius).color(color); - } - Render2DEngine.endBuilding(buffer); - } - - for (j = 0; j < slices; ++j) { - theta = (float) j * dtheta; - - BufferBuilder buffer = Tessellator.getInstance().begin(VertexFormat.DrawMode.DEBUG_LINE_STRIP, VertexFormats.POSITION_COLOR); - - RenderSystem.setShader(ShaderProgramKeys.POSITION_COLOR); - - for (i = 0; i <= stacks; ++i) { - rho = (float) i * drho; - x = (float) (Math.cos(theta) * Math.sin(rho)); - y = (float) (Math.sin(theta) * Math.sin(rho)); - z = (float) Math.cos(rho); - buffer.vertex(matrix.peek().getPositionMatrix(), x * radius, y * radius, z * radius).color(color); - } - BufferRenderer.drawWithGlobalProgram(buffer.end()); - } - endRender(); - } - - public static void drawCylinder(MatrixStack stack, final float radius, final float height, final int slices, final int stacks, int color) { - - final float da = (float) ((Math.PI * 2f) / slices); - final float dz = height / stacks; - - BufferBuilder buffer = Tessellator.getInstance().begin(VertexFormat.DrawMode.DEBUG_LINE_STRIP, VertexFormats.POSITION_COLOR); - RenderSystem.setShader(ShaderProgramKeys.POSITION_COLOR); - - float y = 0; - - for (int j = 0; j <= stacks; ++j) { - for (int i = 0; i <= slices; ++i) { - final float x = (float) Math.cos(i * da); - final float z = (float) Math.sin(i * da); - buffer.vertex(stack.peek().getPositionMatrix(), x * radius, y, z * radius).color(color); - } - y += dz; - } - - BufferRenderer.drawWithGlobalProgram(buffer.end()); - - buffer = Tessellator.getInstance().begin(VertexFormat.DrawMode.DEBUG_LINE_STRIP, VertexFormats.POSITION_COLOR); - RenderSystem.setShader(ShaderProgramKeys.POSITION_COLOR); - - for (int i = 0; i <= slices; ++i) { - final float x = (float) Math.cos(i * da); - final float z = (float) Math.sin(i * da); - - buffer.vertex(stack.peek().getPositionMatrix(), x * radius, 0, z * radius).color(color); - buffer.vertex(stack.peek().getPositionMatrix(), x * radius, height, z * radius).color(color); - } - - BufferRenderer.drawWithGlobalProgram(buffer.end()); - } - - - public static void drawCircle3D(MatrixStack stack, Entity ent, float radius, int color, int points, boolean hudColor, int colorOffset) { - setupRender(); - RenderSystem.setShader(ShaderProgramKeys.POSITION_COLOR); - BufferBuilder bufferBuilder = Tessellator.getInstance().begin(VertexFormat.DrawMode.DEBUG_LINE_STRIP, VertexFormats.POSITION_COLOR); - double x = ent.prevX + (ent.getX() - ent.prevX) * getTickDelta() - mc.getEntityRenderDispatcher().camera.getPos().getX(); - double y = ent.prevY + (ent.getY() - ent.prevY) * getTickDelta() - mc.getEntityRenderDispatcher().camera.getPos().getY(); - double z = ent.prevZ + (ent.getZ() - ent.prevZ) * getTickDelta() - mc.getEntityRenderDispatcher().camera.getPos().getZ(); - stack.push(); - stack.translate(x, y, z); - - Matrix4f matrix = stack.peek().getPositionMatrix(); - for (int i = 0; i <= points; i++) { - if (hudColor) - color = Hud.get().textColors.get().getFirst().getPacked(); - - bufferBuilder.vertex(matrix, (float) (radius * Math.cos(i * 6.28 / points)), 0f, (float) (radius * Math.sin(i * 6.28 / points))).color(color); - } - - BufferRenderer.drawWithGlobalProgram(bufferBuilder.end()); - endRender(); - stack.translate(-x, -y, -z); - stack.pop(); - } - - public static void drawOldTargetEsp(MatrixStack stack, Entity target) { - double cs = prevCircleStep + (circleStep - prevCircleStep) * getTickDelta(); - double prevSinAnim = absSinAnimation(cs - 0.45f); - double sinAnim = absSinAnimation(cs); - double x = target.prevX + (target.getX() - target.prevX) * getTickDelta() - mc.getEntityRenderDispatcher().camera.getPos().getX(); - double y = target.prevY + (target.getY() - target.prevY) * getTickDelta() - mc.getEntityRenderDispatcher().camera.getPos().getY() + prevSinAnim * target.getHeight(); - double z = target.prevZ + (target.getZ() - target.prevZ) * getTickDelta() - mc.getEntityRenderDispatcher().camera.getPos().getZ(); - double nextY = target.prevY + (target.getY() - target.prevY) * getTickDelta() - mc.getEntityRenderDispatcher().camera.getPos().getY() + sinAnim * target.getHeight(); - stack.push(); - setupRender(); - RenderSystem.disableCull(); - RenderSystem.disableDepthTest(); - BufferBuilder bufferBuilder = Tessellator.getInstance().begin(VertexFormat.DrawMode.TRIANGLE_STRIP, VertexFormats.POSITION_COLOR); - - RenderSystem.setShader(ShaderProgramKeys.POSITION_COLOR); - float cos; - float sin; - for (int i = 0; i <= 30; i++) { - cos = (float) (x + Math.cos(i * 6.28 / 30) * target.getWidth() * 0.8); - sin = (float) (z + Math.sin(i * 6.28 / 30) * target.getWidth() * 0.8); - bufferBuilder.vertex(stack.peek().getPositionMatrix(), cos, (float) nextY, sin).color(Hud.get().textColors.get().getFirst().a(170).getPacked()); - bufferBuilder.vertex(stack.peek().getPositionMatrix(), cos, (float) y, sin).color(Hud.get().textColors.get().getFirst().a(0).getPacked()); - } - Render2DEngine.endBuilding(bufferBuilder); - RenderSystem.enableCull(); - endRender(); - RenderSystem.enableDepthTest(); - stack.pop(); - } + public static void drawOldTargetEsp(MatrixStack stack, Entity target) {} // Kalry не пасть // anti yg protection - public static void renderGhosts(int espLength, int factor, float shaking, float amplitude, Entity target) { - Camera camera = mc.gameRenderer.getCamera(); - - double tPosX = Render2DEngine.interpolate(target.prevX, target.getX(), Render3DEngine.getTickDelta()) - camera.getPos().x; - double tPosY = Render2DEngine.interpolate(target.prevY, target.getY(), Render3DEngine.getTickDelta()) - camera.getPos().y; - double tPosZ = Render2DEngine.interpolate(target.prevZ, target.getZ(), Render3DEngine.getTickDelta()) - camera.getPos().z; - float iAge = (float) Render2DEngine.interpolate(target.age - 1, target.age, Render3DEngine.getTickDelta()); - - RenderSystem.enableBlend(); - RenderSystem.blendFunc(GlStateManager.SrcFactor.SRC_ALPHA, GlStateManager.DstFactor.ONE); - RenderSystem.setShader(ShaderProgramKeys.POSITION_TEX_COLOR); - BufferBuilder buffer = Tessellator.getInstance().begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR); - - boolean canSee = mc.player.canSee(target); - - if (canSee) { - RenderSystem.enableDepthTest(); - RenderSystem.depthMask(false); - } else RenderSystem.disableDepthTest(); - - for (int j = 0; j < 3; j++) { - for (int i = 0; i <= espLength; i++) { - double radians = Math.toRadians((((float) i / 1.5f + iAge) * factor + (j * 120)) % (factor * 360)); - double sinQuad = Math.sin(Math.toRadians(iAge * 2.5f + i * (j + 1)) * amplitude) / shaking; - - float offset = ((float) i / espLength); - MatrixStack matrices = new MatrixStack(); - matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(camera.getPitch())); - matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(camera.getYaw() + 180.0F)); - matrices.translate(tPosX + Math.cos(radians) * target.getWidth(), (tPosY + 1 + sinQuad), tPosZ + Math.sin(radians) * target.getWidth()); - matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(-camera.getYaw())); - matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(camera.getPitch())); - Matrix4f matrix = matrices.peek().getPositionMatrix(); - int color = Hud.get().textColors.get().getFirst().getPacked(); - float scale = Math.max(0.24f * (offset), 0.2f); - buffer.vertex(matrix, -scale, scale, 0).texture(0f, 1f).color(color); - buffer.vertex(matrix, scale, scale, 0).texture(1f, 1f).color(color); - buffer.vertex(matrix, scale, -scale, 0).texture(1f, 0).color(color); - buffer.vertex(matrix, -scale, -scale, 0).texture(0, 0).color(color); - } - } - - BufferRenderer.drawWithGlobalProgram(buffer.end()); - - if (canSee) { - RenderSystem.depthMask(true); - RenderSystem.disableDepthTest(); - } else RenderSystem.enableDepthTest(); - - RenderSystem.disableBlend(); - } + public static void renderGhosts(int espLength, int factor, float shaking, float amplitude, Entity target) {} public static void updateTargetESP() { prevCircleStep = circleStep; @@ -907,9 +327,9 @@ public static double absSinAnimation(double input) { } public static Vec3d interpolatePos(float prevposX, float prevposY, float prevposZ, float posX, float posY, float posZ) { - double x = prevposX + ((posX - prevposX) * getTickDelta()) - mc.getEntityRenderDispatcher().camera.getPos().getX(); - double y = prevposY + ((posY - prevposY) * getTickDelta()) - mc.getEntityRenderDispatcher().camera.getPos().getY(); - double z = prevposZ + ((posZ - prevposZ) * getTickDelta()) - mc.getEntityRenderDispatcher().camera.getPos().getZ(); + double x = prevposX + ((posX - prevposX) * getTickDelta()) - mc.getEntityRenderDispatcher().camera.getCameraPos().getX(); + double y = prevposY + ((posY - prevposY) * getTickDelta()) - mc.getEntityRenderDispatcher().camera.getCameraPos().getY(); + double z = prevposZ + ((posZ - prevposZ) * getTickDelta()) - mc.getEntityRenderDispatcher().camera.getCameraPos().getZ(); return new Vec3d(x, y, z); } @@ -918,7 +338,7 @@ public static void drawLineDebug(Vec3d start, Vec3d end, Color color) { } public static float getTickDelta() { - return mc.getRenderTickCounter().getTickDelta(true); + return mc.getRenderTickCounter().getTickProgress(true); } public record FillAction(Box box, Color color) { diff --git a/src/main/java/com/genyo/systems/config/GenyoConfig.java b/src/main/java/com/genyo/systems/config/GenyoConfig.java index 2c66316..7ccd1bc 100644 --- a/src/main/java/com/genyo/systems/config/GenyoConfig.java +++ b/src/main/java/com/genyo/systems/config/GenyoConfig.java @@ -33,6 +33,33 @@ public class GenyoConfig extends System { .build() ); + // In sgSounds group, add these three: + + public final Setting guiSounds = sgSounds.add(new BoolSetting.Builder() + .name("gui-sounds") + .description("Play sounds when hovering and clicking in Meteor's GUI.") + .defaultValue(true) + .build() + ); + + public final Setting hoverVolume = sgSounds.add(new IntSetting.Builder() + .name("hover-volume") + .description("Volume of the hover sound.") + .min(1).defaultValue(60).max(100) + .sliderRange(1, 100) + .visible(guiSounds::get) + .build() + ); + + public final Setting clickVolume = sgSounds.add(new IntSetting.Builder() + .name("click-volume") + .description("Volume of left/right click sounds.") + .min(1).defaultValue(80).max(100) + .sliderRange(1, 100) + .visible(guiSounds::get) + .build() + ); + public final Setting blackPerson = sgSounds.add(new BoolSetting.Builder() .name("black-person") .description("Detect when black person") @@ -85,7 +112,7 @@ public NbtCompound toTag() { @Override public GenyoConfig fromTag(NbtCompound tag) { - if (tag.contains("settings")) settings.fromTag(tag.getCompound("settings")); + if (tag.contains("settings")) tag.getCompound("settings").ifPresent(settings::fromTag); return this; } diff --git a/src/main/java/com/genyo/systems/enemies/Enemies.java b/src/main/java/com/genyo/systems/enemies/Enemies.java index 0b09117..c5f0e22 100644 --- a/src/main/java/com/genyo/systems/enemies/Enemies.java +++ b/src/main/java/com/genyo/systems/enemies/Enemies.java @@ -125,7 +125,7 @@ public Enemy get(PlayerEntity player) { } public Enemy get(PlayerListEntry player) { - return get(player.getProfile().getName()); + return get(player.getProfile().name()); } public boolean isEnemy(PlayerEntity player) { @@ -170,16 +170,16 @@ public NbtCompound toTag() { @Override public Enemies fromTag(NbtCompound tag) { enemies.clear(); - if (tag.contains("settings")) settings.fromTag(tag.getCompound("settings")); + if (tag.contains("settings")) tag.getCompound("settings").ifPresent(settings::fromTag); - for (NbtElement itemTag : tag.getList("enemies", 10)) { + for (NbtElement itemTag : tag.getList("enemies").orElse(new net.minecraft.nbt.NbtList())) { NbtCompound enemyTag = (NbtCompound) itemTag; if (!enemyTag.contains("name")) continue; - String name = enemyTag.getString("name"); + String name = enemyTag.getString("name").orElse(""); if (get(name) != null) continue; - String uuid = enemyTag.getString("id"); + String uuid = enemyTag.getString("id").orElse(""); Enemy enemy = !uuid.isBlank() ? new Enemy(name, UndashedUuid.fromStringLenient(uuid)) : new Enemy(name); diff --git a/src/main/java/com/genyo/systems/enemies/Enemy.java b/src/main/java/com/genyo/systems/enemies/Enemy.java index 16ebedc..5c5d22a 100644 --- a/src/main/java/com/genyo/systems/enemies/Enemy.java +++ b/src/main/java/com/genyo/systems/enemies/Enemy.java @@ -8,8 +8,7 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.nbt.NbtCompound; import org.jetbrains.annotations.NotNull; - -import javax.annotation.Nullable; +import org.jetbrains.annotations.Nullable; import java.util.Objects; import java.util.UUID; @@ -19,7 +18,7 @@ public class Enemy implements ISerializable, Comparable { public volatile String name; private volatile @Nullable UUID id; - private volatile @Nullable PlayerHeadTexture headTexture; + private volatile byte[] headTexture; private volatile boolean updating; public Enemy(String name, @Nullable UUID id) { @@ -45,7 +44,7 @@ public String getName() { } public PlayerHeadTexture getHead() { - return headTexture != null ? headTexture : PlayerHeadUtils.STEVE_HEAD; + return headTexture != null ? new PlayerHeadTexture(headTexture, false) : PlayerHeadUtils.STEVE_HEAD; } public void updateInfo() { diff --git a/src/main/java/com/genyo/systems/hud/GenyoTargetHud.java b/src/main/java/com/genyo/systems/hud/GenyoTargetHud.java new file mode 100644 index 0000000..57b743c --- /dev/null +++ b/src/main/java/com/genyo/systems/hud/GenyoTargetHud.java @@ -0,0 +1,582 @@ +package com.genyo.systems.hud; + +import com.genyo.Genyo; +import com.genyo.systems.modules.combat.GenyoAutoCrystal; +import com.genyo.managers.Managers; +import com.genyo.systems.modules.combat.KFCSpawnKill; +import meteordevelopment.meteorclient.settings.*; +import meteordevelopment.meteorclient.systems.hud.*; +import meteordevelopment.meteorclient.systems.modules.Modules; +import meteordevelopment.meteorclient.utils.render.color.Color; +import meteordevelopment.meteorclient.utils.render.color.SettingColor; +import net.minecraft.client.network.PlayerListEntry; +import net.minecraft.component.DataComponentTypes; +import net.minecraft.component.type.ProfileComponent; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EquipmentSlot; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; +import net.minecraft.util.math.MathHelper; + +import java.util.ArrayList; +import java.util.List; + +import static meteordevelopment.meteorclient.MeteorClient.mc; + +public class GenyoTargetHud extends HudElement { + + public static final HudElementInfo INFO = new HudElementInfo<>( + Genyo.HUD_GROUP, "target-hud", "Displays info about your crystal/killaura target.", GenyoTargetHud::new + ); + + private final SettingGroup sgGeneral = settings.getDefaultGroup(); + private final SettingGroup sgColors = settings.createGroup("Colors"); + private final SettingGroup sgScale = settings.createGroup("Scale"); + + // --- General --- + private final Setting showFace = sgGeneral.add(new BoolSetting.Builder() + .name("show-face") + .description("Shows the target's player face on the left side of the HUD.") + .defaultValue(true) + .build() + ); + + private final Setting flatFace = sgGeneral.add(new BoolSetting.Builder() + .name("flat-face") + .description("Renders a flat 2D face instead of the 3D player head.") + .defaultValue(false) + .visible(showFace::get) + .build() + ); + + private final Setting showHealth = sgGeneral.add(new BoolSetting.Builder() + .name("show-health") + .description("Shows target health and absorption.") + .defaultValue(true) + .build() + ); + + private final Setting showArmor = sgGeneral.add(new BoolSetting.Builder() + .name("show-armor") + .description("Shows target armor durability bars.") + .defaultValue(true) + .build() + ); + + private final Setting showArmorItems = sgGeneral.add(new BoolSetting.Builder() + .name("show-armor-items") + .description("Renders armor item icons above bars.") + .defaultValue(true) + .build() + ); + + private final Setting showGearPercent = sgGeneral.add(new BoolSetting.Builder() + .name("show-gear-percent") + .description("Shows armor durability percentage(s).") + .defaultValue(true) + .build() + ); + + private final Setting perPieceGear = sgGeneral.add(new BoolSetting.Builder() + .name("per-piece-gear") + .description("Show each piece's durability % above its icon instead of an average.") + .defaultValue(false) + .visible(showGearPercent::get) + .build() + ); + + private final Setting showHands = sgGeneral.add(new BoolSetting.Builder() + .name("show-hands") + .description("Renders main hand and offhand items on the right.") + .defaultValue(true) + .build() + ); + + private final Setting showDistance = sgGeneral.add(new BoolSetting.Builder() + .name("show-distance") + .description("Shows distance to target.") + .defaultValue(true) + .build() + ); + + private final Setting showPing = sgGeneral.add(new BoolSetting.Builder() + .name("show-ping") + .description("Shows target ping.") + .defaultValue(true) + .build() + ); + + private final Setting showSource = sgGeneral.add(new BoolSetting.Builder() + .name("show-source") + .description("Shows [AC] or [KA] source tag.") + .defaultValue(true) + .build() + ); + + private final Setting showPops = sgGeneral.add(new BoolSetting.Builder() + .name("show-pops") + .description("Shows totem pop counter next to the target name.") + .defaultValue(true) + .build() + ); + + private final Setting shadow = sgGeneral.add(new BoolSetting.Builder() + .name("shadow") + .description("Renders shadow behind text.") + .defaultValue(true) + .build() + ); + + // --- Colors --- + private final Setting bgColor = sgColors.add(new ColorSetting.Builder() + .name("background-color") + .defaultValue(new SettingColor(0, 0, 0, 120)) + .build() + ); + + private final Setting borderColor = sgColors.add(new ColorSetting.Builder() + .name("border-color") + .defaultValue(new SettingColor(80, 80, 80, 180)) + .build() + ); + + private final Setting nameColor = sgColors.add(new ColorSetting.Builder() + .name("name-color") + .defaultValue(new SettingColor(255, 255, 255, 255)) + .build() + ); + + private final Setting healthColorHigh = sgColors.add(new ColorSetting.Builder() + .name("health-color-high") + .defaultValue(new SettingColor(80, 220, 80, 255)) + .build() + ); + + private final Setting healthColorLow = sgColors.add(new ColorSetting.Builder() + .name("health-color-low") + .defaultValue(new SettingColor(220, 60, 60, 255)) + .build() + ); + + private final Setting armorColor = sgColors.add(new ColorSetting.Builder() + .name("armor-color") + .defaultValue(new SettingColor(100, 180, 255, 255)) + .build() + ); + + private final Setting textColor = sgColors.add(new ColorSetting.Builder() + .name("text-color") + .defaultValue(new SettingColor(200, 200, 200, 255)) + .build() + ); + + private final Setting popColor = sgColors.add(new ColorSetting.Builder() + .name("pop-color") + .description("Color of the pop counter text.") + .defaultValue(new SettingColor(255, 80, 80, 255)) + .build() + ); + + private final Setting gearColorHigh = sgColors.add(new ColorSetting.Builder() + .name("gear-color-high") + .defaultValue(new SettingColor(80, 220, 80, 255)) + .build() + ); + + private final Setting gearColorLow = sgColors.add(new ColorSetting.Builder() + .name("gear-color-low") + .defaultValue(new SettingColor(220, 60, 60, 255)) + .build() + ); + + private final Setting customScale = sgScale.add(new BoolSetting.Builder() + .name("custom-scale") + .defaultValue(false) + .build() + ); + + private final Setting scale = sgScale.add(new DoubleSetting.Builder() + .name("scale") + .defaultValue(1.0) + .min(0.5) + .sliderRange(0.5, 3.0) + .visible(customScale::get) + .build() + ); + + private final Setting iconScale = sgScale.add(new DoubleSetting.Builder() + .name("icon-scale") + .description("Scale multiplier for armor and hand item icons.") + .defaultValue(1.0) + .min(0.5) + .sliderRange(0.5, 2.0) + .build() + ); + private static final int PADDING = 6; + private static final int BOTTOM_PADDING = 8; + private static final int BAR_HEIGHT = 5; + private static final int HAND_COLUMN_WIDTH = 28; + private static final float HAND_ITEM_SCALE_BASE = 1.4f; + private static final int HAND_ITEM_SIZE_BASE = (int)(16 * HAND_ITEM_SCALE_BASE); + private static final int BORDER = 1; + private static final int CONTENT_BASE_WIDTH = 220; // width of the info area (excluding face and hands) + + private static final EquipmentSlot[] ARMOR_SLOTS = { + EquipmentSlot.HEAD, + EquipmentSlot.CHEST, + EquipmentSlot.LEGS, + EquipmentSlot.FEET + }; + + private int lastHeight = 60; + + public GenyoTargetHud() { + super(INFO); + } + + @Override + public void tick(HudRenderer renderer) { + LivingEntity target = getTarget(); + if (target == null) { + if (isInEditor()) setSize(getPanelWidth(), getRequiredHeight(null, renderer)); + else setSize(0, 0); + return; + } + lastHeight = getRequiredHeight(target, renderer); + setSize(getPanelWidth(), lastHeight); + } + + + // Render + @Override + public void render(HudRenderer renderer) { + LivingEntity target = getTarget(); + + if (target == null) { + if (isInEditor()) renderer.text("Target HUD", x, y, textColor.get(), shadow.get(), getScale()); + return; + } + + int pw = getPanelWidth(); + int ph = getRequiredHeight(target, renderer); + double cx = x; + double cy = y; + + // Background + renderer.quad(cx, cy, pw, ph, bgColor.get()); + + + Color bc = borderColor.get(); + renderer.quad(cx, cy, pw, BORDER, bc); // top + renderer.quad(cx, cy + ph - BORDER, pw, BORDER, bc); // bottom + renderer.quad(cx, cy, BORDER, ph, bc); // left + renderer.quad(cx + pw - BORDER, cy, BORDER, ph, bc); // right + + int faceSize = 0; + if (showFace.get() && target instanceof PlayerEntity facePlayer) { + faceSize = ph; + PlayerListEntry entry = mc.getNetworkHandler() != null + ? mc.getNetworkHandler().getPlayerListEntry(facePlayer.getUuid()) : null; + if (entry != null) { + if (flatFace.get()) { + net.minecraft.util.Identifier skinTex = entry.getSkinTextures().body().texturePath(); + + int drawX = (int)cx + BORDER; + int drawY = (int)cy + BORDER; + int size = faceSize - BORDER * 2; + + var tex = mc.getTextureManager().getTexture(skinTex); + + meteordevelopment.meteorclient.renderer.Renderer2D.TEXTURE.begin(); + meteordevelopment.meteorclient.renderer.Renderer2D.TEXTURE.texQuad( + drawX, drawY, size, size, + 0, // rotation + 8f/64f, 8f/64f, // texX1, texY1 + 16f/64f, 16f/64f, // texX2, texY2 + Color.WHITE + ); + meteordevelopment.meteorclient.renderer.Renderer2D.TEXTURE.render( + tex.getGlTextureView(), tex.getSampler() + ); + + meteordevelopment.meteorclient.renderer.Renderer2D.TEXTURE.begin(); + meteordevelopment.meteorclient.renderer.Renderer2D.TEXTURE.texQuad( + drawX, drawY, size, size, + 0, + 40f/64f, 8f/64f, + 48f/64f, 16f/64f, + Color.WHITE + ); + meteordevelopment.meteorclient.renderer.Renderer2D.TEXTURE.render( + tex.getGlTextureView(), tex.getSampler() + ); + } else { + ItemStack skull = new ItemStack(Items.PLAYER_HEAD); + skull.set(DataComponentTypes.PROFILE, + ProfileComponent.ofStatic(facePlayer.getGameProfile())); + + float itemScale = (faceSize - BORDER * 2) / 16f; + int drawX = (int)cx + BORDER; + int drawY = (int)cy + BORDER; + renderer.item(skull, drawX, drawY, itemScale, false); + } + } + renderer.quad(cx + faceSize, cy, 1, ph, borderColor.get()); + } + + int accentX = (int)cx + faceSize; + renderer.quad(accentX, cy, 2, ph, getHealthColor(target)); + + int handColX = (int)(cx + pw - HAND_COLUMN_WIDTH - PADDING); + if (showHands.get() && target instanceof PlayerEntity player) { + renderer.quad(handColX - 1, cy + PADDING, 1, ph - PADDING * 2, + new Color(80, 80, 80, 120)); + + float handItemScale = HAND_ITEM_SCALE_BASE * (float)(double) iconScale.get(); + int handItemSize = (int)(16 * handItemScale); + ItemStack mainHand = player.getMainHandStack(); + ItemStack offHand = player.getOffHandStack(); + int totalHandH = handItemSize * 2 + 4; + int handStartY = (int)(cy + (ph - totalHandH) / 2.0); + int handX = handColX + (HAND_COLUMN_WIDTH - handItemSize) / 2; + + if (!mainHand.isEmpty()) renderer.item(mainHand, handX, handStartY, handItemScale, true); + if (!offHand.isEmpty()) renderer.item(offHand, handX, handStartY + handItemSize + 4, handItemScale, true); + } + + int contentEndX = showHands.get() ? handColX - PADDING : (int)(cx + pw - PADDING); + int textStartX = accentX + 2 + PADDING; + int barW = contentEndX - textStartX; + double curY = cy + PADDING; + + String name = target.getName().getString(); + String sourceTag = showSource.get() ? " " + getSource(target) : ""; + double curX = textStartX; + renderer.text(name, curX, curY, nameColor.get(), shadow.get(), getScale()); + curX += renderer.textWidth(name, shadow.get(), getScale()); + if (!sourceTag.isEmpty()) { + renderer.text(sourceTag, curX, curY, new Color(160, 160, 160, 200), shadow.get(), getScale()); + curX += renderer.textWidth(sourceTag, shadow.get(), getScale()); + } + if (showPops.get() && target instanceof PlayerEntity popPlayer) { + Integer pops = Managers.COMBAT.popList.get(popPlayer.getName().getString()); + if (pops != null && pops > 0) { + String popText = " -" + pops; + renderer.text(popText, curX, curY, popColor.get(), shadow.get(), getScale()); + } + } + curY += renderer.textHeight(shadow.get(), getScale()) + 2; + + if (showHealth.get()) { + float health = target.getHealth(); + float absorption = target.getAbsorptionAmount(); + float maxHealth = target.getMaxHealth(); + float healthPct = MathHelper.clamp(health / maxHealth, 0f, 1f); + + renderer.quad(textStartX, curY, barW, BAR_HEIGHT, new Color(40, 40, 40, 180)); + renderer.quad(textStartX, curY, (int)(barW * healthPct), BAR_HEIGHT, getHealthColor(target)); + + if (absorption > 0) { + float absPct = MathHelper.clamp(absorption / maxHealth, 0f, 1f); + int absW = (int)(barW * absPct); + int fillW = (int)(barW * healthPct); + int absX = Math.max(textStartX, textStartX + fillW - absW); + renderer.quad(absX, curY, absW, BAR_HEIGHT, new Color(255, 220, 80, 120)); + } + curY += BAR_HEIGHT + 2; + + String healthText = String.format("%.1f / %.1f", health, maxHealth); + if (absorption > 0) healthText += String.format(" (+%.1f)", absorption); + renderer.text(healthText, textStartX, curY, textColor.get(), shadow.get(), getScale()); + curY += renderer.textHeight(shadow.get(), getScale()) + 2; + } + + if (target instanceof PlayerEntity player) { + List durs = getArmorDurabilities(player); + int slotCount = 4; + int gap = 2; + int slotW = (barW - gap * (slotCount - 1)) / slotCount; + + float itemScale = Math.min((float) slotW / 16f, 1.5f) * (float)(double) iconScale.get(); + int itemRenderSize = (int)(16 * itemScale); + + if (showArmorItems.get()) { + int itemOffsetY = (int) curY; + for (int i = 0; i < slotCount; i++) { + ItemStack stack = player.getEquippedStack(ARMOR_SLOTS[i]); + if (!stack.isEmpty()) { + int slotX = textStartX + i * (slotW + gap); + int itemX = slotX + (slotW - itemRenderSize) / 2; + renderer.item(stack, itemX, itemOffsetY, itemScale, true); + } + } + curY += itemRenderSize + 3; + } + + if (showArmor.get()) { + for (int i = 0; i < slotCount; i++) { + float dur = durs.get(i)[0]; + boolean has = durs.get(i)[1] > 0; + int slotX = textStartX + i * (slotW + gap); + + renderer.quad(slotX, curY, slotW, BAR_HEIGHT, new Color(40, 40, 40, 180)); + if (has) { + Color fill = dur < 0.2f ? new Color(220, 60, 60, 255) : armorColor.get(); + renderer.quad(slotX, curY, (int)(slotW * dur), BAR_HEIGHT, fill); + } + } + curY += BAR_HEIGHT + 2; + } + + if (showGearPercent.get()) { + if (perPieceGear.get()) { + for (int i = 0; i < slotCount; i++) { + float dur = durs.get(i)[0]; + boolean has = durs.get(i)[1] > 0; + if (!has) continue; + String label = String.format("%.0f%%", dur * 100f); + Color col = interpolateColor(gearColorLow.get(), gearColorHigh.get(), dur); + double lw = renderer.textWidth(label, shadow.get(), getScale()); + double slotCentX = textStartX + i * (slotW + gap) + slotW / 2.0; + renderer.text(label, slotCentX - lw / 2.0, curY, col, shadow.get(), getScale()); + } + } else { + float gearPct = getGearPercent(player); + String gearText = String.format("Gear: %.0f%%", gearPct * 100f); + Color gearCol = interpolateColor(gearColorLow.get(), gearColorHigh.get(), gearPct); + renderer.text(gearText, textStartX, curY, gearCol, shadow.get(), getScale()); + } + curY += renderer.textHeight(shadow.get(), getScale()) + 2; + } + } + + boolean hasDistance = showDistance.get(); + boolean hasPing = showPing.get() && target instanceof PlayerEntity; + if (hasDistance || hasPing) { + renderer.quad(textStartX, curY, barW, 1, new Color(80, 80, 80, 140)); + curY += 4; + + String distText = hasDistance ? String.format("%.1fm", mc.player.distanceTo(target)) : null; + String pingText = null; + if (hasPing) { + int ping = getPing((PlayerEntity) target); + if (ping >= 0) pingText = ping + "ms"; + } + + if (distText != null && pingText != null) { + double distW = renderer.textWidth(distText, shadow.get(), getScale()); + double pingW = renderer.textWidth(pingText, shadow.get(), getScale()); + double textH = renderer.textHeight(shadow.get(), getScale()); + double totalW = distW + 9 + pingW; + double startX = textStartX + (barW - totalW) / 2.0; + + renderer.text(distText, startX, curY, textColor.get(), shadow.get(), getScale()); + double divX = startX + distW + 4; + renderer.quad(divX, curY - 1, 1, (int)textH + 2, new Color(100, 100, 100, 160)); + renderer.text(pingText, divX + 5, curY, textColor.get(), shadow.get(), getScale()); + } else { + String single = distText != null ? distText : pingText; + if (single != null) + renderer.text(single, textStartX, curY, textColor.get(), shadow.get(), getScale()); + } + } + } + + private LivingEntity getTarget() { + GenyoAutoCrystal crystal = Modules.get().get(GenyoAutoCrystal.class); + if (Modules.get().isActive(GenyoAutoCrystal.class) && crystal.targetEntity != null) + return crystal.targetEntity; + KFCSpawnKill kfc = Modules.get().get(KFCSpawnKill.class); + if (Modules.get().isActive(KFCSpawnKill.class)) { + Entity e = kfc.getEntityTarget(); + if (e instanceof LivingEntity living) return living;}return null;} + + private String getSource(LivingEntity target) { + GenyoAutoCrystal crystal = Modules.get().get(GenyoAutoCrystal.class); + if (Modules.get().isActive(GenyoAutoCrystal.class) && crystal.targetEntity == target) return "[AC]";return "[KA]";} + + private Color getHealthColor(LivingEntity target) { + float t = MathHelper.clamp(target.getHealth() / target.getMaxHealth(), 0f, 1f); + return interpolateColor(healthColorLow.get(), healthColorHigh.get(), t);} + + private Color interpolateColor(SettingColor lo, SettingColor hi, float t) { + return new Color( + (int)(lo.r + (hi.r - lo.r) * t), + (int)(lo.g + (hi.g - lo.g) * t), + (int)(lo.b + (hi.b - lo.b) * t), + 255);} + + private List getArmorDurabilities(PlayerEntity player) { + List result = new ArrayList<>(); + for (EquipmentSlot slot : ARMOR_SLOTS) { + ItemStack stack = player.getEquippedStack(slot); + if (stack.isEmpty() || stack.getMaxDamage() == 0) { + result.add(new float[]{ 0f, 0f }); + } else { + result.add(new float[]{ + 1f - (stack.getDamage() / (float) stack.getMaxDamage()), + stack.getMaxDamage() + }); + } + }return result;} + + private float getGearPercent(PlayerEntity player) { + float total = 0f; + int count = 0; + for (EquipmentSlot slot : ARMOR_SLOTS) { + ItemStack stack = player.getEquippedStack(slot); + if (!stack.isEmpty() && stack.getMaxDamage() > 0) { + total += 1f - (stack.getDamage() / (float) stack.getMaxDamage()); + count++; + } + } + return count == 0 ? 1f : total / count; + } + + private int getPing(PlayerEntity player) { + PlayerListEntry entry = mc.getNetworkHandler() != null + ? mc.getNetworkHandler().getPlayerListEntry(player.getUuid()) : null; + return entry != null ? entry.getLatency() : -1; + } + + private int getPanelWidth() { + int handExtra = showHands.get() ? HAND_COLUMN_WIDTH + PADDING : 0; + int faceExtra = showFace.get() ? lastHeight : 0; + return CONTENT_BASE_WIDTH + handExtra + faceExtra; + } + + private int getRequiredHeight(LivingEntity target, HudRenderer renderer) { + boolean isPlayer = target == null || target instanceof PlayerEntity; + + double textH = renderer.textHeight(shadow.get(), getScale()); + + double h = PADDING + textH + 2; // top padding + name row + + if (showHealth.get()) h += BAR_HEIGHT + 2 + textH + 2; + + if (isPlayer) { + float itemScaleEst = Math.min(((CONTENT_BASE_WIDTH - PADDING * 2 - 2 - 3 * 2) / 4) / 16f, 1.5f) + * (float)(double) iconScale.get(); + int itemSizeEst = (int)(16 * itemScaleEst); + + if (showArmorItems.get()) h += itemSizeEst + 3; + if (showArmor.get()) h += BAR_HEIGHT + 2; + if (showGearPercent.get()) h += textH + 2; + } + + if (showDistance.get() || showPing.get()) + h += 1 + 4 + textH; + + h += BOTTOM_PADDING; + + if (showHands.get()) h = Math.max(h, HAND_ITEM_SIZE_BASE * 2 + 4 + PADDING * 2); + + return (int) Math.ceil(h); + } + + private double getScale() { + return customScale.get() ? scale.get() : Hud.get().getTextScale(); + } +} diff --git a/src/main/java/com/genyo/systems/hud/LogoHud.java b/src/main/java/com/genyo/systems/hud/LogoHud.java index e12f564..6447bd6 100644 --- a/src/main/java/com/genyo/systems/hud/LogoHud.java +++ b/src/main/java/com/genyo/systems/hud/LogoHud.java @@ -1,7 +1,6 @@ package com.genyo.systems.hud; import com.genyo.Genyo; -import meteordevelopment.meteorclient.renderer.GL; import meteordevelopment.meteorclient.renderer.Renderer2D; import meteordevelopment.meteorclient.settings.DoubleSetting; import meteordevelopment.meteorclient.settings.Setting; @@ -9,8 +8,9 @@ import meteordevelopment.meteorclient.systems.hud.HudElement; import meteordevelopment.meteorclient.systems.hud.HudElementInfo; import meteordevelopment.meteorclient.systems.hud.HudRenderer; +import net.minecraft.client.MinecraftClient; import meteordevelopment.meteorclient.utils.render.color.Color; -import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.client.texture.AbstractTexture; import net.minecraft.util.Identifier; public class LogoHud extends HudElement { @@ -36,11 +36,11 @@ public LogoHud() { @Override public void render(HudRenderer renderer) { setSize(256 * scale.get(), 256 * scale.get()); - MatrixStack matrices = new MatrixStack(); - GL.bindTexture(logo); + AbstractTexture texture = MinecraftClient.getInstance().getTextureManager().getTexture(logo); + Renderer2D.TEXTURE.begin(); Renderer2D.TEXTURE.texQuad(x, y, 256 * scale.get(), 256 * scale.get(), new Color(255, 255, 255, 255)); - Renderer2D.TEXTURE.render(matrices); + Renderer2D.TEXTURE.render(texture.getGlTextureView(), texture.getSampler()); } } diff --git a/src/main/java/com/genyo/systems/modules/combat/AutoCrawlTrap.java b/src/main/java/com/genyo/systems/modules/combat/AutoCrawlTrap.java index 8c0abae..252cdbf 100644 --- a/src/main/java/com/genyo/systems/modules/combat/AutoCrawlTrap.java +++ b/src/main/java/com/genyo/systems/modules/combat/AutoCrawlTrap.java @@ -321,8 +321,8 @@ public List getCrawlTrap(PlayerEntity entity, BlockPos playerPos) int ticks = 0; while (ticks <= extrapolateTicks.get()) { - double ox = (x - entity.prevX) * ticks; - double oz = (z - entity.prevZ) * ticks; + double ox = (x - entity.lastX) * ticks; + double oz = (z - entity.lastZ) * ticks; BlockPos blockPos = BlockPos.ofFloored(x + ox, y, z + oz); if (!crawlTrap.contains(blockPos.up())) { diff --git a/src/main/java/com/genyo/systems/modules/combat/BasePlace.java b/src/main/java/com/genyo/systems/modules/combat/BasePlace.java index 496aa11..a5d5e65 100644 --- a/src/main/java/com/genyo/systems/modules/combat/BasePlace.java +++ b/src/main/java/com/genyo/systems/modules/combat/BasePlace.java @@ -14,7 +14,8 @@ import meteordevelopment.meteorclient.settings.*; import meteordevelopment.meteorclient.systems.modules.Modules; import meteordevelopment.meteorclient.systems.modules.combat.CrystalAura; -import meteordevelopment.meteorclient.systems.modules.world.AirPlace; + +import meteordevelopment.meteorclient.systems.modules.player.AirPlace; import meteordevelopment.meteorclient.utils.render.color.Color; import meteordevelopment.meteorclient.utils.render.color.SettingColor; import meteordevelopment.orbit.EventHandler; diff --git a/src/main/java/com/genyo/systems/modules/combat/FriendProtector.java b/src/main/java/com/genyo/systems/modules/combat/FriendProtector.java index cbf5734..52e3a23 100644 --- a/src/main/java/com/genyo/systems/modules/combat/FriendProtector.java +++ b/src/main/java/com/genyo/systems/modules/combat/FriendProtector.java @@ -15,7 +15,7 @@ import meteordevelopment.meteorclient.renderer.ShapeMode; import meteordevelopment.meteorclient.settings.*; import meteordevelopment.meteorclient.systems.modules.Modules; -import meteordevelopment.meteorclient.systems.modules.world.AirPlace; +import meteordevelopment.meteorclient.systems.modules.player.AirPlace; import meteordevelopment.meteorclient.utils.render.color.Color; import meteordevelopment.meteorclient.utils.render.color.SettingColor; import meteordevelopment.orbit.EventHandler; diff --git a/src/main/java/com/genyo/systems/modules/combat/GenyoAutoArmor.java b/src/main/java/com/genyo/systems/modules/combat/GenyoAutoArmor.java index 0eac8be..151de41 100644 --- a/src/main/java/com/genyo/systems/modules/combat/GenyoAutoArmor.java +++ b/src/main/java/com/genyo/systems/modules/combat/GenyoAutoArmor.java @@ -83,6 +83,13 @@ public GenyoAutoArmor() { private final Queue leggings = new PriorityQueue<>(); private final Queue boots = new PriorityQueue<>(); + private static final EquipmentSlot[] ARMOR_SLOTS = { + EquipmentSlot.HEAD, + EquipmentSlot.CHEST, + EquipmentSlot.LEGS, + EquipmentSlot.FEET + }; + @EventHandler public void onTick(PlayerTickEvent event) { @@ -123,7 +130,7 @@ public void onTick(PlayerTickEvent event) } for (int i = 0; i < 4; i++) { - ItemStack armorStack = mc.player.getInventory().getArmorStack(i); + ItemStack armorStack = mc.player.getEquippedStack(ARMOR_SLOTS[i]); if (elytraPriorityConfig.get() && armorStack.getItem() == Items.ELYTRA) { continue; diff --git a/src/main/java/com/genyo/systems/modules/combat/GenyoAutoCrystal.java b/src/main/java/com/genyo/systems/modules/combat/GenyoAutoCrystal.java index b16da12..7882909 100644 --- a/src/main/java/com/genyo/systems/modules/combat/GenyoAutoCrystal.java +++ b/src/main/java/com/genyo/systems/modules/combat/GenyoAutoCrystal.java @@ -7,6 +7,7 @@ import com.genyo.systems.modules.misc.FastLatency; import com.genyo.systems.settings.FloatSetting; import com.genyo.utils.player.RotationUtil; +import com.genyo.utils.world.ExplosionUtil; import meteordevelopment.meteorclient.settings.*; import meteordevelopment.meteorclient.utils.render.color.Color; import meteordevelopment.meteorclient.utils.render.color.SettingColor; @@ -24,7 +25,6 @@ import com.genyo.utils.player.InventoryUtil; import com.genyo.utils.player.PlayerUtil; import com.genyo.utils.world.BlastResistantBlocks; -import com.genyo.utils.world.ExplosionUtil; import com.google.common.collect.Lists; import meteordevelopment.meteorclient.events.packets.PacketEvent; import meteordevelopment.meteorclient.events.render.Render2DEvent; @@ -38,7 +38,6 @@ import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.block.ShulkerBoxBlock; -import net.minecraft.component.type.AttributeModifierSlot; import net.minecraft.entity.*; import net.minecraft.entity.decoration.EndCrystalEntity; import net.minecraft.entity.effect.StatusEffectInstance; @@ -701,7 +700,7 @@ public void onPlayerUpdate(PlayerTickEvent event) } renderPos = null; ArrayList entities = Lists.newArrayList(mc.world.getEntities()); - List blocks = getSphere(placeRangeEye.get() ? mc.player.getEyePos() : mc.player.getPos()); + List blocks = getSphere(placeRangeEye.get() ? mc.player.getEyePos() : mc.player.getEntityPos()); long timePre = System.nanoTime(); if (place.get()) { @@ -718,7 +717,7 @@ public void onPlayerUpdate(PlayerTickEvent event) EndCrystalEntity crystalEntity = intersectingCrystalCheck(placeCrystal.getDamageData()); if (crystalEntity != null) { - double self = ExplosionUtil.getDamageTo(mc.player, crystalEntity.getPos(), + double self = ExplosionUtil.getDamageTo(mc.player, crystalEntity.getEntityPos(), blockDestruction.get(), selfExtrapolate.get() ? extrapolateTicks.get() : 0, false); if (!safety.get() || !playerDamageCheck(self)) { @@ -757,7 +756,7 @@ public void onPlayerUpdate(PlayerTickEvent event) attackRotate = attackCrystal != null && attackDelay.get() <= 0.0 && lastAttackTimer.passed(breakDelay); if (attackCrystal != null) { - crystalRotation = attackCrystal.damageData.getPos(); + crystalRotation = attackCrystal.damageData.getEntityPos(); } else if (placeCrystal != null) { @@ -1017,7 +1016,7 @@ public void onAddEntity(AddEntityEvent event) { return; } - Vec3d crystalPos = crystalEntity.getPos(); + Vec3d crystalPos = crystalEntity.getEntityPos(); BlockPos blockPos = BlockPos.ofFloored(crystalPos.add(0.0, -1.0, 0.0)); renderSpawnPos = blockPos; Long time = placePackets.remove(blockPos); @@ -1061,7 +1060,7 @@ else if (instantCalc.get()) { continue; } - double crystalDist = crystalPos.squaredDistanceTo(entity.getPos()); + double crystalDist = crystalPos.squaredDistanceTo(entity.getEntityPos()); if (crystalDist > 144.0f) { continue; @@ -1135,9 +1134,9 @@ public void attackCrystal(EndCrystalEntity entity, Hand hand) for (int i = 0; i < 9; ++i) { ItemStack stack = mc.player.getInventory().getStack(i); - if (!stack.isEmpty() && (stack.getItem() instanceof SwordItem + if (!stack.isEmpty() && (stack.isIn(ItemTags.SWORDS) || stack.getItem() instanceof AxeItem - || stack.getItem() instanceof PickaxeItem)) + || stack.isIn(ItemTags.PICKAXES))) { slot = i; break; @@ -1151,7 +1150,7 @@ public void attackCrystal(EndCrystalEntity entity, Hand hand) if (antiWeakness.get() == Swap.SILENT_ALT) { mc.interactionManager.clickSlot(mc.player.playerScreenHandler.syncId, - slot + 36, mc.player.getInventory().selectedSlot, SlotActionType.SWAP, mc.player); + slot + 36, mc.player.getInventory().getSelectedSlot(), SlotActionType.SWAP, mc.player); } else if (antiWeakness.get() == Swap.SILENT) { @@ -1168,7 +1167,7 @@ else if (antiWeakness.get() == Swap.SILENT) if (antiWeakness.get() == Swap.SILENT_ALT) { mc.interactionManager.clickSlot(mc.player.playerScreenHandler.syncId, - slot + 36, mc.player.getInventory().selectedSlot, SlotActionType.SWAP, mc.player); + slot + 36, mc.player.getInventory().getSelectedSlot(), SlotActionType.SWAP, mc.player); } else if (antiWeakness.get() == Swap.SILENT) { @@ -1279,7 +1278,7 @@ public void placeCrystal(BlockPos blockPos, Hand hand, boolean checkPlacement) if (autoSwap.get() == Swap.SILENT_ALT) { mc.interactionManager.clickSlot(mc.player.playerScreenHandler.syncId, - crystalSlot + 36, mc.player.getInventory().selectedSlot, SlotActionType.SWAP, mc.player); + crystalSlot + 36, mc.player.getInventory().getSelectedSlot(), SlotActionType.SWAP, mc.player); } else if (autoSwap.get() == Swap.SILENT) { @@ -1297,7 +1296,7 @@ else if (autoSwap.get() == Swap.SILENT) if (autoSwap.get() == Swap.SILENT_ALT) { mc.interactionManager.clickSlot(mc.player.playerScreenHandler.syncId, - crystalSlot + 36, mc.player.getInventory().selectedSlot, SlotActionType.SWAP, mc.player); + crystalSlot + 36, mc.player.getInventory().getSelectedSlot(), SlotActionType.SWAP, mc.player); } else if (autoSwap.get() == Swap.SILENT) { @@ -1437,7 +1436,7 @@ private DamageData calculateAttackCrystal(List entitie { continue; } - double selfDamage = ExplosionUtil.getDamageTo(mc.player, crystal.getPos(), + double selfDamage = ExplosionUtil.getDamageTo(mc.player, crystal.getEntityPos(), blockDestruction.get(), selfExtrapolate.get() ? extrapolateTicks.get() : 0, false); boolean unsafeToPlayer = playerDamageCheck(selfDamage); if (unsafeToPlayer && !safetyOverride.get()) @@ -1495,7 +1494,7 @@ private DamageData calculateAttackCrystal(List entitie } } - double damage = ExplosionUtil.getDamageTo(entity, crystal.getPos(), blockDestruction.get(), + double damage = ExplosionUtil.getDamageTo(entity, crystal.getEntityPos(), blockDestruction.get(), extrapolateTicks.get(), assumeArmor.get()); if (checkOverrideSafety(unsafeToPlayer, damage, entity)) { @@ -1528,7 +1527,7 @@ private DamageData calculateAttackCrystal(List entitie private boolean attackRangeCheck(EndCrystalEntity entity) { - return attackRangeCheck(entity.getPos()); + return attackRangeCheck(entity.getEntityPos()); } /** @@ -1587,7 +1586,7 @@ private DamageData calculatePlaceCrystal(List placeBlocks, L { continue; } - double blockDist = pos.getSquaredDistance(entity.getPos()); + double blockDist = pos.getSquaredDistance(entity.getEntityPos()); if (blockDist > 144.0f) { continue; @@ -1670,7 +1669,7 @@ private boolean placeRangeCheck(BlockPos pos) { double placeRange = placeRangeC.get(); double placeWallRange = placeWallRangeC.get(); - Vec3d player = placeRangeEye.get() ? mc.player.getEyePos() : mc.player.getPos(); + Vec3d player = placeRangeEye.get() ? mc.player.getEyePos() : mc.player.getEntityPos(); double dist = placeRangeCenter.get() ? player.squaredDistanceTo(pos.toCenterPos()) : pos.getSquaredDistance(player.x, player.y, player.z); if (dist > placeRange * placeRange) @@ -1812,8 +1811,9 @@ private boolean isCrystalLethalTo(double damage, LivingEntity entity) } if (armorBreaker.get()) { - for (ItemStack armorStack : entity.getArmorItems()) + for (EquipmentSlot slot : new EquipmentSlot[]{EquipmentSlot.HEAD, EquipmentSlot.CHEST, EquipmentSlot.LEGS, EquipmentSlot.FEET}) { + ItemStack armorStack = entity.getEquippedStack(slot); int n = armorStack.getDamage(); int n1 = armorStack.getMaxDamage(); float durability = ((n1 - n) / (float) n1) * 100.0f; @@ -1827,7 +1827,7 @@ private boolean isCrystalLethalTo(double damage, LivingEntity entity) // Antiregear if (shulkers.get() && entity instanceof PlayerEntity) { - for (BlockPos pos : getSphere(3.0f, entity.getPos())) + for (BlockPos pos : getSphere(3.0f, entity.getEntityPos())) { BlockState state = mc.world.getBlockState(pos); if (state.getBlock() instanceof ShulkerBoxBlock) @@ -1954,7 +1954,7 @@ else if (entity instanceof EndCrystalEntity entity1 else { double dist = mc.player.squaredDistanceTo(entity1); - stuckCrystals.add(new AntiStuckData(entity1.getId(), entity1.getBlockPos(), entity1.getPos(), dist)); + stuckCrystals.add(new AntiStuckData(entity1.getId(), entity1.getBlockPos(), entity1.getEntityPos(), dist)); } } } diff --git a/src/main/java/com/genyo/systems/modules/combat/GenyoAutoTotem.java b/src/main/java/com/genyo/systems/modules/combat/GenyoAutoTotem.java index 91331f0..179d0d3 100644 --- a/src/main/java/com/genyo/systems/modules/combat/GenyoAutoTotem.java +++ b/src/main/java/com/genyo/systems/modules/combat/GenyoAutoTotem.java @@ -220,7 +220,7 @@ public void onTick(TickEvent.Pre event) // If offhand gap is enabled & the use key is pressed down, equip a golden apple. final Item mainHandItem = mc.player.getMainHandStack().getItem(); if (gappleConfig.get() && mc.options.useKey.isPressed() - && (mainHandItem instanceof SwordItem + && (mc.player.getMainHandStack().isIn(ItemTags.SWORDS) || mainHandItem instanceof TridentItem || mainHandItem instanceof AxeItem) && PlayerUtil.getLocalPlayerHealth() >= healthConfig.get()) @@ -366,7 +366,7 @@ private boolean checkLethalCrystal(float health) { continue; } - double potential = ExplosionUtil.getDamageTo(mc.player, crystal.getPos(), false); + double potential = ExplosionUtil.getDamageTo(mc.player, crystal.getEntityPos(), false); if (health + 0.5 > potential) { continue; diff --git a/src/main/java/com/genyo/systems/modules/combat/GenyoAutoTrap.java b/src/main/java/com/genyo/systems/modules/combat/GenyoAutoTrap.java index 73c10ae..a9f8ad4 100644 --- a/src/main/java/com/genyo/systems/modules/combat/GenyoAutoTrap.java +++ b/src/main/java/com/genyo/systems/modules/combat/GenyoAutoTrap.java @@ -15,7 +15,7 @@ import meteordevelopment.meteorclient.renderer.ShapeMode; import meteordevelopment.meteorclient.settings.*; import meteordevelopment.meteorclient.systems.modules.Modules; -import meteordevelopment.meteorclient.systems.modules.world.AirPlace; +import meteordevelopment.meteorclient.systems.modules.player.AirPlace; import meteordevelopment.meteorclient.utils.render.color.Color; import meteordevelopment.meteorclient.utils.render.color.SettingColor; import meteordevelopment.orbit.EventHandler; diff --git a/src/main/java/com/genyo/systems/modules/combat/GenyoAutoXP.java b/src/main/java/com/genyo/systems/modules/combat/GenyoAutoXP.java index c1abad2..b0918fb 100644 --- a/src/main/java/com/genyo/systems/modules/combat/GenyoAutoXP.java +++ b/src/main/java/com/genyo/systems/modules/combat/GenyoAutoXP.java @@ -139,8 +139,9 @@ private boolean areItemsFullDura(PlayerEntity player) return false; } - for (ItemStack stack : player.getArmorItems()) + for (EquipmentSlot slot : new EquipmentSlot[]{EquipmentSlot.HEAD, EquipmentSlot.CHEST, EquipmentSlot.LEGS, EquipmentSlot.FEET}) { + ItemStack stack = player.getEquippedStack(slot); if (!isItemFullDura(stack)) { return false; diff --git a/src/main/java/com/genyo/systems/modules/combat/KFCSpawnKill.java b/src/main/java/com/genyo/systems/modules/combat/KFCSpawnKill.java index a129205..190e0d6 100644 --- a/src/main/java/com/genyo/systems/modules/combat/KFCSpawnKill.java +++ b/src/main/java/com/genyo/systems/modules/combat/KFCSpawnKill.java @@ -493,7 +493,7 @@ public void onPlayerUpdate(PlayerTickEvent event) if (attackDelayConfig.get()) { PlayerInventory inventory = mc.player.getInventory(); - ItemStack itemStack = inventory.getStack((slot == -1 || !swordCheckConfig.get()) ? mc.player.getInventory().selectedSlot : slot); + ItemStack itemStack = inventory.getStack((slot == -1 || !swordCheckConfig.get()) ? mc.player.getInventory().getSelectedSlot() : slot); MutableDouble attackSpeed = new MutableDouble( mc.player.getAttributeBaseValue(EntityAttributes.ATTACK_SPEED)); @@ -643,11 +643,10 @@ private int getSwordSlot() for (int i = 0; i < 9; i++) { final ItemStack stack = mc.player.getInventory().getStack(i); - if (stack.getItem() instanceof SwordItem swordItem) + if (stack.isIn(ItemTags.SWORDS)) { - float sharpness = EnchantmentUtil.getLevel(stack, - Enchantments.SHARPNESS) * 0.5f + 0.5f; - float dmg = swordItem.getDefaultStack().getDamage() + sharpness; + float sharpness = EnchantmentUtil.getLevel(stack, Enchantments.SHARPNESS) * 0.5f + 0.5f; + float dmg = stack.getItem().getDefaultStack().getDamage() + sharpness; if (dmg > sharp) { sharp = dmg; @@ -734,8 +733,7 @@ private void preAttackTarget() sneaking = Managers.POSITION.isSneaking(); if (sneaking) { - Managers.NETWORK.sendPacket(new ClientCommandC2SPacket(mc.player, - ClientCommandC2SPacket.Mode.RELEASE_SHIFT_KEY)); + mc.player.setSneaking(false); } sprinting = Managers.POSITION.isSprinting(); if (sprinting) @@ -756,8 +754,7 @@ private void postAttackTarget(Entity entity) } if (sneaking) { - Managers.NETWORK.sendPacket(new ClientCommandC2SPacket(mc.player, - ClientCommandC2SPacket.Mode.PRESS_SHIFT_KEY)); + mc.player.setSneaking(true); } if (sprinting) { @@ -797,11 +794,11 @@ private Entity getAttackTarget(Vec3d pos) } if (armorCheckConfig.get() && entity instanceof LivingEntity livingEntity - && !livingEntity.getArmorItems().iterator().hasNext()) + && !Stream.of(EquipmentSlot.HEAD, EquipmentSlot.CHEST, EquipmentSlot.LEGS, EquipmentSlot.FEET).anyMatch(s -> !livingEntity.getEquippedStack(s).isEmpty())) { continue; } - double dist = pos.distanceTo(entity.getPos()); + double dist = pos.distanceTo(entity.getEntityPos()); if (dist <= searchRangeConfig.get()) { if (entity.age < ticksExistedConfig.get()) @@ -852,8 +849,9 @@ private float getArmorDurability(LivingEntity e) { float edmg = 0.0f; float emax = 0.0f; - for (ItemStack armor : e.getArmorItems()) + for (EquipmentSlot s : new EquipmentSlot[]{EquipmentSlot.HEAD, EquipmentSlot.CHEST, EquipmentSlot.LEGS, EquipmentSlot.FEET}) { + ItemStack armor = e.getEquippedStack(s); if (armor != null && !armor.isEmpty()) { edmg += armor.getDamage(); @@ -905,7 +903,7 @@ public boolean isInAttackRange(double dist, Vec3d pos, Vec3d entityPos) public boolean isHoldingSword() { - return !swordCheckConfig.get() || mc.player.getMainHandStack().getItem() instanceof SwordItem + return !swordCheckConfig.get() || mc.player.getMainHandStack().isIn(ItemTags.SWORDS) || mc.player.getMainHandStack().getItem() instanceof AxeItem || mc.player.getMainHandStack().getItem() instanceof TridentItem || mc.player.getMainHandStack().getItem() instanceof MaceItem; @@ -913,7 +911,7 @@ public boolean isHoldingSword() private Vec3d getAttackRotateVec(Entity entity) { - Vec3d feetPos = entity.getPos(); + Vec3d feetPos = entity.getEntityPos(); return switch (hitVectorConfig.get()) { case FEET -> feetPos; diff --git a/src/main/java/com/genyo/systems/modules/misc/AutoOminous.java b/src/main/java/com/genyo/systems/modules/misc/AutoOminous.java index ef07efb..3449ebb 100644 --- a/src/main/java/com/genyo/systems/modules/misc/AutoOminous.java +++ b/src/main/java/com/genyo/systems/modules/misc/AutoOminous.java @@ -29,7 +29,7 @@ public AutoOminous() { public void onTick(TickEvent.Pre event) { if (mc.player == null || mc.world == null || mc.interactionManager == null || mc.getServer() == null) return; - RaidManager raidManager = mc.getServer().getWorld(mc.player.getWorld().getRegistryKey()).getRaidManager(); + RaidManager raidManager = mc.getServer().getWorld(mc.world.getRegistryKey()).getRaidManager(); if (raidManager == null) return; Raid raid = raidManager.getRaidAt(mc.player.getBlockPos(), 50); @@ -61,7 +61,7 @@ private void drinkPotion() { return; } - selectedSlot = mc.player.getInventory().selectedSlot; + selectedSlot = mc.player.getInventory().getSelectedSlot(); int itemSlot = result.slot(); boolean wasHeld = result.isMainHand(); diff --git a/src/main/java/com/genyo/systems/modules/misc/AutoRename.java b/src/main/java/com/genyo/systems/modules/misc/AutoRename.java index 02526c7..56dd33c 100644 --- a/src/main/java/com/genyo/systems/modules/misc/AutoRename.java +++ b/src/main/java/com/genyo/systems/modules/misc/AutoRename.java @@ -120,7 +120,7 @@ public AutoRename() { private boolean hasValidItems(AnvilScreenHandler handler) { if (mc.player == null) return false; - for (int n = 0; n < mc.player.getInventory().main.size() + ANVIL_OFFSET; n++) { + for (int n = 0; n < 36 + ANVIL_OFFSET; n++) { if (n == 2) continue; ItemStack stack = handler.getSlot(n).getStack(); if ((blacklistMode.get() && !itemList.get().contains(stack.getItem())) @@ -189,7 +189,7 @@ private void onTick(TickEvent.Post event) { if (!hasValidItems(anvil)) finished(); else if (input1.isEmpty() && input2.isEmpty()) { - for (int n = ANVIL_OFFSET; n < mc.player.getInventory().main.size() + ANVIL_OFFSET; n++) { + for (int n = ANVIL_OFFSET; n < 36 + ANVIL_OFFSET; n++) { ItemStack stack = anvil.getSlot(n).getStack(); if (stack.contains(DataComponentTypes.CUSTOM_NAME) && !renameNamed.get()) continue; else if (stack.getName().getString().equals(itemName.get())) continue; diff --git a/src/main/java/com/genyo/systems/modules/misc/CombatBrainrot.java b/src/main/java/com/genyo/systems/modules/misc/CombatBrainrot.java index 0d811f2..7bd782a 100644 --- a/src/main/java/com/genyo/systems/modules/misc/CombatBrainrot.java +++ b/src/main/java/com/genyo/systems/modules/misc/CombatBrainrot.java @@ -60,7 +60,7 @@ public void onPacketSend(PacketEvent.Send event) { if (mc.getServer() == null) return; if (event.packet instanceof PlayerInteractEntityC2SPacket packet) { - Entity entity = packet.getEntity(mc.getServer().getWorld(mc.player.getWorld().getRegistryKey())); + Entity entity = packet.getEntity(mc.getServer().getWorld(mc.world.getRegistryKey())); if (entity == null) return; if (entity instanceof EndCrystalEntity) { diff --git a/src/main/java/com/genyo/systems/modules/misc/GenyoAutoEZ.java b/src/main/java/com/genyo/systems/modules/misc/GenyoAutoEZ.java index 0f95ee8..d73e659 100644 --- a/src/main/java/com/genyo/systems/modules/misc/GenyoAutoEZ.java +++ b/src/main/java/com/genyo/systems/modules/misc/GenyoAutoEZ.java @@ -98,7 +98,7 @@ private void onReceive(PacketEvent.Receive event) { if (packet.getStatus() == 35) { //----Pop----// Entity entity = packet.getEntity(mc.world); if (mc.player != null && mc.world != null && entity instanceof PlayerEntity playerEntity) { - if (entity != mc.player && mc.player.getPos().distanceTo(entity.getPos()) <= range.get()) { + if (entity != mc.player && mc.player.getEntityPos().distanceTo(entity.getEntityPos()) <= range.get()) { if (trackPlayers.get()) { if (taggedPlayers.containsKey(playerEntity)) { diff --git a/src/main/java/com/genyo/systems/modules/misc/GenyoDiscord.java b/src/main/java/com/genyo/systems/modules/misc/GenyoDiscord.java index e0ba4a6..6c59e9c 100644 --- a/src/main/java/com/genyo/systems/modules/misc/GenyoDiscord.java +++ b/src/main/java/com/genyo/systems/modules/misc/GenyoDiscord.java @@ -18,7 +18,7 @@ import meteordevelopment.meteorclient.utils.Utils; import meteordevelopment.meteorclient.utils.misc.MeteorStarscript; import meteordevelopment.orbit.EventHandler; -import meteordevelopment.starscript.Script; +import org.meteordev.starscript.Script; import net.minecraft.client.gui.screen.*; import net.minecraft.client.gui.screen.multiplayer.AddServerScreen; import net.minecraft.client.gui.screen.multiplayer.ConnectScreen; diff --git a/src/main/java/com/genyo/systems/modules/misc/GenyoGoodbye.java b/src/main/java/com/genyo/systems/modules/misc/GenyoGoodbye.java index c187e13..9baf4f3 100644 --- a/src/main/java/com/genyo/systems/modules/misc/GenyoGoodbye.java +++ b/src/main/java/com/genyo/systems/modules/misc/GenyoGoodbye.java @@ -72,7 +72,7 @@ private void onReceivePacket(PacketEvent.Receive event) { PlayerListEntry entry = mc.getNetworkHandler().getPlayerListEntry(pac.profileIds().getFirst()); if (entry == null) return; - String name = entry.getProfile().getName(); + String name = entry.getProfile().name(); if (!namesList.contains(name)) return; handleMessage(name); diff --git a/src/main/java/com/genyo/systems/modules/misc/GenyoWelcome.java b/src/main/java/com/genyo/systems/modules/misc/GenyoWelcome.java index d38a37f..3ec3757 100644 --- a/src/main/java/com/genyo/systems/modules/misc/GenyoWelcome.java +++ b/src/main/java/com/genyo/systems/modules/misc/GenyoWelcome.java @@ -63,7 +63,7 @@ private void onGameJoined(GameJoinedEvent event) { if (mc.player == null && mc.world == null) return; onlinePlayers.clear(); mc.getNetworkHandler().getPlayerList().iterator().forEachRemaining(p -> { - if (p.getProfile() != null) onlinePlayers.add(p.getProfile().getId()); + if (p.getProfile() != null) onlinePlayers.add(p.getProfile().id()); }); } @@ -96,9 +96,9 @@ private void onReceivePacket(PacketEvent.Receive event) { GameProfile profile = entry.profile(); if (profile == null) return; - String name = profile.getName(); + String name = profile.name(); if (!namesList.contains(name)) return; - UUID playerUuid = profile.getId(); + UUID playerUuid = profile.id(); if (!pac.getActions().contains(PlayerListS2CPacket.Action.ADD_PLAYER) && playerUuid != null && !onlinePlayers.contains(playerUuid)) return; diff --git a/src/main/java/com/genyo/systems/modules/movement/GenyoNoSlow.java b/src/main/java/com/genyo/systems/modules/movement/GenyoNoSlow.java index 7b6ed32..190e398 100644 --- a/src/main/java/com/genyo/systems/modules/movement/GenyoNoSlow.java +++ b/src/main/java/com/genyo/systems/modules/movement/GenyoNoSlow.java @@ -26,6 +26,7 @@ import net.minecraft.client.gui.screen.ChatScreen; import net.minecraft.client.gui.screen.DeathScreen; import net.minecraft.client.gui.screen.ingame.SignEditScreen; +import net.minecraft.client.input.Input; import net.minecraft.client.option.KeyBinding; import net.minecraft.client.util.InputUtil; import net.minecraft.component.DataComponentTypes; @@ -34,10 +35,9 @@ import net.minecraft.item.Items; import net.minecraft.network.packet.c2s.play.*; import net.minecraft.util.Hand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Box; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.MathHelper; +import com.genyo.mixin.accessor.AccessorInput; +import net.minecraft.util.math.Vec2f; +import net.minecraft.util.math.*; import org.lwjgl.glfw.GLFW; import java.util.ArrayList; @@ -179,8 +179,7 @@ public void onDeactivate() { if (airStrict.get() && sneaking) { - Managers.NETWORK.sendPacket(new ClientCommandC2SPacket(mc.player, - ClientCommandC2SPacket.Mode.RELEASE_SHIFT_KEY)); + mc.player.setSneaking(false); } sneaking = false; Managers.TICK.setClientTick(1.0f); @@ -191,9 +190,7 @@ public void onSetCurrentHand(SetCurrentHandEvent event) { if (airStrict.get() && !sneaking && checkSlowed()) { - sneaking = true; - Managers.NETWORK.sendPacket(new ClientCommandC2SPacket(mc.player, - ClientCommandC2SPacket.Mode.PRESS_SHIFT_KEY)); + mc.player.setSneaking(true); } } @@ -226,26 +223,25 @@ public void onTick(TickEvent.Pre event) { if (airStrict.get() && !mc.player.isUsingItem()) { sneaking = false; - Managers.NETWORK.sendPacket(new ClientCommandC2SPacket(mc.player, - ClientCommandC2SPacket.Mode.RELEASE_SHIFT_KEY)); + mc.player.setSneaking(false); } if (inventoryMove.get() && checkScreen()) { - final long handle = mc.getWindow().getHandle(); + KeyBinding[] keys = new KeyBinding[]{mc.options.jumpKey, mc.options.forwardKey, mc.options.backKey, mc.options.rightKey, mc.options.leftKey}; for (KeyBinding binding : keys) { - binding.setPressed(InputUtil.isKeyPressed(handle, ((AccessorKeyBinding) binding).getBoundKey().getCode())); + binding.setPressed(InputUtil.isKeyPressed(mc.getWindow(), ((AccessorKeyBinding) binding).getBoundKey().getCode())); } if (arrowMove.get()) { float yaw = mc.player.getYaw(); float pitch = mc.player.getPitch(); - if (InputUtil.isKeyPressed(handle, GLFW.GLFW_KEY_UP)) pitch -= 3.0f; - else if (InputUtil.isKeyPressed(handle, GLFW.GLFW_KEY_DOWN)) pitch += 3.0f; - else if (InputUtil.isKeyPressed(handle, GLFW.GLFW_KEY_LEFT)) yaw -= 3.0f; - else if (InputUtil.isKeyPressed(handle, GLFW.GLFW_KEY_RIGHT)) yaw += 3.0f; + if (InputUtil.isKeyPressed(mc.getWindow(), GLFW.GLFW_KEY_UP)) pitch -= 3.0f; + else if (InputUtil.isKeyPressed(mc.getWindow(), GLFW.GLFW_KEY_DOWN)) pitch += 3.0f; + else if (InputUtil.isKeyPressed(mc.getWindow(), GLFW.GLFW_KEY_LEFT)) yaw -= 3.0f; + else if (InputUtil.isKeyPressed(mc.getWindow(), GLFW.GLFW_KEY_RIGHT)) yaw += 3.0f; mc.player.setYaw(yaw); mc.player.setPitch(MathHelper.clamp(pitch, -90.0f, 90.0f)); @@ -304,14 +300,14 @@ public void onMovementSlowdown(MovementSlowdownEvent event) if (sneak.get() && mc.player.isSneaking() || crawl.get() && mc.player.isCrawling()) { float f = 1.0f / (float) mc.player.getAttributeValue(EntityAttributes.SNEAKING_SPEED); - event.input.movementForward *= f; - event.input.movementSideways *= f; + Vec2f vec = event.input.getMovementInput(); + ((AccessorInput) event.input).setMovementVector(new Vec2f(vec.x * f, vec.y * f)); } if (checkSlowed()) { - event.input.movementForward *= 5.0f; - event.input.movementSideways *= 5.0f; + Vec2f vec = event.input.getMovementInput(); + ((AccessorInput) event.input).setMovementVector(new Vec2f(vec.x * 5.0f, vec.y * 5.0f)); } } @@ -334,7 +330,6 @@ public void onBlockSlipperiness(BlockSlipperinessEvent event) event.slipperiness = 0.6f; } } - @EventHandler public void onPacketSend(PacketEvent.Send event) { @@ -342,7 +337,7 @@ public void onPacketSend(PacketEvent.Send event) else if (event.packet instanceof PlayerMoveC2SPacket packet && packet.changesPosition() && strict.get() && checkSlowed()) { - Managers.INVENTORY.setSlotForced(mc.player.getInventory().selectedSlot); + Managers.INVENTORY.setSlotForced(mc.player.getInventory().getSelectedSlot()); } else if (event.packet instanceof ClickSlotC2SPacket && strict.get()) { @@ -352,8 +347,7 @@ else if (event.packet instanceof ClickSlotC2SPacket && strict.get()) } if (sneaking || Managers.POSITION.isSneaking()) { - Managers.NETWORK.sendPacket(new ClientCommandC2SPacket(mc.player, - ClientCommandC2SPacket.Mode.RELEASE_SHIFT_KEY)); + mc.player.setSneaking(false); } if (Managers.POSITION.isSprinting()) { diff --git a/src/main/java/com/genyo/systems/modules/movement/GenyoPhase.java b/src/main/java/com/genyo/systems/modules/movement/GenyoPhase.java index 7d337fd..6711f0e 100644 --- a/src/main/java/com/genyo/systems/modules/movement/GenyoPhase.java +++ b/src/main/java/com/genyo/systems/modules/movement/GenyoPhase.java @@ -268,7 +268,7 @@ else if (yaw1 >= 292.5 && yaw1 < 337.5) if (swapAltConfig.get()) { mc.interactionManager.clickSlot(0, pearlSlot < 9 ? pearlSlot + 36 : pearlSlot, 0, SlotActionType.PICKUP, mc.player); - mc.interactionManager.clickSlot(0, mc.player.getInventory().selectedSlot + 36, 0, SlotActionType.PICKUP, mc.player); + mc.interactionManager.clickSlot(0, mc.player.getInventory().getSelectedSlot() + 36, 0, SlotActionType.PICKUP, mc.player); mc.interactionManager.clickSlot(0, pearlSlot < 9 ? pearlSlot + 36 : pearlSlot, 0, SlotActionType.PICKUP, mc.player); } else if (pearlSlot < 9) @@ -291,7 +291,7 @@ else if (pearlSlot < 9) if (swapAltConfig.get()) { mc.interactionManager.clickSlot(0, pearlSlot < 9 ? pearlSlot + 36 : pearlSlot, 0, SlotActionType.PICKUP, mc.player); - mc.interactionManager.clickSlot(0, mc.player.getInventory().selectedSlot + 36, 0, SlotActionType.PICKUP, mc.player); + mc.interactionManager.clickSlot(0, mc.player.getInventory().getSelectedSlot() + 36, 0, SlotActionType.PICKUP, mc.player); mc.interactionManager.clickSlot(0, pearlSlot < 9 ? pearlSlot + 36 : pearlSlot, 0, SlotActionType.PICKUP, mc.player); } else if (pearlSlot < 9) diff --git a/src/main/java/com/genyo/systems/modules/movement/GenyoVelocity.java b/src/main/java/com/genyo/systems/modules/movement/GenyoVelocity.java index 2543a72..34f613b 100644 --- a/src/main/java/com/genyo/systems/modules/movement/GenyoVelocity.java +++ b/src/main/java/com/genyo/systems/modules/movement/GenyoVelocity.java @@ -28,6 +28,7 @@ import net.minecraft.sound.SoundEvents; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; +import net.minecraft.util.math.Vec3d; import java.util.ArrayList; import java.util.List; @@ -198,7 +199,9 @@ public void onPacketReceive(PacketEvent.Receive event) { if (packet.getEntityId() != mc.player.getId()) return; - if (concealVelocity && packet.getVelocityX() == 0 && packet.getVelocityZ() == 0 && packet.getVelocityZ() == 0) { + Vec3d vel = ((AccessorEntityVelocityUpdateS2CPacket) packet).getVelocity(); + + if (concealVelocity && vel.x == 0 && vel.z == 0) { concealVelocity = false; return; } @@ -221,12 +224,11 @@ public void onPacketReceive(PacketEvent.Receive event) event.cancel(); return; } - ((AccessorEntityVelocityUpdateS2CPacket) packet).setVelocityX((int) (packet.getVelocityX() - * (horizontalConfig.get() / 100.0f))); - ((AccessorEntityVelocityUpdateS2CPacket) packet).setVelocityY((int) (packet.getVelocityY() - * (verticalConfig.get() / 100.0f))); - ((AccessorEntityVelocityUpdateS2CPacket) packet).setVelocityZ((int) (packet.getVelocityZ() - * (horizontalConfig.get() / 100.0f))); + ((AccessorEntityVelocityUpdateS2CPacket) packet).setVelocity(new Vec3d( + vel.x * (horizontalConfig.get() / 100.0f), + vel.y * (verticalConfig.get() / 100.0f), + vel.z * (horizontalConfig.get() / 100.0f) + )); } case GRIM -> { @@ -270,7 +272,6 @@ else if (event.packet instanceof ExplosionS2CPacket packet && explosionConfig.ge if (event.isCancelled()) { - // Dumb fix bc canceling explosion velocity removes explosion handling in 1.19 mc.executeSync(() -> ((AccessorClientWorld) mc.world).hookPlaySound(packet.center().getX(), packet.center().getY(), packet.center().getZ(), SoundEvents.ENTITY_GENERIC_EXPLODE.value(), SoundCategory.BLOCKS, 4.0f, (1.0f + (RANDOM.nextFloat() - RANDOM.nextFloat()) * 0.2f) * 0.7f, false, RANDOM.nextLong())); @@ -341,7 +342,7 @@ else if (packet1 instanceof EntityVelocityUpdateS2CPacket packet2 && knockbackCo if (!isPhased() && (!wallsTrappedConfig.get() || !isWallsTrapped())) { allowedBundle.add(packet1); - return; + continue; // was "return" — bug fix } if (wallsAirConfig.get() && !Managers.POSITION.isOnGround()) @@ -361,12 +362,12 @@ else if (packet1 instanceof EntityVelocityUpdateS2CPacket packet2 && knockbackCo } else { - ((AccessorEntityVelocityUpdateS2CPacket) packet2).setVelocityX((int) (packet2.getVelocityX() - * (horizontalConfig.get() / 100.0f))); - ((AccessorEntityVelocityUpdateS2CPacket) packet2).setVelocityY((int) (packet2.getVelocityY() - * (verticalConfig.get() / 100.0f))); - ((AccessorEntityVelocityUpdateS2CPacket) packet2).setVelocityZ((int) (packet2.getVelocityZ() - * (horizontalConfig.get() / 100.0f))); + Vec3d vel2 = ((AccessorEntityVelocityUpdateS2CPacket) packet2).getVelocity(); + ((AccessorEntityVelocityUpdateS2CPacket) packet2).setVelocity(new Vec3d( + vel2.x * (horizontalConfig.get() / 100.0f), + vel2.y * (verticalConfig.get() / 100.0f), + vel2.z * (horizontalConfig.get() / 100.0f) + )); } } case GRIM -> @@ -402,7 +403,6 @@ else if (event.packet instanceof EntityDamageS2CPacket packet { Managers.NETWORK.sendPacket(new PlayerMoveC2SPacket.OnGroundOnly(false, mc.player.horizontalCollision)); Managers.NETWORK.sendPacket(new PlayerMoveC2SPacket.OnGroundOnly(true, mc.player.horizontalCollision)); - // Managers.NETWORK.sendPacket(new PlayerMoveC2SPacket.PositionAndOnGround(mc.player.getX(), mc.player.getY(), mc.player.getZ(), mc.player.isOnGround())); } else if (event.packet instanceof EntityStatusS2CPacket packet @@ -415,7 +415,6 @@ else if (event.packet instanceof EntityStatusS2CPacket packet } } } - @EventHandler public void onPlayerTick(PlayerTickEvent event) { diff --git a/src/main/java/com/genyo/systems/modules/movement/TsunodaBlinker.java b/src/main/java/com/genyo/systems/modules/movement/TsunodaBlinker.java index 6804f07..5406964 100644 --- a/src/main/java/com/genyo/systems/modules/movement/TsunodaBlinker.java +++ b/src/main/java/com/genyo/systems/modules/movement/TsunodaBlinker.java @@ -66,7 +66,7 @@ public void onActivate() { if (mc.player != null && render.get()) { - serverModel = new FakePlayerEntity(mc.player, mc.player.getGameProfile().getName(), 20, true); + serverModel = new FakePlayerEntity(mc.player, mc.player.getGameProfile().name(), 20, true); serverModel.spawn(); serverModel.setUuid(mc.player.getUuid()); } diff --git a/src/main/java/com/genyo/systems/modules/visual/AngelSexHulkenberg.java b/src/main/java/com/genyo/systems/modules/visual/AngelSexHulkenberg.java deleted file mode 100644 index 1e7fc5e..0000000 --- a/src/main/java/com/genyo/systems/modules/visual/AngelSexHulkenberg.java +++ /dev/null @@ -1,259 +0,0 @@ -package com.genyo.systems.modules.visual; - -import com.genyo.Genyo; -import com.genyo.events.TotemPopEvent; -import com.genyo.mixin.entity.IEntity; -import com.genyo.systems.modules.GenyoModule; -import com.genyo.render.Render2DEngine; -import com.genyo.render.Render3DEngine; -import com.genyo.systems.enemies.Enemies; -import com.genyo.utils.math.MathUtil; -import com.mojang.authlib.GameProfile; -import com.mojang.blaze3d.platform.GlStateManager; -import com.mojang.blaze3d.systems.RenderSystem; -import meteordevelopment.meteorclient.events.render.Render3DEvent; -import meteordevelopment.meteorclient.events.world.TickEvent; -import meteordevelopment.meteorclient.settings.*; -import meteordevelopment.meteorclient.utils.render.color.Color; -import meteordevelopment.meteorclient.utils.render.color.SettingColor; -import meteordevelopment.orbit.EventHandler; -import net.minecraft.client.gl.ShaderProgramKeys; -import net.minecraft.client.network.AbstractClientPlayerEntity; -import net.minecraft.client.render.*; -import net.minecraft.client.render.entity.PlayerEntityRenderer; -import net.minecraft.client.render.entity.state.PlayerEntityRenderState; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.entity.Entity; -import net.minecraft.entity.LivingEntity; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.util.Identifier; -import net.minecraft.util.math.RotationAxis; -import org.jetbrains.annotations.NotNull; - -import java.util.concurrent.CopyOnWriteArrayList; - -public final class AngelSexHulkenberg extends GenyoModule { - - public AngelSexHulkenberg() { - super(Genyo.VISUAL, "angel-sex-hulkenberg", "jön a verstappen, nekiütközött a verstappen, kiesik a verstappen"); - } - - private final SettingGroup sgGeneral = settings.getDefaultGroup(); - private final SettingGroup sgRender = settings.createGroup("Render"); - private final SettingGroup sgSpeed = settings.createGroup("Speed"); - - private final Setting focusEnemy = sgGeneral.add(new BoolSetting.Builder() - .name("Focus Enemies") - .description("enemyknél csinálja csak") - .defaultValue(false) - .build() - ); - - // Render - - private final Setting mode = sgRender.add(new EnumSetting.Builder() - .name("Mode") - .description("Ki a faszom az a Hulkenberg??????????") - .defaultValue(Mode.Textured) - .build() - ); - - private final Setting rotate180 = sgRender.add(new BoolSetting.Builder() - .name("Rotate Y 180") - .description("fejjel lefelé mert igen") - .defaultValue(false) - .build() - ); - - private final Setting secondLayer = sgRender.add(new BoolSetting.Builder() - .name("Second Layer") - .description("kiyártam a kettedik osztájt") - .defaultValue(true) - .build() - ); - - private final Setting color = sgRender.add(new ColorSetting.Builder() - .name("Color") - .description("színcápa színcápa mondj egy színt") - .defaultValue(new Color(53, 46, 46, 255)) - .build() - ); - - // Speed - - private final Setting ySpeed = sgSpeed.add(new IntSetting.Builder() - .name("Y Speed") - .description("y show speed") - .defaultValue(2) - .min(0) - .max(6) - .build() - ); - - private final Setting aSpeed = sgSpeed.add(new IntSetting.Builder() - .name("Alpha Speed") - .description("alpha-i show speed") - .defaultValue(5) - .min(1) - .max(100) - .build() - ); - - private final Setting rotSpeed = sgSpeed.add(new DoubleSetting.Builder() - .name("Rotation Speed") - .description("rotációs kapa") - .defaultValue(1d) - .min(0d) - .max(6d) - .build() - ); - - private final CopyOnWriteArrayList popList = new CopyOnWriteArrayList<>(); - - private enum Mode { - Simple, Textured - } - - @EventHandler - public void onTick(TickEvent.Pre event) { - popList.forEach(person -> person.update(popList)); - } - - @EventHandler - public void onRender(Render3DEvent event) { - MatrixStack stack = event.matrices; - - RenderSystem.enableBlend(); - RenderSystem.disableDepthTest(); - - if (mode.get().equals(Mode.Simple)) RenderSystem.defaultBlendFunc(); - else RenderSystem.blendFunc(GlStateManager.SrcFactor.SRC_ALPHA, GlStateManager.DstFactor.ONE); - - popList.forEach(person -> renderEntity(stack, person.player, person.getTexture(), person.getAlpha())); - - RenderSystem.enableDepthTest(); - RenderSystem.disableBlend(); - - popList.forEach(person -> renderEntity(stack, person.player, person.getTexture(), person.getAlpha())); - } - - @EventHandler - @SuppressWarnings("unused") - private void onTotemPop(@NotNull TotemPopEvent e) { - if (e.entity.equals(mc.player) || mc.world == null) return; - //if (mc.world == null) return; //-------- for testing - if (mc.getServer() == null) return; - - if (focusEnemy.get()) if (!(Enemies.get().isEnemy(e.entity))) return; - - AbstractClientPlayerEntity entity = new AbstractClientPlayerEntity(mc.world, new GameProfile(e.entity.getUuid(), e.entity.getName().getString())) { - @Override public boolean isSpectator() {return false;} - @Override public boolean isCreative() {return false;} - }; - - entity.copyPositionAndRotation(e.entity); - entity.bodyYaw = e.entity.bodyYaw; - entity.headYaw = e.entity.headYaw; - entity.handSwingProgress = e.entity.handSwingProgress; - entity.handSwingTicks = e.entity.handSwingTicks; - entity.setSneaking(e.entity.isSneaking()); - entity.limbAnimator.setSpeed(e.entity.limbAnimator.getSpeed()); - - Identifier skin = ((AbstractClientPlayerEntity) e.entity).getSkinTextures().texture(); - - popList.add(new Person(entity, skin, mc.getServer().getWorld(entity.getWorld().getRegistryKey()))); - } - - private void renderEntity(@NotNull MatrixStack matrices, @NotNull LivingEntity entity, Identifier texture, int alpha) { - PlayerEntityRenderer entityRenderer = (PlayerEntityRenderer) mc.getEntityRenderDispatcher().getRenderer((AbstractClientPlayerEntity) entity); - PlayerEntityRenderState renderState = entityRenderer.createRenderState(); - - renderState.leftPantsLegVisible = secondLayer.get(); - renderState.rightPantsLegVisible = secondLayer.get(); - renderState.leftSleeveVisible = secondLayer.get(); - renderState.rightSleeveVisible = secondLayer.get(); - renderState.jacketVisible = secondLayer.get(); - renderState.hatVisible = secondLayer.get(); - - double x = entity.getX() - mc.getEntityRenderDispatcher().camera.getPos().getX(); - double y = entity.getY() - mc.getEntityRenderDispatcher().camera.getPos().getY(); - double z = entity.getZ() - mc.getEntityRenderDispatcher().camera.getPos().getZ(); - ((IEntity) entity).setPos(entity.getPos().add(0, (double) ySpeed.get() / 50., 0)); - - matrices.push(); - matrices.translate((float) x, (float) y, (float) z); - - float yRotYaw = ((alpha / 255f) * 360f * rotSpeed.get().floatValue()); - yRotYaw = yRotYaw == 0 ? 0 : Render2DEngine.interpolateFloat(yRotYaw, yRotYaw - (((aSpeed.get() / 255f) * 360f * rotSpeed.get().floatValue())), Render3DEngine.getTickDelta()); - - matrices.multiply(RotationAxis.POSITIVE_Y.rotation(MathUtil.rad(180 - entity.bodyYaw + yRotYaw))); - prepareScale(matrices, rotate180.get()); - - float limbSpeed = Math.min(entity.limbAnimator.getSpeed(), 1f); - - entityRenderer.updateRenderState((AbstractClientPlayerEntity) entity, renderState, limbSpeed); - renderState.limbFrequency = limbSpeed; - renderState.age = entity.age; - renderState.yawDegrees = entity.headYaw - entity.bodyYaw; - renderState.pitch = entity.getPitch(); - - BufferBuilder buffer; - if (mode.get().equals(Mode.Textured)) { - RenderSystem.setShaderTexture(0, texture); - RenderSystem.setShader(ShaderProgramKeys.POSITION_TEX); - buffer = Tessellator.getInstance().begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE); - } else { - RenderSystem.setShader(ShaderProgramKeys.POSITION); - buffer = Tessellator.getInstance().begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION); - } - - RenderSystem.setShaderColor(color.get().r, color.get().g, color.get().b, alpha / 255f); - - entityRenderer.render(renderState, matrices, mc.getBufferBuilders().getEntityVertexConsumers(), 1); - - Render2DEngine.endBuilding(buffer); - RenderSystem.setShaderColor(1f, 1f, 1f, 1f); - matrices.pop(); - } - - private static void prepareScale(@NotNull MatrixStack matrixStack, boolean rotate) { - if (rotate) matrixStack.scale(-1.0F, -1.0F, 1.0F); - else matrixStack.scale(-1.0F, 1.0F, 1.0F); - - matrixStack.scale(1.6f, 1.8f, 1.6f); - matrixStack.translate(0.0F, -1.501F, 0.0F); - } - - private class Person { - private final AbstractClientPlayerEntity player; - private final Identifier texture; - private int alpha; - private final ServerWorld world; - - public Person(AbstractClientPlayerEntity player, Identifier texture, ServerWorld world) { - this.player = player; - this.world = world; - this.texture = texture; - alpha = color.get().a; - } - - public void update(CopyOnWriteArrayList arrayList) { - if (alpha <= 0) { - arrayList.remove(this); - player.kill(world); - player.remove(Entity.RemovalReason.KILLED); - player.onRemoved(); - return; - } - alpha -= aSpeed.get(); - } - - public int getAlpha() { - return MathUtil.clamp(alpha, 0, 255); - } - - public Identifier getTexture() { - return texture; - } - } -} diff --git a/src/main/java/com/genyo/systems/modules/visual/GenyoCapes.java b/src/main/java/com/genyo/systems/modules/visual/GenyoCapes.java index 99cea24..1f6029a 100644 --- a/src/main/java/com/genyo/systems/modules/visual/GenyoCapes.java +++ b/src/main/java/com/genyo/systems/modules/visual/GenyoCapes.java @@ -2,19 +2,43 @@ import com.genyo.Genyo; import com.genyo.systems.modules.GenyoModule; +import meteordevelopment.meteorclient.settings.BoolSetting; +import meteordevelopment.meteorclient.settings.Setting; +import meteordevelopment.meteorclient.settings.SettingGroup; import net.minecraft.util.Identifier; +import java.util.Set; + public class GenyoCapes extends GenyoModule { + private static final Set DEV_NAMES = Set.of( + "Awakeyv", + "wuritz", + "Barnika18" + ); + + private final SettingGroup sgGeneral = settings.getDefaultGroup(); + + public final Setting everyoneConfig = sgGeneral.add(new BoolSetting.Builder() + .name("Everyone") + .description("Apply Genyo cape to all players.") + .defaultValue(false) + .build() + ); + private final Identifier capeTexture; + private final Identifier devCapeTexture; public GenyoCapes() { super(Genyo.VISUAL, "genyo-capes", "The thing"); this.capeTexture = Identifier.of(Genyo.MOD_ID, "textures/cape.png"); + this.devCapeTexture = Identifier.of(Genyo.MOD_ID, "textures/cape_dev.png"); } - public Identifier getCapeTexture() { - return capeTexture; - } + public Identifier getCapeTexture() {return capeTexture;} + + public Identifier getDevCapeTexture() {return devCapeTexture;} + + public boolean isDev(String username) {return DEV_NAMES.contains(username);} } diff --git a/src/main/java/com/genyo/systems/modules/visual/GenyoNametags.java b/src/main/java/com/genyo/systems/modules/visual/GenyoNametags.java index 87ecee4..d47728d 100644 --- a/src/main/java/com/genyo/systems/modules/visual/GenyoNametags.java +++ b/src/main/java/com/genyo/systems/modules/visual/GenyoNametags.java @@ -17,7 +17,7 @@ import meteordevelopment.meteorclient.systems.friends.Friends; import meteordevelopment.meteorclient.systems.modules.Categories; import meteordevelopment.meteorclient.systems.modules.Modules; -import meteordevelopment.meteorclient.systems.modules.misc.NameProtect; +import meteordevelopment.meteorclient.systems.modules.player.NameProtect; import meteordevelopment.meteorclient.systems.modules.render.Freecam; import meteordevelopment.meteorclient.systems.modules.render.Nametags; import meteordevelopment.meteorclient.utils.Utils; @@ -339,7 +339,7 @@ private void onTick(TickEvent.Post event) { boolean freecamNotActive = !Modules.get().isActive(Freecam.class); boolean notThirdPerson = mc.options.getPerspective().isFirstPerson(); - Vec3d cameraPos = mc.gameRenderer.getCamera().getPos(); + Vec3d cameraPos = mc.gameRenderer.getCamera().getCameraPos(); for (Entity entity : mc.world.getEntities()) { EntityType type = entity.getType(); @@ -479,7 +479,7 @@ private void renderNametagPlayer(Render2DEvent event, PlayerEntity player, boole double width = nameWidth; - boolean renderPlayerDistance = player != mc.cameraEntity || Modules.get().isActive(Freecam.class); + boolean renderPlayerDistance = player != mc.getCameraEntity() || Modules.get().isActive(Freecam.class); if (displayHealth.get()) width += healthWidth; if (displayGameMode.get()) width += gmWidth; @@ -735,10 +735,10 @@ private void renderTntNametag(String fuseText, boolean shadow) { private ItemStack getItem(PlayerEntity entity, int index) { return switch (index) { case 0 -> entity.getMainHandStack(); - case 1 -> entity.getInventory().armor.get(3); - case 2 -> entity.getInventory().armor.get(2); - case 3 -> entity.getInventory().armor.get(1); - case 4 -> entity.getInventory().armor.get(0); + case 1 -> entity.getInventory().getStack(39); // HEAD + case 2 -> entity.getInventory().getStack(38); // CHEST + case 3 -> entity.getInventory().getStack(37); // LEGS + case 4 -> entity.getInventory().getStack(36); // FEET case 5 -> entity.getOffHandStack(); default -> ItemStack.EMPTY; }; @@ -747,7 +747,7 @@ private ItemStack getItem(PlayerEntity entity, int index) { private void drawBg(double x, double y, double width, double height) { Renderer2D.COLOR.begin(); Renderer2D.COLOR.quad(x - 1, y - 1, width + 2, height + 2, background.get()); - Renderer2D.COLOR.render(null); + Renderer2D.COLOR.render(); } public enum Position { diff --git a/src/main/java/com/genyo/systems/modules/visual/Parkinsons.java b/src/main/java/com/genyo/systems/modules/visual/Parkinsons.java index 73edfe3..26139ab 100644 --- a/src/main/java/com/genyo/systems/modules/visual/Parkinsons.java +++ b/src/main/java/com/genyo/systems/modules/visual/Parkinsons.java @@ -23,7 +23,7 @@ public Parkinsons() { public void onActivate() { shouldFreeze = true; - storedPos = mc.player.getPos(); + storedPos = mc.player.getEntityPos(); storedYaw = mc.player.getYaw(); storedPitch = mc.player.getPitch(); @@ -41,7 +41,7 @@ public void onActivate() { @EventHandler public void onTick(TickEvent.Pre event) { - Entity camera = mc.cameraEntity; + Entity camera = mc.getCameraEntity(); Vec3d forward = Vec3d.fromPolar(0, camera.getYaw()).normalize(); Vec3d right = new Vec3d(-forward.z, 0, forward.x).normalize(); @@ -56,7 +56,7 @@ public void onTick(TickEvent.Pre event) { if (velocity.lengthSquared() > 0) { velocity = velocity.normalize().multiply(1); - Vec3d pos = camera.getPos(); + Vec3d pos = camera.getEntityPos(); camera.setPos(pos.x + velocity.x, pos.y + velocity.y, pos.z + velocity.z); } diff --git a/src/main/java/com/genyo/systems/modules/visual/PenisESP.java b/src/main/java/com/genyo/systems/modules/visual/PenisESP.java index eeef202..db6e22a 100644 --- a/src/main/java/com/genyo/systems/modules/visual/PenisESP.java +++ b/src/main/java/com/genyo/systems/modules/visual/PenisESP.java @@ -111,9 +111,9 @@ public void onRender3D(Render3DEvent event) { } public Vec3d getBase(Entity entity, float tickDelta) { - double x = entity.prevX + ((entity.getX() - entity.prevX) * tickDelta); - double y = entity.prevY + ((entity.getY() - entity.prevY) * tickDelta); - double z = entity.prevZ + ((entity.getZ() - entity.prevZ) * tickDelta); + double x = entity.lastX + ((entity.getX() - entity.lastX) * tickDelta); + double y = entity.lastY + ((entity.getY() - entity.lastY) * tickDelta); + double z = entity.lastZ + ((entity.getZ() - entity.lastZ) * tickDelta); return new Vec3d(x, y, z); } diff --git a/src/main/java/com/genyo/systems/modules/world/AutoMineV2.java b/src/main/java/com/genyo/systems/modules/world/AutoMineV2.java deleted file mode 100644 index ec8b196..0000000 --- a/src/main/java/com/genyo/systems/modules/world/AutoMineV2.java +++ /dev/null @@ -1,334 +0,0 @@ -package com.genyo.systems.modules.world; - -import com.genyo.Genyo; -import com.genyo.managers.player.InteractionManager; -import com.genyo.systems.modules.PlacerModule; -import com.genyo.utils.math.timer.CacheTimer; -import com.genyo.utils.math.timer.Timer; -import com.genyo.utils.player.Rotation; -import com.genyo.utils.player.RotationUtil; -import meteordevelopment.meteorclient.events.world.TickEvent; -import meteordevelopment.meteorclient.settings.*; -import meteordevelopment.meteorclient.utils.entity.SortPriority; -import meteordevelopment.meteorclient.utils.entity.TargetUtils; -import meteordevelopment.meteorclient.utils.render.color.SettingColor; -import meteordevelopment.meteorclient.utils.world.BlockUtils; -import meteordevelopment.orbit.EventHandler; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.util.math.BlockPos; - -import java.util.*; - -public class AutoMineV2 extends PlacerModule { - - public AutoMineV2() { - super(Genyo.WORLD, "auto-mine-v2", "Hopefully better automine"); - } - - /*private final SettingGroup sgGeneral = settings.getDefaultGroup(); - private final SettingGroup sgRender = settings.createGroup("Render"); - - private final Setting delay = sgGeneral.add(new IntSetting.Builder() - .name("delay") - .description("MS delay") - .min(0).defaultValue(0).max(1000) - .sliderRange(0, 1000) - .onChanged((asd) -> {}) - .build() - ); - - private final Setting minDmg = sgGeneral.add(new IntSetting.Builder() - .name("minimum-damage") - .description("-") - .min(0).defaultValue(7).max(36) - .sliderRange(0, 36) - .build() - ); - - private final Setting targetRange = sgGeneral.add(new DoubleSetting.Builder() - .name("target-range") - .description("") - .min(1d).defaultValue(5d).max(10d) - .sliderRange(1d, 10d) - .build() - ); - - private final Setting range = sgGeneral.add(new IntSetting.Builder() - .name("range") - .description("-") - .min(3).defaultValue(6).max(6) - .sliderRange(3, 6) - .build() - ); - - private final Setting blocksPerTick = sgGeneral.add(new IntSetting.Builder() - .name("blocks-per-tick") - .description("-") - .min(1).defaultValue(10).max(10) - .sliderRange(1, 10) - .build() - ); - - private final Setting rotate = sgGeneral.add(new BoolSetting.Builder() - .name("rotate") - .description("-") - .defaultValue(false) - .build() - ); - - // render - - private final Setting render = sgRender.add(new BoolSetting.Builder() - .name("render") - .description("render") - .defaultValue(true) - .build() - ); - - private final Setting fill = sgRender.add(new ColorSetting.Builder() - .name("fill-color") - .description("Fill Color") - .defaultValue(new SettingColor(255, 0, 0, 25)) - .visible(render::get) - .build() - ); - - private final Setting line = sgRender.add(new ColorSetting.Builder() - .name("line-color") - .description("Line Color") - .defaultValue(new SettingColor(255, 0, 0, 255)) - .visible(render::get) - .build() - ); - - private final Setting fadeTime = sgRender.add(new IntSetting.Builder() - .name("fade-time") - .description("Fade Time in milliseconds") - .min(0).defaultValue(200).max(1000) - .sliderRange(0, 1000) - .build() - ); - - - private Timer timer = new CacheTimer(); - public Map renderPositions = new HashMap<>(); - - private Entity target; - private List toPlace = new ArrayList<>(); - - public Map placed = new HashMap<>(); - - double startY = 0; - - @EventHandler - public void onTick(TickEvent.Pre event) { - if (mc.player == null || mc.world == null || mc.interactionManager == null) return; - - if (getSlot() == -1) { - return; - } - - for (Map.Entry entry : placed.entrySet()) { - BlockPos pos = entry.getKey(); - long time = entry.getValue(); - - if (System.currentTimeMillis() - time > 200) { - placed.remove(pos); - } - } - - toPlace.clear(); - int blocksInTick = 0; - - target = TargetUtils.getPlayerTarget(targetRange.get(), SortPriority.LowestDistance); - - if (target != null) { - - BlockPos targetPos = getBestCrystalPlacePos((PlayerEntity) target); - - if (mc.world.getBlockState(targetPos).isReplaceable()) { - placeLabel: - if (timer.passed(delay.get())) { - - if (blocksInTick >= blocksPerTick.get()) break placeLabel; - - if (toPlace.contains(targetPos)) break placeLabel; - - if (placed.containsKey(targetPos)) { - - if (CrystalManager.INSTANCE.isRecentlyBlocked(targetPos)) - placed.remove(targetPos); - else if (System.currentTimeMillis() - placed.get(targetPos) < 60) - break placeLabel; - } - - if (blocksInTick == 0 && rotate.get()) - Rotation.get().setRotationSilentSync(); - - toPlace.add(targetPos); - blocksInTick++; - timer.reset(); - } - } - } - - doPlace(); - } - - public BlockPos getBestCrystalPlacePos(PlayerEntity player) { - BlockPos bestPos = null; - double bestDMG = 0.5D; - - final List sphere = BlockUtils.sphere(range.getValue().doubleValue() + 1.0f, mc.player.getBlockPos(), true, false); - Set keySet = new HashSet<>(Set.copyOf(placed.keySet())); - keySet.addAll(toPlace); - - for (BlockPos pos : sphere) { - - BlockPos basePos = pos.down(); - - //check if valid place spot too cuz if theres an obby already there not tryna spam obby like a retard - if (!CrystalUtil.canPlaceCrystal(basePos, CatAura.INSTANCE.onePointTwelve.getValue()) && !BlockUtils.isReplaceable(basePos)) - continue; - - if (basePos.getY() >= player.getBlockPos().getY()) - continue; - - if(!CrystalUtil.canPlaceCrystalAir(basePos)) continue; - - if(BlockUtils.isBlockedOff(basePos) || BlockUtils.isBlockedOff(pos)) continue; - - if(BlockUtils.isReplaceable(basePos)) { - if (!BlockUtils.canPlaceBlock(basePos, strictDirection.getValue(), keySet)) continue; - } - - double distance = mc.player.getEyePos().squaredDistanceTo(new Vec3d(basePos.getX() + 0.5, basePos.getY() + 0.5, basePos.getZ() + 0.5)); - if (distance > MathUtil.square(range.getValue().doubleValue())) - continue; - - double dmg = CrystalUtil.calculateDamage(player, pos.toCenterPos(), CatAura.INSTANCE.terrain.getValue(), CatAura.INSTANCE.getMiningIgnore()); - if (dmg < minDmg.getValue().doubleValue()) { - continue; - } - - if (dmg > bestDMG) { - bestPos = basePos; - bestDMG = dmg; - } - - - } - return bestPos; - } - - @SubscribeEvent - public void onPlayerUpdate(TickEvent.PlayerTickEvent.Post event) { - - if (NullUtils.nullCheck()) return; - - if (!AntiCheat.INSTANCE.protocol.getValue()) - doPlace(); - } - - - @SubscribeEvent - public void onCollision(CollisionBoxEvent event) { - if (NullUtils.nullCheck()) return; - - - if (placed.containsKey(event.getPos())) { - - event.setCancelled(true); - event.setVoxelShape(VoxelShapes.cuboid(new Box(0, 0, 0, 1.0, 1.0, 1.0))); - } - } - - - @Override - public void onEnable() { - super.onEnable(); - if (NullUtils.nullCheck()) return; - - startY = mc.player.getY(); - - placed.clear(); - } - - - @Override - public void onDisable() { - super.onDisable(); - if (NullUtils.nullCheck()) return; - - if (PriorityManager.INSTANCE.isUsageLocked() && PriorityManager.INSTANCE.usageLockCause.equals("AutoPlacer")) - PriorityManager.INSTANCE.unlockUsageLock(); - - placed.clear(); - - } - - boolean rotateFlag = false; - - - public void doPlace() { - if (NullUtils.nullCheck()) return; - - int blockSlot = getSlot(); - - int oldSlot = mc.player.getInventory().selectedSlot; - boolean switched = false; - for (BlockPos pos : toPlace) { - - if (blockSlot != mc.player.getInventory().selectedSlot) { - InventoryUtils.switchToSlot(blockSlot); - switched = true; - } - - placed.put(pos, System.currentTimeMillis()); - - - if (rotate.getValue() && AntiCheat.INSTANCE.protocol.getValue()) - RotationUtils.doSilentRotate(pos, strictDirection.getValue()); - - BlockUtils.placeBlock(pos, BlockUtils.getPlaceableSide(pos, strictDirection.getValue(), placed.keySet()), !mc.player.getMainHandStack().getItem().equals(Items.ENDER_CHEST)); - - - if (render.getValue()) - renderPositions.put(pos, System.currentTimeMillis()); - - } - if (switched) { - InventoryUtils.switchToSlot(oldSlot); - } - if ((!toPlace.isEmpty() && AntiCheat.INSTANCE.protocol.getValue() && rotate.getValue()) || rotateFlag) { - RotationUtils.silentSync(); - } - toPlace.clear(); - - } - - - int getSlot() { - return InventoryUtils.getHotbarItemSlot(Items.OBSIDIAN); - } - - - @SubscribeEvent - public void onPacket(PacketEvent.Receive event) { - if (NullUtils.nullCheck()) return; - - if (event.getPacket() instanceof BlockUpdateS2CPacket packet) { - final BlockPos targetPos = packet.getPos(); - if (placed.containsKey(targetPos)) { - placed.remove(targetPos); - } - } - } - - @Override - public String getDescription() { - return "AutoPlacer: places obby in places to place crystals"; - }*/ - -} diff --git a/src/main/java/com/genyo/systems/modules/world/GenyoAutoMine.java b/src/main/java/com/genyo/systems/modules/world/GenyoAutoMine.java index 285cad8..7a5e8a8 100644 --- a/src/main/java/com/genyo/systems/modules/world/GenyoAutoMine.java +++ b/src/main/java/com/genyo/systems/modules/world/GenyoAutoMine.java @@ -1,4 +1,5 @@ -package com.genyo.systems.modules.world; + + package com.genyo.systems.modules.world; import com.genyo.Genyo; import com.genyo.events.AttackBlockEvent; @@ -21,7 +22,7 @@ import meteordevelopment.meteorclient.renderer.Renderer3D; import meteordevelopment.meteorclient.renderer.ShapeMode; import meteordevelopment.meteorclient.settings.*; -import meteordevelopment.meteorclient.systems.modules.Modules; + import meteordevelopment.meteorclient.systems.modules.Modules; import meteordevelopment.meteorclient.utils.render.color.Color; import meteordevelopment.meteorclient.utils.render.color.SettingColor; import meteordevelopment.orbit.EventHandler; @@ -38,7 +39,7 @@ import net.minecraft.network.packet.s2c.play.BlockUpdateS2CPacket; import net.minecraft.util.Hand; import net.minecraft.util.math.*; -import net.minecraft.util.shape.VoxelShape; + import net.minecraft.util.shape.VoxelShape; import net.minecraft.util.shape.VoxelShapes; import org.jetbrains.annotations.NotNull; diff --git a/src/main/java/com/genyo/systems/modules/world/GenyoAutoMineV2.java b/src/main/java/com/genyo/systems/modules/world/GenyoAutoMineV2.java new file mode 100644 index 0000000..5cbe1c2 --- /dev/null +++ b/src/main/java/com/genyo/systems/modules/world/GenyoAutoMineV2.java @@ -0,0 +1,1274 @@ +package com.genyo.systems.modules.world; + +import com.genyo.Genyo; +import com.genyo.events.AttackBlockEvent; +import com.genyo.managers.Managers; +import com.genyo.systems.modules.GenyoModule; +import com.genyo.systems.modules.combat.GenyoAutoCrystal; +import com.genyo.render.animation.Animation; +import com.genyo.systems.settings.FloatSetting; +import com.genyo.utils.GEntityUtils; +import com.genyo.utils.math.GPositionUtils; +import com.genyo.utils.math.MathUtil; +import com.genyo.utils.math.timer.CacheTimer; +import com.genyo.utils.math.timer.Timer; +import com.genyo.utils.player.RotationUtil; +import com.genyo.utils.render.ColorUtil; +import com.genyo.utils.world.BlastResistantBlocks; +import meteordevelopment.meteorclient.events.packets.PacketEvent; +import meteordevelopment.meteorclient.events.render.Render3DEvent; +import meteordevelopment.meteorclient.events.world.TickEvent; +import meteordevelopment.meteorclient.renderer.Renderer3D; +import meteordevelopment.meteorclient.renderer.ShapeMode; +import meteordevelopment.meteorclient.settings.*; +import meteordevelopment.meteorclient.systems.modules.Modules; +import meteordevelopment.meteorclient.utils.render.color.Color; +import meteordevelopment.meteorclient.utils.render.color.SettingColor; +import meteordevelopment.orbit.EventHandler; +import net.minecraft.block.Block; +import net.minecraft.block.Blocks; +import net.minecraft.block.BlockState; +import net.minecraft.block.ShapeContext; +import net.minecraft.client.MinecraftClient; +import net.minecraft.entity.EntityPose; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.network.packet.c2s.play.HandSwingC2SPacket; +import net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket; +import net.minecraft.network.packet.c2s.play.UpdateSelectedSlotC2SPacket; +import net.minecraft.network.packet.s2c.play.BlockUpdateS2CPacket; +import net.minecraft.util.Hand; +import net.minecraft.util.math.*; +import net.minecraft.util.shape.VoxelShape; +import net.minecraft.util.shape.VoxelShapes; +import org.jetbrains.annotations.NotNull; + +import java.util.*; + +public class GenyoAutoMineV2 extends GenyoModule { + + public GenyoAutoMineV2() { + super(Genyo.WORLD, "Genyo AutoMineV2", "fasz"); + } + + private final SettingGroup sgGeneral = settings.getDefaultGroup(); + private final SettingGroup sgSelection = settings.createGroup("Selection"); + private final SettingGroup sgRender = settings.createGroup("Render"); + + private final Setting multitask = sgGeneral.add(new BoolSetting.Builder() + .name("Allow Multitask") + .description("Allows actions while using items") + .defaultValue(true) + .build() + ); + + private final Setting auto = sgSelection.add(new BoolSetting.Builder() + .name("Auto") + .description("Automatically mines nearby players feet") + .defaultValue(false) + .build() + ); + + private final Setting selection = sgSelection.add(new EnumSetting.Builder() + .name("Selection") + .description("The selection of blocks mine") + .visible(auto::get) + .defaultValue(Selection.ALL) + .build() + ); + + private final Setting avoidSelf = sgSelection.add(new BoolSetting.Builder() + .name("Avoid Self") + .description("Avoids mining blocks in your surround") + .defaultValue(false) + .visible(auto::get) + .build() + ); + + private final Setting> whitelist = sgSelection.add(new BlockListSetting.Builder() + .name("Block Whitelist") + .description("Valid block whitelist") + .defaultValue(Blocks.OBSIDIAN, Blocks.ENDER_CHEST) + .build() + ); + + private final Setting> blacklist = sgSelection.add(new BlockListSetting.Builder() + .name("Block Blacklist") + .description("Valid block blacklist") + .defaultValue(Blocks.SHULKER_BOX) + .build() + ); + + private final Setting enemyRange = sgSelection.add(new FloatSetting.Builder() + .name("Enemy Range") + .description("Only mines on visible faces") + .defaultValue(5.0f) + .min(1.0f) + .max(10.0f) + .visible(auto::get) + .build() + ); + + private final Setting strictDirection = sgSelection.add(new BoolSetting.Builder() + .name("Strict Direction") + .description("Only mines on visible faces") + .visible(auto::get) + .defaultValue(false) + .build() + ); + + private final Setting antiCrawl = sgSelection.add(new BoolSetting.Builder() + .name("Anti Crawl") + .description("Attempts to stop player from crawling") + .defaultValue(false) + .build() + ); + + private final Setting head = sgSelection.add(new BoolSetting.Builder() + .name("Target Body") + .description("Attempts to mine players face blocks") + .defaultValue(false) + .visible(auto::get) + .build() + ); + + private final Setting aboveHead = sgSelection.add(new BoolSetting.Builder() + .name("Target Head") + .description("Attempts to mine above players head") + .defaultValue(false) + .visible(auto::get) + .build() + ); + + private final Setting doubleBreak = sgGeneral.add(new BoolSetting.Builder() + .name("Double Break") + .description("Allows you to mine two blocks at once") + .defaultValue(true) + .build() + ); + + private final Setting mineTicks = sgGeneral.add(new IntSetting.Builder() + .name("Mining Ticks") + .description("The max number of ticks to hold a pickaxe for the packet mine") + .min(5) + .max(60) + .defaultValue(20) + .visible(doubleBreak::get) + .build() + ); + + private final Setting remine = sgGeneral.add(new EnumSetting.Builder() + .name("Remine") + .description("Remines already mined blocks") + .defaultValue(RemineMode.INSTANT) + .build() + ); + + private final Setting packetInstant = sgGeneral.add(new BoolSetting.Builder() + .name("Fast") + .description("Instant mines on packet") + .defaultValue(true) + .visible(() -> remine.get() == RemineMode.INSTANT) + .build() + ); + + private final Setting range = sgGeneral.add(new FloatSetting.Builder() + .name("Range") + .description("The range to mine blocks") + .min(0.1f) + .defaultValue(6.0f) + .max(6.0f) + .build() + ); + + private final Setting speed = sgGeneral.add(new FloatSetting.Builder() + .name("Speed") + .description("The speed to mine blocks (idk what the fuck this is)") + .min(0.1f) + .defaultValue(1.0f) + .max(1.0f) + .build() + ); + + private final Setting swap = sgGeneral.add(new EnumSetting.Builder() + .name("Auto Swap") + .description("Swaps to the best tool once the mining is complete") + .defaultValue(Swap.SILENT) + .build() + ); + + private final Setting swapBefore = sgGeneral.add(new BoolSetting.Builder() + .name("Swap Before") + .description("Swaps before fully done mining") + .defaultValue(false) + .visible(() -> swap.get() != Swap.OFF) + .build() + ); + + private final Setting rotate = sgGeneral.add(new BoolSetting.Builder() + .name("Rotate") + .description("yes") + .defaultValue(true) + .build() + ); + + private final Setting switchReset = sgGeneral.add(new BoolSetting.Builder() + .name("Switch Reset") + .description("Resets mining after switching items") + .defaultValue(false) + .build() + ); + + private final Setting grim = sgGeneral.add(new BoolSetting.Builder() + .name("Grim") + .description("Uses grim block breaking speeds") + .defaultValue(false) + .build() + ); + + private final Setting grimNew = sgGeneral.add(new BoolSetting.Builder() + .name("Grim V3") + .description("Allows mining on new grim servers") + .defaultValue(false) + .visible(grim::get) + .build() + ); + + private final Setting anticheat = sgGeneral.add(new BoolSetting.Builder() + .name("Anti Cheat") + .description("grim anti cheat genyo fasz") + .defaultValue(false) + .build() + ); + + // Render + + private final Setting render = sgRender.add(new BoolSetting.Builder() + .name("Render") + .description("wa") + .defaultValue(true) + .build() + ); + + private final Setting mineColor = sgRender.add(new ColorSetting.Builder() + .name("Mine Color") + .description("The mine render color") + .defaultValue(new SettingColor(255, 0, 0, 255)) + .build() + ); + + private final Setting colorDone = sgRender.add(new ColorSetting.Builder() + .name("Done Color") + .description("The done render color") + .defaultValue(new SettingColor(0, 255, 0, 255)) + .build() + ); + + private final Setting fadeTime = sgRender.add(new IntSetting.Builder() + .name("Fade Time") + .description("Time to fade") + .min(0) + .defaultValue(250) + .max(1000) + .visible(() -> false) + .build() + ); + + private final Setting smoothColor = sgRender.add(new BoolSetting.Builder() + .name("Smooth Color") + .description("Interpolates from start to done color") + .defaultValue(false) + .build() + ); + + private PlayerEntity playerTarget; + private MineData packetMine, instantMine; + private boolean packetSwapBack; + private boolean manualOverride; + private final Timer remineTimer = new CacheTimer(); + + private boolean changedInstantMine; + private boolean waitForPacketMine; + private boolean packetMineStuck; + + private boolean antiCrawlOverride; + private int antiCrawlTicks; + + private final Queue autoMineQueue = new ArrayDeque<>(); + private int autoMineTickDelay; + + private MineAnimation packetMineAnim = new MineAnimation( + MineData.empty(), new Animation(true, 200)); + private MineAnimation instantMineAnim = new MineAnimation( + MineData.empty(), new Animation(true, 200)); + + @Override + public void onDeactivate() + { + autoMineQueue.clear(); + playerTarget = null; + packetMine = null; + if (instantMine != null) + { + abortMining(instantMine); + instantMine = null; + } + packetMineAnim = new MineAnimation(MineData.empty(), new Animation(true, 200)); + instantMineAnim = new MineAnimation(MineData.empty(), new Animation(true, 200)); + autoMineTickDelay = 0; + antiCrawlTicks = 0; + manualOverride = false; + antiCrawlOverride = false; + waitForPacketMine = false; + packetMineStuck = false; + if (packetSwapBack) + { + Managers.INVENTORY.syncToClient(); + packetSwapBack = false; + } + } + + @EventHandler + public void onTick(TickEvent.Pre event) + { + if (mc.player.isCreative() || mc.player.isSpectator()) + { + return; + } + + PlayerEntity currentTarget = getClosestPlayer(enemyRange.get()); + boolean targetChanged = playerTarget != null && playerTarget != currentTarget; + playerTarget = currentTarget; + + if (isInstantMineComplete()) + { + if (changedInstantMine) + { + changedInstantMine = false; + } + if (waitForPacketMine) + { + waitForPacketMine = false; + } + } + + autoMineTickDelay--; + antiCrawlTicks--; + + // Mining packet handling + if (packetMine != null && packetMine.getTicksMining() > mineTicks.get()) + { + packetMineStuck = true; + packetMineAnim.animation.setState(false); + if (packetSwapBack) + { + Managers.INVENTORY.syncToClient(); + packetSwapBack = false; + } + packetMine = null; + if (!isInstantMineComplete()) + { + waitForPacketMine = true; + } + } + + if (packetMine != null) + { + final float damageDelta = Modules.get().get(GenyoSpeedmine.class).calcBlockBreakingDelta( + packetMine.getState(), mc.world, packetMine.getPos()); + packetMine.addBlockDamage(damageDelta); + + int slot = packetMine.getBestSlot(); + float damageDone = packetMine.getBlockDamage() + (swapBefore.get() + || packetMineStuck ? damageDelta : 0.0f); + if (damageDone >= 1.0f && slot != -1 && !checkMultitask()) + { + Managers.INVENTORY.setSlot(slot); + packetSwapBack = true; + if (packetMineStuck) + { + packetMineStuck = false; + } + } + } + + if (packetSwapBack) + { + if (packetMine != null && canMine(packetMine.getState())) + { + packetMine.markAttemptedMine(); + } + else + { + Managers.INVENTORY.syncToClient(); + packetSwapBack = false; + packetMineAnim.animation.setState(false); + packetMine = null; + if (!isInstantMineComplete()) + { + waitForPacketMine = true; + } + } + } + + if (instantMine != null) + { + final double distance = mc.player.getEyePos().squaredDistanceTo(instantMine.getPos().toCenterPos()); + if (distance > MathUtil.squared(range.get()) + || instantMine.getTicksMining() > mineTicks.get()) + { + abortMining(instantMine); + instantMineAnim.animation.setState(false); + instantMine = null; + } + } + + if (instantMine != null) + { + final float damageDelta = Modules.get().get(GenyoSpeedmine.class).calcBlockBreakingDelta( + instantMine.getState(), mc.world, instantMine.getPos()); + instantMine.addBlockDamage(damageDelta); + + if (instantMine.getBlockDamage() >= speed.get()) + { + boolean canMine = canMine(instantMine.getState()); + boolean canPlace = mc.world.canPlace(instantMine.getState(), instantMine.getPos(), ShapeContext.absent()); + if (canMine) + { + instantMine.markAttemptedMine(); + } + else + { + instantMine.resetMiningTicks(); + if (remine.get() == RemineMode.NORMAL || remine.get() == RemineMode.FAST) + { + instantMine.setTotalBlockDamage(0.0f, 0.0f); + } + + if (manualOverride) + { + manualOverride = false; + abortMining(instantMine); + instantMineAnim.animation.setState(false); + instantMine = null; + } + } + + boolean passedRemine = remine.get() == RemineMode.INSTANT || remineTimer.passed(500); + if (instantMine != null && (remine.get() == RemineMode.INSTANT + && packetInstant.get() && packetMine == null && canPlace || canMine && passedRemine) + && (!checkMultitask() || multitask.get() || swap.get() == Swap.OFF)) + { + stopMining(instantMine); + remineTimer.reset(); + + if (Modules.get().isActive(GenyoAutoCrystal.class) + && Modules.get().get(GenyoAutoCrystal.class).shouldPreForcePlace()) + { + Modules.get().get(GenyoAutoCrystal.class).placeCrystalForTarget(playerTarget, instantMine.getPos().down()); + } + + if (remine.get() == RemineMode.FAST) + { + startMining(instantMine); + } + } + } + } + + // Clear overrides + if (manualOverride && (instantMine == null || instantMine.getGoal() != MiningGoal.MANUAL)) + { + manualOverride = false; + } + + if (antiCrawlOverride && (instantMine == null || instantMine.getGoal() != MiningGoal.PREVENT_CRAWL)) + { + antiCrawlOverride = false; + } + + if (auto.get()) + { + if (!autoMineQueue.isEmpty() && autoMineTickDelay <= 0) + { + MineData nextMine = autoMineQueue.poll(); + if (nextMine != null) + { + startMining(nextMine); + autoMineTickDelay = 5; + } + } + + BlockPos antiCrawlPos = getAntiCrawlPos(playerTarget); + if (antiCrawlOverride) + { + if (mc.player.getPose().equals(EntityPose.SWIMMING)) + { + antiCrawlTicks = 10; + } + + if (antiCrawlTicks <= 0 || !isInstantMineComplete() && antiCrawlPos != null + && !instantMine.getPos().equals(antiCrawlPos)) + { + antiCrawlOverride = false; + } + } + + if (autoMineQueue.isEmpty() && !manualOverride && !antiCrawlOverride) + { + if (antiCrawl.get() && mc.player.getPose().equals(EntityPose.SWIMMING) && antiCrawlPos != null) + { + MineData data = new MineData(antiCrawlPos, strictDirection.get() ? + Managers.INTERACT.getInteractDirection(antiCrawlPos, false) : Direction.UP, MiningGoal.PREVENT_CRAWL); + if (isInstantMineComplete() || !instantMine.equals(data)) + { + startAutoMine(data); + antiCrawlOverride = true; + } + } + + else if (playerTarget != null && !targetChanged) + { + BlockPos targetPos = GEntityUtils.getRoundedBlockPos(playerTarget); + boolean bedrockPhased = GPositionUtils.isBedrock(playerTarget.getBoundingBox(), targetPos) && !playerTarget.isCrawling(); + + if (!isInstantMineComplete() && checkDataY(instantMine, targetPos, bedrockPhased)) + { + abortMining(instantMine); + instantMineAnim.animation.setState(false); + instantMine = null; + } + + else if (packetMine != null && checkDataY(packetMine, targetPos, bedrockPhased)) + { + packetMineAnim.animation.setState(false); + if (packetSwapBack) + { + Managers.INVENTORY.syncToClient(); + packetSwapBack = false; + } + packetMine = null; + waitForPacketMine = false; + } + + else + { + List phasedBlocks = getPhaseBlocks(playerTarget, targetPos, bedrockPhased); + + MineData bestMine; + if (!phasedBlocks.isEmpty()) + { + BlockPos pos1 = phasedBlocks.removeFirst(); + bestMine = new MineData(pos1, strictDirection.get() ? + Managers.INTERACT.getInteractDirection(pos1, false) : Direction.UP); + + if (packetMine == null && doubleBreak.get() || isInstantMineComplete()) + { + startAutoMine(bestMine); + } + } + + else + { + List miningBlocks = getMiningBlocks(playerTarget, targetPos, bedrockPhased); + bestMine = getInstantMine(miningBlocks, bedrockPhased, null); + + if (bestMine != null && (packetMine == null && !changedInstantMine + && doubleBreak.get() || isInstantMineComplete())) + { + startAutoMine(bestMine); + + if (doubleBreak.get() && packetMine == null && !isInstantMineComplete()) + { + MineData secondMine = getInstantMine(miningBlocks, bedrockPhased, bestMine.getPos()); + if (secondMine != null) + { + startAutoMine(secondMine); + } + } + } + } + } + } + + else + { + if (!isInstantMineComplete() && instantMine.getGoal() == MiningGoal.MINING_ENEMY) + { + abortMining(instantMine); + instantMineAnim.animation.setState(false); + instantMine = null; + } + + if (packetMine != null && packetMine.getGoal() == MiningGoal.MINING_ENEMY) + { + packetMineAnim.animation.setState(false); + if (packetSwapBack) + { + Managers.INVENTORY.syncToClient(); + packetSwapBack = false; + } + packetMine = null; + waitForPacketMine = false; + } + } + } + } + } + + @EventHandler + public void onAttackBlock(AttackBlockEvent event) + { + if (mc.player.isCreative() || mc.player.isSpectator()) + { + return; + } + + event.cancel(); + + if (event.state.getBlock().getHardness() == -1.0f || !canMine(event.state) || isMining(event.pos)) + { + return; + } + + MineData data = new MineData(event.pos, event.direction, MiningGoal.MANUAL); + + if (instantMine != null && instantMine.getGoal() == MiningGoal.MINING_ENEMY + || packetMine != null && packetMine.getGoal() == MiningGoal.MINING_ENEMY) + { + manualOverride = true; + } + + if (!doubleBreak.get()) + { + instantMine = data; + startMining(instantMine); + mc.player.swingHand(Hand.MAIN_HAND, false); + return; + } + + boolean updateChanged = false; + if (!isInstantMineComplete() && !changedInstantMine) + { + if (packetMine == null) + { + packetMine = instantMine.copy(); + packetMineAnim = new MineAnimation(packetMine, + new Animation(true, fadeTime.get())); + } + else + { + updateChanged = true; + } + } + + instantMine = data; + startMining(instantMine); + mc.player.swingHand(Hand.MAIN_HAND, false); + if (updateChanged) + { + changedInstantMine = true; + } + } + + @EventHandler + public void onPacketSend(PacketEvent.Send event) + { + if (event.packet instanceof UpdateSelectedSlotC2SPacket && switchReset.get() && instantMine != null) + { + instantMine.setTotalBlockDamage(0.0f, 0.0f); + } + } + + @EventHandler + public void onPacketReceive(PacketEvent.Receive event) + { + if (event.packet instanceof BlockUpdateS2CPacket packet && canMine(packet.getState())) + { + if (antiCrawlOverride && packet.getPos().equals(getAntiCrawlPos(playerTarget))) + { + antiCrawlTicks = 10; + } + } + } + + public void startAutoMine(MineData data) + { + if (!canMine(data.getState()) || isMining(data.getPos())) + { + return; + } + + if (!doubleBreak.get()) + { + instantMine = data; + autoMineQueue.offer(data); + return; + } + + if (changedInstantMine && !isInstantMineComplete() || waitForPacketMine) + { + return; + } + + boolean updateChanged = false; + if (!isInstantMineComplete() && !changedInstantMine) + { + if (packetMine == null) + { + packetMine = instantMine.copy(); + packetMineAnim = new MineAnimation(packetMine, + new Animation(true, fadeTime.get())); + } + else + { + updateChanged = true; + } + } + + instantMine = data; + autoMineQueue.offer(data); + + if (updateChanged) + { + changedInstantMine = true; + } + } + + public MineData getInstantMine(List miningBlocks, boolean bedrockPhased, BlockPos exclude) + { + PriorityQueue validInstantMines = new PriorityQueue<>(); + for (BlockPos blockPos : miningBlocks) + { + if (exclude != null && blockPos.equals(exclude)) continue; + + BlockState state1 = mc.world.getBlockState(blockPos); + if (!isAutoMineBlock(state1.getBlock())) + { + continue; + } + + double dist = mc.player.getEyePos().squaredDistanceTo(blockPos.toCenterPos()); + if (dist > MathUtil.squared(range.get())) + { + continue; + } + + BlockState state2 = mc.world.getBlockState(blockPos.down()); + if (bedrockPhased || state2.isOf(Blocks.OBSIDIAN) || state2.isOf(Blocks.BEDROCK)) + { + Direction direction = strictDirection.get() ? + Managers.INTERACT.getInteractDirection(blockPos, false) : Direction.UP; + + validInstantMines.add(new MineData(blockPos, direction)); + } + } + + if (validInstantMines.isEmpty()) + { + return null; + } + + return validInstantMines.poll(); + } + + public List getPhaseBlocks(PlayerEntity player, BlockPos playerPos, boolean targetBedrockPhased) + { + List phaseBlocks = GPositionUtils.getAllInBox(player.getBoundingBox(), + targetBedrockPhased && head.get() ? playerPos.up() : playerPos); + + phaseBlocks.removeIf(p -> + { + BlockState state = mc.world.getBlockState(p); + if (!isAutoMineBlock(state.getBlock()) || !canMine(state) || isMining(p)) + { + return true; + } + + double dist = mc.player.getEyePos().squaredDistanceTo(p.toCenterPos()); + if (dist > MathUtil.squared(range.get())) + { + return true; + } + + return avoidSelf.get() && intersectsPlayer(p); + }); + + if (targetBedrockPhased && aboveHead.get()) + { + phaseBlocks.add(playerPos.up(2)); + } + + return phaseBlocks; + } + + public List getMiningBlocks(PlayerEntity player, BlockPos playerPos, boolean bedrockPhased) + { + List surroundingBlocks = Modules.get().get(GenyoSurroundV2.class).getSurroundNoDown(player, range.get()); + List miningBlocks; + if (bedrockPhased) + { + List facePlaceBlocks = new ArrayList<>(); + if (head.get()) + { + facePlaceBlocks.addAll(surroundingBlocks.stream().map(BlockPos::up).toList()); + } + + BlockState belowFeet = mc.world.getBlockState(playerPos.down()); + if (canMine(belowFeet)) + { + facePlaceBlocks.add(playerPos.down()); + } + miningBlocks = facePlaceBlocks; + } + else + { + miningBlocks = surroundingBlocks; + } + + miningBlocks.removeIf(p -> avoidSelf.get() && intersectsPlayer(p)); + return miningBlocks; + } + + private BlockPos getAntiCrawlPos(PlayerEntity playerTarget) + { + if (!mc.player.isOnGround()) + { + return null; + } + BlockPos crawlingPos = GEntityUtils.getRoundedBlockPos(mc.player); + boolean playerBelow = playerTarget != null && GEntityUtils.getRoundedBlockPos(playerTarget).getY() < crawlingPos.getY(); + if (playerBelow) + { + BlockState state = mc.world.getBlockState(crawlingPos.down()); + if (isAutoMineBlock(state.getBlock()) && canMine(state)) + { + return crawlingPos.down(); + } + } + else + { + BlockState state = mc.world.getBlockState(crawlingPos.up()); + if (isAutoMineBlock(state.getBlock()) && canMine(state)) + { + return crawlingPos.up(); + } + } + return null; + } + + private boolean checkDataY(MineData data, BlockPos targetPos, boolean bedrockPhased) + { + return data.getGoal() == MiningGoal.MINING_ENEMY && !bedrockPhased && data.getPos().getY() != targetPos.getY(); + } + + private boolean intersectsPlayer(BlockPos pos) + { + List playerBlocks = Modules.get().get(GenyoSurroundV2.class).getPlayerBlocks(mc.player); + List surroundingBlocks = Modules.get().get(GenyoSurroundV2.class).getSurroundNoDown(mc.player); + return playerBlocks.contains(pos) || surroundingBlocks.contains(pos); + } + + @EventHandler + public void onRender3D(Render3DEvent event) + { + if (mc.player.isCreative() || mc.player.isSpectator()) + { + return; + } + + if (!render.get()) return; + + if (instantMineAnim != null && instantMineAnim.animation().getFactor() > 0.01f) + { + renderMiningData(event.renderer, event.tickDelta, + instantMineAnim, true); + } + + if (doubleBreak.get() && packetMineAnim != null && packetMineAnim.animation().getFactor() > 0.01f) + { + renderMiningData(event.renderer, event.tickDelta, + packetMineAnim, false); + } + } + + public void renderMiningData(Renderer3D renderer, float tickDelta, + MineAnimation mineAnimation, boolean instantMine) + { + MineData data = mineAnimation.data(); + Animation animation = mineAnimation.animation(); + int boxAlpha = (int) (40 * animation.getFactor()); + int lineAlpha = (int) (100 * animation.getFactor()); + + Color boxColor; + Color lineColor; + if (smoothColor.get()) + { + boxColor = !canMine(data.getState()) ? colorDone.get().a(boxAlpha) : + ColorUtil.interpolateColor(Math.min(data.getBlockDamage(), 1.0f), colorDone.get().a(boxAlpha), mineColor.get().a(boxAlpha)); + lineColor = !canMine(data.getState()) ? colorDone.get().a(lineAlpha) : + ColorUtil.interpolateColor(Math.min(data.getBlockDamage(), 1.0f), colorDone.get().a(lineAlpha), mineColor.get().a(lineAlpha)); + } + else + { + boxColor = data.getBlockDamage() >= 0.95f || !canMine(data.getState()) ? colorDone.get().a(boxAlpha) : mineColor.get().a(boxAlpha); + lineColor = data.getBlockDamage() >= 0.95f || !canMine(data.getState()) ? colorDone.get().a(lineAlpha) : mineColor.get().a(lineAlpha); + } + + BlockPos mining = data.getPos(); + VoxelShape outlineShape = VoxelShapes.fullCube(); + if (!instantMine || data.getBlockDamage() < speed.get()) + { + outlineShape = data.getState().getOutlineShape(mc.world, mining); + outlineShape = outlineShape.isEmpty() ? VoxelShapes.fullCube() : outlineShape; + } + Box render1 = outlineShape.getBoundingBox(); + Vec3d center = render1.offset(mining).getCenter(); + float total = instantMine ? speed.get() : 1.0f; + float scale = (instantMine && data.getBlockDamage() >= speed.get()) || !canMine(data.getState()) ? 1.0f : + MathHelper.clamp((data.getBlockDamage() + (data.getBlockDamage() - data.getLastDamage()) * tickDelta) / total, 0.0f, 1.0f); + double dx = (render1.maxX - render1.minX) / 2.0; + double dy = (render1.maxY - render1.minY) / 2.0; + double dz = (render1.maxZ - render1.minZ) / 2.0; + final Box scaled = new Box(center, center).expand(dx * scale, dy * scale, dz * scale); + + renderer.box(scaled, boxColor, lineColor, ShapeMode.Both, 0); + } + + public void startMining(MineData data) + { + if (rotate.get()) + { + float[] rotations = RotationUtil.getRotationsTo(mc.player.getEyePos(), data.getPos().toCenterPos()); + if (grim.get()) + { + setRotationSilent(rotations[0], rotations[1]); + } + else + { + setRotation(rotations[0], rotations[1]); + } + } + + if (doubleBreak.get()) + { + if (grimNew.get()) + { + if (!anticheat.get()) + { + Managers.NETWORK.sendPacket(new PlayerActionC2SPacket( + PlayerActionC2SPacket.Action.STOP_DESTROY_BLOCK, data.getPos(), data.getDirection())); + Managers.NETWORK.sendPacket(new PlayerActionC2SPacket( + PlayerActionC2SPacket.Action.START_DESTROY_BLOCK, data.getPos(), data.getDirection())); + Managers.NETWORK.sendPacket(new PlayerActionC2SPacket( + PlayerActionC2SPacket.Action.ABORT_DESTROY_BLOCK, data.getPos(), data.getDirection())); + } + else + { + Managers.NETWORK.sendPacket(new PlayerActionC2SPacket( + PlayerActionC2SPacket.Action.START_DESTROY_BLOCK, data.getPos(), data.getDirection())); + } + + Managers.NETWORK.sendPacket(new PlayerActionC2SPacket( + PlayerActionC2SPacket.Action.STOP_DESTROY_BLOCK, data.getPos(), data.getDirection())); + Managers.NETWORK.sendPacket(new HandSwingC2SPacket(Hand.MAIN_HAND)); + Managers.NETWORK.sendPacket(new HandSwingC2SPacket(Hand.MAIN_HAND)); + Managers.NETWORK.sendPacket(new HandSwingC2SPacket(Hand.MAIN_HAND)); + } + else + { + Managers.NETWORK.sendPacket(new PlayerActionC2SPacket( + PlayerActionC2SPacket.Action.STOP_DESTROY_BLOCK, data.getPos(), data.getDirection())); + Managers.NETWORK.sendPacket(new PlayerActionC2SPacket( + PlayerActionC2SPacket.Action.START_DESTROY_BLOCK, data.getPos(), data.getDirection())); + Managers.NETWORK.sendPacket(new PlayerActionC2SPacket( + PlayerActionC2SPacket.Action.STOP_DESTROY_BLOCK, data.getPos(), data.getDirection())); + Managers.NETWORK.sendPacket(new PlayerActionC2SPacket( + PlayerActionC2SPacket.Action.STOP_DESTROY_BLOCK, data.getPos(), data.getDirection())); + Managers.NETWORK.sendPacket(new PlayerActionC2SPacket( + PlayerActionC2SPacket.Action.START_DESTROY_BLOCK, data.getPos(), data.getDirection())); + Managers.NETWORK.sendPacket(new PlayerActionC2SPacket( + PlayerActionC2SPacket.Action.STOP_DESTROY_BLOCK, data.getPos(), data.getDirection())); + Managers.NETWORK.sendPacket(new HandSwingC2SPacket(Hand.MAIN_HAND)); + } + } + else + { + Managers.NETWORK.sendPacket(new PlayerActionC2SPacket( + PlayerActionC2SPacket.Action.START_DESTROY_BLOCK, data.getPos(), data.getDirection())); + } + + if (rotate.get() && grim.get()) + { + Managers.ROTATION.setRotationSilentSync(); + } + + instantMineAnim = new MineAnimation(data, new Animation(true, fadeTime.get())); + } + + public void abortMining(MineData data) + { + Managers.NETWORK.sendPacket(new PlayerActionC2SPacket( + PlayerActionC2SPacket.Action.ABORT_DESTROY_BLOCK, data.getPos(), data.getDirection())); + } + + public void stopMining(MineData data) + { + if (rotate.get()) + { + float[] rotations = RotationUtil.getRotationsTo(mc.player.getEyePos(), data.getPos().toCenterPos()); + if (grim.get()) + { + setRotationSilent(rotations[0], rotations[1]); + } + else + { + setRotation(rotations[0], rotations[1]); + } + } + + int slot = data.getBestSlot(); + if (slot != -1) + { + swapTo(slot); + } + + stopMiningInternal(data); + + if (slot != -1) + { + swapSync(slot); + } + + if (rotate.get() && grim.get()) + { + Managers.ROTATION.setRotationSilentSync(); + } + } + + private void stopMiningInternal(MineData data) + { + Managers.NETWORK.sendPacket(new PlayerActionC2SPacket( + PlayerActionC2SPacket.Action.STOP_DESTROY_BLOCK, data.getPos(), data.getDirection())); + Managers.NETWORK.sendPacket(new PlayerActionC2SPacket( + PlayerActionC2SPacket.Action.ABORT_DESTROY_BLOCK, data.getPos(), data.getDirection())); + } + + public boolean isInstantMineComplete() + { + return instantMine == null || instantMine.getBlockDamage() >= speed.get() && !canMine(instantMine.getState()); + } + + public BlockPos getMiningBlock() + { + if (instantMine != null) + { + double damage = instantMine.getBlockDamage() / speed.get(); + if (damage > 0.75) + { + return instantMine.getPos(); + } + } + return null; + } + + private void swapTo(int slot) + { + switch (swap.get()) + { + case NORMAL -> Managers.INVENTORY.setClientSlot(slot); + case SILENT -> Managers.INVENTORY.setSlot(slot); + case SILENT_ALT -> Managers.INVENTORY.setSlotAlt(slot); + } + } + + private void swapSync(int slot) + { + switch (swap.get()) + { + case SILENT -> Managers.INVENTORY.syncToClient(); + case SILENT_ALT -> Managers.INVENTORY.setSlotAlt(slot); + } + } + + public boolean isSilentSwapping() + { + return packetSwapBack; + } + + private boolean isMining(BlockPos blockPos) + { + return instantMine != null && instantMine.getPos().equals(blockPos) || + packetMine != null && packetMine.getPos().equals(blockPos); + } + + private boolean isAutoMineBlock(Block block) + { + if (BlastResistantBlocks.isUnbreakable(block)) + { + return false; + } + return switch (selection.get()) + { + case WHITELIST -> whitelist.get().contains(block); + case BLACKLIST -> !blacklist.get().contains(block); + case ALL -> true; + }; + } + + public boolean canMine(BlockState state) + { + return !state.isAir() && state.getFluidState().isEmpty(); + } + + public static class MineData implements Comparable + { + private static final MinecraftClient mc = MinecraftClient.getInstance(); + private final BlockPos pos; + private final Direction direction; + private final MiningGoal goal; + private int ticksMining; + private float blockDamage, lastDamage; + + public MineData(BlockPos pos, Direction direction) + { + this.pos = pos; + this.direction = direction; + this.goal = MiningGoal.MINING_ENEMY; + } + + public MineData(BlockPos pos, Direction direction, MiningGoal goal) + { + this.pos = pos; + this.direction = direction; + this.goal = goal; + } + + private double getPriority() + { + double dist = mc.player.getEyePos().squaredDistanceTo(pos.down().toCenterPos()); + if (dist <= Modules.get().get(GenyoAutoCrystal.class).getPlaceRange()) + { + return 10.0f; + } + + return 0.0f; + } + + @Override + public int compareTo(@NotNull MineData o) + { + return Double.compare(getPriority(), o.getPriority()); + } + + @Override + public boolean equals(Object obj) + { + return obj instanceof MineData d && d.getPos().equals(pos); + } + + public void resetMiningTicks() + { + ticksMining = 0; + } + + public void markAttemptedMine() + { + ticksMining++; + } + + public void addBlockDamage(float blockDamage) + { + this.lastDamage = this.blockDamage; + this.blockDamage += blockDamage; + } + + public void setTotalBlockDamage(float blockDamage, float lastDamage) + { + this.blockDamage = blockDamage; + this.lastDamage = lastDamage; + } + + public BlockPos getPos() + { + return pos; + } + + public Direction getDirection() + { + return direction; + } + + public MiningGoal getGoal() + { + return goal; + } + + public int getTicksMining() + { + return ticksMining; + } + + public float getBlockDamage() + { + return blockDamage; + } + + public float getLastDamage() + { + return lastDamage; + } + + public static MineData empty() + { + return new MineData(BlockPos.ORIGIN, Direction.UP); + } + + public MineData copy() + { + final MineData data = new MineData(pos, direction, goal); + data.setTotalBlockDamage(blockDamage, lastDamage); + return data; + } + + public BlockState getState() + { + return mc.world.getBlockState(pos); + } + + public int getBestSlot() + { + return Modules.get().get(GenyoAutoTool.class).getBestToolNoFallback(getState()); + } + } + + public record MineAnimation(MineData data, Animation animation) {} + + public enum MiningGoal + { + MANUAL, + MINING_ENEMY, + PREVENT_CRAWL + } + + public enum RemineMode + { + INSTANT, + NORMAL, + FAST + } + + public enum Selection + { + WHITELIST, + BLACKLIST, + ALL + } + + public enum Swap + { + NORMAL, + SILENT, + SILENT_ALT, + OFF + } +} diff --git a/src/main/java/com/genyo/systems/modules/world/GenyoAutoTool.java b/src/main/java/com/genyo/systems/modules/world/GenyoAutoTool.java index 8b34097..92ca9de 100644 --- a/src/main/java/com/genyo/systems/modules/world/GenyoAutoTool.java +++ b/src/main/java/com/genyo/systems/modules/world/GenyoAutoTool.java @@ -38,7 +38,7 @@ public int getBestTool(final BlockState state) { return slot; } - return mc.player.getInventory().selectedSlot; + return mc.player.getInventory().getSelectedSlot(); } public int getBestToolNoFallback(final BlockState state) diff --git a/src/main/java/com/genyo/systems/modules/world/GenyoSelfTrap.java b/src/main/java/com/genyo/systems/modules/world/GenyoSelfTrap.java index 5e1e615..f3c6bf5 100644 --- a/src/main/java/com/genyo/systems/modules/world/GenyoSelfTrap.java +++ b/src/main/java/com/genyo/systems/modules/world/GenyoSelfTrap.java @@ -31,10 +31,7 @@ import net.minecraft.network.packet.Packet; import net.minecraft.network.packet.c2s.play.HandSwingC2SPacket; import net.minecraft.network.packet.c2s.play.PlayerInteractEntityC2SPacket; -import net.minecraft.network.packet.s2c.play.BlockUpdateS2CPacket; -import net.minecraft.network.packet.s2c.play.BundleS2CPacket; -import net.minecraft.network.packet.s2c.play.EntitySpawnS2CPacket; -import net.minecraft.network.packet.s2c.play.ExplosionS2CPacket; +import net.minecraft.network.packet.s2c.play.*; import net.minecraft.util.Hand; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Box; @@ -43,6 +40,7 @@ import java.util.*; + public class GenyoSelfTrap extends PlacerModule { public GenyoSelfTrap() { @@ -125,7 +123,22 @@ public GenyoSelfTrap() { .defaultValue(false) .build() ); + private final Setting mineProtect = sgGeneral.add(new BoolSetting.Builder() + .name("Mine Protect") + .description("Places a block on surround when an enemy mines past a set threshold") + .defaultValue(false) + .build() + ); + private final Setting mineProtectThreshold = sgGeneral.add(new FloatSetting.Builder() + .name("Mine Threshold") + .description("Mining progress % at which to place a protective block (0-100)") + .defaultValue(50.0f) + .min(0.0f) + .max(100.0f) + .visible(() -> mineProtect.get()) + .build() + ); private final Setting support = sgGeneral.add(new BoolSetting.Builder() .name("Support") .description("Creates a floor for the trap if there is none") @@ -187,6 +200,8 @@ public GenyoSelfTrap() { private List placements = new ArrayList<>(); private final Map packets = new HashMap<>(); private final Map fadeList = new HashMap<>(); + private final Map mineProgress = new HashMap<>(); + private final Map mineProtectCooldown = new HashMap<>(); private double prevY; @Override @@ -202,6 +217,8 @@ public void onDeactivate() { placements.clear(); packets.clear(); fadeList.clear(); + mineProgress.clear(); + mineProtectCooldown.clear(); } @EventHandler @@ -280,6 +297,39 @@ public void onPacketReceive(PacketEvent.Receive event) { private void handlePackets(Packet serverPacket) { + if (serverPacket instanceof BlockBreakingProgressS2CPacket packet && mineProtect.get()) { + BlockPos minedPos = packet.getPos(); + int entityId = packet.getEntityId(); + int stage = packet.getProgress(); + + if (stage < 0) { + mineProgress.remove(entityId); + return; + } + + if (!trap.contains(minedPos)) return; + + float progressPercent = (stage / 9.0f) * 100.0f; + long[] prev = mineProgress.get(entityId); + float prevPercent = (prev != null) ? (prev[1] / 9.0f) * 100.0f : 0.0f; + + mineProgress.put(entityId, new long[]{minedPos.asLong(), stage}); + + if (prevPercent < mineProtectThreshold.get() && progressPercent >= mineProtectThreshold.get()) { + Long lastReact = mineProtectCooldown.get(minedPos); + if (lastReact != null && System.currentTimeMillis() - lastReact < 500) return; + + final int slot = getResistantBlockItem(); + if (slot == -1) return; + + for (BlockPos adjacent : getAdjacentPlacements(minedPos)) { + placeBlock(adjacent, slot); + } + mineProtectCooldown.put(minedPos, System.currentTimeMillis()); + } + return; + } + if (timing.get() != Timing.SEQUENTIAL) return; if (serverPacket instanceof BlockUpdateS2CPacket packet) @@ -291,10 +341,7 @@ private void handlePackets(Packet serverPacket) if (blockState.isReplaceable() && Objects.requireNonNull(mc.world).canPlace(DEFAULT_OBSIDIAN_STATE, targetPos, ShapeContext.absent())) { final int slot = getResistantBlockItem(); - if (slot == -1) - { - return; - } + if (slot == -1) return; placeBlock(targetPos, slot); } else if (BlastResistantBlocks.isBlastResistant(blockState)) @@ -304,10 +351,7 @@ else if (BlastResistantBlocks.isBlastResistant(blockState)) } } - if (blocksPlaced > shiftTicks.get() * 2) // Give some leniency if we are getting place on - { - return; - } + if (blocksPlaced > shiftTicks.get() * 2) return; if (serverPacket instanceof ExplosionS2CPacket packet && prePlaceExplosion.get()) { @@ -315,10 +359,7 @@ else if (BlastResistantBlocks.isBlastResistant(blockState)) if (trap.contains(pos)) { final int slot = getResistantBlockItem(); - if (slot == -1) - { - return; - } + if (slot == -1) return; placeBlock(pos, slot); } } @@ -328,22 +369,31 @@ else if (BlastResistantBlocks.isBlastResistant(blockState)) { for (BlockPos pos : trap) { - if (!pos.equals(BlockPos.ofFloored(packet.getX(), packet.getY(), packet.getZ()))) - { - continue; - } + if (!pos.equals(BlockPos.ofFloored(packet.getX(), packet.getY(), packet.getZ()))) continue; final int slot = getResistantBlockItem(); - if (slot == -1) - { - return; - } + if (slot == -1) return; placeBlock(pos, slot); break; } } } + private List getAdjacentPlacements(BlockPos minedPos) + { + List result = new ArrayList<>(); + for (Direction dir : Direction.values()) + { + BlockPos adjacent = minedPos.offset(dir); + + if (adjacent.equals(mc.player.getBlockPos()) || adjacent.equals(mc.player.getBlockPos().up())) continue; + if (!mc.world.getBlockState(adjacent).isReplaceable()) continue; + if (!mc.world.canPlace(DEFAULT_OBSIDIAN_STATE, adjacent, ShapeContext.absent())) continue; + + result.add(adjacent); + } + return result; + } private void placeBlock(BlockPos pos, int slot) { if (!buggy.get()) { @@ -356,6 +406,7 @@ private void placeBlock(BlockPos pos, int slot) } else { if (InvUtils.findInHotbar(Items.OBSIDIAN).slot() == -1) return; + Managers.INVENTORY.setSlot(slot); BlockUtils.place(pos, InvUtils.findInHotbar(Items.OBSIDIAN), rotate.get(), 0, true); } packets.put(pos, System.currentTimeMillis()); diff --git a/src/main/java/com/genyo/systems/modules/world/GenyoSurroundV2.java b/src/main/java/com/genyo/systems/modules/world/GenyoSurroundV2.java index a1df57f..40d9e91 100644 --- a/src/main/java/com/genyo/systems/modules/world/GenyoSurroundV2.java +++ b/src/main/java/com/genyo/systems/modules/world/GenyoSurroundV2.java @@ -30,10 +30,7 @@ import net.minecraft.network.packet.Packet; import net.minecraft.network.packet.c2s.play.HandSwingC2SPacket; import net.minecraft.network.packet.c2s.play.PlayerInteractEntityC2SPacket; -import net.minecraft.network.packet.s2c.play.BlockUpdateS2CPacket; -import net.minecraft.network.packet.s2c.play.BundleS2CPacket; -import net.minecraft.network.packet.s2c.play.EntitySpawnS2CPacket; -import net.minecraft.network.packet.s2c.play.ExplosionS2CPacket; +import net.minecraft.network.packet.s2c.play.*; import net.minecraft.util.Hand; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Box; @@ -124,6 +121,22 @@ public GenyoSurroundV2() { .defaultValue(false) .build() ); + private final Setting mineProtect = sgGeneral.add(new BoolSetting.Builder() + .name("Mine Protect") + .description("Places a block on surround when an enemy mines past a set threshold") + .defaultValue(false) + .build() + ); + + private final Setting mineProtectThreshold = sgGeneral.add(new FloatSetting.Builder() + .name("Mine Threshold") + .description("Mining progress % at which to place a protective block (0-100)") + .defaultValue(50.0f) + .min(0.0f) + .max(100.0f) + .visible(() -> mineProtect.get()) + .build() + ); private final Setting support = sgGeneral.add(new BoolSetting.Builder() .name("Support") @@ -186,6 +199,8 @@ public GenyoSurroundV2() { private List placements = new ArrayList<>(); private final Map packets = new HashMap<>(); private final Map fadeList = new HashMap<>(); + private final Map mineProgress = new HashMap<>(); + private final Map mineProtectCooldown = new HashMap<>(); private double prevY; @Override @@ -201,6 +216,8 @@ public void onDeactivate() { placements.clear(); packets.clear(); fadeList.clear(); + mineProgress.clear(); + mineProtectCooldown.clear(); } @EventHandler @@ -277,6 +294,39 @@ public void onPacketReceive(PacketEvent.Receive event) { private void handlePackets(Packet serverPacket) { + if (serverPacket instanceof BlockBreakingProgressS2CPacket packet && mineProtect.get()) { + BlockPos minedPos = packet.getPos(); + int entityId = packet.getEntityId(); + int stage = packet.getProgress(); + + if (stage < 0) { + mineProgress.remove(entityId); + return; + } + + if (!surround.contains(minedPos)) return; + + float progressPercent = (stage / 9.0f) * 100.0f; + long[] prev = mineProgress.get(entityId); + float prevPercent = (prev != null) ? (prev[1] / 9.0f) * 100.0f : 0.0f; + + mineProgress.put(entityId, new long[]{minedPos.asLong(), stage}); + + if (prevPercent < mineProtectThreshold.get() && progressPercent >= mineProtectThreshold.get()) { + Long lastReact = mineProtectCooldown.get(minedPos); + if (lastReact != null && System.currentTimeMillis() - lastReact < 500) return; + + final int slot = getResistantBlockItem(); + if (slot == -1) return; + + for (BlockPos adjacent : getAdjacentPlacements(minedPos)) { + placeBlock(adjacent, slot); + } + mineProtectCooldown.put(minedPos, System.currentTimeMillis()); + } + return; + } + if (timing.get() != Timing.SEQUENTIAL) return; if (serverPacket instanceof BlockUpdateS2CPacket packet) @@ -288,10 +338,7 @@ private void handlePackets(Packet serverPacket) if (blockState.isReplaceable() && Objects.requireNonNull(mc.world).canPlace(DEFAULT_OBSIDIAN_STATE, targetPos, ShapeContext.absent())) { final int slot = getResistantBlockItem(); - if (slot == -1) - { - return; - } + if (slot == -1) return; placeBlock(targetPos, slot); } else if (BlastResistantBlocks.isBlastResistant(blockState)) @@ -301,10 +348,7 @@ else if (BlastResistantBlocks.isBlastResistant(blockState)) } } - if (blocksPlaced > shiftTicks.get() * 2) // Give some leniency if we are getting place on - { - return; - } + if (blocksPlaced > shiftTicks.get() * 2) return; if (serverPacket instanceof ExplosionS2CPacket packet && prePlaceExplosion.get()) { @@ -312,10 +356,7 @@ else if (BlastResistantBlocks.isBlastResistant(blockState)) if (surround.contains(pos)) { final int slot = getResistantBlockItem(); - if (slot == -1) - { - return; - } + if (slot == -1) return; placeBlock(pos, slot); } } @@ -325,22 +366,32 @@ else if (BlastResistantBlocks.isBlastResistant(blockState)) { for (BlockPos pos : surround) { - if (!pos.equals(BlockPos.ofFloored(packet.getX(), packet.getY(), packet.getZ()))) - { - continue; - } + if (!pos.equals(BlockPos.ofFloored(packet.getX(), packet.getY(), packet.getZ()))) continue; final int slot = getResistantBlockItem(); - if (slot == -1) - { - return; - } + if (slot == -1) return; placeBlock(pos, slot); break; } } } + private List getAdjacentPlacements(BlockPos minedPos) + { + List result = new ArrayList<>(); + for (Direction dir : Direction.values()) + { + BlockPos adjacent = minedPos.offset(dir); + + if (adjacent.equals(mc.player.getBlockPos()) || adjacent.equals(mc.player.getBlockPos().up())) continue; + if (!mc.world.getBlockState(adjacent).isReplaceable()) continue; + if (!mc.world.canPlace(DEFAULT_OBSIDIAN_STATE, adjacent, ShapeContext.absent())) continue; + + result.add(adjacent); + } + return result; + } + private void placeBlock(BlockPos pos, int slot) { if (!buggy.get()) { diff --git a/src/main/java/com/genyo/systems/settings/FloatSetting.java b/src/main/java/com/genyo/systems/settings/FloatSetting.java index c0152ef..b0a207d 100644 --- a/src/main/java/com/genyo/systems/settings/FloatSetting.java +++ b/src/main/java/com/genyo/systems/settings/FloatSetting.java @@ -49,7 +49,7 @@ protected NbtCompound save(NbtCompound tag) { @Override public Float load(NbtCompound tag) { - set(tag.getFloat("value")); + set(tag.getFloat("value").orElse(0f)); return get(); } diff --git a/src/main/java/com/genyo/systems/settings/playerlist/ListPlayer.java b/src/main/java/com/genyo/systems/settings/playerlist/ListPlayer.java index 26ed6e0..70b1d43 100644 --- a/src/main/java/com/genyo/systems/settings/playerlist/ListPlayer.java +++ b/src/main/java/com/genyo/systems/settings/playerlist/ListPlayer.java @@ -9,8 +9,7 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.nbt.NbtCompound; import org.jetbrains.annotations.NotNull; - -import javax.annotation.Nullable; +import org.jetbrains.annotations.Nullable; import java.util.Objects; import java.util.UUID; @@ -19,7 +18,7 @@ public class ListPlayer implements ISerializable, Comparable load(NbtCompound tag) { NbtList groupNames = (NbtList) tag.get("group_names"); NbtList messages = (NbtList) tag.get("messages"); for (int i = 0; i < indexes.size(); i++) { - String msg = messages.get(i).asString(); - String groupName = groupNames.get(i).asString(); + String msg = messages.get(i).asString().orElse(""); + String groupName = groupNames.get(i).asString().orElse(""); List players = new ArrayList<>(); NbtList playersList = (NbtList) tag.get("players"); @@ -160,7 +160,7 @@ protected List load(NbtCompound tag) { for (NbtElement val : playersList) { NbtList currentPlayers = (NbtList) playersList.get(i); currentPlayers.forEach(player -> { - ListPlayer listPlayer = new ListPlayer(player.asString()); + ListPlayer listPlayer = new ListPlayer(player.asString().orElse("")); players.add(listPlayer); }); } diff --git a/src/main/java/com/genyo/utils/GInvUtils.java b/src/main/java/com/genyo/utils/GInvUtils.java index 3be585a..456aa92 100644 --- a/src/main/java/com/genyo/utils/GInvUtils.java +++ b/src/main/java/com/genyo/utils/GInvUtils.java @@ -62,7 +62,7 @@ public static SearchInvResult findInHotBar(Searcher searcher) { public static void switchTo(int slot) { if (mc.player == null || mc.getNetworkHandler() == null) return; - if (mc.player.getInventory().selectedSlot == slot && Managers.INVENTORY.getServerSlot() == slot) + if (mc.player.getInventory().getSelectedSlot() == slot && Managers.INVENTORY.getServerSlot() == slot) return; mc.player.getInventory().setSelectedSlot(slot); Managers.INVENTORY.syncToClient(); @@ -77,16 +77,16 @@ public static SearchInvResult getAntiWeaknessItem() { if (mc.player == null) return SearchInvResult.notFound(); Item mainHand = mc.player.getMainHandStack().getItem(); - if ((mainHand instanceof SwordItem) - || (mainHand instanceof PickaxeItem) + if (mc.player.getMainHandStack().isIn(ItemTags.SWORDS) + || mc.player.getMainHandStack().isIn(ItemTags.PICKAXES) || (mainHand instanceof AxeItem) || (mainHand instanceof ShovelItem)) { - return new SearchInvResult(mc.player.getInventory().selectedSlot, true, mc.player.getMainHandStack()); + return new SearchInvResult(mc.player.getInventory().getSelectedSlot(), true, mc.player.getMainHandStack()); } return findInHotBar( - itemStack -> itemStack.getItem() instanceof SwordItem - || itemStack.getItem() instanceof PickaxeItem + itemStack -> itemStack.isIn(ItemTags.SWORDS) + || itemStack.isIn(ItemTags.PICKAXES) || itemStack.getItem() instanceof AxeItem || itemStack.getItem() instanceof ShovelItem ); diff --git a/src/main/java/com/genyo/utils/HudUtils.java b/src/main/java/com/genyo/utils/HudUtils.java index ebcbb68..7d8895e 100644 --- a/src/main/java/com/genyo/utils/HudUtils.java +++ b/src/main/java/com/genyo/utils/HudUtils.java @@ -3,7 +3,7 @@ import meteordevelopment.meteorclient.systems.hud.HudRenderer; import meteordevelopment.meteorclient.utils.render.color.Color; import net.minecraft.client.gui.DrawContext; -import net.minecraft.client.util.math.MatrixStack; + import net.minecraft.item.ItemStack; import static meteordevelopment.meteorclient.MeteorClient.mc; @@ -11,17 +11,15 @@ public class HudUtils { public static void drawItem(DrawContext drawContext, ItemStack itemStack, int x, int y, float scale) { - MatrixStack matrices = drawContext.getMatrices(); - matrices.push(); - matrices.scale(scale, scale, 1f); - matrices.translate(0, 0, 401); // Thanks Mojang + drawContext.getMatrices().pushMatrix(); + drawContext.getMatrices().scale(scale, scale); int scaledX = (int) (x / scale); int scaledY = (int) (y / scale); drawContext.drawItem(itemStack, scaledX, scaledY); - matrices.pop(); + drawContext.getMatrices().popMatrix(); } } diff --git a/src/main/java/com/genyo/utils/player/InteractionUtil.java b/src/main/java/com/genyo/utils/player/InteractionUtil.java index 33f33de..d364f87 100644 --- a/src/main/java/com/genyo/utils/player/InteractionUtil.java +++ b/src/main/java/com/genyo/utils/player/InteractionUtil.java @@ -18,8 +18,7 @@ import net.minecraft.util.math.*; import net.minecraft.world.RaycastContext; import org.jetbrains.annotations.NotNull; - -import javax.annotation.Nullable; +import org.jetbrains.annotations.Nullable; import java.util.*; @@ -40,7 +39,7 @@ public class InteractionUtil { public static Map awaiting = new HashMap<>(); public static Vec3d getEyesPos(@NotNull Entity entity) { - return entity.getPos().add(0, entity.getEyeHeight(entity.getPose()), 0); + return entity.getEyePos().add(0, entity.getEyeHeight(entity.getPose()), 0); } public static float @NotNull [] calculateAngle(Vec3d to) { @@ -91,7 +90,7 @@ public static BlockHitResult getPlaceResult(@NotNull BlockPos bp, Interact inter } BlockHitResult result = null; if (interact == Interact.Legit) { - Vec3d p = getVisibleDirectionPoint(support.facing, support.position, 0, 6); //TODO Implement Range + Vec3d p = getVisibleDirectionPoint(support.facing, support.position, 0, 6); if (p != null) return new BlockHitResult(p, support.facing, support.position, false); } else { @@ -107,10 +106,8 @@ public static BlockHitResult getPlaceResult(@NotNull BlockPos bp, Interact inter return switch (dir) { case UP -> new Box(.15f, 1f, .15f, .85f, 1f, .85f); case DOWN -> new Box(.15f, 0f, .15f, .85f, 0f, .85f); - case EAST -> new Box(1f, .15f, .15f, 1f, .85f, .85f); case WEST -> new Box(0f, .15f, .15f, 0f, .85f, .85f); - case NORTH -> new Box(.15f, .15f, 0f, .85f, .85f, 0f); case SOUTH -> new Box(.15f, .15f, 1f, .85f, .85f, 1f); }; @@ -119,60 +116,39 @@ public static BlockHitResult getPlaceResult(@NotNull BlockPos bp, Interact inter public static @Nullable Vec3d getVisibleDirectionPoint(@NotNull Direction dir, @NotNull BlockPos bp, float wallRange, float range) { Box brutBox = getDirectionBox(dir); - // EAST, WEST if (brutBox.maxX - brutBox.minX == 0) for (double y = brutBox.minY; y < brutBox.maxY; y += 0.1f) for (double z = brutBox.minZ; z < brutBox.maxZ; z += 0.1f) { Vec3d point = new Vec3d(bp.getX() + brutBox.minX, bp.getY() + y, bp.getZ() + z); - - if (shouldSkipPoint(point, bp, dir, wallRange, range)) - continue; - + if (shouldSkipPoint(point, bp, dir, wallRange, range)) continue; return point; } - - // DOWN, UP if (brutBox.maxY - brutBox.minY == 0) for (double x = brutBox.minX; x < brutBox.maxX; x += 0.1f) for (double z = brutBox.minZ; z < brutBox.maxZ; z += 0.1f) { Vec3d point = new Vec3d(bp.getX() + x, bp.getY() + brutBox.minY, bp.getZ() + z); - - if (shouldSkipPoint(point, bp, dir, wallRange, range)) - continue; - + if (shouldSkipPoint(point, bp, dir, wallRange, range)) continue; return point; } - - // NORTH, SOUTH if (brutBox.maxZ - brutBox.minZ == 0) for (double x = brutBox.minX; x < brutBox.maxX; x += 0.1f) for (double y = brutBox.minY; y < brutBox.maxY; y += 0.1f) { Vec3d point = new Vec3d(bp.getX() + x, bp.getY() + y, bp.getZ() + brutBox.minZ); - - if (shouldSkipPoint(point, bp, dir, wallRange, range)) - continue; - + if (shouldSkipPoint(point, bp, dir, wallRange, range)) continue; return point; } - return null; } private static boolean shouldSkipPoint(Vec3d point, BlockPos bp, Direction dir, float wallRange, float range) { RaycastContext context = new RaycastContext(InteractionUtil.getEyesPos(mc.player), point, RaycastContext.ShapeType.COLLIDER, RaycastContext.FluidHandling.NONE, mc.player); BlockHitResult result = mc.world.raycast(context); - float dst = InteractionUtil.squaredDistanceFromEyes(point); - - if (result != null - && result.getType() == HitResult.Type.BLOCK - && !result.getBlockPos().equals(bp) - && dst > wallRange * wallRange) + if (result != null && result.getType() == HitResult.Type.BLOCK && !result.getBlockPos().equals(bp) && dst > wallRange * wallRange) return true; - return dst > range * range; } @@ -191,32 +167,20 @@ public static boolean isSolid(BlockPos bp) { double upDelta = getEyesPos(mc.player).y - (positionVector.add(0, 0.5, 0).y); double downDelta = getEyesPos(mc.player).y - (positionVector.add(0, -0.5, 0).y); - if (westDelta > 0 && isSolid(bp.west())) - visibleSides.add(Direction.EAST); - if (westDelta < 0 && isSolid(bp.east())) - visibleSides.add(Direction.WEST); - if (eastDelta < 0 && isSolid(bp.east())) - visibleSides.add(Direction.WEST); - if (eastDelta > 0 && isSolid(bp.west())) - visibleSides.add(Direction.EAST); - - if (northDelta > 0 && isSolid(bp.north())) - visibleSides.add(Direction.SOUTH); - if (northDelta < 0 && isSolid(bp.south())) - visibleSides.add(Direction.NORTH); - if (southDelta < 0 && isSolid(bp.south())) - visibleSides.add(Direction.NORTH); - if (southDelta > 0 && isSolid(bp.north())) - visibleSides.add(Direction.SOUTH); - - if (upDelta > 0 && isSolid(bp.down())) - visibleSides.add(Direction.UP); - if (upDelta < 0 && isSolid(bp.up())) - visibleSides.add(Direction.DOWN); - if (downDelta < 0 && isSolid(bp.up())) - visibleSides.add(Direction.DOWN); - if (downDelta > 0 && isSolid(bp.down())) - visibleSides.add(Direction.UP); + if (westDelta > 0 && isSolid(bp.west())) visibleSides.add(Direction.EAST); + if (westDelta < 0 && isSolid(bp.east())) visibleSides.add(Direction.WEST); + if (eastDelta < 0 && isSolid(bp.east())) visibleSides.add(Direction.WEST); + if (eastDelta > 0 && isSolid(bp.west())) visibleSides.add(Direction.EAST); + + if (northDelta > 0 && isSolid(bp.north())) visibleSides.add(Direction.SOUTH); + if (northDelta < 0 && isSolid(bp.south())) visibleSides.add(Direction.NORTH); + if (southDelta < 0 && isSolid(bp.south())) visibleSides.add(Direction.NORTH); + if (southDelta > 0 && isSolid(bp.north())) visibleSides.add(Direction.SOUTH); + + if (upDelta > 0 && isSolid(bp.down())) visibleSides.add(Direction.UP); + if (upDelta < 0 && isSolid(bp.up())) visibleSides.add(Direction.DOWN); + if (downDelta < 0 && isSolid(bp.up())) visibleSides.add(Direction.DOWN); + if (downDelta > 0 && isSolid(bp.down())) visibleSides.add(Direction.UP); return visibleSides; } @@ -226,19 +190,14 @@ public static boolean isSolid(BlockPos bp) { if (mc.world.getBlockState(bp.add(0, -1, 0)).isSolid() || awaiting.containsKey(bp.add(0, -1, 0))) list.add(new BlockPosWithFacing(bp.add(0, -1, 0), Direction.UP)); - if (mc.world.getBlockState(bp.add(0, 1, 0)).isSolid() || awaiting.containsKey(bp.add(0, 1, 0))) list.add(new BlockPosWithFacing(bp.add(0, 1, 0), Direction.DOWN)); - if (mc.world.getBlockState(bp.add(-1, 0, 0)).isSolid() || awaiting.containsKey(bp.add(-1, 0, 0))) list.add(new BlockPosWithFacing(bp.add(-1, 0, 0), Direction.EAST)); - if (mc.world.getBlockState(bp.add(1, 0, 0)).isSolid() || awaiting.containsKey(bp.add(1, 0, 0))) list.add(new BlockPosWithFacing(bp.add(1, 0, 0), Direction.WEST)); - if (mc.world.getBlockState(bp.add(0, 0, 1)).isSolid() || awaiting.containsKey(bp.add(0, 0, 1))) list.add(new BlockPosWithFacing(bp.add(0, 0, 1), Direction.NORTH)); - if (mc.world.getBlockState(bp.add(0, 0, -1)).isSolid() || awaiting.containsKey(bp.add(0, 0, -1))) list.add(new BlockPosWithFacing(bp.add(0, 0, -1), Direction.SOUTH)); @@ -255,22 +214,20 @@ public static boolean needSneak(Block in) { } public static boolean placeBlock(BlockPos bp, Rotate rotate, Interact interact, PlaceMode mode, int slot, boolean returnSlot, boolean ignoreEntities) { - int prevItem = mc.player.getInventory().selectedSlot; + int prevItem = mc.player.getInventory().getSelectedSlot(); if (slot != -1) GInvUtils.switchTo(slot); else return false; boolean result = placeBlock(bp, rotate, interact, mode, ignoreEntities); - if (returnSlot) GInvUtils.switchTo(prevItem); return result; } public static boolean placeBlock(BlockPos bp, Rotate rotate, Interact interact, PlaceMode mode, @NotNull SearchInvResult invResult, boolean returnSlot, boolean ignoreEntities) { - int prevItem = mc.player.getInventory().selectedSlot; + int prevItem = mc.player.getInventory().getSelectedSlot(); invResult.switchTo(); boolean result = placeBlock(bp, rotate, interact, mode, ignoreEntities); if (returnSlot) GInvUtils.switchTo(prevItem); - return result; } @@ -283,15 +240,12 @@ public static boolean placeBlock(BlockPos bp, Rotate rotate, Interact interact, if (sprint) mc.player.networkHandler.sendPacket(new ClientCommandC2SPacket(mc.player, ClientCommandC2SPacket.Mode.STOP_SPRINTING)); - if (sneak) - mc.player.networkHandler.sendPacket(new ClientCommandC2SPacket(mc.player, ClientCommandC2SPacket.Mode.PRESS_SHIFT_KEY)); + if (sneak) mc.player.setSneaking(true); float[] angle = calculateAngle(result.getPos()); switch (rotate) { - case None -> { - - } + case None -> {} case Default -> mc.player.networkHandler.sendPacket(new PlayerMoveC2SPacket.LookAndOnGround(angle[0], angle[1], mc.player.isOnGround(), mc.player.horizontalCollision)); case Grim -> mc.player.networkHandler.sendPacket(new PlayerMoveC2SPacket.Full(mc.player.getX(), mc.player.getY(), mc.player.getZ(), angle[0], angle[1], mc.player.isOnGround(), mc.player.horizontalCollision)); } @@ -307,8 +261,7 @@ public static boolean placeBlock(BlockPos bp, Rotate rotate, Interact interact, if (rotate == Rotate.Grim) mc.player.networkHandler.sendPacket(new PlayerMoveC2SPacket.Full(mc.player.getX(), mc.player.getY(), mc.player.getZ(), mc.player.getYaw(), mc.player.getPitch(), mc.player.isOnGround(), mc.player.horizontalCollision)); - if (sneak) - mc.player.networkHandler.sendPacket(new ClientCommandC2SPacket(mc.player, ClientCommandC2SPacket.Mode.RELEASE_SHIFT_KEY)); + if (sneak) mc.player.setSneaking(false); // ← was RELEASE_SHIFT_KEY if (sprint) mc.player.networkHandler.sendPacket(new ClientCommandC2SPacket(mc.player, ClientCommandC2SPacket.Mode.START_SPRINTING)); @@ -317,25 +270,9 @@ public static boolean placeBlock(BlockPos bp, Rotate rotate, Interact interact, return true; } - public record BlockPosWithFacing(BlockPos position, Direction facing) { - } - - public enum PlaceMode { - Packet, - Normal - } - - public enum Rotate { - None, - Default, - Grim - } - - public enum Interact { - Vanilla, - Strict, - Legit, - AirPlace - } + public record BlockPosWithFacing(BlockPos position, Direction facing) {} + public enum PlaceMode { Packet, Normal } + public enum Rotate { None, Default, Grim } + public enum Interact { Vanilla, Strict, Legit, AirPlace } } diff --git a/src/main/java/com/genyo/utils/player/MovementUtil.java b/src/main/java/com/genyo/utils/player/MovementUtil.java index c304578..28f54c7 100644 --- a/src/main/java/com/genyo/utils/player/MovementUtil.java +++ b/src/main/java/com/genyo/utils/player/MovementUtil.java @@ -1,36 +1,29 @@ package com.genyo.utils.player; +import com.genyo.mixin.accessor.AccessorInput; import net.minecraft.enchantment.Enchantments; import net.minecraft.entity.EquipmentSlot; import net.minecraft.util.math.MathHelper; +import net.minecraft.util.math.Vec2f; import static meteordevelopment.meteorclient.MeteorClient.mc; public class MovementUtil { - public static void applySneak() - { + public static void applySneak() { final float modifier = MathHelper.clamp(0.3f + (EnchantmentUtil.getLevel(mc.player.getEquippedStack(EquipmentSlot.FEET), Enchantments.SWIFT_SNEAK) * 0.15F), 0.0f, 1.0f); - mc.player.input.movementForward *= modifier; - mc.player.input.movementSideways *= modifier; + Vec2f vec = mc.player.input.getMovementInput(); + ((AccessorInput) mc.player.input).setMovementVector(new Vec2f(vec.x * modifier, vec.y * modifier)); } - /** - * @return - */ - public static boolean isInputtingMovement() - { + public static boolean isInputtingMovement() { return mc.options.forwardKey.isPressed() || mc.options.backKey.isPressed() || mc.options.leftKey.isPressed() || mc.options.rightKey.isPressed(); } - /** - * @return - */ - public static boolean isMoving() - { + public static boolean isMoving() { double d = mc.player.getX() - mc.player.lastRenderX; double e = mc.player.getY() - mc.player.lastRenderY; double f = mc.player.getZ() - mc.player.lastRenderZ; @@ -45,8 +38,8 @@ public static double[] forwardWithoutStrafe(final double d) { } public static double[] forward(final double d) { - float f = mc.player.input.movementForward; - float f2 = mc.player.input.movementSideways; + float f = mc.player.input.getMovementInput().y; + float f2 = mc.player.input.getMovementInput().x; float f3 = mc.player.getYaw(); if (f != 0.0f) { if (f2 > 0.0f) { @@ -68,13 +61,8 @@ public static double[] forward(final double d) { return new double[]{d4, d5}; } - /** - * @return - */ - public static boolean isMovingInput() - { - return mc.player.input.movementForward != 0.0f - || mc.player.input.movementSideways != 0.0f; + public static boolean isMovingInput() { + Vec2f vec = mc.player.input.getMovementInput(); + return vec.y != 0.0f || vec.x != 0.0f; } - } diff --git a/src/main/java/com/genyo/utils/player/SearchInvResult.java b/src/main/java/com/genyo/utils/player/SearchInvResult.java index 434fa4f..5584c33 100644 --- a/src/main/java/com/genyo/utils/player/SearchInvResult.java +++ b/src/main/java/com/genyo/utils/player/SearchInvResult.java @@ -21,7 +21,7 @@ public static SearchInvResult notFound() { public boolean isHolding() { if (mc.player == null) return false; - return mc.player.getInventory().selectedSlot == slot; + return mc.player.getInventory().getSelectedSlot() == slot; } public boolean isInHotBar() { diff --git a/src/main/java/com/genyo/utils/render/SInterpolation.java b/src/main/java/com/genyo/utils/render/SInterpolation.java index 4c9a87b..14dc9b5 100644 --- a/src/main/java/com/genyo/utils/render/SInterpolation.java +++ b/src/main/java/com/genyo/utils/render/SInterpolation.java @@ -8,32 +8,32 @@ public class SInterpolation { /** - * @param prev + * @param last * @param value * @param factor * @return */ - public static double interpolateDouble(double prev, double value, double factor) + public static double interpolateDouble(double last, double value, double factor) { - return prev + ((value - prev) * factor); + return last + ((value - last) * factor); } /** - * @param prevBox + * @param lastBox * @param box * @return */ - public static Box getInterpolatedBox(Box prevBox, Box box) + public static Box getInterpolatedBox(Box lastBox, Box box) { - double delta = mc.isPaused() ? 1f : mc.getRenderTickCounter().getTickDelta(true); + double delta = mc.isPaused() ? 1f : mc.getRenderTickCounter().getTickProgress(true); - return new Box(interpolateDouble(prevBox.minX, box.minX, delta), - interpolateDouble(prevBox.minY, box.minY, delta), - interpolateDouble(prevBox.minZ, box.minZ, delta), - interpolateDouble(prevBox.maxX, box.maxX, delta), - interpolateDouble(prevBox.maxY, box.maxY, delta), - interpolateDouble(prevBox.maxZ, box.maxZ, delta)); + return new Box(interpolateDouble(lastBox.minX, box.minX, delta), + interpolateDouble(lastBox.minY, box.minY, delta), + interpolateDouble(lastBox.minZ, box.minZ, delta), + interpolateDouble(lastBox.maxX, box.maxX, delta), + interpolateDouble(lastBox.maxY, box.maxY, delta), + interpolateDouble(lastBox.maxZ, box.maxZ, delta)); } /** @@ -43,8 +43,8 @@ public static Box getInterpolatedBox(Box prevBox, Box box) public static Box getInterpolatedEntityBox(Entity entity) { Box box = entity.getBoundingBox(); - Box prevBox = entity.getBoundingBox().offset(entity.prevX - entity.getX(), entity.prevY - entity.getY(), entity.prevZ - entity.getZ()); - return getInterpolatedBox(prevBox, box); + Box lastBox = entity.getBoundingBox().offset(entity.lastX - entity.getX(), entity.lastY - entity.getY(), entity.lastZ - entity.getZ()); + return getInterpolatedBox(lastBox, box); } } diff --git a/src/main/java/com/genyo/utils/world/ExplosionUtil.java b/src/main/java/com/genyo/utils/world/ExplosionUtil.java index 41119d3..a950918 100644 --- a/src/main/java/com/genyo/utils/world/ExplosionUtil.java +++ b/src/main/java/com/genyo/utils/world/ExplosionUtil.java @@ -24,6 +24,8 @@ import net.minecraft.world.RaycastContext; import org.apache.commons.lang3.mutable.MutableInt; +import java.util.ArrayList; +import java.util.List; import java.util.Set; import java.util.function.BiFunction; @@ -97,9 +99,9 @@ public static double getDamageTo(final Entity entity, Vec3d vec3d2 = Vec3d.ZERO; if (extrapolationTicks != 0) { - double ox = (x - entity.prevX) * extrapolationTicks; - double oy = (y - entity.prevY) * extrapolationTicks * 0.3; - double oz = (z - entity.prevZ) * extrapolationTicks; + double ox = (x - entity.lastRenderX) * extrapolationTicks; + double oy = (y - entity.lastRenderY) * extrapolationTicks * 0.3; + double oz = (z - entity.lastRenderZ) * extrapolationTicks; x += ox; y += oy; z += oz; @@ -150,9 +152,9 @@ public static double getDamageTo(final Entity entity, Vec3d vec3d2 = Vec3d.ZERO; if (extrapolationTicks != 0) { - double ox = (x - entity.prevX) * extrapolationTicks; - double oy = (y - entity.prevY) * extrapolationTicks * 0.3; - double oz = (z - entity.prevZ) * extrapolationTicks; + double ox = (x - entity.lastRenderX) * extrapolationTicks; + double oy = (y - entity.lastRenderY) * extrapolationTicks * 0.3; + double oz = (z - entity.lastRenderZ) * extrapolationTicks; x += ox; y += oy; z += oz; @@ -193,9 +195,9 @@ public static double getDamageTo(final Entity entity, Vec3d vec3d2 = Vec3d.ZERO; if (extrapolationTicks != 0) { - double ox = (x - entity.prevX) * extrapolationTicks; - double oy = (y - entity.prevY) * extrapolationTicks * 0.3; - double oz = (z - entity.prevZ) * extrapolationTicks; + double ox = (x - entity.lastRenderX) * extrapolationTicks; + double oy = (y - entity.lastRenderY) * extrapolationTicks * 0.3; + double oz = (z - entity.lastRenderZ) * extrapolationTicks; x += ox; y += oy; z += oz; @@ -231,9 +233,9 @@ public static double getDamageTo(final Entity entity, Vec3d vec3d2 = Vec3d.ZERO; if (extrapolationTicks != 0) { - double ox = (x - entity.prevX) * extrapolationTicks; - double oy = (y - entity.prevY) * extrapolationTicks * 0.3; - double oz = (z - entity.prevZ) * extrapolationTicks; + double ox = (x - entity.lastRenderX) * extrapolationTicks; + double oy = (y - entity.lastRenderY) * extrapolationTicks * 0.3; + double oz = (z - entity.lastRenderZ) * extrapolationTicks; x += ox; y += oy; z += oz; @@ -312,7 +314,12 @@ private static float getArmor(LivingEntity entity) private static float getProtectionReduction(Entity player, double damage, DamageSource source, boolean assumeBestArmor) { if (player instanceof LivingEntity livingEntity) { - float protLevel = getProtectionAmount(livingEntity.getArmorItems(), assumeBestArmor); + List armorItems = new ArrayList<>(); + armorItems.add(livingEntity.getEquippedStack(EquipmentSlot.HEAD)); + armorItems.add(livingEntity.getEquippedStack(EquipmentSlot.CHEST)); + armorItems.add(livingEntity.getEquippedStack(EquipmentSlot.LEGS)); + armorItems.add(livingEntity.getEquippedStack(EquipmentSlot.FEET)); + float protLevel = getProtectionAmount(armorItems, assumeBestArmor); return DamageUtil.getInflictedDamage((float) damage, protLevel); } return 0.0f; diff --git a/src/main/resources/assets/genyo/sounds.json b/src/main/resources/assets/genyo/sounds.json index de913d0..1ff2a2c 100644 --- a/src/main/resources/assets/genyo/sounds.json +++ b/src/main/resources/assets/genyo/sounds.json @@ -33,5 +33,20 @@ "sounds": [ "genyo:kiwi" ] + }, + "gui_hover": { + "sounds": [ + "genyo:gui_hover" + ] + }, + "gui_click_left": { + "sounds": [ + "genyo:gui_click_left" + ] + }, + "gui_click_right": { + "sounds": [ + "genyo:gui_click_right" + ] } } diff --git a/src/main/resources/assets/genyo/sounds/gui_click_left.ogg b/src/main/resources/assets/genyo/sounds/gui_click_left.ogg new file mode 100644 index 0000000..6a2fa61 Binary files /dev/null and b/src/main/resources/assets/genyo/sounds/gui_click_left.ogg differ diff --git a/src/main/resources/assets/genyo/sounds/gui_click_right.ogg b/src/main/resources/assets/genyo/sounds/gui_click_right.ogg new file mode 100644 index 0000000..10b4e68 Binary files /dev/null and b/src/main/resources/assets/genyo/sounds/gui_click_right.ogg differ diff --git a/src/main/resources/assets/genyo/sounds/gui_hover.ogg b/src/main/resources/assets/genyo/sounds/gui_hover.ogg new file mode 100644 index 0000000..db19ed0 Binary files /dev/null and b/src/main/resources/assets/genyo/sounds/gui_hover.ogg differ diff --git a/src/main/resources/assets/genyo/textures/cape_dev.png b/src/main/resources/assets/genyo/textures/cape_dev.png new file mode 100644 index 0000000..2168b42 Binary files /dev/null and b/src/main/resources/assets/genyo/textures/cape_dev.png differ diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 134048b..6002625 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -6,7 +6,8 @@ "description": "Utility Meteor addon powered by special people's special minds.", "authors": [ "wuritz", - "Barnika18" + "Barnika18", + "Awakeyv" ], "contact": { "homepage": "https://genyo.dev", diff --git a/src/main/resources/genyo.accesswidener b/src/main/resources/genyo.accesswidener index 6345181..50960f1 100644 --- a/src/main/resources/genyo.accesswidener +++ b/src/main/resources/genyo.accesswidener @@ -1,16 +1,14 @@ -accessWidener v1 named +accessWidener v1 named accessible class net/minecraft/network/packet/c2s/play/PlayerInteractEntityC2SPacket$InteractTypeHandler accessible class net/minecraft/network/packet/c2s/play/PlayerInteractEntityC2SPacket$InteractType accessible class net/minecraft/network/packet/c2s/play/PlayerInteractEntityC2SPacket accessible field net/minecraft/client/network/ClientPlayerEntity lastSprinting Z -accessible field net/minecraft/client/render/chunk/ChunkBuilder$ChunkData nonEmptyLayers Ljava/util/Set; -accessible field net/minecraft/client/render/chunk/ChunkBuilder$ChunkData occlusionGraph Lnet/minecraft/client/render/chunk/ChunkOcclusionData; accessible field net/minecraft/entity/projectile/FishingBobberEntity CAUGHT_FISH Lnet/minecraft/entity/data/TrackedData; accessible field net/minecraft/network/packet/c2s/play/PlayerMoveC2SPacket onGround Z accessible field net/minecraft/network/packet/c2s/play/PlayerMoveC2SPacket pitch F accessible field net/minecraft/network/packet/c2s/play/ChatMessageC2SPacket chatMessage Ljava/lang/String; -accessible field net/minecraft/entity/LimbAnimator pos F +accessible field net/minecraft/entity/LimbAnimator speed F accessible field net/minecraft/network/packet/s2c/play/PlayerRemoveS2CPacket profileIds Ljava/util/List; accessible field net/minecraft/client/network/ClientPlayerInteractionManager currentBreakingProgress F accessible field net/minecraft/client/Mouse cursorDeltaY D diff --git a/src/main/resources/genyo.mixins.json b/src/main/resources/genyo.mixins.json index 3bde77a..45f8185 100644 --- a/src/main/resources/genyo.mixins.json +++ b/src/main/resources/genyo.mixins.json @@ -16,6 +16,7 @@ "accessor.AccessorClientWorld", "accessor.AccessorGameOptions", "accessor.AccessorKeyBinding", + "accessor.AccessorInput", "entity.player.MixinPlayerListEntry", "game.MixinSplashTextResourceSupplier", "game.MixinTitleScreen", @@ -42,6 +43,7 @@ "entity.player.MixinPlayerEntity", "game.MixinMinecraftClient", "meteor.MixinBetterTab", + "meteor.MixinWWidget", "network.MixinDecoderHandler", "network.MixinServerPlayerEntity", "world.MixinBlockCollisionSpliterator"