diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000000..e91c4ffc88 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,22 @@ +## Type of change + +- [ ] Bug fix +- [ ] New feature + +## Description + +A summary of the changes along with the reasoning behind the changes. + +## Related issues + +Mention any issues that this pr relates to. + +# How Has This Been Tested? + +Videos or screenshots of the changes if applicable. + +# Checklist: + +- [ ] My code follows the style guidelines of this project. +- [ ] I have added comments to my code in more complex areas. +- [ ] I have tested the code in both development and production environments. diff --git a/.github/workflows/issue-moderator.yml b/.github/workflows/issue-moderator.yml new file mode 100644 index 0000000000..dc686c7d2a --- /dev/null +++ b/.github/workflows/issue-moderator.yml @@ -0,0 +1,33 @@ +name: Issue automatic actions + +on: + issues: + types: [opened] + +permissions: + issues: write + +jobs: + issue-moderator: + runs-on: ubuntu-latest + steps: + - name: Similarity analysis + uses: actions-cool/issues-similarity-analysis@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + filter-threshold: 0.60 + title-excludes: '' + comment-title: | + ### Your issue looks similar to these issues: + Please close if duplicate. + comment-body: '${index}. ${similarity} #${number}' + - uses: actions/checkout@v2 + - name: Automatically close issues that don't follow the issue template + uses: lucasbento/auto-close-issues@v1.0.2 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + issue-close-message: | + @${issue.user.login}: hello! :wave: + This issue is being automatically closed because it does not follow the issue template." + closed-issues-label: "invalid" + diff --git a/build.gradle b/build.gradle index 48fed85b4b..a5f45893dc 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,7 @@ plugins { - id 'fabric-loom' version '1.0-SNAPSHOT' - id 'maven-publish' - id 'com.github.johnrengelman.shadow' version '7.1.2' + id "fabric-loom" version "1.1-SNAPSHOT" + id "maven-publish" + id "com.github.johnrengelman.shadow" version "7.1.2" } sourceCompatibility = targetCompatibility = JavaVersion.VERSION_17 @@ -45,11 +45,11 @@ configurations { dependencies { // Fabric - minecraft "com.mojang:minecraft:${project.minecraft_version}" - mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" - modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" + minecraft "com.mojang:minecraft:${project.minecraft_version}" + mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" + modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" - // Fabric API + // Fabric API modImplementation("net.fabricmc.fabric-api:fabric-api:${project.fapi_version}") shadow(fabricApi.module("fabric-api-base", project.fapi_version)) { transitive = false @@ -57,6 +57,7 @@ dependencies { // Compat fixes modCompileOnly("maven.modrinth:sodium:${project.sodium_version}") { transitive = false } + modCompileOnly("maven.modrinth:lithium:${project.lithium_version}") { transitive = false } //modCompileOnly("io.vram:canvas-fabric-mc119:1.0.+") { transitive = false } // TODO: 1.19.3 // Baritone (https://github.com/MeteorDevelopment/baritone) @@ -86,6 +87,12 @@ afterEvaluate { shadowJar { configurations = [ project.configurations.shadow ] + + dependencies { + exclude { + it.moduleGroup == "org.slf4j" + } + } } processResources { @@ -104,7 +111,7 @@ remapJar { } javadoc { - options.addStringOption('Xdoclint:none', '-quiet') + options.addStringOption("Xdoclint:none", "-quiet") options.encoding = "UTF-8" } diff --git a/gradle.properties b/gradle.properties index 95738dc889..eee5cc36eb 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,20 +1,23 @@ org.gradle.jvmargs=-Xmx2G # Fabric (https://fabricmc.net/develop) -minecraft_version=1.19.3 -yarn_mappings=1.19.3+build.2 -loader_version=0.14.11 -fapi_version=0.69.1+1.19.3 +minecraft_version=1.19.4 +yarn_mappings=1.19.4+build.1 +loader_version=0.14.17 +fapi_version=0.75.3+1.19.4 # Mod Properties -mod_version=0.5.2 +mod_version=0.5.3 maven_group=meteordevelopment archives_base_name=meteor-client # Dependency Versions # Sodium (https://github.com/CaffeineMC/sodium-fabric) -sodium_version=mc1.19.3-0.4.6 +sodium_version=mc1.19.4-0.4.10 + +# Lithium (https://github.com/CaffeineMC/lithium-fabric) +lithium_version=mc1.19.4-0.11.1 # Orbit (https://github.com/MeteorDevelopment/orbit) orbit_version=0.2.3 @@ -23,7 +26,7 @@ orbit_version=0.2.3 starscript_version=0.2.2 # LibJF (https://gitlab.com/jfmods/libjf) -libjf_version=3.3.1 +libjf_version=3.7.0 # Reflections (https://github.com/ronmamo/reflections) reflections_version=0.10.2 diff --git a/src/main/java/meteordevelopment/meteorclient/MeteorClient.java b/src/main/java/meteordevelopment/meteorclient/MeteorClient.java index 2e19329823..b9949b5a97 100644 --- a/src/main/java/meteordevelopment/meteorclient/MeteorClient.java +++ b/src/main/java/meteordevelopment/meteorclient/MeteorClient.java @@ -42,18 +42,25 @@ public class MeteorClient implements ClientModInitializer { public static final String MOD_ID = "meteor-client"; - public static final ModMetadata MOD_META = FabricLoader.getInstance().getModContainer(MOD_ID).get().getMetadata(); - public final static Version VERSION; - public final static String DEV_BUILD = ""; + public static final ModMetadata MOD_META; + public static final String NAME; + public static final Version VERSION; + public static final String DEV_BUILD = ""; + + public static MeteorClient INSTANCE; public static MeteorAddon ADDON; public static MinecraftClient mc; - public static MeteorClient INSTANCE; public static final IEventBus EVENT_BUS = new EventBus(); - public static final File FOLDER = new File(FabricLoader.getInstance().getGameDir().toString(), MOD_ID); - public static final Logger LOG = LoggerFactory.getLogger("Meteor Client"); + public static final File FOLDER = FabricLoader.getInstance().getGameDir().resolve(MOD_ID).toFile(); + public static final Logger LOG; static { + MOD_META = FabricLoader.getInstance().getModContainer(MOD_ID).orElseThrow().getMetadata(); + + NAME = MOD_META.getName(); + LOG = LoggerFactory.getLogger(NAME); + String versionString = MOD_META.getVersion().getFriendlyString(); if (versionString.contains("-")) versionString = versionString.split("-")[0]; @@ -62,12 +69,14 @@ public class MeteorClient implements ClientModInitializer { @Override public void onInitializeClient() { + KeyBinds.ensureInitialized(); + if (INSTANCE == null) { INSTANCE = this; return; } - LOG.info("Initializing Meteor Client"); + LOG.info("Initializing {}", NAME); // Global minecraft client accessor mc = MinecraftClient.getInstance(); diff --git a/src/main/java/meteordevelopment/meteorclient/MixinPlugin.java b/src/main/java/meteordevelopment/meteorclient/MixinPlugin.java index 0eed3a03db..ec93d4c9dd 100644 --- a/src/main/java/meteordevelopment/meteorclient/MixinPlugin.java +++ b/src/main/java/meteordevelopment/meteorclient/MixinPlugin.java @@ -21,6 +21,7 @@ public class MixinPlugin implements IMixinConfigPlugin { private static boolean isOriginsPresent; private static boolean isSodiumPresent; private static boolean isCanvasPresent; + private static boolean isLithiumPresent; @Override public void onLoad(String mixinPackage) { @@ -29,6 +30,7 @@ public void onLoad(String mixinPackage) { isOriginsPresent = FabricLoader.getInstance().isModLoaded("origins"); isSodiumPresent = FabricLoader.getInstance().isModLoaded("sodium"); isCanvasPresent = FabricLoader.getInstance().isModLoaded("canvas"); + isLithiumPresent = FabricLoader.getInstance().isModLoaded("lithium"); loaded = true; } @@ -52,6 +54,9 @@ else if (mixinClassName.startsWith(mixinPackage + ".sodium")) { else if (mixinClassName.startsWith(mixinPackage + ".canvas")) { return isCanvasPresent; } + else if (mixinClassName.startsWith(mixinPackage + ".lithium")) { + return isLithiumPresent; + } return true; diff --git a/src/main/java/meteordevelopment/meteorclient/events/entity/player/BlockBreakingCooldownEvent.java b/src/main/java/meteordevelopment/meteorclient/events/entity/player/BlockBreakingCooldownEvent.java new file mode 100644 index 0000000000..837a8b977b --- /dev/null +++ b/src/main/java/meteordevelopment/meteorclient/events/entity/player/BlockBreakingCooldownEvent.java @@ -0,0 +1,17 @@ +/* + * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). + * Copyright (c) Meteor Development. + */ + +package meteordevelopment.meteorclient.events.entity.player; + +public class BlockBreakingCooldownEvent { + private static final BlockBreakingCooldownEvent INSTANCE = new BlockBreakingCooldownEvent(); + + public int cooldown; + + public static BlockBreakingCooldownEvent get(int cooldown) { + INSTANCE.cooldown = cooldown; + return INSTANCE; + } +} diff --git a/src/main/java/meteordevelopment/meteorclient/events/entity/player/CobwebEntityCollisionEvent.java b/src/main/java/meteordevelopment/meteorclient/events/entity/player/CobwebEntityCollisionEvent.java deleted file mode 100644 index 662a700cd7..0000000000 --- a/src/main/java/meteordevelopment/meteorclient/events/entity/player/CobwebEntityCollisionEvent.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). - * Copyright (c) Meteor Development. - */ - -package meteordevelopment.meteorclient.events.entity.player; - -import meteordevelopment.meteorclient.events.Cancellable; -import net.minecraft.block.BlockState; -import net.minecraft.util.math.BlockPos; - -public class CobwebEntityCollisionEvent extends Cancellable { - private static final CobwebEntityCollisionEvent INSTANCE = new CobwebEntityCollisionEvent(); - - public BlockState state; - public BlockPos blockPos; - - public static CobwebEntityCollisionEvent get(BlockState state, BlockPos blockPos) { - INSTANCE.setCancelled(false); - INSTANCE.state = state; - INSTANCE.blockPos = blockPos; - return INSTANCE; - } -} diff --git a/src/main/java/meteordevelopment/meteorclient/events/packets/PacketEvent.java b/src/main/java/meteordevelopment/meteorclient/events/packets/PacketEvent.java index db2faa63fa..bac2ba9376 100644 --- a/src/main/java/meteordevelopment/meteorclient/events/packets/PacketEvent.java +++ b/src/main/java/meteordevelopment/meteorclient/events/packets/PacketEvent.java @@ -6,7 +6,7 @@ package meteordevelopment.meteorclient.events.packets; import meteordevelopment.meteorclient.events.Cancellable; -import net.minecraft.network.Packet; +import net.minecraft.network.packet.Packet; public class PacketEvent extends Cancellable { public Packet packet; diff --git a/src/main/java/meteordevelopment/meteorclient/events/world/CollisionShapeEvent.java b/src/main/java/meteordevelopment/meteorclient/events/world/CollisionShapeEvent.java index f34f3a8bec..492c23d300 100644 --- a/src/main/java/meteordevelopment/meteorclient/events/world/CollisionShapeEvent.java +++ b/src/main/java/meteordevelopment/meteorclient/events/world/CollisionShapeEvent.java @@ -5,28 +5,22 @@ package meteordevelopment.meteorclient.events.world; +import meteordevelopment.meteorclient.events.Cancellable; import net.minecraft.block.BlockState; import net.minecraft.util.math.BlockPos; import net.minecraft.util.shape.VoxelShape; -public class CollisionShapeEvent { - public enum CollisionType { - BLOCK, - FLUID - } - +public class CollisionShapeEvent extends Cancellable { private static final CollisionShapeEvent INSTANCE = new CollisionShapeEvent(); public BlockState state; public BlockPos pos; public VoxelShape shape; - public CollisionType type; - public static CollisionShapeEvent get(BlockState state, BlockPos pos, CollisionType type) { + public static CollisionShapeEvent get(BlockState state, BlockPos pos, VoxelShape shape) { INSTANCE.state = state; INSTANCE.pos = pos; - INSTANCE.shape = null; - INSTANCE.type = type; + INSTANCE.shape = shape; return INSTANCE; } } diff --git a/src/main/java/meteordevelopment/meteorclient/gui/DefaultSettingsWidgetFactory.java b/src/main/java/meteordevelopment/meteorclient/gui/DefaultSettingsWidgetFactory.java index 379827e369..f127ad39ac 100644 --- a/src/main/java/meteordevelopment/meteorclient/gui/DefaultSettingsWidgetFactory.java +++ b/src/main/java/meteordevelopment/meteorclient/gui/DefaultSettingsWidgetFactory.java @@ -61,6 +61,7 @@ public DefaultSettingsWidgetFactory(GuiTheme theme) { factories.put(StatusEffectAmplifierMapSetting.class, (table, setting) -> statusEffectAmplifierMapW(table, (StatusEffectAmplifierMapSetting) setting)); factories.put(StatusEffectListSetting.class, (table, setting) -> statusEffectListW(table, (StatusEffectListSetting) setting)); factories.put(StorageBlockListSetting.class, (table, setting) -> storageBlockListW(table, (StorageBlockListSetting) setting)); + factories.put(ScreenHandlerListSetting.class, (table, setting) -> screenHandlerListW(table, (ScreenHandlerListSetting) setting)); factories.put(BlockDataSetting.class, (table, setting) -> blockDataW(table, (BlockDataSetting) setting)); factories.put(PotionSetting.class, (table, setting) -> potionW(table, (PotionSetting) setting)); factories.put(StringListSetting.class, (table, setting) -> stringListW(table, (StringListSetting) setting)); @@ -229,9 +230,14 @@ private void colorW(WTable table, ColorSetting setting) { } private void keybindW(WTable table, KeybindSetting setting) { - WKeybind keybind = table.add(theme.keybind(setting.get(), setting.getDefaultValue())).expandX().widget(); + WHorizontalList list = table.add(theme.horizontalList()).expandX().widget(); + + WKeybind keybind = list.add(theme.keybind(setting.get(), setting.getDefaultValue())).expandX().widget(); keybind.action = setting::onChanged; setting.widget = keybind; + + WButton reset = list.add(theme.button(GuiRenderer.RESET)).expandCellX().right().widget(); + reset.action = keybind::resetBind; } private void blockW(WTable table, BlockSetting setting) { @@ -320,6 +326,10 @@ private void storageBlockListW(WTable table, StorageBlockListSetting setting) { selectW(table, setting, () -> mc.setScreen(new StorageBlockListSettingScreen(theme, setting))); } + private void screenHandlerListW(WTable table, ScreenHandlerListSetting setting) { + selectW(table, setting, () -> mc.setScreen(new ScreenHandlerSettingScreen(theme, setting))); + } + private void blockDataW(WTable table, BlockDataSetting setting) { WButton button = table.add(theme.button(GuiRenderer.EDIT)).expandCellX().widget(); button.action = () -> mc.setScreen(new BlockDataSettingScreen(theme, setting)); diff --git a/src/main/java/meteordevelopment/meteorclient/gui/screens/ModuleScreen.java b/src/main/java/meteordevelopment/meteorclient/gui/screens/ModuleScreen.java index 46ab561b4e..22e14a8596 100644 --- a/src/main/java/meteordevelopment/meteorclient/gui/screens/ModuleScreen.java +++ b/src/main/java/meteordevelopment/meteorclient/gui/screens/ModuleScreen.java @@ -5,15 +5,18 @@ package meteordevelopment.meteorclient.gui.screens; +import meteordevelopment.meteorclient.events.meteor.ActiveModulesChangedEvent; import meteordevelopment.meteorclient.events.meteor.ModuleBindChangedEvent; import meteordevelopment.meteorclient.gui.GuiTheme; import meteordevelopment.meteorclient.gui.WindowScreen; +import meteordevelopment.meteorclient.gui.renderer.GuiRenderer; import meteordevelopment.meteorclient.gui.utils.Cell; import meteordevelopment.meteorclient.gui.widgets.WKeybind; import meteordevelopment.meteorclient.gui.widgets.WWidget; import meteordevelopment.meteorclient.gui.widgets.containers.WContainer; import meteordevelopment.meteorclient.gui.widgets.containers.WHorizontalList; import meteordevelopment.meteorclient.gui.widgets.containers.WSection; +import meteordevelopment.meteorclient.gui.widgets.pressable.WButton; import meteordevelopment.meteorclient.gui.widgets.pressable.WCheckbox; import meteordevelopment.meteorclient.gui.widgets.pressable.WFavorite; import meteordevelopment.meteorclient.systems.modules.Module; @@ -29,6 +32,7 @@ public class ModuleScreen extends WindowScreen { private WContainer settingsContainer; private WKeybind keybind; + private WCheckbox active; public ModuleScreen(GuiTheme theme, Module module) { super(theme, theme.favorite(module.favorite), module.title); @@ -59,9 +63,17 @@ public void initWidgets() { // Bind WSection section = add(theme.section("Bind", true)).expandX().widget(); - keybind = section.add(theme.keybind(module.keybind)).expandX().widget(); + + // Keybind + WHorizontalList bind = section.add(theme.horizontalList()).expandX().widget(); + + bind.add(theme.label("Bind: ")); + keybind = bind.add(theme.keybind(module.keybind)).expandX().widget(); keybind.actionOnSet = () -> Modules.get().setModuleToBind(module); + WButton reset = bind.add(theme.button(GuiRenderer.RESET)).expandCellX().right().widget(); + reset.action = keybind::resetBind; + // Toggle on bind release WHorizontalList tobr = section.add(theme.horizontalList()).widget(); @@ -83,7 +95,7 @@ public void initWidgets() { // Active bottom.add(theme.label("Active: ")); - WCheckbox active = bottom.add(theme.checkbox(module.isActive())).expandCellX().widget(); + active = bottom.add(theme.checkbox(module.isActive())).expandCellX().widget(); active.action = () -> { if (module.isActive() != active.checked) module.toggle(); }; @@ -106,6 +118,11 @@ private void onModuleBindChanged(ModuleBindChangedEvent event) { keybind.reset(); } + @EventHandler + private void onActiveModulesChanged(ActiveModulesChangedEvent event) { + this.active.checked = module.isActive(); + } + @Override public boolean toClipboard() { return NbtUtils.toClipboard(module.title, module.toTag()); diff --git a/src/main/java/meteordevelopment/meteorclient/gui/screens/settings/EntityTypeListSettingScreen.java b/src/main/java/meteordevelopment/meteorclient/gui/screens/settings/EntityTypeListSettingScreen.java index 12aa7991b1..4d8f23c0b6 100644 --- a/src/main/java/meteordevelopment/meteorclient/gui/screens/settings/EntityTypeListSettingScreen.java +++ b/src/main/java/meteordevelopment/meteorclient/gui/screens/settings/EntityTypeListSettingScreen.java @@ -69,7 +69,7 @@ public void initWidgets() { for (EntityType entityType : setting.get().keySet()) { if (!setting.get().getBoolean(entityType)) continue; - if (!setting.onlyAttackable || EntityUtils.isAttackable(entityType)) { + if (setting.filter == null || setting.filter.test(entityType)) { switch (entityType.getSpawnGroup()) { case CREATURE -> hasAnimal++; case WATER_AMBIENT, WATER_CREATURE, UNDERGROUND_WATER_CREATURE, AXOLOTLS -> hasWaterAnimal++; @@ -133,7 +133,7 @@ public void initWidgets() { miscT = misc.add(theme.table()).expandX().widget(); Consumer> entityTypeForEach = entityType -> { - if (!setting.onlyAttackable || EntityUtils.isAttackable(entityType)) { + if (setting.filter == null || setting.filter.test(entityType)) { switch (entityType.getSpawnGroup()) { case CREATURE -> { animalsE.add(entityType); diff --git a/src/main/java/meteordevelopment/meteorclient/gui/screens/settings/PacketBoolSettingScreen.java b/src/main/java/meteordevelopment/meteorclient/gui/screens/settings/PacketBoolSettingScreen.java index f899199bb9..c88d59137f 100644 --- a/src/main/java/meteordevelopment/meteorclient/gui/screens/settings/PacketBoolSettingScreen.java +++ b/src/main/java/meteordevelopment/meteorclient/gui/screens/settings/PacketBoolSettingScreen.java @@ -10,7 +10,7 @@ import meteordevelopment.meteorclient.settings.PacketListSetting; import meteordevelopment.meteorclient.settings.Setting; import meteordevelopment.meteorclient.utils.network.PacketUtils; -import net.minecraft.network.Packet; +import net.minecraft.network.packet.Packet; import java.util.Set; import java.util.function.Predicate; diff --git a/src/main/java/meteordevelopment/meteorclient/gui/screens/settings/ScreenHandlerSettingScreen.java b/src/main/java/meteordevelopment/meteorclient/gui/screens/settings/ScreenHandlerSettingScreen.java new file mode 100644 index 0000000000..8e6443b8b4 --- /dev/null +++ b/src/main/java/meteordevelopment/meteorclient/gui/screens/settings/ScreenHandlerSettingScreen.java @@ -0,0 +1,30 @@ +/* + * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). + * Copyright (c) Meteor Development. + */ + +package meteordevelopment.meteorclient.gui.screens.settings; + +import meteordevelopment.meteorclient.gui.GuiTheme; +import meteordevelopment.meteorclient.gui.widgets.WWidget; +import meteordevelopment.meteorclient.settings.Setting; +import net.minecraft.registry.Registries; +import net.minecraft.screen.ScreenHandlerType; + +import java.util.List; + +public class ScreenHandlerSettingScreen extends LeftRightListSettingScreen> { + public ScreenHandlerSettingScreen(GuiTheme theme, Setting>> setting) { + super(theme, "Select Screen Handlers", setting, setting.get(), Registries.SCREEN_HANDLER); + } + + @Override + protected WWidget getValueWidget(ScreenHandlerType value) { + return theme.label(getValueName(value)); + } + + @Override + protected String getValueName(ScreenHandlerType type) { + return Registries.SCREEN_HANDLER.getId(type).toString(); + } +} diff --git a/src/main/java/meteordevelopment/meteorclient/gui/tabs/builtin/FriendsTab.java b/src/main/java/meteordevelopment/meteorclient/gui/tabs/builtin/FriendsTab.java index c326c98a66..b5c1c305ec 100644 --- a/src/main/java/meteordevelopment/meteorclient/gui/tabs/builtin/FriendsTab.java +++ b/src/main/java/meteordevelopment/meteorclient/gui/tabs/builtin/FriendsTab.java @@ -76,6 +76,15 @@ private void initTable(WTable table) { table.clear(); if (Friends.get().isEmpty()) return; + Friends.get().forEach(friend -> + MeteorExecutor.execute(() -> { + if (friend.headTextureNeedsUpdate()) { + friend.updateInfo(); + reload(); + } + }) + ); + for (Friend friend : Friends.get()) { table.add(theme.texture(32, 32, friend.getHead().needsRotate() ? 90 : 0, friend.getHead())); table.add(theme.label(friend.getName())); diff --git a/src/main/java/meteordevelopment/meteorclient/gui/themes/meteor/MeteorGuiTheme.java b/src/main/java/meteordevelopment/meteorclient/gui/themes/meteor/MeteorGuiTheme.java index 7a8c895b61..0ef01422f1 100644 --- a/src/main/java/meteordevelopment/meteorclient/gui/themes/meteor/MeteorGuiTheme.java +++ b/src/main/java/meteordevelopment/meteorclient/gui/themes/meteor/MeteorGuiTheme.java @@ -32,6 +32,7 @@ import meteordevelopment.meteorclient.utils.render.color.SettingColor; import static meteordevelopment.meteorclient.MeteorClient.mc; +import static net.minecraft.client.MinecraftClient.IS_SYSTEM_MAC; public class MeteorGuiTheme extends GuiTheme { private final SettingGroup sgGeneral = settings.getDefaultGroup(); @@ -368,7 +369,13 @@ public TextRenderer textRenderer() { @Override public double scale(double value) { - return value * scale.get(); + double scaled = value * scale.get(); + + if (IS_SYSTEM_MAC) { + scaled /= (double) mc.getWindow().getWidth() / mc.getWindow().getFramebufferWidth(); + } + + return scaled; } @Override diff --git a/src/main/java/meteordevelopment/meteorclient/gui/utils/SettingsWidgetFactory.java b/src/main/java/meteordevelopment/meteorclient/gui/utils/SettingsWidgetFactory.java index ae5c238247..6e890fadf7 100644 --- a/src/main/java/meteordevelopment/meteorclient/gui/utils/SettingsWidgetFactory.java +++ b/src/main/java/meteordevelopment/meteorclient/gui/utils/SettingsWidgetFactory.java @@ -5,7 +5,6 @@ package meteordevelopment.meteorclient.gui.utils; -import meteordevelopment.meteorclient.gui.DefaultSettingsWidgetFactory; import meteordevelopment.meteorclient.gui.GuiTheme; import meteordevelopment.meteorclient.gui.widgets.WWidget; import meteordevelopment.meteorclient.gui.widgets.containers.WTable; @@ -17,7 +16,7 @@ import java.util.function.Function; public abstract class SettingsWidgetFactory { - private static final Map, Function> customFactories = new HashMap<>(); + private static final Map, Function> customFactories = new HashMap<>(); protected final GuiTheme theme; protected final Map, Factory> factories = new HashMap<>(); diff --git a/src/main/java/meteordevelopment/meteorclient/gui/widgets/WItem.java b/src/main/java/meteordevelopment/meteorclient/gui/widgets/WItem.java index e003fc4b0e..4a8f4071d7 100644 --- a/src/main/java/meteordevelopment/meteorclient/gui/widgets/WItem.java +++ b/src/main/java/meteordevelopment/meteorclient/gui/widgets/WItem.java @@ -5,7 +5,6 @@ package meteordevelopment.meteorclient.gui.widgets; -import com.mojang.blaze3d.systems.RenderSystem; import meteordevelopment.meteorclient.gui.renderer.GuiRenderer; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.item.ItemStack; @@ -13,6 +12,8 @@ import static meteordevelopment.meteorclient.MeteorClient.mc; public class WItem extends WWidget { + private static final MatrixStack MATRICES = new MatrixStack(); + protected ItemStack itemStack; public WItem(ItemStack itemStack) { @@ -33,15 +34,14 @@ protected void onRender(GuiRenderer renderer, double mouseX, double mouseY, doub renderer.post(() -> { double s = theme.scale(2); - MatrixStack matrices = RenderSystem.getModelViewStack(); - - matrices.push(); - matrices.scale((float) s, (float) s, 1); - matrices.translate(x / s, y / s, 0); + MATRICES.push(); + MATRICES.scale((float) s, (float) s, 1); + MATRICES.translate(x / s, y / s, 0); - mc.getItemRenderer().renderGuiItemIcon(itemStack, 0, 0); + mc.getItemRenderer().renderGuiItemIcon(MATRICES, itemStack, 0, 0); + mc.getItemRenderer().renderGuiItemOverlay(MATRICES, mc.textRenderer, itemStack, 0, 0); - matrices.pop(); + MATRICES.pop(); }); } } diff --git a/src/main/java/meteordevelopment/meteorclient/gui/widgets/WItemWithLabel.java b/src/main/java/meteordevelopment/meteorclient/gui/widgets/WItemWithLabel.java index 14a132a4b3..caaeeeed51 100644 --- a/src/main/java/meteordevelopment/meteorclient/gui/widgets/WItemWithLabel.java +++ b/src/main/java/meteordevelopment/meteorclient/gui/widgets/WItemWithLabel.java @@ -34,15 +34,20 @@ public void init() { private String getStringToAppend() { String str = ""; + if (itemStack.getItem() == Items.POTION) { List effects = PotionUtil.getPotion(itemStack).getEffects(); + if (effects.size() > 0) { str += " "; + StatusEffectInstance effect = effects.get(0); if (effect.getAmplifier() > 0) str += effect.getAmplifier() + 1 + " "; - str += "(" + StatusEffectUtil.durationToString(effect, 1) + ")"; + + str += "(" + StatusEffectUtil.durationToString(effect, 1).getString() + ")"; } } + return str; } diff --git a/src/main/java/meteordevelopment/meteorclient/gui/widgets/WKeybind.java b/src/main/java/meteordevelopment/meteorclient/gui/widgets/WKeybind.java index 3dc952d822..6115d26865 100644 --- a/src/main/java/meteordevelopment/meteorclient/gui/widgets/WKeybind.java +++ b/src/main/java/meteordevelopment/meteorclient/gui/widgets/WKeybind.java @@ -5,7 +5,6 @@ package meteordevelopment.meteorclient.gui.widgets; -import meteordevelopment.meteorclient.gui.renderer.GuiRenderer; import meteordevelopment.meteorclient.gui.widgets.containers.WHorizontalList; import meteordevelopment.meteorclient.gui.widgets.pressable.WButton; import meteordevelopment.meteorclient.systems.modules.Modules; @@ -33,14 +32,11 @@ public void init() { WButton set = add(theme.button("Set")).widget(); set.action = () -> { listening = true; - label.set(appendBindText("...")); + label.set("..."); if (actionOnSet != null) actionOnSet.run(); }; - WButton reset = add(theme.button(GuiRenderer.RESET)).expandCellX().right().widget(); - reset.action = this::resetBind; - refreshLabel(); } @@ -69,10 +65,6 @@ public void reset() { } private void refreshLabel() { - label.set(appendBindText(keybind.toString())); - } - - private String appendBindText(String text) { - return "Bind: " + text; + label.set(keybind.toString()); } } diff --git a/src/main/java/meteordevelopment/meteorclient/gui/widgets/containers/WTable.java b/src/main/java/meteordevelopment/meteorclient/gui/widgets/containers/WTable.java index 858edaae21..fa8baecb9c 100644 --- a/src/main/java/meteordevelopment/meteorclient/gui/widgets/containers/WTable.java +++ b/src/main/java/meteordevelopment/meteorclient/gui/widgets/containers/WTable.java @@ -65,6 +65,7 @@ public void removeRow(int i) { } public List> getRow(int i) { + if (i < 0 || i >= rows.size()) return null; return rows.get(i); } diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/AbstractBlockMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/AbstractBlockMixin.java index 5b262cd667..acea24a485 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/AbstractBlockMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/AbstractBlockMixin.java @@ -7,12 +7,9 @@ import meteordevelopment.meteorclient.MeteorClient; import meteordevelopment.meteorclient.events.world.AmbientOcclusionEvent; -import meteordevelopment.meteorclient.events.world.CollisionShapeEvent; import net.minecraft.block.AbstractBlock; import net.minecraft.block.BlockState; -import net.minecraft.block.ShapeContext; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.shape.VoxelShape; import net.minecraft.world.BlockView; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -27,17 +24,4 @@ private void onGetAmbientOcclusionLightLevel(BlockState state, BlockView world, if (event.lightLevel != -1) info.setReturnValue(event.lightLevel); } - - @Inject(method = "getCollisionShape", at = @At("HEAD"), cancellable = true) - private void onGetCollisionShape(BlockState state, BlockView view, BlockPos pos, ShapeContext context, CallbackInfoReturnable info) { - if (!(state.getFluidState().isEmpty())) { - CollisionShapeEvent event = MeteorClient.EVENT_BUS.post(CollisionShapeEvent.get(state.getFluidState().getBlockState(), pos, CollisionShapeEvent.CollisionType.FLUID)); - - if (event.shape != null) info.setReturnValue(event.shape); - } else { - CollisionShapeEvent event = MeteorClient.EVENT_BUS.post(CollisionShapeEvent.get(state, pos, CollisionShapeEvent.CollisionType.BLOCK)); - - if (event.shape != null) info.setReturnValue(event.shape); - } - } } diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/BannerBlockEntityRendererMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/BannerBlockEntityRendererMixin.java index e251cb20bb..c91b941616 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/BannerBlockEntityRendererMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/BannerBlockEntityRendererMixin.java @@ -34,7 +34,7 @@ public class BannerBlockEntityRendererMixin { @Final @Shadow private ModelPart crossbar; - @Inject(method = "render", at = @At("HEAD"), cancellable = true) + @Inject(method = "render(Lnet/minecraft/block/entity/BannerBlockEntity;FLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;II)V", at = @At("HEAD"), cancellable = true) private void render(BannerBlockEntity bannerBlockEntity, float f, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, int j, CallbackInfo ci) { if (bannerBlockEntity.getWorld() != null) { //Don't modify banners in item form NoRender.BannerRenderMode renderMode = Modules.get().get(NoRender.class).getBannerRenderMode(); diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/BeaconBlockEntityRendererMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/BeaconBlockEntityRendererMixin.java new file mode 100644 index 0000000000..7d2dc86390 --- /dev/null +++ b/src/main/java/meteordevelopment/meteorclient/mixin/BeaconBlockEntityRendererMixin.java @@ -0,0 +1,25 @@ +/* + * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). + * Copyright (c) Meteor Development. + */ + +package meteordevelopment.meteorclient.mixin; + +import meteordevelopment.meteorclient.systems.modules.Modules; +import meteordevelopment.meteorclient.systems.modules.render.NoRender; +import net.minecraft.block.entity.BeaconBlockEntity; +import net.minecraft.client.render.VertexConsumerProvider; +import net.minecraft.client.render.block.entity.BeaconBlockEntityRenderer; +import net.minecraft.client.util.math.MatrixStack; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(BeaconBlockEntityRenderer.class) +public class BeaconBlockEntityRendererMixin { + @Inject(method = "render(Lnet/minecraft/block/entity/BeaconBlockEntity;FLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;II)V", at = @At("HEAD"), cancellable = true) + private void onRender(BeaconBlockEntity beaconBlockEntity, float f, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, int j, CallbackInfo info) { + if (Modules.get().get(NoRender.class).noBeaconBeams()) info.cancel(); + } +} diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/BlockCollisionSpliteratorMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/BlockCollisionSpliteratorMixin.java new file mode 100644 index 0000000000..c1c26a9240 --- /dev/null +++ b/src/main/java/meteordevelopment/meteorclient/mixin/BlockCollisionSpliteratorMixin.java @@ -0,0 +1,28 @@ +/* + * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). + * Copyright (c) Meteor Development. + */ + +package meteordevelopment.meteorclient.mixin; + +import meteordevelopment.meteorclient.MeteorClient; +import meteordevelopment.meteorclient.events.world.CollisionShapeEvent; +import net.minecraft.block.BlockState; +import net.minecraft.block.ShapeContext; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.shape.VoxelShape; +import net.minecraft.util.shape.VoxelShapes; +import net.minecraft.world.BlockCollisionSpliterator; +import net.minecraft.world.BlockView; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +@Mixin(BlockCollisionSpliterator.class) +public class BlockCollisionSpliteratorMixin { + @Redirect(method = "computeNext()Lnet/minecraft/util/shape/VoxelShape;", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BlockState;getCollisionShape(Lnet/minecraft/world/BlockView;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/ShapeContext;)Lnet/minecraft/util/shape/VoxelShape;")) + private VoxelShape onComputeNextCollisionBox(BlockState state, BlockView world, BlockPos pos, ShapeContext context) { + CollisionShapeEvent event = MeteorClient.EVENT_BUS.post(CollisionShapeEvent.get(state, pos, state.getCollisionShape(world, pos, context))); + return event.isCancelled() ? VoxelShapes.empty() : event.shape; + } +} diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/BlockMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/BlockMixin.java index e231337e93..b9e5ebd376 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/BlockMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/BlockMixin.java @@ -6,11 +6,13 @@ package meteordevelopment.meteorclient.mixin; import meteordevelopment.meteorclient.systems.modules.Modules; +import meteordevelopment.meteorclient.systems.modules.movement.NoSlow; import meteordevelopment.meteorclient.systems.modules.movement.Slippy; import meteordevelopment.meteorclient.systems.modules.render.Xray; import net.minecraft.block.AbstractBlock; import net.minecraft.block.Block; import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; import net.minecraft.item.ItemConvertible; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; @@ -46,5 +48,7 @@ public void getSlipperiness(CallbackInfoReturnable info) { if (slippy.isActive() && !slippy.ignoredBlocks.get().contains(block)) { info.setReturnValue(slippy.friction.get().floatValue()); } + + if (block == Blocks.SLIME_BLOCK && Modules.get().get(NoSlow.class).slimeBlock()) info.setReturnValue(0.6F); } } diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/BlockRenderManagerMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/BlockRenderManagerMixin.java index 6ebf6bdfd3..05ae764d48 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/BlockRenderManagerMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/BlockRenderManagerMixin.java @@ -21,10 +21,8 @@ @Mixin(BlockRenderManager.class) public class BlockRenderManagerMixin { - @Inject(method = "renderDamage", at = @At("HEAD"), cancellable = true) private void renderDamage(BlockState state, BlockPos pos, BlockRenderView world, MatrixStack matrix, VertexConsumer vertexConsumer, CallbackInfo info) { if (Modules.get().isActive(BreakIndicators.class) || Modules.get().get(NoRender.class).noBlockBreakOverlay()) info.cancel(); } - } diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/CactusBlockMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/CactusBlockMixin.java deleted file mode 100644 index 7014cdba20..0000000000 --- a/src/main/java/meteordevelopment/meteorclient/mixin/CactusBlockMixin.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). - * Copyright (c) Meteor Development. - */ - -package meteordevelopment.meteorclient.mixin; - -import meteordevelopment.meteorclient.systems.modules.Modules; -import meteordevelopment.meteorclient.systems.modules.world.AntiCactus; -import net.minecraft.block.BlockState; -import net.minecraft.block.CactusBlock; -import net.minecraft.block.ShapeContext; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.shape.VoxelShape; -import net.minecraft.util.shape.VoxelShapes; -import net.minecraft.world.BlockView; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Mixin(CactusBlock.class) -public class CactusBlockMixin { - @Inject(method = "getCollisionShape", at = @At("HEAD"), cancellable = true) - private void onGetCollisionShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable info) { - Modules modules = Modules.get(); - - if (modules != null && modules.isActive(AntiCactus.class)) { - info.setReturnValue(VoxelShapes.fullCube()); - } - } -} diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/ChatHudMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/ChatHudMixin.java index 98e15f55e2..0a9fa62af6 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/ChatHudMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/ChatHudMixin.java @@ -27,6 +27,7 @@ import net.minecraft.network.message.MessageSignatureData; import net.minecraft.text.Text; import net.minecraft.util.Identifier; +import net.minecraft.util.math.MathHelper; import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; @@ -101,6 +102,14 @@ private int addMessageListSizeProxy(List list) { return list.size(); } + @Inject(method = "clear(Z)V", at = @At("HEAD"), cancellable = true) + private void onClear(CallbackInfo info) { + BetterChat betterChat = Modules.get().get(BetterChat.class); + if (betterChat.antiHistClear.get()) { + info.cancel(); + } + } + @Inject(method = "render", at = @At("TAIL")) private void onRender(MatrixStack matrices, int currentTick, int mouseX, int mouseY, CallbackInfo info) { if (!Modules.get().get(BetterChat.class).displayPlayerHeads()) return; @@ -111,8 +120,12 @@ private void onRender(MatrixStack matrices, int currentTick, int mouseX, int mou double g = 9.0D * (mc.options.getChatLineSpacing().getValue() + 1.0D); double h = -8.0D * (mc.options.getChatLineSpacing().getValue() + 1.0D) + 4.0D * mc.options.getChatLineSpacing().getValue() + 8.0D; + float chatScale = (float) this.getChatScale(); + float scaledHeight = mc.getWindow().getScaledHeight(); + matrices.push(); - matrices.translate(2, -0.1f, 10); + matrices.scale(chatScale, chatScale, 1.0f); + matrices.translate(2.0f, MathHelper.floor((scaledHeight - 40) / chatScale) - g - 0.1f, 10.0f); RenderSystem.enableBlend(); for(int m = 0; m + this.scrolledLines < this.visibleMessages.size() && m < maxLineCount; ++m) { ChatHudLine.Visible chatHudLine = this.visibleMessages.get(m + this.scrolledLines); @@ -153,6 +166,9 @@ private static double getMessageOpacityMultiplier(int age) { @Final private List messages; + @Shadow + public abstract double getChatScale(); + private void drawIcon(MatrixStack matrices, String line, int y, float opacity) { if (METEOR_PREFIX_REGEX.matcher(line).find()) { RenderSystem.setShaderTexture(0, METEOR_CHAT_ICON); diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/ChatScreenMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/ChatScreenMixin.java index 2ae98da5d8..c2463e8fd8 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/ChatScreenMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/ChatScreenMixin.java @@ -5,54 +5,22 @@ package meteordevelopment.meteorclient.mixin; -import baritone.api.BaritoneAPI; -import com.mojang.brigadier.exceptions.CommandSyntaxException; -import meteordevelopment.meteorclient.MeteorClient; -import meteordevelopment.meteorclient.events.game.SendMessageEvent; -import meteordevelopment.meteorclient.systems.commands.Commands; -import meteordevelopment.meteorclient.systems.config.Config; import meteordevelopment.meteorclient.systems.modules.Modules; import meteordevelopment.meteorclient.systems.modules.misc.BetterChat; -import meteordevelopment.meteorclient.utils.player.ChatUtils; -import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.screen.ChatScreen; import net.minecraft.client.gui.widget.TextFieldWidget; 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(ChatScreen.class) public abstract class ChatScreenMixin { @Shadow protected TextFieldWidget chatField; - @Shadow public abstract boolean sendMessage(String chatText, boolean addToHistory); - - @Unique private boolean ignoreChatMessage; - @Inject(method = "init", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/widget/TextFieldWidget;setMaxLength(I)V", shift = At.Shift.AFTER)) private void onInit(CallbackInfo info) { if (Modules.get().get(BetterChat.class).isInfiniteChatBox()) chatField.setMaxLength(Integer.MAX_VALUE); } - - @Inject(method = "sendMessage", at = @At("HEAD"), cancellable = true) - private void onSendChatMessage(String message, boolean addToHistory, CallbackInfoReturnable info) { - if (ignoreChatMessage) return; - - if (!message.startsWith("/") && !message.startsWith(BaritoneAPI.getSettings().prefix.value)) { - SendMessageEvent event = MeteorClient.EVENT_BUS.post(SendMessageEvent.get(message)); - - if (!event.isCancelled()) { - ignoreChatMessage = true; - sendMessage(event.message, addToHistory); - ignoreChatMessage = false; - } - - info.setReturnValue(true); - return; - } - } } diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/ChunkSkyLightProviderMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/ChunkSkyLightProviderMixin.java index ce7a89806b..26bf7870d0 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/ChunkSkyLightProviderMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/ChunkSkyLightProviderMixin.java @@ -17,7 +17,6 @@ public class ChunkSkyLightProviderMixin { @Inject(at = @At("HEAD"), method = "recalculateLevel", cancellable = true) private void recalculateLevel(long long_1, long long_2, int int_1, CallbackInfoReturnable ci) { - if (Modules.get().get(NoRender.class).noSkylightUpdates()) { //return; ci.setReturnValue(15); diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/ClientConnectionMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/ClientConnectionMixin.java index 6608801bde..06aa9f0384 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/ClientConnectionMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/ClientConnectionMixin.java @@ -6,6 +6,7 @@ package meteordevelopment.meteorclient.mixin; import io.netty.channel.ChannelHandlerContext; +import io.netty.handler.timeout.TimeoutException; import meteordevelopment.meteorclient.MeteorClient; import meteordevelopment.meteorclient.events.packets.PacketEvent; import meteordevelopment.meteorclient.events.world.ConnectToServerEvent; @@ -13,7 +14,8 @@ import meteordevelopment.meteorclient.systems.modules.misc.AntiPacketKick; import meteordevelopment.meteorclient.systems.modules.world.HighwayBuilder; import net.minecraft.network.ClientConnection; -import net.minecraft.network.Packet; +import net.minecraft.network.packet.Packet; +import net.minecraft.network.PacketEncoderException; import net.minecraft.network.listener.PacketListener; import net.minecraft.text.MutableText; import net.minecraft.text.Text; @@ -24,7 +26,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import java.io.IOException; import java.net.InetSocketAddress; @Mixin(ClientConnection.class) @@ -49,18 +50,22 @@ private static void onConnect(InetSocketAddress address, boolean useEpoll, Callb MeteorClient.EVENT_BUS.post(ConnectToServerEvent.get()); } - @Inject(method = "exceptionCaught", at = @At("HEAD"), cancellable = true) - private void exceptionCaught(ChannelHandlerContext context, Throwable throwable, CallbackInfo ci) { - if (throwable instanceof IOException && Modules.get().isActive(AntiPacketKick.class)) ci.cancel(); - } - - @Inject(at = @At("HEAD"), method = "send(Lnet/minecraft/network/Packet;)V", cancellable = true) + @Inject(at = @At("HEAD"), method = "send(Lnet/minecraft/network/packet/Packet;)V", cancellable = true) private void onSendPacketHead(Packet packet, CallbackInfo info) { if (MeteorClient.EVENT_BUS.post(PacketEvent.Send.get(packet)).isCancelled()) info.cancel(); } - @Inject(method = "send(Lnet/minecraft/network/Packet;)V", at = @At("TAIL")) + @Inject(method = "send(Lnet/minecraft/network/packet/Packet;)V", at = @At("TAIL")) private void onSendPacketTail(Packet packet, CallbackInfo info) { MeteorClient.EVENT_BUS.post(PacketEvent.Sent.get(packet)); } + + @Inject(method = "exceptionCaught", at = @At("HEAD"), cancellable = true) + private void exceptionCaught(ChannelHandlerContext context, Throwable throwable, CallbackInfo ci) { + AntiPacketKick apk = Modules.get().get(AntiPacketKick.class); + if (!(throwable instanceof TimeoutException) && !(throwable instanceof PacketEncoderException) && apk.catchExceptions()) { + if (apk.logExceptions.get()) apk.warning("Caught exception: %s", throwable); + ci.cancel(); + } + } } diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/ClientPlayNetworkHandlerMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/ClientPlayNetworkHandlerMixin.java index 984cc324f5..817f086989 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/ClientPlayNetworkHandlerMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/ClientPlayNetworkHandlerMixin.java @@ -5,19 +5,25 @@ package meteordevelopment.meteorclient.mixin; +import baritone.api.BaritoneAPI; +import com.mojang.brigadier.exceptions.CommandSyntaxException; import meteordevelopment.meteorclient.MeteorClient; import meteordevelopment.meteorclient.events.entity.EntityDestroyEvent; import meteordevelopment.meteorclient.events.entity.player.PickItemsEvent; import meteordevelopment.meteorclient.events.game.GameJoinedEvent; import meteordevelopment.meteorclient.events.game.GameLeftEvent; +import meteordevelopment.meteorclient.events.game.SendMessageEvent; import meteordevelopment.meteorclient.events.packets.ContainerSlotUpdateEvent; import meteordevelopment.meteorclient.events.packets.InventoryEvent; import meteordevelopment.meteorclient.events.packets.PlaySoundPacketEvent; import meteordevelopment.meteorclient.events.world.ChunkDataEvent; import meteordevelopment.meteorclient.mixininterface.IExplosionS2CPacket; +import meteordevelopment.meteorclient.systems.commands.Commands; +import meteordevelopment.meteorclient.systems.config.Config; import meteordevelopment.meteorclient.systems.modules.Modules; import meteordevelopment.meteorclient.systems.modules.movement.Velocity; import meteordevelopment.meteorclient.systems.modules.render.NoRender; +import meteordevelopment.meteorclient.utils.player.ChatUtils; import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.ClientPlayNetworkHandler; import net.minecraft.client.world.ClientWorld; @@ -28,6 +34,7 @@ import org.spongepowered.asm.mixin.Final; 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; @@ -40,6 +47,12 @@ public abstract class ClientPlayNetworkHandlerMixin { @Shadow private ClientWorld world; + @Shadow + public abstract void sendChatMessage(String content); + + @Unique + private boolean ignoreChatMessage; + private boolean worldNotNull; @Inject(method = "onEntitySpawn", at = @At("HEAD"), cancellable = true) @@ -93,7 +106,7 @@ private void onEntitiesDestroy(EntitiesDestroyS2CPacket packet, CallbackInfo ci) } } - @Inject(method = "onExplosion", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/NetworkThreadUtils;forceMainThread(Lnet/minecraft/network/Packet;Lnet/minecraft/network/listener/PacketListener;Lnet/minecraft/util/thread/ThreadExecutor;)V", shift = At.Shift.AFTER)) + @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)) private void onExplosionVelocity(ExplosionS2CPacket packet, CallbackInfo ci) { Velocity velocity = Modules.get().get(Velocity.class); if (!velocity.explosions.get()) return; @@ -112,4 +125,21 @@ private void onItemPickupAnimation(ItemPickupAnimationS2CPacket packet, Callback MeteorClient.EVENT_BUS.post(PickItemsEvent.get(((ItemEntity) itemEntity).getStack(), packet.getStackAmount())); } } + + @Inject(method = "sendChatMessage", at = @At("HEAD"), cancellable = true) + private void onSendChatMessage(String message, CallbackInfo ci) { + if (ignoreChatMessage) return; + + if (!message.startsWith(BaritoneAPI.getSettings().prefix.value)) { + SendMessageEvent event = MeteorClient.EVENT_BUS.post(SendMessageEvent.get(message)); + + if (!event.isCancelled()) { + ignoreChatMessage = true; + sendChatMessage(event.message); + ignoreChatMessage = false; + } + ci.cancel(); + return; + } + } } diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/ClientPlayerEntityMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/ClientPlayerEntityMixin.java index ab54e5df7a..7938565636 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/ClientPlayerEntityMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/ClientPlayerEntityMixin.java @@ -24,9 +24,7 @@ import net.minecraft.client.world.ClientWorld; import net.minecraft.entity.damage.DamageSource; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.*; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @@ -55,7 +53,7 @@ private boolean redirectUsingItem(ClientPlayerEntity player) { @Inject(method = "isSneaking", at = @At("HEAD"), cancellable = true) private void onIsSneaking(CallbackInfoReturnable info) { - if (Modules.get().isActive(Scaffold.class)) info.setReturnValue(false); + if (Modules.get().get(Scaffold.class).scaffolding()) info.setReturnValue(false); } @Inject(method = "shouldSlowDown", at = @At("HEAD"), cancellable = true) @@ -78,6 +76,12 @@ private void onDamage(DamageSource source, float amount, CallbackInfoReturnable< if (Utils.canUpdate() && world.isClient && canTakeDamage()) MeteorClient.EVENT_BUS.post(DamageEvent.get(this, source)); } + @ModifyConstant(method = "canSprint", constant = @Constant(floatValue = 6.0f)) + private float onHunger(float constant) { + if (Modules.get().get(NoSlow.class).hunger()) return -1; + return constant; + } + // Rotations @Inject(method = "sendMovementPackets", at = @At("HEAD")) @@ -85,7 +89,7 @@ private void onSendMovementPacketsHead(CallbackInfo info) { MeteorClient.EVENT_BUS.post(SendMovementPacketsEvent.Pre.get()); } - @Inject(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayNetworkHandler;sendPacket(Lnet/minecraft/network/Packet;)V", ordinal = 0)) + @Inject(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayNetworkHandler;sendPacket(Lnet/minecraft/network/packet/Packet;)V", ordinal = 0)) private void onTickHasVehicleBeforeSendPackets(CallbackInfo info) { MeteorClient.EVENT_BUS.post(SendMovementPacketsEvent.Pre.get()); } @@ -95,7 +99,7 @@ private void onSendMovementPacketsTail(CallbackInfo info) { MeteorClient.EVENT_BUS.post(SendMovementPacketsEvent.Post.get()); } - @Inject(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayNetworkHandler;sendPacket(Lnet/minecraft/network/Packet;)V", ordinal = 1, shift = At.Shift.AFTER)) + @Inject(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayNetworkHandler;sendPacket(Lnet/minecraft/network/packet/Packet;)V", ordinal = 1, shift = At.Shift.AFTER)) private void onTickHasVehicleAfterSendPackets(CallbackInfo info) { MeteorClient.EVENT_BUS.post(SendMovementPacketsEvent.Post.get()); } diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/ClientPlayerInteractionManagerMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/ClientPlayerInteractionManagerMixin.java index 062397fdb4..29927e0be2 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/ClientPlayerInteractionManagerMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/ClientPlayerInteractionManagerMixin.java @@ -11,11 +11,11 @@ import meteordevelopment.meteorclient.mixininterface.IClientPlayerInteractionManager; import meteordevelopment.meteorclient.systems.modules.Modules; import meteordevelopment.meteorclient.systems.modules.misc.InventoryTweaks; -import meteordevelopment.meteorclient.systems.modules.player.NoBreakDelay; +import meteordevelopment.meteorclient.systems.modules.player.BreakDelay; import meteordevelopment.meteorclient.systems.modules.player.Reach; -import meteordevelopment.meteorclient.systems.modules.world.Nuker; import meteordevelopment.meteorclient.utils.player.Rotations; import meteordevelopment.meteorclient.utils.world.BlockUtils; +import net.minecraft.block.BlockState; import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.client.network.ClientPlayerInteractionManager; import net.minecraft.entity.Entity; @@ -29,13 +29,11 @@ import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; +import net.minecraft.world.BlockView; import org.objectweb.asm.Opcodes; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.ModifyArgs; -import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.*; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import org.spongepowered.asm.mixin.injection.invoke.arg.Args; @@ -112,16 +110,33 @@ private void onGetReachDistance(CallbackInfoReturnable info) { info.setReturnValue(Modules.get().get(Reach.class).getReach()); } - @Redirect(method = "updateBlockBreakingProgress", at = @At(value = "FIELD", target = "Lnet/minecraft/client/network/ClientPlayerInteractionManager;blockBreakingCooldown:I", opcode = Opcodes.PUTFIELD)) - private void onMethod_2902SetField_3716Proxy(ClientPlayerInteractionManager interactionManager, int value) { - if (Modules.get().isActive(NoBreakDelay.class) || Modules.get().isActive(Nuker.class)) value = 0; - blockBreakingCooldown = value; + @Redirect(method = "updateBlockBreakingProgress", at = @At(value = "FIELD", target = "Lnet/minecraft/client/network/ClientPlayerInteractionManager;blockBreakingCooldown:I", opcode = Opcodes.PUTFIELD, ordinal = 1)) + private void creativeBreakDelayChange(ClientPlayerInteractionManager interactionManager, int value) { + BlockBreakingCooldownEvent event = MeteorClient.EVENT_BUS.post(BlockBreakingCooldownEvent.get(value)); + blockBreakingCooldown = event.cooldown; + } + + @Redirect(method = "updateBlockBreakingProgress", at = @At(value = "FIELD", target = "Lnet/minecraft/client/network/ClientPlayerInteractionManager;blockBreakingCooldown:I", opcode = Opcodes.PUTFIELD, ordinal = 2)) + private void survivalBreakDelayChange(ClientPlayerInteractionManager interactionManager, int value) { + BlockBreakingCooldownEvent event = MeteorClient.EVENT_BUS.post(BlockBreakingCooldownEvent.get(value)); + blockBreakingCooldown = event.cooldown; } @Redirect(method = "attackBlock", at = @At(value = "FIELD", target = "Lnet/minecraft/client/network/ClientPlayerInteractionManager;blockBreakingCooldown:I", opcode = Opcodes.PUTFIELD)) - private void onAttackBlockSetField_3719Proxy(ClientPlayerInteractionManager interactionManager, int value) { - if (Modules.get().isActive(NoBreakDelay.class) || Modules.get().isActive(Nuker.class)) value = 0; - blockBreakingCooldown = value; + private void creativeBreakDelayChange2(ClientPlayerInteractionManager interactionManager, int value) { + BlockBreakingCooldownEvent event = MeteorClient.EVENT_BUS.post(BlockBreakingCooldownEvent.get(value)); + blockBreakingCooldown = event.cooldown; + } + + @Redirect(method = "method_41930",at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BlockState;calcBlockBreakingDelta(Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/world/BlockView;Lnet/minecraft/util/math/BlockPos;)F")) + private float deltaChange(BlockState blockState, PlayerEntity player, BlockView world, BlockPos pos) { + float delta = blockState.calcBlockBreakingDelta(player, world, pos); + if (Modules.get().get(BreakDelay.class).noInstaBreak.get() && delta >= 1) { + BlockBreakingCooldownEvent event = MeteorClient.EVENT_BUS.post(BlockBreakingCooldownEvent.get(blockBreakingCooldown)); + blockBreakingCooldown = event.cooldown; + return 0; + } + return delta; } @Inject(method = "breakBlock", at = @At("HEAD"), cancellable = true) diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/CobwebBlockMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/CobwebBlockMixin.java index 340982b0aa..59c0655bf6 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/CobwebBlockMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/CobwebBlockMixin.java @@ -5,8 +5,8 @@ package meteordevelopment.meteorclient.mixin; -import meteordevelopment.meteorclient.MeteorClient; -import meteordevelopment.meteorclient.events.entity.player.CobwebEntityCollisionEvent; +import meteordevelopment.meteorclient.systems.modules.Modules; +import meteordevelopment.meteorclient.systems.modules.movement.NoSlow; import net.minecraft.block.BlockState; import net.minecraft.block.CobwebBlock; import net.minecraft.entity.Entity; @@ -17,12 +17,12 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import static meteordevelopment.meteorclient.MeteorClient.mc; + @Mixin(CobwebBlock.class) public class CobwebBlockMixin { @Inject(method = "onEntityCollision", at = @At("HEAD"), cancellable = true) private void onEntityCollision(BlockState state, World world, BlockPos pos, Entity entity, CallbackInfo info) { - CobwebEntityCollisionEvent event = MeteorClient.EVENT_BUS.post(CobwebEntityCollisionEvent.get(state, pos)); - - if (event.isCancelled()) info.cancel(); + if (entity == mc.player && Modules.get().get(NoSlow.class).cobweb()) info.cancel(); } } diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/CustomPayloadS2CPacketMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/CustomPayloadS2CPacketMixin.java new file mode 100644 index 0000000000..553e0fe18e --- /dev/null +++ b/src/main/java/meteordevelopment/meteorclient/mixin/CustomPayloadS2CPacketMixin.java @@ -0,0 +1,21 @@ +/* + * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). + * Copyright (c) Meteor Development. + */ + +package meteordevelopment.meteorclient.mixin; + +import meteordevelopment.meteorclient.systems.modules.Modules; +import meteordevelopment.meteorclient.systems.modules.misc.AntiPacketKick; +import net.minecraft.network.packet.s2c.play.CustomPayloadS2CPacket; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.Constant; +import org.spongepowered.asm.mixin.injection.ModifyConstant; + +@Mixin(CustomPayloadS2CPacket.class) +public class CustomPayloadS2CPacketMixin { + @ModifyConstant(method = "", constant = @Constant(intValue = 1048576)) + private int maxValue(int value) { + return Modules.get().isActive(AntiPacketKick.class) ? Integer.MAX_VALUE : value; + } +} diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/EnchantingTableBlockEntityRendererMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/EnchantingTableBlockEntityRendererMixin.java index 3ab3cb020d..695ee129cc 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/EnchantingTableBlockEntityRendererMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/EnchantingTableBlockEntityRendererMixin.java @@ -17,7 +17,7 @@ @Mixin(EnchantingTableBlockEntityRenderer.class) public class EnchantingTableBlockEntityRendererMixin { - @Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/entity/model/BookModel;renderBook(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumer;IIFFFF)V")) + @Redirect(method = "render(Lnet/minecraft/block/entity/EnchantingTableBlockEntity;FLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;II)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/entity/model/BookModel;renderBook(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumer;IIFFFF)V")) private void onRenderBookModelRenderProxy(BookModel model, MatrixStack matrixStack, VertexConsumer vertexConsumer, int i, int j, float f, float g, float h, float k) { if (!Modules.get().get(NoRender.class).noEnchTableBook()) model.renderBook(matrixStack, vertexConsumer, i, j, f, g, h, k); } diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/EntityMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/EntityMixin.java index 21d1282856..14a2291fea 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/EntityMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/EntityMixin.java @@ -11,6 +11,7 @@ import meteordevelopment.meteorclient.events.entity.player.PlayerMoveEvent; import meteordevelopment.meteorclient.systems.modules.Modules; import meteordevelopment.meteorclient.systems.modules.combat.Hitboxes; +import meteordevelopment.meteorclient.systems.modules.movement.NoFall; import meteordevelopment.meteorclient.systems.modules.movement.NoSlow; import meteordevelopment.meteorclient.systems.modules.movement.Velocity; import meteordevelopment.meteorclient.systems.modules.movement.elytrafly.ElytraFly; @@ -18,6 +19,7 @@ import meteordevelopment.meteorclient.systems.modules.render.NoRender; import meteordevelopment.meteorclient.utils.Utils; import meteordevelopment.meteorclient.utils.entity.fakeplayer.FakePlayerEntity; +import meteordevelopment.meteorclient.utils.render.color.Color; import meteordevelopment.meteorclient.utils.render.postprocess.PostProcessShaders; import net.minecraft.block.Block; import net.minecraft.block.BlockState; @@ -105,7 +107,8 @@ else if ((Object) this instanceof LivingEntity) { @Inject(method = "getTeamColorValue", at = @At("HEAD"), cancellable = true) private void onGetTeamColorValue(CallbackInfoReturnable info) { if (PostProcessShaders.rendering) { - info.setReturnValue(Modules.get().get(ESP.class).getColor((Entity) (Object) this).getPacked()); + Color color = Modules.get().get(ESP.class).getColor((Entity) (Object) this); + if (color != null) info.setReturnValue(color.getPacked()); } } @@ -120,7 +123,8 @@ private Block getVelocityMultiplierGetBlockProxy(BlockState blockState) { @Inject(method = "isInvisibleTo(Lnet/minecraft/entity/player/PlayerEntity;)Z", at = @At("HEAD"), cancellable = true) private void isInvisibleToCanceller(PlayerEntity player, CallbackInfoReturnable info) { if (!Utils.canUpdate()) return; - if (Modules.get().get(NoRender.class).noInvisibility() || !Modules.get().get(ESP.class).shouldSkip((Entity) (Object) this)) info.setReturnValue(false); + ESP esp = Modules.get().get(ESP.class); + if (Modules.get().get(NoRender.class).noInvisibility() || esp.isActive() && !esp.shouldSkip((Entity) (Object) this)) info.setReturnValue(false); } @Inject(method = "isGlowing", at = @At("HEAD"), cancellable = true) @@ -145,4 +149,9 @@ private void getPoseHook(CallbackInfoReturnable info) { info.setReturnValue(EntityPose.FALL_FLYING); } } + + @Inject(method = "bypassesLandingEffects", at = @At("RETURN"), cancellable = true) + private void cancelBounce(CallbackInfoReturnable cir) { + cir.setReturnValue(Modules.get().get(NoFall.class).cancelBounce() || cir.getReturnValue()); + } } diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/FluidBlockMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/FluidBlockMixin.java deleted file mode 100644 index 8b1407aafd..0000000000 --- a/src/main/java/meteordevelopment/meteorclient/mixin/FluidBlockMixin.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). - * Copyright (c) Meteor Development. - */ - -package meteordevelopment.meteorclient.mixin; - -import meteordevelopment.meteorclient.MeteorClient; -import meteordevelopment.meteorclient.events.world.CollisionShapeEvent; -import net.minecraft.block.*; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.shape.VoxelShape; -import net.minecraft.world.BlockView; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Mixin(FluidBlock.class) -public abstract class FluidBlockMixin extends Block implements FluidDrainable { - public FluidBlockMixin(Settings settings) { - super(settings); - } - - @Inject(method = "getCollisionShape", at = @At("HEAD"), cancellable = true) - private void onGetCollisionShape(BlockState state, BlockView view, BlockPos pos, ShapeContext context, CallbackInfoReturnable info) { - CollisionShapeEvent event = MeteorClient.EVENT_BUS.post(CollisionShapeEvent.get(state, pos, CollisionShapeEvent.CollisionType.FLUID)); - - if (event.shape != null) info.setReturnValue(event.shape); - } -} diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/GameRendererMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/GameRendererMixin.java index 16b5c7728f..97c8c97c3a 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/GameRendererMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/GameRendererMixin.java @@ -98,11 +98,6 @@ private HitResult updateTargetedEntityEntityRayTraceProxy(Entity entity, double return entity.raycast(maxDistance, tickDelta, includeFluids); } - @Inject(method = "bobViewWhenHurt", at = @At("HEAD"), cancellable = true) - private void onBobViewWhenHurt(MatrixStack matrixStack, float f, CallbackInfo info) { - if (Modules.get().get(NoRender.class).noHurtCam()) info.cancel(); - } - @Inject(method = "showFloatingItem", at = @At("HEAD"), cancellable = true) private void onShowFloatingItem(ItemStack floatingItem, CallbackInfo info) { if (floatingItem.getItem() == Items.TOTEM_OF_UNDYING && Modules.get().get(NoRender.class).noTotemAnimation()) { diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/GenericContainerScreenMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/GenericContainerScreenMixin.java deleted file mode 100644 index d7d9a90308..0000000000 --- a/src/main/java/meteordevelopment/meteorclient/mixin/GenericContainerScreenMixin.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). - * Copyright (c) Meteor Development. - */ - -package meteordevelopment.meteorclient.mixin; - -import meteordevelopment.meteorclient.systems.modules.Modules; -import meteordevelopment.meteorclient.systems.modules.misc.InventoryTweaks; -import net.minecraft.client.gui.screen.ingame.GenericContainerScreen; -import net.minecraft.client.gui.screen.ingame.HandledScreen; -import net.minecraft.client.gui.screen.ingame.ScreenHandlerProvider; -import net.minecraft.client.gui.widget.ButtonWidget; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.screen.GenericContainerScreenHandler; -import net.minecraft.text.Text; -import org.spongepowered.asm.mixin.Mixin; - -@Mixin(GenericContainerScreen.class) -public abstract class GenericContainerScreenMixin extends HandledScreen implements ScreenHandlerProvider { - public GenericContainerScreenMixin(GenericContainerScreenHandler container, PlayerInventory playerInventory, Text name) { - super(container, playerInventory, name); - } - - @Override - protected void init() { - super.init(); - - InventoryTweaks invTweaks = Modules.get().get(InventoryTweaks.class); - - if (invTweaks.isActive() && invTweaks.showButtons()) { - addDrawableChild( - new ButtonWidget.Builder(Text.literal("Steal"), button -> invTweaks.steal(handler)) - .position(x + backgroundWidth - 88, y + 3) - .size(40, 12) - .build() - ); - - addDrawableChild( - new ButtonWidget.Builder(Text.literal("Dump"), button -> invTweaks.dump(handler)) - .position(x + backgroundWidth - 46, y + 3) - .size(40, 12) - .build() - ); - } - } -} diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/HandledScreenMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/HandledScreenMixin.java index 0788e6ea43..0ddd1638c2 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/HandledScreenMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/HandledScreenMixin.java @@ -13,6 +13,7 @@ import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.screen.ingame.HandledScreen; import net.minecraft.client.gui.screen.ingame.ScreenHandlerProvider; +import net.minecraft.client.gui.widget.ButtonWidget; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; @@ -52,6 +53,27 @@ public HandledScreenMixin(Text title) { super(title); } + @Inject(method = "init", at = @At("TAIL")) + private void onInit(CallbackInfo info) { + InventoryTweaks invTweaks = Modules.get().get(InventoryTweaks.class); + + if (invTweaks.isActive() && invTweaks.showButtons() && invTweaks.canSteal(getScreenHandler())) { + addDrawableChild( + new ButtonWidget.Builder(Text.literal("Steal"), button -> invTweaks.steal(getScreenHandler())) + .position(width / 2 - 41, 3) + .size(40, 20) + .build() + ); + + addDrawableChild( + new ButtonWidget.Builder(Text.literal("Dump"), button -> invTweaks.dump(getScreenHandler())) + .position(width / 2 + 2, 3) + .size(40, 20) + .build() + ); + } + } + // Inventory Tweaks @Inject(method = "mouseDragged", at = @At("TAIL")) private void onMouseDragged(double mouseX, double mouseY, int button, double deltaX, double deltaY, CallbackInfoReturnable info) { diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/HeldItemRendererMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/HeldItemRendererMixin.java index 7c6cdd65ad..9ab6a1520e 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/HeldItemRendererMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/HeldItemRendererMixin.java @@ -44,7 +44,7 @@ private float modifySwing(float swingProgress) { return swingProgress; } - @Inject(method = "renderFirstPersonItem", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/item/HeldItemRenderer;renderItem(Lnet/minecraft/entity/LivingEntity;Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/render/model/json/ModelTransformation$Mode;ZLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V")) + @Inject(method = "renderFirstPersonItem", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/item/HeldItemRenderer;renderItem(Lnet/minecraft/entity/LivingEntity;Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/render/model/json/ModelTransformationMode;ZLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V")) private void onRenderItem(AbstractClientPlayerEntity player, float tickDelta, float pitch, Hand hand, float swingProgress, ItemStack item, float equipProgress, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) { MeteorClient.EVENT_BUS.post(HeldItemRendererEvent.get(hand, matrices)); } diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/InGameHudMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/InGameHudMixin.java index b1c1227198..6e29b19a77 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/InGameHudMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/InGameHudMixin.java @@ -60,22 +60,22 @@ private void onRenderStatusEffectOverlay(CallbackInfo info) { } @Inject(method = "renderPortalOverlay", at = @At("HEAD"), cancellable = true) - private void onRenderPortalOverlay(float f, CallbackInfo info) { + private void onRenderPortalOverlay(MatrixStack matrices, float f, CallbackInfo info) { if (Modules.get().get(NoRender.class).noPortalOverlay()) info.cancel(); } - @ModifyArgs(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/InGameHud;renderOverlay(Lnet/minecraft/util/Identifier;F)V", ordinal = 0)) + @ModifyArgs(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/InGameHud;renderOverlay(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/util/Identifier;F)V", ordinal = 0)) private void onRenderPumpkinOverlay(Args args) { - if (Modules.get().get(NoRender.class).noPumpkinOverlay()) args.set(1, 0f); + if (Modules.get().get(NoRender.class).noPumpkinOverlay()) args.set(2, 0f); } - @ModifyArgs(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/InGameHud;renderOverlay(Lnet/minecraft/util/Identifier;F)V", ordinal = 1)) + @ModifyArgs(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/InGameHud;renderOverlay(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/util/Identifier;F)V", ordinal = 1)) private void onRenderPowderedSnowOverlay(Args args) { - if (Modules.get().get(NoRender.class).noPowderedSnowOverlay()) args.set(1, 0f); + if (Modules.get().get(NoRender.class).noPowderedSnowOverlay()) args.set(2, 0f); } @Inject(method = "renderVignetteOverlay", at = @At("HEAD"), cancellable = true) - private void onRenderVignetteOverlay(Entity entity, CallbackInfo info) { + private void onRenderVignetteOverlay(MatrixStack matrices, Entity entity, CallbackInfo info) { if (Modules.get().get(NoRender.class).noVignette()) info.cancel(); } @@ -85,7 +85,7 @@ private void onRenderScoreboardSidebar(MatrixStack matrixStack, ScoreboardObject } @Inject(method = "renderSpyglassOverlay", at = @At("HEAD"), cancellable = true) - private void onRenderSpyglassOverlay(float scale, CallbackInfo info) { + private void onRenderSpyglassOverlay(MatrixStack matrices, float scale, CallbackInfo info) { if (Modules.get().get(NoRender.class).noSpyglassOverlay()) info.cancel(); } diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/ItemEntityRendererMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/ItemEntityRendererMixin.java index 3d828e8e50..fe556b2b7c 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/ItemEntityRendererMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/ItemEntityRendererMixin.java @@ -25,7 +25,7 @@ public abstract class ItemEntityRendererMixin { @Shadow @Final private Random random; @Shadow @Final private ItemRenderer itemRenderer; - @Inject(method = "render", at = @At("HEAD"), cancellable = true) + @Inject(method = "render(Lnet/minecraft/entity/ItemEntity;FFLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V", at = @At("HEAD"), cancellable = true) private void render(ItemEntity itemEntity, float f, float g, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, CallbackInfo ci) { RenderItemEntityEvent event = MeteorClient.EVENT_BUS.post(RenderItemEntityEvent.get(itemEntity, f, g, matrixStack, vertexConsumerProvider, i, random, itemRenderer)); if (event.isCancelled()) ci.cancel(); diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/ItemRendererMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/ItemRendererMixin.java new file mode 100644 index 0000000000..fca37ed5ad --- /dev/null +++ b/src/main/java/meteordevelopment/meteorclient/mixin/ItemRendererMixin.java @@ -0,0 +1,39 @@ +/* + * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). + * Copyright (c) Meteor Development. + */ + +package meteordevelopment.meteorclient.mixin; + +import meteordevelopment.meteorclient.systems.modules.Modules; +import meteordevelopment.meteorclient.systems.modules.render.NoRender; +import net.minecraft.block.StainedGlassPaneBlock; +import net.minecraft.block.TransparentBlock; +import net.minecraft.client.render.RenderLayers; +import net.minecraft.client.render.VertexConsumerProvider; +import net.minecraft.client.render.item.ItemRenderer; +import net.minecraft.client.render.model.BakedModel; +import net.minecraft.client.render.model.json.ModelTransformationMode; +import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.item.BlockItem; +import net.minecraft.item.ItemStack; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.ModifyArgs; +import org.spongepowered.asm.mixin.injection.invoke.arg.Args; + +@Mixin(ItemRenderer.class) +public class ItemRendererMixin { + @ModifyArgs( + method = "renderItem(Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/render/model/json/ModelTransformationMode;ZLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;IILnet/minecraft/client/render/model/BakedModel;)V", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/client/render/item/ItemRenderer;renderBakedItemModel(Lnet/minecraft/client/render/model/BakedModel;Lnet/minecraft/item/ItemStack;IILnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumer;)V" + ) + ) + private void modifyEnchant(Args args, ItemStack stack, ModelTransformationMode renderMode, boolean leftHanded, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay, BakedModel model) { + if (!Modules.get().get(NoRender.class).noEnchantGlint()) return; + boolean bl = (renderMode == ModelTransformationMode.GUI || renderMode.isFirstPerson() || !(stack.getItem() instanceof BlockItem blockItem) || !(blockItem.getBlock() instanceof TransparentBlock) && !(blockItem.getBlock() instanceof StainedGlassPaneBlock)); + args.set(5, vertexConsumers.getBuffer(RenderLayers.getItemLayer(stack, bl))); + } +} diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/LivingEntityAccessor.java b/src/main/java/meteordevelopment/meteorclient/mixin/LivingEntityAccessor.java index 6cf8ec0f8b..c7d4630c92 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/LivingEntityAccessor.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/LivingEntityAccessor.java @@ -17,6 +17,9 @@ public interface LivingEntityAccessor { @Invoker("swimUpward") void swimUpwards(TagKey fluid); + @Accessor("jumping") + boolean isJumping(); + @Accessor("jumpingCooldown") int getJumpCooldown(); diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/LivingEntityMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/LivingEntityMixin.java index 38d975bbb9..fc630f2b7e 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/LivingEntityMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/LivingEntityMixin.java @@ -9,9 +9,9 @@ import meteordevelopment.meteorclient.events.entity.DamageEvent; import meteordevelopment.meteorclient.events.entity.player.CanWalkOnFluidEvent; import meteordevelopment.meteorclient.systems.modules.Modules; -import meteordevelopment.meteorclient.systems.modules.movement.AntiLevitation; import meteordevelopment.meteorclient.systems.modules.movement.elytrafly.ElytraFly; import meteordevelopment.meteorclient.systems.modules.player.OffhandCrash; +import meteordevelopment.meteorclient.systems.modules.player.PotionSpoof; import meteordevelopment.meteorclient.systems.modules.render.HandView; import meteordevelopment.meteorclient.systems.modules.render.NoRender; import meteordevelopment.meteorclient.utils.Utils; @@ -21,27 +21,37 @@ import net.minecraft.entity.LivingEntity; import net.minecraft.entity.damage.DamageSource; import net.minecraft.entity.effect.StatusEffect; +import net.minecraft.entity.effect.StatusEffectInstance; import net.minecraft.entity.effect.StatusEffects; import net.minecraft.fluid.FluidState; import net.minecraft.item.ItemStack; import net.minecraft.util.Hand; import net.minecraft.world.World; +import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.*; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import java.util.Map; + import static meteordevelopment.meteorclient.MeteorClient.mc; @Mixin(LivingEntity.class) public abstract class LivingEntityMixin extends Entity { + @Shadow + @Final + private Map activeStatusEffects; + public LivingEntityMixin(EntityType type, World world) { super(type, world); } @Inject(method = "damage", at = @At("HEAD")) private void onDamageHead(DamageSource source, float amount, CallbackInfoReturnable info) { - if (Utils.canUpdate() && world.isClient) MeteorClient.EVENT_BUS.post(DamageEvent.get((LivingEntity) (Object) this, source)); + if (Utils.canUpdate() && world.isClient) + MeteorClient.EVENT_BUS.post(DamageEvent.get((LivingEntity) (Object) this, source)); } @Inject(method = "canWalkOnFluid", at = @At("HEAD"), cancellable = true) @@ -52,16 +62,10 @@ private void onCanWalkOnFluid(FluidState fluidState, CallbackInfoReturnable info) { info.setReturnValue(true); } } + + @Inject(method = "hasStatusEffect", at = @At("HEAD"), cancellable = true) + private void hasStatusEffect(StatusEffect effect, CallbackInfoReturnable info) { + if (Modules.get().get(PotionSpoof.class).shouldBlock(effect)) info.setReturnValue(false); + } } diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/MinecraftClientAccessor.java b/src/main/java/meteordevelopment/meteorclient/mixin/MinecraftClientAccessor.java index af8f4cd401..b4929a7ff1 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/MinecraftClientAccessor.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/MinecraftClientAccessor.java @@ -5,9 +5,17 @@ package meteordevelopment.meteorclient.mixin; +import com.mojang.authlib.minecraft.MinecraftSessionService; +import com.mojang.authlib.minecraft.UserApiService; +import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService; import net.minecraft.client.MinecraftClient; +import net.minecraft.client.network.SocialInteractionsManager; +import net.minecraft.client.report.AbuseReportContext; import net.minecraft.client.resource.ResourceReloadLogger; +import net.minecraft.client.texture.PlayerSkinProvider; +import net.minecraft.client.util.ProfileKeys; import net.minecraft.client.util.Session; +import net.minecraft.network.encryption.SignatureVerifier; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mutable; import org.spongepowered.asm.mixin.gen.Accessor; @@ -40,4 +48,39 @@ static int getFps() { @Invoker("doAttack") boolean leftClick(); + + @Mutable + @Accessor("profileKeys") + void setProfileKeys(ProfileKeys keys); + + @Accessor("authenticationService") + YggdrasilAuthenticationService getAuthenticationService(); + + @Mutable + @Accessor + void setUserApiService(UserApiService apiService); + + @Mutable + @Accessor("sessionService") + void setSessionService(MinecraftSessionService sessionService); + + @Mutable + @Accessor("authenticationService") + void setAuthenticationService(YggdrasilAuthenticationService authenticationService); + + @Mutable + @Accessor("servicesSignatureVerifier") + void setServicesSignatureVerifier(SignatureVerifier servicesSignatureVerifier); + + @Mutable + @Accessor("skinProvider") + void setSkinProvider(PlayerSkinProvider skinProvider); + + @Mutable + @Accessor("socialInteractionsManager") + void setSocialInteractionsManager(SocialInteractionsManager socialInteractionsManager); + + @Mutable + @Accessor("abuseReportContext") + void setAbuseReportContext(AbuseReportContext abuseReportContext); } diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/MobSpawnerBlockEntityRendererMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/MobSpawnerBlockEntityRendererMixin.java index 37314c71a4..6f6313d1b9 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/MobSpawnerBlockEntityRendererMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/MobSpawnerBlockEntityRendererMixin.java @@ -15,7 +15,7 @@ @Mixin(MobSpawnerBlockEntityRenderer.class) public class MobSpawnerBlockEntityRendererMixin { - @Inject(method = "render", at = @At("HEAD"), cancellable = true) + @Inject(method = "render(Lnet/minecraft/block/entity/MobSpawnerBlockEntity;FLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;II)V", at = @At("HEAD"), cancellable = true) private void onRender(CallbackInfo ci) { if (Modules.get().get(NoRender.class).noMobInSpawner()) ci.cancel(); } diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/PacketByteBufMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/PacketByteBufMixin.java new file mode 100644 index 0000000000..78401930af --- /dev/null +++ b/src/main/java/meteordevelopment/meteorclient/mixin/PacketByteBufMixin.java @@ -0,0 +1,22 @@ +/* + * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). + * Copyright (c) Meteor Development. + */ + +package meteordevelopment.meteorclient.mixin; + +import meteordevelopment.meteorclient.systems.modules.Modules; +import meteordevelopment.meteorclient.systems.modules.misc.AntiPacketKick; +import net.minecraft.nbt.NbtTagSizeTracker; +import net.minecraft.network.PacketByteBuf; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.ModifyArg; + +@Mixin(PacketByteBuf.class) +public class PacketByteBufMixin { + @ModifyArg(method = "readNbt()Lnet/minecraft/nbt/NbtCompound;", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/PacketByteBuf;readNbt(Lnet/minecraft/nbt/NbtTagSizeTracker;)Lnet/minecraft/nbt/NbtCompound;")) + private NbtTagSizeTracker xlPackets(NbtTagSizeTracker sizeTracker) { + return Modules.get().isActive(AntiPacketKick.class) ? NbtTagSizeTracker.EMPTY : sizeTracker; + } +} diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/PacketInflaterMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/PacketInflaterMixin.java new file mode 100644 index 0000000000..049bb87cd0 --- /dev/null +++ b/src/main/java/meteordevelopment/meteorclient/mixin/PacketInflaterMixin.java @@ -0,0 +1,21 @@ +/* + * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). + * Copyright (c) Meteor Development. + */ + +package meteordevelopment.meteorclient.mixin; + +import meteordevelopment.meteorclient.systems.modules.Modules; +import meteordevelopment.meteorclient.systems.modules.misc.AntiPacketKick; +import net.minecraft.network.PacketInflater; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.Constant; +import org.spongepowered.asm.mixin.injection.ModifyConstant; + +@Mixin(PacketInflater.class) +public class PacketInflaterMixin { + @ModifyConstant(method = "decode", constant = @Constant(intValue = 8388608)) + private int maxValue(int value) { + return Modules.get().isActive(AntiPacketKick.class) ? Integer.MAX_VALUE : value; + } +} diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/PlayerArmorSlotMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/PlayerArmorSlotMixin.java index e91e8f3981..e23fc32ab4 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/PlayerArmorSlotMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/PlayerArmorSlotMixin.java @@ -16,7 +16,6 @@ @Mixin(targets = "net/minecraft/screen/PlayerScreenHandler$1") public class PlayerArmorSlotMixin { - @Inject(method = "getMaxItemCount", at = @At("HEAD"), cancellable = true) private void onGetMaxItemCount(CallbackInfoReturnable cir) { if (Modules.get().get(InventoryTweaks.class).armorStorage()) cir.setReturnValue(64); diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/PlayerEntityMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/PlayerEntityMixin.java index 9c05671865..36d748e37d 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/PlayerEntityMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/PlayerEntityMixin.java @@ -10,22 +10,35 @@ import meteordevelopment.meteorclient.events.entity.player.ClipAtLedgeEvent; import meteordevelopment.meteorclient.systems.modules.Modules; import meteordevelopment.meteorclient.systems.modules.movement.Anchor; +import meteordevelopment.meteorclient.systems.modules.movement.Flight; +import meteordevelopment.meteorclient.systems.modules.movement.NoSlow; import meteordevelopment.meteorclient.systems.modules.player.SpeedMine; +import meteordevelopment.meteorclient.utils.world.BlockUtils; import net.minecraft.block.BlockState; import net.minecraft.entity.EntityType; import net.minecraft.entity.ItemEntity; import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.player.PlayerAbilities; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; +import net.minecraft.util.hit.BlockHitResult; +import net.minecraft.util.hit.HitResult; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; 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; +import static meteordevelopment.meteorclient.MeteorClient.mc; + @Mixin(PlayerEntity.class) public abstract class PlayerEntityMixin extends LivingEntity { + @Shadow + public abstract PlayerAbilities getAbilities(); + protected PlayerEntityMixin(EntityType entityType, World world) { super(entityType, world); } @@ -47,9 +60,19 @@ private void onDropItem(ItemStack stack, boolean bl, boolean bl2, CallbackInfoRe @Inject(method = "getBlockBreakingSpeed", at = @At(value = "RETURN"), cancellable = true) public void onGetBlockBreakingSpeed(BlockState block, CallbackInfoReturnable cir) { SpeedMine module = Modules.get().get(SpeedMine.class); - if (!module.isActive() || module.mode.get() != SpeedMine.Mode.Normal) return; + if (!module.isActive() || !module.filter(block.getBlock()) || module.mode.get() != SpeedMine.Mode.Normal) return; + float breakSpeed = cir.getReturnValue(); + float breakSpeedMod = (float) (breakSpeed * module.modifier.get()); + + HitResult result = mc.crosshairTarget; + if (result != null && result.getType() == HitResult.Type.BLOCK) { + BlockPos pos = ((BlockHitResult) result).getBlockPos(); + if (module.modifier.get() < 1 || (BlockUtils.canInstaBreak(pos, breakSpeed) == BlockUtils.canInstaBreak(pos, breakSpeedMod))) + cir.setReturnValue(breakSpeedMod); + else + cir.setReturnValue(0.9f / BlockUtils.calcBlockBreakingDelta2(pos, 1)); + } - cir.setReturnValue((float) (cir.getReturnValue() * module.modifier.get())); } @Inject(method = "jump", at = @At("HEAD"), cancellable = true) @@ -57,4 +80,20 @@ public void dontJump(CallbackInfo info) { Anchor module = Modules.get().get(Anchor.class); if (module.isActive() && module.cancelJump) info.cancel(); } + + @Inject(method = "getMovementSpeed", at = @At("RETURN"), cancellable = true) + private void onGetMovementSpeed(CallbackInfoReturnable info) { + if (!Modules.get().get(NoSlow.class).slowness()) return; + float walkSpeed = getAbilities().getWalkSpeed(); + if (info.getReturnValueF() < walkSpeed) { + if (isSprinting()) info.setReturnValue((float) (walkSpeed * 1.30000001192092896)); + else info.setReturnValue(walkSpeed); + } + } + + @Inject(method = "getOffGroundSpeed", at = @At("HEAD"), cancellable = true) + private void onGetOffGroundSpeed(CallbackInfoReturnable info) { + float speed = Modules.get().get(Flight.class).getOffGroundSpeed(); + if (speed != -1) info.setReturnValue(speed); + } } diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/PlayerListEntryMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/PlayerListEntryMixin.java new file mode 100644 index 0000000000..7c5a0c1068 --- /dev/null +++ b/src/main/java/meteordevelopment/meteorclient/mixin/PlayerListEntryMixin.java @@ -0,0 +1,34 @@ +/* + * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). + * Copyright (c) Meteor Development. + */ + +package meteordevelopment.meteorclient.mixin; + +import com.mojang.authlib.GameProfile; +import meteordevelopment.meteorclient.systems.modules.Modules; +import meteordevelopment.meteorclient.systems.modules.misc.NameProtect; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.network.PlayerListEntry; +import net.minecraft.client.util.DefaultSkinHelper; +import net.minecraft.util.Identifier; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(PlayerListEntry.class) +public abstract class PlayerListEntryMixin { + @Shadow + public abstract GameProfile getProfile(); + + @Inject(method = "getSkinTexture", at = @At("HEAD"), cancellable = true) + private void onGetTexture(CallbackInfoReturnable info) { + if (getProfile().getName().equals(MinecraftClient.getInstance().getSession().getUsername())) { + if (Modules.get().get(NameProtect.class).skinProtect()) { + info.setReturnValue(DefaultSkinHelper.getTexture()); + } + } + } +} diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/PlayerListHudMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/PlayerListHudMixin.java index bf7bbc271d..76cbec2240 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/PlayerListHudMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/PlayerListHudMixin.java @@ -15,16 +15,14 @@ import net.minecraft.client.util.math.MatrixStack; import net.minecraft.text.Text; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.ModifyArg; +import org.spongepowered.asm.mixin.injection.*; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(PlayerListHud.class) public class PlayerListHudMixin { - @ModifyArg(method = "render", at = @At(value = "INVOKE", target = "Ljava/lang/Math;min(II)I", ordinal = 0), index = 1) - private int modifyCount(int count) { + @ModifyConstant(constant = @Constant(longValue = 80L), method = "collectPlayerEntries") + private long modifyCount(long count) { BetterTab module = Modules.get().get(BetterTab.class); return module.isActive() ? module.tabSize.get() : count; diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/PlayerSkinProviderAccessor.java b/src/main/java/meteordevelopment/meteorclient/mixin/PlayerSkinProviderAccessor.java new file mode 100644 index 0000000000..5f2dc2f56e --- /dev/null +++ b/src/main/java/meteordevelopment/meteorclient/mixin/PlayerSkinProviderAccessor.java @@ -0,0 +1,18 @@ +/* + * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). + * Copyright (c) Meteor Development. + */ + +package meteordevelopment.meteorclient.mixin; + +import net.minecraft.client.texture.PlayerSkinProvider; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +import java.io.File; + +@Mixin(PlayerSkinProvider.class) +public interface PlayerSkinProviderAccessor { + @Accessor("skinCacheDir") + File getSkinCacheDir(); +} diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/ScreenMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/ScreenMixin.java index 28338fadf9..8daf612681 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/ScreenMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/ScreenMixin.java @@ -5,6 +5,9 @@ package meteordevelopment.meteorclient.mixin; +import com.mojang.brigadier.exceptions.CommandSyntaxException; +import meteordevelopment.meteorclient.systems.commands.Commands; +import meteordevelopment.meteorclient.systems.config.Config; import meteordevelopment.meteorclient.systems.modules.Modules; import meteordevelopment.meteorclient.systems.modules.render.NoRender; import meteordevelopment.meteorclient.utils.Utils; @@ -12,15 +15,17 @@ import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.tooltip.TooltipComponent; import net.minecraft.client.item.TooltipData; +import net.minecraft.text.Style; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import org.spongepowered.asm.mixin.injection.callback.LocalCapture; import java.util.List; -@Mixin(Screen.class) +@Mixin(value = Screen.class, priority = 500) // needs to be before baritone public abstract class ScreenMixin { @Inject(method = "renderBackground(Lnet/minecraft/client/util/math/MatrixStack;)V", at = @At("HEAD"), cancellable = true) private void onRenderBackground(CallbackInfo info) { diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/ShulkerBoxScreenMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/ShulkerBoxScreenMixin.java deleted file mode 100644 index ae9a35f5d4..0000000000 --- a/src/main/java/meteordevelopment/meteorclient/mixin/ShulkerBoxScreenMixin.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). - * Copyright (c) Meteor Development. - */ - -package meteordevelopment.meteorclient.mixin; - -import meteordevelopment.meteorclient.systems.modules.Modules; -import meteordevelopment.meteorclient.systems.modules.misc.InventoryTweaks; -import net.minecraft.client.gui.screen.ingame.HandledScreen; -import net.minecraft.client.gui.screen.ingame.ShulkerBoxScreen; -import net.minecraft.client.gui.widget.ButtonWidget; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.screen.ShulkerBoxScreenHandler; -import net.minecraft.text.Text; -import org.spongepowered.asm.mixin.Mixin; - -@Mixin(ShulkerBoxScreen.class) -public abstract class ShulkerBoxScreenMixin extends HandledScreen { - public ShulkerBoxScreenMixin(ShulkerBoxScreenHandler handler, PlayerInventory inventory, Text title) { - super(handler, inventory, title); - } - - @Override - protected void init() { - super.init(); - - InventoryTweaks invTweaks = Modules.get().get(InventoryTweaks.class); - - if (invTweaks.isActive() && invTweaks.showButtons()) { - addDrawableChild( - new ButtonWidget.Builder(Text.literal("Steal"), button -> invTweaks.steal(handler)) - .position(x + backgroundWidth - 88, y + 3) - .size(40, 12) - .build() - ); - - addDrawableChild( - new ButtonWidget.Builder(Text.literal("Dump"), button -> invTweaks.dump(handler)) - .position(x + backgroundWidth - 46, y + 3) - .size(40, 12) - .build() - ); - } - } -} diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/SimpleOptionMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/SimpleOptionMixin.java index 650e3c87db..ee22308152 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/SimpleOptionMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/SimpleOptionMixin.java @@ -5,111 +5,30 @@ package meteordevelopment.meteorclient.mixin; -import com.mojang.datafixers.util.Either; -import com.mojang.serialization.Codec; +import meteordevelopment.meteorclient.mixininterface.ISimpleOption; import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.widget.ClickableWidget; -import net.minecraft.client.option.GameOptions; import net.minecraft.client.option.SimpleOption; -import org.jetbrains.annotations.NotNull; -import org.spongepowered.asm.mixin.*; -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; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; -import java.util.Optional; +import java.util.Objects; import java.util.function.Consumer; -import java.util.function.Function; @Mixin(SimpleOption.class) -public class SimpleOptionMixin { - @Shadow @Final @Mutable private SimpleOption.Callbacks callbacks; - - @Unique private SimpleOption.Callbacks aCallbacks; - - @Inject(method = "setValue", at = @At("HEAD")) - private void onSetValueHead(T value, CallbackInfo info) { - if (MinecraftClient.getInstance().options == null) return; - - SimpleOption.Callbacks c = getCallbacks(); - - if (c != null) { - aCallbacks = this.callbacks; - this.callbacks = c; - } - } - - @Inject(method = "setValue", at = @At("RETURN")) - public void onSetValueReturn(T value, CallbackInfo info) { - if (aCallbacks != null) { - this.callbacks = aCallbacks; - aCallbacks = null; - } - } - - @SuppressWarnings("unchecked") - @Inject(method = "getCodec", at = @At("HEAD"), cancellable = true) - public void onGetCodec(CallbackInfoReturnable> info) { - GameOptions options = MinecraftClient.getInstance().options; - if (options == null) return; - - if ((Object) this == options.getGamma()) { - info.setReturnValue((Codec) Codec.either(Codec.doubleRange(Double.MIN_VALUE, Double.MAX_VALUE), Codec.BOOL).xmap(either -> either.map(value -> value, value -> value ? 1.0 : 0.0), Either::left)); - } - } - - @Unique - public SimpleOption.Callbacks getCallbacks() { - GameOptions options = MinecraftClient.getInstance().options; - - if ((Object) this == options.getGamma()) { - return createCallback(); - } - else if ((Object) this == options.getFov()) { - return createCallback(); - } - - return null; - } - - @NotNull - private SimpleOption.Callbacks createCallback() { - return new SimpleOption.Callbacks<>() { - @Override - public Function, ClickableWidget> getButtonCreator(SimpleOption.TooltipFactory tooltipFactory, GameOptions gameOptions, int x, int y, int width, Consumer changeCallback) { - return null; - } - - @Override - public Optional validate(T value) { - return Optional.of(value); - } - - @Override - public Codec codec() { - return null; +public class SimpleOptionMixin implements ISimpleOption { + @Shadow Object value; + @Shadow @Final private Consumer changeCallback; + + @Override + public void set(Object value) { + if (!MinecraftClient.getInstance().isRunning()) { + this.value = value; + } else { + if (!Objects.equals(this.value, value)) { + this.value = value; + this.changeCallback.accept(this.value); } - }; - } - @Shadow - T value; -// Credit to https://github.com/seasnale/custom-fov - @Shadow @Final - private Consumer changeCallback; - - @Inject( - method = "setValue", - at = @At(value = "INVOKE", target = "Lnet/minecraft/client/option/SimpleOption$Callbacks;validate(Ljava/lang/Object;)Ljava/util/Optional;", shift = At.Shift.BEFORE), - cancellable = true - ) - private void earlyReturn(T value, CallbackInfo ci) { - this.value = value; - - if (MinecraftClient.getInstance().isRunning()) { - changeCallback.accept(value); } - - ci.cancel(); } } diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/StringHelperMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/StringHelperMixin.java new file mode 100644 index 0000000000..1375bbb0b8 --- /dev/null +++ b/src/main/java/meteordevelopment/meteorclient/mixin/StringHelperMixin.java @@ -0,0 +1,21 @@ +/* + * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). + * Copyright (c) Meteor Development. + */ + +package meteordevelopment.meteorclient.mixin; + +import meteordevelopment.meteorclient.systems.modules.Modules; +import meteordevelopment.meteorclient.systems.modules.misc.BetterChat; +import net.minecraft.util.StringHelper; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.ModifyArg; + +@Mixin(StringHelper.class) +public class StringHelperMixin { + @ModifyArg(method = "truncateChat", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/StringHelper;truncate(Ljava/lang/String;IZ)Ljava/lang/String;"), index = 1) + private static int injected(int maxLength) { // this method is only used in one place, to truncate chat messages, so it's fine to do this + return (Modules.get().get(BetterChat.class).isInfiniteChatBox() ? Integer.MAX_VALUE : maxLength); + } +} diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/SweetBerryBushBlockMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/SweetBerryBushBlockMixin.java new file mode 100644 index 0000000000..342e5f9cd8 --- /dev/null +++ b/src/main/java/meteordevelopment/meteorclient/mixin/SweetBerryBushBlockMixin.java @@ -0,0 +1,28 @@ +/* + * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). + * Copyright (c) Meteor Development. + */ + +package meteordevelopment.meteorclient.mixin; + +import meteordevelopment.meteorclient.systems.modules.Modules; +import meteordevelopment.meteorclient.systems.modules.movement.NoSlow; +import net.minecraft.block.BlockState; +import net.minecraft.block.SweetBerryBushBlock; +import net.minecraft.entity.Entity; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import static meteordevelopment.meteorclient.MeteorClient.mc; + +@Mixin(SweetBerryBushBlock.class) +public class SweetBerryBushBlockMixin { + @Inject(method = "onEntityCollision", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;slowMovement(Lnet/minecraft/block/BlockState;Lnet/minecraft/util/math/Vec3d;)V"), cancellable = true) + private void onEntityCollision(BlockState state, World world, BlockPos pos, Entity entity, CallbackInfo info) { + if (entity == mc.player && Modules.get().get(NoSlow.class).berryBush()) info.cancel(); + } +} diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/TextRendererMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/TextRendererMixin.java new file mode 100644 index 0000000000..d90845dc90 --- /dev/null +++ b/src/main/java/meteordevelopment/meteorclient/mixin/TextRendererMixin.java @@ -0,0 +1,21 @@ +/* + * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). + * Copyright (c) Meteor Development. + */ + +package meteordevelopment.meteorclient.mixin; + +import meteordevelopment.meteorclient.systems.modules.Modules; +import meteordevelopment.meteorclient.systems.modules.render.NoRender; +import net.minecraft.text.Style; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +@Mixin(targets = "net.minecraft.client.font.TextRenderer$Drawer") +public class TextRendererMixin { + @Redirect(method = "accept", at = @At(value = "INVOKE", target = "Lnet/minecraft/text/Style;isObfuscated()Z")) + private boolean onRenderObfuscatedStyle(Style instance) { + return !Modules.get().get(NoRender.class).noObfuscation() && instance.isObfuscated(); + } +} diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/WorldAccessor.java b/src/main/java/meteordevelopment/meteorclient/mixin/WorldAccessor.java index e6a248c9a6..2c61eb7a38 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/WorldAccessor.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/WorldAccessor.java @@ -7,19 +7,12 @@ import net.minecraft.entity.Entity; import net.minecraft.world.World; -import net.minecraft.world.chunk.BlockEntityTickInvoker; import net.minecraft.world.entity.EntityLookup; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; import org.spongepowered.asm.mixin.gen.Invoker; -import java.util.List; - @Mixin(World.class) public interface WorldAccessor { - @Accessor("blockEntityTickers") - List getBlockEntityTickers(); - @Invoker("getEntityLookup") EntityLookup getEntityLookup(); } diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/WorldBorderMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/WorldBorderMixin.java new file mode 100644 index 0000000000..e92c975fcd --- /dev/null +++ b/src/main/java/meteordevelopment/meteorclient/mixin/WorldBorderMixin.java @@ -0,0 +1,27 @@ +/* + * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). + * Copyright (c) Meteor Development. + */ + +package meteordevelopment.meteorclient.mixin; + +import meteordevelopment.meteorclient.systems.modules.Modules; +import meteordevelopment.meteorclient.systems.modules.world.Collisions; +import net.minecraft.world.border.WorldBorder; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(WorldBorder.class) +public abstract class WorldBorderMixin { + @Inject(method = "canCollide", at = @At("HEAD"), cancellable = true) + private void canCollide(CallbackInfoReturnable info) { + if (Modules.get().get(Collisions.class).ignoreBorder()) info.setReturnValue(false); + } + + @Inject(method = "contains(Lnet/minecraft/util/math/BlockPos;)Z", at = @At("HEAD"), cancellable = true) + private void contains(CallbackInfoReturnable info) { + if (Modules.get().get(Collisions.class).ignoreBorder()) info.setReturnValue(true); + } +} diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/WorldRendererMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/WorldRendererMixin.java index 2bb5c5ab59..c6538a7396 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/WorldRendererMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/WorldRendererMixin.java @@ -58,8 +58,8 @@ private void onRenderWeather(LightmapTextureManager manager, float f, double d, if (Modules.get().get(NoRender.class).noWeather()) info.cancel(); } - @Inject(method = "method_43788(Lnet/minecraft/client/render/Camera;)Z", at = @At("HEAD"), cancellable = true) - private void method_43788(Camera camera, CallbackInfoReturnable info) { + @Inject(method = "hasBlindnessOrDarkness(Lnet/minecraft/client/render/Camera;)Z", at = @At("HEAD"), cancellable = true) + private void hasBlindnessOrDarkness(Camera camera, CallbackInfoReturnable info) { if (Modules.get().get(NoRender.class).noBlindness() || Modules.get().get(NoRender.class).noDarkness()) info.setReturnValue(null); } @@ -78,7 +78,7 @@ private void renderEntity(Entity entity, double cameraX, double cameraY, double @Unique private void draw(Entity entity, double cameraX, double cameraY, double cameraZ, float tickDelta, VertexConsumerProvider vertexConsumers, MatrixStack matrices, EntityShader shader, Color color) { - if (shader.shouldDraw(entity) && !PostProcessShaders.isCustom(vertexConsumers)) { + if (shader.shouldDraw(entity) && !PostProcessShaders.isCustom(vertexConsumers) && color != null) { Framebuffer prevBuffer = this.entityOutlinesFramebuffer; this.entityOutlinesFramebuffer = shader.framebuffer; PostProcessShaders.rendering = true; diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/YggdrasilMinecraftSessionServiceAccessor.java b/src/main/java/meteordevelopment/meteorclient/mixin/YggdrasilMinecraftSessionServiceAccessor.java new file mode 100644 index 0000000000..36dc719950 --- /dev/null +++ b/src/main/java/meteordevelopment/meteorclient/mixin/YggdrasilMinecraftSessionServiceAccessor.java @@ -0,0 +1,20 @@ +/* + * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). + * Copyright (c) Meteor Development. + */ + +package meteordevelopment.meteorclient.mixin; + +import com.mojang.authlib.Environment; +import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService; +import com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Invoker; + +@Mixin(YggdrasilMinecraftSessionService.class) +public interface YggdrasilMinecraftSessionServiceAccessor { + @Invoker("") + static YggdrasilMinecraftSessionService createYggdrasilMinecraftSessionService(final YggdrasilAuthenticationService service, final Environment env) { + throw new UnsupportedOperationException(); + } +} diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/indigo/TerrainRenderContextMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/indigo/TerrainRenderContextMixin.java deleted file mode 100644 index 4089fbf284..0000000000 --- a/src/main/java/meteordevelopment/meteorclient/mixin/indigo/TerrainRenderContextMixin.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). - * Copyright (c) Meteor Development. - */ - -package meteordevelopment.meteorclient.mixin.indigo; - -import meteordevelopment.meteorclient.systems.modules.Modules; -import meteordevelopment.meteorclient.systems.modules.render.Xray; -import net.fabricmc.fabric.impl.client.indigo.renderer.render.TerrainRenderContext; -import net.minecraft.block.BlockState; -import net.minecraft.client.render.model.BakedModel; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.util.math.BlockPos; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Mixin(value = TerrainRenderContext.class, remap = false) -public class TerrainRenderContextMixin { - @Inject(method = "tessellateBlock", at = @At("HEAD"), cancellable = true) - private void onTessellateBlock(BlockState blockState, BlockPos blockPos, BakedModel model, MatrixStack matrixStack, CallbackInfoReturnable info) { - Xray xray = Modules.get().get(Xray.class); - - if (xray.isActive() && xray.isBlocked(blockState.getBlock(), blockPos)) { -// info.cancel(); - } - } -} diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/lithium/ChunkAwareBlockCollisionSweeperMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/lithium/ChunkAwareBlockCollisionSweeperMixin.java new file mode 100644 index 0000000000..1ada66b788 --- /dev/null +++ b/src/main/java/meteordevelopment/meteorclient/mixin/lithium/ChunkAwareBlockCollisionSweeperMixin.java @@ -0,0 +1,28 @@ +/* + * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). + * Copyright (c) Meteor Development. + */ + +package meteordevelopment.meteorclient.mixin.lithium; + +import me.jellysquid.mods.lithium.common.entity.movement.ChunkAwareBlockCollisionSweeper; +import meteordevelopment.meteorclient.MeteorClient; +import meteordevelopment.meteorclient.events.world.CollisionShapeEvent; +import net.minecraft.block.BlockState; +import net.minecraft.block.ShapeContext; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.shape.VoxelShape; +import net.minecraft.util.shape.VoxelShapes; +import net.minecraft.world.BlockView; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +@Mixin(value = ChunkAwareBlockCollisionSweeper.class) +public abstract class ChunkAwareBlockCollisionSweeperMixin { + @Redirect(method = "computeNext", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BlockState;getCollisionShape(Lnet/minecraft/world/BlockView;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/ShapeContext;)Lnet/minecraft/util/shape/VoxelShape;")) + private VoxelShape onComputeNextCollisionBox(BlockState state, BlockView world, BlockPos pos, ShapeContext context) { + CollisionShapeEvent event = MeteorClient.EVENT_BUS.post(CollisionShapeEvent.get(state, pos, state.getCollisionShape(world, pos, context))); + return event.isCancelled() ? VoxelShapes.empty() : event.shape; + } +} diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/sodium/MeshVertexConsumerMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/sodium/MeshVertexConsumerMixin.java new file mode 100644 index 0000000000..7c361703a2 --- /dev/null +++ b/src/main/java/meteordevelopment/meteorclient/mixin/sodium/MeshVertexConsumerMixin.java @@ -0,0 +1,35 @@ +/* + * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). + * Copyright (c) Meteor Development. + */ + +package meteordevelopment.meteorclient.mixin.sodium; + +import me.jellysquid.mods.sodium.client.render.vertex.VertexBufferWriter; +import me.jellysquid.mods.sodium.client.render.vertex.VertexFormatDescription; +import me.jellysquid.mods.sodium.client.render.vertex.transform.CommonVertexElement; +import meteordevelopment.meteorclient.utils.render.MeshVertexConsumerProvider; +import net.minecraft.client.render.VertexConsumer; +import org.lwjgl.system.MemoryStack; +import org.lwjgl.system.MemoryUtil; +import org.spongepowered.asm.mixin.Mixin; + +@Mixin(value = MeshVertexConsumerProvider.MeshVertexConsumer.class, remap = false) +public abstract class MeshVertexConsumerMixin implements VertexConsumer, VertexBufferWriter { + @Override + public void push(MemoryStack stack, long ptr, int count, VertexFormatDescription format) { + int positionOffset = format.elementOffsets[CommonVertexElement.POSITION.ordinal()]; + if (positionOffset == -1) return; + + for (int i = 0; i < count; i++) { + long positionPtr = ptr + (long) format.stride * i + positionOffset; + + float x = MemoryUtil.memGetFloat(positionPtr); + float y = MemoryUtil.memGetFloat(positionPtr + 4); + float z = MemoryUtil.memGetFloat(positionPtr + 8); + + vertex(x, y, z); + next(); + } + } +} diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/sodium/SodiumBlockRendererMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/sodium/SodiumBlockRendererMixin.java index 1cd58332be..a5922e33b6 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/sodium/SodiumBlockRendererMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/sodium/SodiumBlockRendererMixin.java @@ -5,104 +5,50 @@ package meteordevelopment.meteorclient.mixin.sodium; -import me.jellysquid.mods.sodium.client.model.IndexBufferBuilder; -import me.jellysquid.mods.sodium.client.model.light.data.QuadLightData; -import me.jellysquid.mods.sodium.client.model.quad.ModelQuadView; -import me.jellysquid.mods.sodium.client.model.quad.blender.ColorBlender; -import me.jellysquid.mods.sodium.client.model.quad.blender.ColorSampler; -import me.jellysquid.mods.sodium.client.model.quad.properties.ModelQuadOrientation; -import me.jellysquid.mods.sodium.client.model.quad.properties.ModelQuadWinding; import me.jellysquid.mods.sodium.client.render.chunk.compile.buffers.ChunkModelBuilder; -import me.jellysquid.mods.sodium.client.render.chunk.format.ModelVertexSink; -import me.jellysquid.mods.sodium.client.render.pipeline.BlockRenderer; +import me.jellysquid.mods.sodium.client.render.chunk.compile.pipeline.BlockRenderContext; +import me.jellysquid.mods.sodium.client.render.chunk.compile.pipeline.BlockRenderer; import me.jellysquid.mods.sodium.client.util.color.ColorABGR; import meteordevelopment.meteorclient.systems.modules.render.Xray; -import net.minecraft.block.BlockState; -import net.minecraft.client.render.model.BakedModel; -import net.minecraft.client.render.model.BakedQuad; -import net.minecraft.client.texture.Sprite; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Vec3d; -import net.minecraft.world.BlockRenderView; -import org.spongepowered.asm.mixin.Final; 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.ModifyVariable; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import java.util.Arrays; + @Mixin(value = BlockRenderer.class, remap = false) public class SodiumBlockRendererMixin { - @Shadow @Final private ColorBlender colorBlender; - @Unique private final ThreadLocal alphas = new ThreadLocal<>(); + @Unique private final ThreadLocal colors = ThreadLocal.withInitial(() -> new int[4]); @Inject(method = "renderModel", at = @At("HEAD"), cancellable = true) - private void onRenderModel(BlockRenderView world, BlockState state, BlockPos pos, BlockPos origin, BakedModel model, ChunkModelBuilder buffers, boolean cull, long seed, CallbackInfoReturnable info) { - int alpha = Xray.getAlpha(state, pos); + private void onRenderModel(BlockRenderContext ctx, ChunkModelBuilder buffers, CallbackInfoReturnable info) { + int alpha = Xray.getAlpha(ctx.state(), ctx.pos()); if (alpha == 0) info.setReturnValue(false); else alphas.set(alpha); } - @Inject(method = "renderQuad", at = @At(value = "HEAD"), cancellable = true) - private void onRenderQuad(BlockRenderView world, BlockState state, BlockPos pos, BlockPos origin, ModelVertexSink vertices, IndexBufferBuilder indices, Vec3d blockOffset, ColorSampler colorSampler, BakedQuad bakedQuad, QuadLightData light, ChunkModelBuilder model, CallbackInfo info) { + // TODO: Looks like Sodium disables transparency on blocks that aren't supposed to be transparent + @ModifyVariable(method = "writeGeometry", at = @At("HEAD"), argsOnly = true, index = 6) + private int[] onWriteGeometryModifyColors(int[] colors) { int alpha = alphas.get(); - if (alpha == 0) info.cancel(); - else if (alpha != -1) { - whRenderQuad(world, state, pos, origin, vertices, indices, blockOffset, colorSampler, bakedQuad, light, model, alpha); - info.cancel(); - } - } - - // https://github.com/CaffeineMC/sodium-fabric/blob/8b3015efe85be9336a150ff7c26085ea3d2d43d0/src/main/java/me/jellysquid/mods/sodium/client/render/pipeline/BlockRenderer.java#L119 - // Copied from Sodium, for now, can't think of a better way, because of the nature of the locals, and for loop. - // Mixin seems to freak out when I try to do this the "right" way - Wala (sobbing) - @Unique - private void whRenderQuad(BlockRenderView world, BlockState state, BlockPos pos, BlockPos origin, ModelVertexSink vertices, IndexBufferBuilder indices, Vec3d blockOffset, ColorSampler colorSampler, BakedQuad bakedQuad, QuadLightData light, ChunkModelBuilder model, int alpha) { - ModelQuadView src = (ModelQuadView) bakedQuad; - ModelQuadOrientation orientation = ModelQuadOrientation.orientByBrightness(light.br); - - int[] colors = null; - - if (bakedQuad.hasColor()) { - colors = this.colorBlender.getColors(world, pos, src, colorSampler, state); - } - - int vertexStart = vertices.getVertexCount(); - - for (int i = 0; i < 4; i++) { - int j = orientation.getVertexIndex(i); - - float x = src.getX(j) + (float) blockOffset.getX(); - float y = src.getY(j) + (float) blockOffset.getY(); - float z = src.getZ(j) + (float) blockOffset.getZ(); - - int color = ColorABGR.mul(colors != null ? colors[j] : 0xFFFFFFFF, light.br[j]); - - int blue = ColorABGR.unpackBlue(color); - int green = ColorABGR.unpackGreen(color); - int red = ColorABGR.unpackRed(color); - - color = ColorABGR.pack(red, green, blue, alpha); - - float u = src.getTexU(j); - float v = src.getTexV(j); - - int lm = light.lm[j]; - - vertices.writeVertex(origin, x, y, z, color, u, v, lm, model.getChunkId()); + if (alpha != -1) { + if (colors == null) { + colors = this.colors.get(); + Arrays.fill(colors, ColorABGR.pack(255, 255, 255, alpha)); + } + else { + for (int i = 0; i < colors.length; i++) { + colors[i] = ColorABGR.withAlpha(colors[i], alpha / 255f); + } + } } - indices.add(vertexStart, ModelQuadWinding.CLOCKWISE); - - Sprite sprite = src.getSprite(); - - if (sprite != null) { - model.addSprite(sprite); - } + return colors; } } diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/sodium/SodiumFluidRendererMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/sodium/SodiumFluidRendererMixin.java index d464339dd9..22a9f1bd5e 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/sodium/SodiumFluidRendererMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/sodium/SodiumFluidRendererMixin.java @@ -9,7 +9,8 @@ import me.jellysquid.mods.sodium.client.model.quad.ModelQuadView; import me.jellysquid.mods.sodium.client.model.quad.blender.ColorSampler; import me.jellysquid.mods.sodium.client.render.chunk.compile.buffers.ChunkModelBuilder; -import me.jellysquid.mods.sodium.client.render.pipeline.FluidRenderer; +import me.jellysquid.mods.sodium.client.render.chunk.compile.pipeline.FluidRenderer; +import me.jellysquid.mods.sodium.client.util.color.ColorABGR; import me.jellysquid.mods.sodium.client.util.color.ColorARGB; import meteordevelopment.meteorclient.systems.modules.Modules; import meteordevelopment.meteorclient.systems.modules.render.Xray; @@ -47,8 +48,8 @@ private void onRender(BlockRenderView world, FluidState fluidState, BlockPos pos /** * @author Walaryne */ - @Inject(method = "calculateQuadColors", at = @At("TAIL")) - private void onCalculateQuadColors(ModelQuadView quad, BlockRenderView world, BlockPos pos, LightPipeline lighter, Direction dir, float brightness, ColorSampler colorSampler, FluidState fluidState, CallbackInfo info) { + @Inject(method = "updateQuad", at = @At("TAIL")) + private void onUpdateQuad(ModelQuadView quad, BlockRenderView world, BlockPos pos, LightPipeline lighter, Direction dir, float brightness, ColorSampler colorSampler, FluidState fluidState, CallbackInfo info) { // Ambience Ambience ambience = Modules.get().get(Ambience.class); @@ -59,11 +60,8 @@ private void onCalculateQuadColors(ModelQuadView quad, BlockRenderView world, Bl // XRay and Wallhack int alpha = alphas.get(); - if (alpha != -1) { - quadColors[0] = (alpha << 24) | (quadColors[0] & 0x00FFFFFF); - quadColors[1] = (alpha << 24) | (quadColors[1] & 0x00FFFFFF); - quadColors[2] = (alpha << 24) | (quadColors[2] & 0x00FFFFFF); - quadColors[3] = (alpha << 24) | (quadColors[3] & 0x00FFFFFF); + for (int i = 0; i < quadColors.length; i++) { + quadColors[i] = ColorABGR.withAlpha(quadColors[i], alpha / 255f); } } } diff --git a/src/main/java/meteordevelopment/meteorclient/mixininterface/IBox.java b/src/main/java/meteordevelopment/meteorclient/mixininterface/IBox.java index 03159d3316..daf97f8a1f 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixininterface/IBox.java +++ b/src/main/java/meteordevelopment/meteorclient/mixininterface/IBox.java @@ -5,8 +5,14 @@ package meteordevelopment.meteorclient.mixininterface; +import net.minecraft.util.math.BlockPos; + public interface IBox { void expand(double v); void set(double x1, double y1, double z1, double x2, double y2, double z2); + + default void set(BlockPos pos) { + set(pos.getX(), pos.getY(), pos.getZ(), pos.getX() + 1, pos.getY() + 1, pos.getZ() + 1); + } } diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/StarscriptAccessor.java b/src/main/java/meteordevelopment/meteorclient/mixininterface/ISimpleOption.java similarity index 57% rename from src/main/java/meteordevelopment/meteorclient/mixin/StarscriptAccessor.java rename to src/main/java/meteordevelopment/meteorclient/mixininterface/ISimpleOption.java index f142235b0b..12ebbebd21 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/StarscriptAccessor.java +++ b/src/main/java/meteordevelopment/meteorclient/mixininterface/ISimpleOption.java @@ -3,5 +3,8 @@ * Copyright (c) Meteor Development. */ -package meteordevelopment.meteorclient.mixin;public interface StarscriptAccessor { +package meteordevelopment.meteorclient.mixininterface; + +public interface ISimpleOption { + void set(Object value); } diff --git a/src/main/java/meteordevelopment/meteorclient/renderer/text/VanillaTextRenderer.java b/src/main/java/meteordevelopment/meteorclient/renderer/text/VanillaTextRenderer.java index 6c5d6e62f3..5e41938cbc 100644 --- a/src/main/java/meteordevelopment/meteorclient/renderer/text/VanillaTextRenderer.java +++ b/src/main/java/meteordevelopment/meteorclient/renderer/text/VanillaTextRenderer.java @@ -7,6 +7,7 @@ import com.mojang.blaze3d.systems.RenderSystem; import meteordevelopment.meteorclient.utils.render.color.Color; +import net.minecraft.client.font.TextRenderer.TextLayerType; import net.minecraft.client.render.BufferBuilder; import net.minecraft.client.render.LightmapTextureManager; import net.minecraft.client.render.VertexConsumerProvider; @@ -78,7 +79,7 @@ public double render(String text, double x, double y, Color color, boolean shado matrix = matrices.peek().getPositionMatrix(); } - double x2 = mc.textRenderer.draw(text, (float) (x / scale), (float) (y / scale), color.getPacked(), shadow, matrix, immediate, false, 0, LightmapTextureManager.MAX_LIGHT_COORDINATE); + double x2 = mc.textRenderer.draw(text, (float) (x / scale), (float) (y / scale), color.getPacked(), shadow, matrix, immediate, TextLayerType.NORMAL, 0, LightmapTextureManager.MAX_LIGHT_COORDINATE); if (scaleIndividually) matrices.pop(); diff --git a/src/main/java/meteordevelopment/meteorclient/settings/EntityTypeListSetting.java b/src/main/java/meteordevelopment/meteorclient/settings/EntityTypeListSetting.java index 908ad8b9be..7ead9f4ead 100644 --- a/src/main/java/meteordevelopment/meteorclient/settings/EntityTypeListSetting.java +++ b/src/main/java/meteordevelopment/meteorclient/settings/EntityTypeListSetting.java @@ -22,15 +22,15 @@ import java.util.HashMap; import java.util.Map; import java.util.function.Consumer; +import java.util.function.Predicate; -// TODO: Change onlyAttackable to a filter public class EntityTypeListSetting extends Setting>> { - public final boolean onlyAttackable; + public final Predicate> filter; - public EntityTypeListSetting(String name, String description, Object2BooleanMap> defaultValue, Consumer>> onChanged, Consumer>>> onModuleActivated, IVisible visible, boolean onlyAttackable) { + public EntityTypeListSetting(String name, String description, Object2BooleanMap> defaultValue, Consumer>> onChanged, Consumer>>> onModuleActivated, IVisible visible, Predicate> filter) { super(name, description, defaultValue, onChanged, onModuleActivated, visible); - this.onlyAttackable = onlyAttackable; + this.filter = filter; } @Override @@ -83,14 +83,14 @@ public Object2BooleanMap> load(NbtCompound tag) { NbtList valueTag = tag.getList("value", 8); for (NbtElement tagI : valueTag) { EntityType type = Registries.ENTITY_TYPE.get(new Identifier(tagI.asString())); - if (!onlyAttackable || EntityUtils.isAttackable(type)) get().put(type, true); + if (filter == null || filter.test(type)) get().put(type, true); } return get(); } public static class Builder extends SettingBuilder>, EntityTypeListSetting> { - private boolean onlyAttackable = false; + private Predicate> filter; public Builder() { super(new Object2BooleanOpenHashMap<>(0)); @@ -101,7 +101,12 @@ public Builder defaultValue(EntityType... defaults) { } public Builder onlyAttackable() { - onlyAttackable = true; + filter = EntityUtils::isAttackable; + return this; + } + + public Builder filter(Predicate> filter){ + this.filter = filter; return this; } @@ -123,7 +128,7 @@ public Builder defaultEnemies() { @Override public EntityTypeListSetting build() { - return new EntityTypeListSetting(name, description, defaultValue, onChanged, onModuleActivated, visible, onlyAttackable); + return new EntityTypeListSetting(name, description, defaultValue, onChanged, onModuleActivated, visible, filter); } } } diff --git a/src/main/java/meteordevelopment/meteorclient/settings/PacketListSetting.java b/src/main/java/meteordevelopment/meteorclient/settings/PacketListSetting.java index c1855775da..a115af1dee 100644 --- a/src/main/java/meteordevelopment/meteorclient/settings/PacketListSetting.java +++ b/src/main/java/meteordevelopment/meteorclient/settings/PacketListSetting.java @@ -11,7 +11,7 @@ import net.minecraft.nbt.NbtElement; import net.minecraft.nbt.NbtList; import net.minecraft.nbt.NbtString; -import net.minecraft.network.Packet; +import net.minecraft.network.packet.Packet; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/meteordevelopment/meteorclient/settings/ScreenHandlerListSetting.java b/src/main/java/meteordevelopment/meteorclient/settings/ScreenHandlerListSetting.java new file mode 100644 index 0000000000..30f624c9c0 --- /dev/null +++ b/src/main/java/meteordevelopment/meteorclient/settings/ScreenHandlerListSetting.java @@ -0,0 +1,96 @@ +/* + * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). + * Copyright (c) Meteor Development. + */ + +package meteordevelopment.meteorclient.settings; + +import net.minecraft.nbt.NbtCompound; +import net.minecraft.nbt.NbtElement; +import net.minecraft.nbt.NbtList; +import net.minecraft.nbt.NbtString; +import net.minecraft.registry.Registries; +import net.minecraft.screen.ScreenHandlerType; +import net.minecraft.util.Identifier; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.function.Consumer; + +public class ScreenHandlerListSetting extends Setting>> { + public ScreenHandlerListSetting(String name, String description, List> defaultValue, Consumer>> onChanged, Consumer>>> onModuleActivated, IVisible visible) { + super(name, description, defaultValue, onChanged, onModuleActivated, visible); + } + + @Override + public void resetImpl() { + value = new ArrayList<>(defaultValue); + } + + @Override + protected List> parseImpl(String str) { + String[] values = str.split(","); + List> handlers = new ArrayList<>(values.length); + + try { + for (String value : values) { + ScreenHandlerType handler = parseId(Registries.SCREEN_HANDLER, value); + if (handler != null) handlers.add(handler); + } + } catch (Exception ignored) { + } + + return handlers; + } + + @Override + protected boolean isValueValid(List> value) { + return true; + } + + @Override + public Iterable getIdentifierSuggestions() { + return Registries.SCREEN_HANDLER.getIds(); + } + + @Override + public NbtCompound save(NbtCompound tag) { + NbtList valueTag = new NbtList(); + for (ScreenHandlerType type : get()) { + Identifier id = Registries.SCREEN_HANDLER.getId(type); + if (id != null) valueTag.add(NbtString.of(id.toString())); + } + tag.put("value", valueTag); + + return tag; + } + + @Override + public List> load(NbtCompound tag) { + get().clear(); + + NbtList valueTag = tag.getList("value", 8); + for (NbtElement tagI : valueTag) { + ScreenHandlerType type = Registries.SCREEN_HANDLER.get(new Identifier(tagI.asString())); + if (type != null) get().add(type); + } + + return get(); + } + + public static class Builder extends SettingBuilder>, ScreenHandlerListSetting> { + public Builder() { + super(new ArrayList<>(0)); + } + + public Builder defaultValue(ScreenHandlerType... defaults) { + return defaultValue(defaults != null ? Arrays.asList(defaults) : new ArrayList<>()); + } + + @Override + public ScreenHandlerListSetting build() { + return new ScreenHandlerListSetting(name, description, defaultValue, onChanged, onModuleActivated, visible); + } + } +} diff --git a/src/main/java/meteordevelopment/meteorclient/systems/Systems.java b/src/main/java/meteordevelopment/meteorclient/systems/Systems.java index 1eceea784e..8b7a06bb31 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/Systems.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/Systems.java @@ -40,9 +40,9 @@ public static void init() { config.load(); add(new Modules()); + add(new Macros()); add(new Commands()); add(new Friends()); - add(new Macros()); add(new Accounts()); add(new Waypoints()); add(new Profiles()); diff --git a/src/main/java/meteordevelopment/meteorclient/systems/accounts/Account.java b/src/main/java/meteordevelopment/meteorclient/systems/accounts/Account.java index 5e202bb564..263895ec17 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/accounts/Account.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/accounts/Account.java @@ -5,13 +5,22 @@ package meteordevelopment.meteorclient.systems.accounts; -import com.mojang.authlib.yggdrasil.YggdrasilEnvironment; -import com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService; +import com.mojang.authlib.exceptions.AuthenticationException; +import com.mojang.authlib.minecraft.MinecraftSessionService; +import com.mojang.authlib.minecraft.UserApiService; +import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService; import meteordevelopment.meteorclient.mixin.MinecraftClientAccessor; +import meteordevelopment.meteorclient.mixin.PlayerSkinProviderAccessor; import meteordevelopment.meteorclient.utils.misc.ISerializable; import meteordevelopment.meteorclient.utils.misc.NbtException; +import net.minecraft.client.network.SocialInteractionsManager; +import net.minecraft.client.report.AbuseReportContext; +import net.minecraft.client.report.ReporterEnvironment; +import net.minecraft.client.texture.PlayerSkinProvider; +import net.minecraft.client.util.ProfileKeys; import net.minecraft.client.util.Session; import net.minecraft.nbt.NbtCompound; +import net.minecraft.network.encryption.SignatureVerifier; import static meteordevelopment.meteorclient.MeteorClient.mc; @@ -30,10 +39,8 @@ public Account(AccountType type, String name) { public abstract boolean fetchInfo(); public boolean login() { - YggdrasilMinecraftSessionService service = (YggdrasilMinecraftSessionService) mc.getSessionService(); - AccountUtils.setBaseUrl(service, YggdrasilEnvironment.PROD.getEnvironment().getSessionHost() + "/session/minecraft/"); - AccountUtils.setJoinUrl(service, YggdrasilEnvironment.PROD.getEnvironment().getSessionHost() + "/session/minecraft/join"); - AccountUtils.setCheckUrl(service, YggdrasilEnvironment.PROD.getEnvironment().getSessionHost() + "/session/minecraft/hasJoined"); + YggdrasilAuthenticationService authenticationService = new YggdrasilAuthenticationService(((MinecraftClientAccessor) mc).getProxy()); + applyLoginEnvironment(authenticationService, authenticationService.createMinecraftSessionService()); return true; } @@ -51,9 +58,28 @@ public AccountCache getCache() { return cache; } - protected void setSession(Session session) { - ((MinecraftClientAccessor) mc).setSession(session); + public static void setSession(Session session) { + MinecraftClientAccessor mca = (MinecraftClientAccessor) mc; + mca.setSession(session); mc.getSessionProperties().clear(); + UserApiService apiService; + try { + apiService = mca.getAuthenticationService().createUserApiService(session.getAccessToken()); + } catch (AuthenticationException e) { + apiService = UserApiService.OFFLINE; + } + mca.setUserApiService(apiService); + mca.setSocialInteractionsManager(new SocialInteractionsManager(mc, apiService)); + mca.setProfileKeys(ProfileKeys.create(apiService, session, mc.runDirectory.toPath())); + mca.setAbuseReportContext(AbuseReportContext.create(ReporterEnvironment.ofIntegratedServer(), apiService)); + } + + public static void applyLoginEnvironment(YggdrasilAuthenticationService authService, MinecraftSessionService sessService) { + MinecraftClientAccessor mca = (MinecraftClientAccessor) mc; + mca.setAuthenticationService(authService); + mca.setServicesSignatureVerifier(SignatureVerifier.create(authService.getServicesKey())); + mca.setSessionService(sessService); + mca.setSkinProvider(new PlayerSkinProvider(mc.getTextureManager(), ((PlayerSkinProviderAccessor) mc.getSkinProvider()).getSkinCacheDir(), sessService)); } @Override diff --git a/src/main/java/meteordevelopment/meteorclient/systems/accounts/AccountUtils.java b/src/main/java/meteordevelopment/meteorclient/systems/accounts/AccountUtils.java deleted file mode 100644 index 205982a18e..0000000000 --- a/src/main/java/meteordevelopment/meteorclient/systems/accounts/AccountUtils.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). - * Copyright (c) Meteor Development. - */ - -package meteordevelopment.meteorclient.systems.accounts; - -import com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService; - -import java.lang.reflect.Field; -import java.net.MalformedURLException; -import java.net.URL; - -public class AccountUtils { - public static void setBaseUrl(YggdrasilMinecraftSessionService service, String url) { - try { - Field field = service.getClass().getDeclaredField("baseUrl"); - field.setAccessible(true); - field.set(service, url); - } catch (IllegalAccessException | NoSuchFieldException e) { - e.printStackTrace(); - } - } - - public static void setJoinUrl(YggdrasilMinecraftSessionService service, String url) { - try { - Field field = service.getClass().getDeclaredField("joinUrl"); - field.setAccessible(true); - field.set(service, new URL(url)); - } catch (IllegalAccessException | NoSuchFieldException | MalformedURLException e) { - e.printStackTrace(); - } - } - - public static void setCheckUrl(YggdrasilMinecraftSessionService service, String url) { - try { - Field field = service.getClass().getDeclaredField("checkUrl"); - field.setAccessible(true); - field.set(service, new URL(url)); - } catch (IllegalAccessException | NoSuchFieldException | MalformedURLException e) { - e.printStackTrace(); - } - } -} diff --git a/src/main/java/meteordevelopment/meteorclient/systems/accounts/types/CrackedAccount.java b/src/main/java/meteordevelopment/meteorclient/systems/accounts/types/CrackedAccount.java index 086c96c03f..447bb623b5 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/accounts/types/CrackedAccount.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/accounts/types/CrackedAccount.java @@ -8,6 +8,7 @@ import meteordevelopment.meteorclient.systems.accounts.Account; import meteordevelopment.meteorclient.systems.accounts.AccountType; import net.minecraft.client.util.Session; +import net.minecraft.util.Uuids; import java.util.Optional; @@ -27,7 +28,7 @@ public boolean login() { super.login(); cache.loadHead(); - setSession(new Session(name, "", "", Optional.empty(), Optional.empty(), Session.AccountType.MOJANG)); + setSession(new Session(name, Uuids.getOfflinePlayerUuid(name).toString(), "", Optional.empty(), Optional.empty(), Session.AccountType.MOJANG)); return true; } diff --git a/src/main/java/meteordevelopment/meteorclient/systems/accounts/types/TheAlteningAccount.java b/src/main/java/meteordevelopment/meteorclient/systems/accounts/types/TheAlteningAccount.java index 644da0b25e..2da37aeb27 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/accounts/types/TheAlteningAccount.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/accounts/types/TheAlteningAccount.java @@ -9,13 +9,12 @@ import com.mojang.authlib.Environment; import com.mojang.authlib.exceptions.AuthenticationException; import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService; -import com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService; import com.mojang.authlib.yggdrasil.YggdrasilUserAuthentication; import meteordevelopment.meteorclient.MeteorClient; import meteordevelopment.meteorclient.mixin.MinecraftClientAccessor; +import meteordevelopment.meteorclient.mixin.YggdrasilMinecraftSessionServiceAccessor; import meteordevelopment.meteorclient.systems.accounts.Account; import meteordevelopment.meteorclient.systems.accounts.AccountType; -import meteordevelopment.meteorclient.systems.accounts.AccountUtils; import net.minecraft.client.util.Session; import java.util.Optional; @@ -23,10 +22,8 @@ import static meteordevelopment.meteorclient.MeteorClient.mc; public class TheAlteningAccount extends Account { - private static final String AUTH = "http://authserver.thealtening.com"; - private static final String ACCOUNT = "https://api.mojang.com"; - private static final String SESSION = "http://sessionserver.thealtening.com"; - private static final String SERVICES = "https://api.minecraftservices.com"; + private static final Environment ENVIRONMENT = Environment.create("http://authserver.thealtening.com", "https://api.mojang.com", "http://sessionserver.thealtening.com", "https://api.minecraftservices.com", "The Altening"); + private static final YggdrasilAuthenticationService SERVICE = new YggdrasilAuthenticationService(((MinecraftClientAccessor) mc).getProxy(), "", ENVIRONMENT); public TheAlteningAccount(String token) { super(AccountType.TheAltening, token); @@ -50,10 +47,7 @@ public boolean fetchInfo() { @Override public boolean login() { - YggdrasilMinecraftSessionService service = (YggdrasilMinecraftSessionService) mc.getSessionService(); - AccountUtils.setBaseUrl(service, SESSION + "/session/minecraft/"); - AccountUtils.setJoinUrl(service, SESSION + "/session/minecraft/join"); - AccountUtils.setCheckUrl(service, SESSION + "/session/minecraft/hasJoined"); + applyLoginEnvironment(SERVICE, YggdrasilMinecraftSessionServiceAccessor.createYggdrasilMinecraftSessionService(SERVICE, ENVIRONMENT)); YggdrasilUserAuthentication auth = getAuth(); @@ -72,7 +66,7 @@ public boolean login() { } private YggdrasilUserAuthentication getAuth() { - YggdrasilUserAuthentication auth = (YggdrasilUserAuthentication) new YggdrasilAuthenticationService(((MinecraftClientAccessor) mc).getProxy(), "", Environment.create(AUTH, ACCOUNT, SESSION, SERVICES, "The Altening")).createUserAuthentication(Agent.MINECRAFT); + YggdrasilUserAuthentication auth = (YggdrasilUserAuthentication) SERVICE.createUserAuthentication(Agent.MINECRAFT); auth.setUsername(name); auth.setPassword("Meteor on Crack!"); diff --git a/src/main/java/meteordevelopment/meteorclient/systems/commands/Command.java b/src/main/java/meteordevelopment/meteorclient/systems/commands/Command.java index 46357c0c2d..81b3118443 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/commands/Command.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/commands/Command.java @@ -77,9 +77,7 @@ public String toString() { public String toString(String... args) { StringBuilder base = new StringBuilder(toString()); - for (String arg : args) - base.append(' ').append(arg); - + for (String arg : args) base.append(' ').append(arg); return base.toString(); } @@ -90,16 +88,16 @@ public void info(Text message) { public void info(String message, Object... args) { ChatUtils.forceNextPrefixClass(getClass()); - ChatUtils.info(title, message, args); + ChatUtils.infoPrefix(title, message, args); } public void warning(String message, Object... args) { ChatUtils.forceNextPrefixClass(getClass()); - ChatUtils.warning(title, message, args); + ChatUtils.warningPrefix(title, message, args); } public void error(String message, Object... args) { ChatUtils.forceNextPrefixClass(getClass()); - ChatUtils.error(title, message, args); + ChatUtils.errorPrefix(title, message, args); } } diff --git a/src/main/java/meteordevelopment/meteorclient/systems/commands/Commands.java b/src/main/java/meteordevelopment/meteorclient/systems/commands/Commands.java index 271a89a3b7..57de847075 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/commands/Commands.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/commands/Commands.java @@ -8,20 +8,15 @@ import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.ParseResults; import com.mojang.brigadier.exceptions.CommandSyntaxException; -import com.mojang.brigadier.tree.*; +import com.mojang.brigadier.tree.CommandNode; import meteordevelopment.meteorclient.systems.System; import meteordevelopment.meteorclient.systems.Systems; import meteordevelopment.meteorclient.systems.commands.commands.*; -import meteordevelopment.meteorclient.systems.commands.commands.EnchantCommand; -import meteordevelopment.meteorclient.systems.commands.commands.GiveCommand; -import meteordevelopment.meteorclient.systems.commands.commands.LocateCommand; -import meteordevelopment.meteorclient.systems.commands.commands.ReloadCommand; -import meteordevelopment.meteorclient.systems.commands.commands.SayCommand; -import meteordevelopment.meteorclient.systems.commands.commands.SpectateCommand; -import net.fabricmc.fabric.api.client.command.v2.*; -import net.minecraft.client.MinecraftClient; +import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback; +import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; import net.minecraft.client.network.ClientCommandSource; -import net.minecraft.command.*; +import net.minecraft.command.CommandRegistryAccess; +import net.minecraft.command.CommandSource; import net.minecraft.registry.BuiltinRegistries; import net.minecraft.server.command.CommandManager; @@ -31,9 +26,11 @@ public class Commands extends System { public static final DelegateCRM REGISTRY_ACCESS = new DelegateCRM(); - private final CommandDispatcher DISPATCHER = new CommandDispatcher<>(); + + public static final CommandDispatcher DISPATCHER = new CommandDispatcher<>(); + public static final FabricClientCommandSource COMMAND_SOURCE = (FabricClientCommandSource) new ClientCommandSource(null, mc); + private final List commands = new ArrayList<>(); - private final Map, Command> commandInstances = new HashMap<>(); public Commands() { super(null); @@ -45,7 +42,6 @@ public static Commands get() { @Override public void init() { - add(new BaritoneCommand()); add(new VClipCommand()); add(new HClipCommand()); add(new DismountCommand()); @@ -60,6 +56,7 @@ public void init() { add(new NbtCommand()); add(new NotebotCommand()); add(new PeekCommand()); + add(new EnderChestCommand()); add(new ProfilesCommand()); add(new ReloadCommand()); add(new ResetCommand()); @@ -71,11 +68,12 @@ public void init() { add(new SpectateCommand()); add(new GamemodeCommand()); add(new SaveMapCommand()); + add(new MacroCommand()); add(new ModulesCommand()); add(new BindsCommand()); add(new GiveCommand()); add(new BindCommand()); - add(new FOVCommand()); + add(new FovCommand()); add(new RotationCommand()); add(new WaypointCommand()); add(new InputCommand()); @@ -104,44 +102,28 @@ private static void copyChildren(CommandNode origin, } } - public void dispatch(String message) throws CommandSyntaxException { - dispatch(message, new ChatCommandSource(mc)); - } - - public void dispatch(String message, CommandSource source) throws CommandSyntaxException { - ParseResults results = getDispatcher().parse(message, source); - getDispatcher().execute(results); - } - - public CommandDispatcher getDispatcher() { - return (CommandDispatcher) (Object) DISPATCHER; - } - - private final static class ChatCommandSource extends ClientCommandSource { - public ChatCommandSource(MinecraftClient client) { - super(null, client); - } - } - public void add(Command command) { - commands.removeIf(command1 -> command1.getName().equals(command.getName())); - commandInstances.values().removeIf(command1 -> command1.getName().equals(command.getName())); - - command.registerTo(getDispatcher()); + commands.removeIf(existing -> existing.getName().equals(command.getName())); + command.registerTo((CommandDispatcher) (Object) DISPATCHER); commands.add(command); - commandInstances.put(command.getClass(), command); } - public int getCount() { - return commands.size(); + public void dispatch(String message) throws CommandSyntaxException { + ParseResults results = DISPATCHER.parse(message, COMMAND_SOURCE); + DISPATCHER.execute(results); } public List getAll() { return commands; } - @SuppressWarnings("unchecked") - public T get(Class klass) { - return (T) commandInstances.get(klass); + public Command get(String name) { + for (Command command : commands) { + if (command.getName().equals(name)) { + return command; + } + } + + return null; } } diff --git a/src/main/java/meteordevelopment/meteorclient/systems/commands/arguments/DirectionArgumentType.java b/src/main/java/meteordevelopment/meteorclient/systems/commands/arguments/DirectionArgumentType.java new file mode 100644 index 0000000000..80cdccf56e --- /dev/null +++ b/src/main/java/meteordevelopment/meteorclient/systems/commands/arguments/DirectionArgumentType.java @@ -0,0 +1,19 @@ +/* + * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). + * Copyright (c) Meteor Development. + */ + +package meteordevelopment.meteorclient.systems.commands.arguments; + +import net.minecraft.command.argument.EnumArgumentType; +import net.minecraft.util.math.Direction; + +public class DirectionArgumentType extends EnumArgumentType { + private DirectionArgumentType() { + super(Direction.CODEC, Direction::values); + } + + public static DirectionArgumentType create() { + return new DirectionArgumentType(); + } +} diff --git a/src/main/java/meteordevelopment/meteorclient/systems/commands/arguments/MacroArgumentType.java b/src/main/java/meteordevelopment/meteorclient/systems/commands/arguments/MacroArgumentType.java new file mode 100644 index 0000000000..d56bafb96a --- /dev/null +++ b/src/main/java/meteordevelopment/meteorclient/systems/commands/arguments/MacroArgumentType.java @@ -0,0 +1,53 @@ +/* + * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). + * Copyright (c) Meteor Development. + */ + +package meteordevelopment.meteorclient.systems.commands.arguments; + +import com.mojang.brigadier.StringReader; +import com.mojang.brigadier.arguments.ArgumentType; +import com.mojang.brigadier.context.CommandContext; +import com.mojang.brigadier.exceptions.CommandSyntaxException; +import com.mojang.brigadier.exceptions.DynamicCommandExceptionType; +import com.mojang.brigadier.suggestion.Suggestions; +import com.mojang.brigadier.suggestion.SuggestionsBuilder; +import meteordevelopment.meteorclient.systems.macros.Macro; +import meteordevelopment.meteorclient.systems.macros.Macros; +import net.minecraft.command.CommandSource; +import net.minecraft.text.Text; + +import java.util.Collection; +import java.util.concurrent.CompletableFuture; +import java.util.stream.Collectors; + +public class MacroArgumentType implements ArgumentType { + private static final DynamicCommandExceptionType NO_SUCH_MACRO = new DynamicCommandExceptionType(name -> Text.literal("Macro with name " + name + " doesn't exist.")); + + public static MacroArgumentType create() { + return new MacroArgumentType(); + } + + public static Macro get(CommandContext context) { + return context.getArgument("macro", Macro.class); + } + + @Override + public Macro parse(StringReader reader) throws CommandSyntaxException { + String argument = reader.readString(); + Macro macro = Macros.get().get(argument); + if (macro == null) throw NO_SUCH_MACRO.create(argument); + + return macro; + } + + @Override + public CompletableFuture listSuggestions(CommandContext context, SuggestionsBuilder builder) { + return CommandSource.suggestMatching(Macros.get().getAll().stream().map(macro -> macro.name.get()), builder); + } + + @Override + public Collection getExamples() { + return Macros.get().getAll().stream().limit(3).map(macro -> macro.name.get()).collect(Collectors.toList()); + } +} diff --git a/src/main/java/meteordevelopment/meteorclient/systems/commands/arguments/NotebotSongArgumentType.java b/src/main/java/meteordevelopment/meteorclient/systems/commands/arguments/NotebotSongArgumentType.java index 33cca861f4..e0582073f2 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/commands/arguments/NotebotSongArgumentType.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/commands/arguments/NotebotSongArgumentType.java @@ -31,14 +31,13 @@ public static NotebotSongArgumentType create() { public Path parse(StringReader reader) throws CommandSyntaxException { final String text = reader.getRemaining(); reader.setCursor(reader.getTotalLength()); - System.out.println("READER: " + text); return MeteorClient.FOLDER.toPath().resolve("notebot/" + text); } @Override public CompletableFuture listSuggestions(CommandContext context, SuggestionsBuilder builder) { - try { - return CommandSource.suggestMatching(Files.list(MeteorClient.FOLDER.toPath().resolve("notebot")) + try (var suggestions = Files.list(MeteorClient.FOLDER.toPath().resolve("notebot"))) { + return CommandSource.suggestMatching(suggestions .filter(SongDecoders::hasDecoder) .map(path -> path.getFileName().toString()), builder diff --git a/src/main/java/meteordevelopment/meteorclient/systems/commands/commands/CommandsCommand.java b/src/main/java/meteordevelopment/meteorclient/systems/commands/commands/CommandsCommand.java index 79d55b70f6..d2b2d34bf0 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/commands/commands/CommandsCommand.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/commands/commands/CommandsCommand.java @@ -28,7 +28,7 @@ public CommandsCommand() { @Override public void build(LiteralArgumentBuilder builder) { builder.executes(context -> { - ChatUtils.info("--- Commands ((highlight)%d(default)) ---", Commands.get().getCount()); + ChatUtils.info("--- Commands ((highlight)%d(default)) ---", Commands.get().getAll().size()); MutableText commands = Text.literal(""); Commands.get().getAll().forEach(command -> commands.append(getCommandText(command))); diff --git a/src/main/java/meteordevelopment/meteorclient/systems/commands/commands/EnchantCommand.java b/src/main/java/meteordevelopment/meteorclient/systems/commands/commands/EnchantCommand.java index c72164e5d7..17e33d383a 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/commands/commands/EnchantCommand.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/commands/commands/EnchantCommand.java @@ -20,6 +20,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.registry.Registries; import net.minecraft.registry.RegistryKeys; +import net.minecraft.registry.entry.RegistryEntry; import net.minecraft.text.Text; import java.util.function.Function; @@ -79,7 +80,8 @@ public void build(LiteralArgumentBuilder builder) { builder.then(literal("remove").then(argument("enchantment", RegistryEntryArgumentType.registryEntry(Commands.REGISTRY_ACCESS, RegistryKeys.ENCHANTMENT)).executes(context -> { ItemStack itemStack = tryGetItemStack(); - Utils.removeEnchantment(itemStack, context.getArgument("enchantment", Enchantment.class)); + RegistryEntry.Reference enchantment = context.getArgument("enchantment", RegistryEntry.Reference.class); + Utils.removeEnchantment(itemStack, enchantment.value()); syncItem(); return SINGLE_SUCCESS; @@ -89,8 +91,8 @@ public void build(LiteralArgumentBuilder builder) { private void one(CommandContext context, Function level) throws CommandSyntaxException { ItemStack itemStack = tryGetItemStack(); - Enchantment enchantment = context.getArgument("enchantment", Enchantment.class); - Utils.addEnchantment(itemStack, enchantment, level.apply(enchantment)); + RegistryEntry.Reference enchantment = context.getArgument("enchantment", RegistryEntry.Reference.class); + Utils.addEnchantment(itemStack, enchantment.value(), level.apply(enchantment.value())); syncItem(); } diff --git a/src/main/java/meteordevelopment/meteorclient/systems/commands/commands/EnderChestCommand.java b/src/main/java/meteordevelopment/meteorclient/systems/commands/commands/EnderChestCommand.java new file mode 100644 index 0000000000..7736d9a998 --- /dev/null +++ b/src/main/java/meteordevelopment/meteorclient/systems/commands/commands/EnderChestCommand.java @@ -0,0 +1,29 @@ +/* + * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). + * Copyright (c) Meteor Development. + */ + +package meteordevelopment.meteorclient.systems.commands.commands; + +import com.mojang.brigadier.builder.LiteralArgumentBuilder; +import meteordevelopment.meteorclient.systems.commands.Command; +import meteordevelopment.meteorclient.utils.Utils; +import net.minecraft.command.CommandSource; +import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; + +import static com.mojang.brigadier.Command.SINGLE_SUCCESS; + +public class EnderChestCommand extends Command { + public EnderChestCommand() { + super("ender-chest", "Allows you to preview memory of your ender chest.", "ec", "echest"); + } + + @Override + public void build(LiteralArgumentBuilder builder) { + builder.executes(context -> { + Utils.openContainer(Items.ENDER_CHEST.getDefaultStack(), new ItemStack[27], true); + return SINGLE_SUCCESS; + }); + } +} diff --git a/src/main/java/meteordevelopment/meteorclient/systems/commands/commands/FOVCommand.java b/src/main/java/meteordevelopment/meteorclient/systems/commands/commands/FovCommand.java similarity index 72% rename from src/main/java/meteordevelopment/meteorclient/systems/commands/commands/FOVCommand.java rename to src/main/java/meteordevelopment/meteorclient/systems/commands/commands/FovCommand.java index 1ed59250fe..f81130b4a9 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/commands/commands/FOVCommand.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/commands/commands/FovCommand.java @@ -7,20 +7,21 @@ import com.mojang.brigadier.arguments.IntegerArgumentType; import com.mojang.brigadier.builder.LiteralArgumentBuilder; +import meteordevelopment.meteorclient.mixininterface.ISimpleOption; import meteordevelopment.meteorclient.systems.commands.Command; import net.minecraft.command.CommandSource; import static com.mojang.brigadier.Command.SINGLE_SUCCESS; -public class FOVCommand extends Command { - public FOVCommand() { - super("fov", "Changes your FOV."); +public class FovCommand extends Command { + public FovCommand() { + super("fov", "Changes your fov."); } @Override public void build(LiteralArgumentBuilder builder) { builder.then(argument("fov", IntegerArgumentType.integer(0, 180)).executes(context -> { - mc.options.getFov().setValue(context.getArgument("fov", Integer.class)); + ((ISimpleOption) (Object) mc.options.getFov()).set(context.getArgument("fov", Integer.class)); return SINGLE_SUCCESS; })); } diff --git a/src/main/java/meteordevelopment/meteorclient/systems/commands/commands/BaritoneCommand.java b/src/main/java/meteordevelopment/meteorclient/systems/commands/commands/MacroCommand.java similarity index 56% rename from src/main/java/meteordevelopment/meteorclient/systems/commands/commands/BaritoneCommand.java rename to src/main/java/meteordevelopment/meteorclient/systems/commands/commands/MacroCommand.java index 615560e7d1..5a97a302e9 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/commands/commands/BaritoneCommand.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/commands/commands/MacroCommand.java @@ -5,25 +5,26 @@ package meteordevelopment.meteorclient.systems.commands.commands; -import baritone.api.BaritoneAPI; -import com.mojang.brigadier.arguments.StringArgumentType; import com.mojang.brigadier.builder.LiteralArgumentBuilder; import meteordevelopment.meteorclient.systems.commands.Command; +import meteordevelopment.meteorclient.systems.commands.arguments.MacroArgumentType; +import meteordevelopment.meteorclient.systems.macros.Macro; import net.minecraft.command.CommandSource; import static com.mojang.brigadier.Command.SINGLE_SUCCESS; -public class BaritoneCommand extends Command { - public BaritoneCommand() { - super("baritone", "Executes baritone commands.", "b"); +public class MacroCommand extends Command { + public MacroCommand() { + super("macro", "Allows you to execute macros."); } @Override public void build(LiteralArgumentBuilder builder) { - builder.then(argument("command", StringArgumentType.greedyString()) + builder.then( + argument("macro", MacroArgumentType.create()) .executes(context -> { - String command = context.getArgument("command", String.class); - BaritoneAPI.getProvider().getPrimaryBaritone().getCommandManager().execute(command); + Macro macro = MacroArgumentType.get(context); + macro.onAction(); return SINGLE_SUCCESS; })); } diff --git a/src/main/java/meteordevelopment/meteorclient/systems/commands/commands/ResetCommand.java b/src/main/java/meteordevelopment/meteorclient/systems/commands/commands/ResetCommand.java index fb3b595155..64467ded90 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/commands/commands/ResetCommand.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/commands/commands/ResetCommand.java @@ -36,7 +36,7 @@ public void build(LiteralArgumentBuilder builder) { })) .then(literal("all").executes(context -> { Modules.get().getAll().forEach(module -> module.settings.forEach(group -> group.forEach(Setting::reset))); - ChatUtils.info("Modules", "Reset all module settings"); + ChatUtils.infoPrefix("Modules", "Reset all module settings"); return SINGLE_SUCCESS; })) ).then(literal("gui").executes(context -> { @@ -54,12 +54,12 @@ public void build(LiteralArgumentBuilder builder) { })) .then(literal("all").executes(context -> { Modules.get().getAll().forEach(module -> module.keybind.set(true, -1)); - ChatUtils.info("Modules", "Reset all binds."); + ChatUtils.infoPrefix("Modules", "Reset all binds."); return SINGLE_SUCCESS; })) ).then(literal("hud").executes(context -> { Systems.get(Hud.class).resetToDefaultElements(); - ChatUtils.info("HUD", "Reset all elements."); + ChatUtils.infoPrefix("HUD", "Reset all elements."); return SINGLE_SUCCESS; })); } diff --git a/src/main/java/meteordevelopment/meteorclient/systems/commands/commands/RotationCommand.java b/src/main/java/meteordevelopment/meteorclient/systems/commands/commands/RotationCommand.java index 005f3426bc..4e3c43b3f1 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/commands/commands/RotationCommand.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/commands/commands/RotationCommand.java @@ -8,7 +8,9 @@ import com.mojang.brigadier.arguments.FloatArgumentType; import com.mojang.brigadier.builder.LiteralArgumentBuilder; import meteordevelopment.meteorclient.systems.commands.Command; +import meteordevelopment.meteorclient.systems.commands.arguments.DirectionArgumentType; import net.minecraft.command.CommandSource; +import net.minecraft.util.math.Direction; import net.minecraft.util.math.MathHelper; import static com.mojang.brigadier.Command.SINGLE_SUCCESS; @@ -22,6 +24,13 @@ public RotationCommand() { public void build(LiteralArgumentBuilder builder) { builder .then(literal("set") + .then(argument("direction", DirectionArgumentType.create()) + .executes(context -> { + mc.player.setPitch(context.getArgument("direction", Direction.class).getVector().getY() * -90); + mc.player.setYaw(context.getArgument("direction", Direction.class).asRotation()); + + return SINGLE_SUCCESS; + })) .then(argument("pitch", FloatArgumentType.floatArg(-90, 90)) .executes(context -> { mc.player.setPitch(context.getArgument("pitch", Float.class)); diff --git a/src/main/java/meteordevelopment/meteorclient/systems/commands/commands/VClipCommand.java b/src/main/java/meteordevelopment/meteorclient/systems/commands/commands/VClipCommand.java index e6f914ce96..11aac18a13 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/commands/commands/VClipCommand.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/commands/commands/VClipCommand.java @@ -10,7 +10,8 @@ import meteordevelopment.meteorclient.systems.commands.Command; import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.command.CommandSource; -import net.minecraft.entity.Entity; +import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket; +import net.minecraft.network.packet.c2s.play.VehicleMoveC2SPacket; import static com.mojang.brigadier.Command.SINGLE_SUCCESS; @@ -22,15 +23,33 @@ public VClipCommand() { @Override public void build(LiteralArgumentBuilder builder) { builder.then(argument("blocks", DoubleArgumentType.doubleArg()).executes(context -> { - ClientPlayerEntity player = mc.player; - assert player != null; double blocks = context.getArgument("blocks", Double.class); - if (player.hasVehicle()) { - Entity vehicle = player.getVehicle(); - vehicle.setPosition(vehicle.getX(), vehicle.getY() + blocks, vehicle.getZ()); + + // Implementation of "PaperClip" aka "TPX" aka "VaultClip" into vclip + // Allows you to teleport up to 200 blocks in one go (as you can send 20 move packets per tick) + // Paper allows you to teleport 10 blocks for each move packet you send in that tick + // Video explanation by LiveOverflow: https://www.youtube.com/watch?v=3HSnDsfkJT8 + int packetsRequired = (int) Math.ceil(blocks / 10); + if (mc.player.hasVehicle()) { + // Vehicle version + // For each 10 blocks, send a vehicle move packet with no delta + for (int packetNumber = 0; packetNumber < (packetsRequired - 1); packetNumber++) { + mc.player.networkHandler.sendPacket(new VehicleMoveC2SPacket(mc.player.getVehicle())); + } + // Now send the final vehicle move packet + mc.player.getVehicle().setPosition(mc.player.getVehicle().getX(), mc.player.getVehicle().getY() + blocks, mc.player.getVehicle().getZ()); + mc.player.networkHandler.sendPacket(new VehicleMoveC2SPacket(mc.player.getVehicle())); + } else { + // No vehicle version + // For each 10 blocks, send a player move packet with no delta + for (int packetNumber = 0; packetNumber < (packetsRequired - 1); packetNumber++) { + mc.player.networkHandler.sendPacket(new PlayerMoveC2SPacket.OnGroundOnly(true)); + } + // Now send the final player move packet + mc.player.networkHandler.sendPacket(new PlayerMoveC2SPacket.PositionAndOnGround(mc.player.getX(), mc.player.getY() + blocks, mc.player.getZ(), true)); + mc.player.setPosition(mc.player.getX(), mc.player.getY() + blocks, mc.player.getZ()); } - player.setPosition(player.getX(), player.getY() + blocks, player.getZ()); return SINGLE_SUCCESS; })); diff --git a/src/main/java/meteordevelopment/meteorclient/systems/friends/Friend.java b/src/main/java/meteordevelopment/meteorclient/systems/friends/Friend.java index e8f591f7e0..5b6187301f 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/friends/Friend.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/friends/Friend.java @@ -19,14 +19,15 @@ import java.util.UUID; public class Friend implements ISerializable, Comparable { - public String name; - private @Nullable UUID id; - private @Nullable PlayerHeadTexture headTexture; + public volatile String name; + private volatile @Nullable UUID id; + private volatile @Nullable PlayerHeadTexture headTexture; + private volatile boolean updating; public Friend(String name, @Nullable UUID id) { this.name = name; this.id = id; - this.headTexture = PlayerHeadUtils.fetchHead(id); + this.headTexture = null; } public Friend(PlayerEntity player) { @@ -45,11 +46,17 @@ public PlayerHeadTexture getHead() { } public void updateInfo() { + updating = true; APIResponse res = Http.get("https://api.mojang.com/users/profiles/minecraft/" + name).sendJson(APIResponse.class); if (res == null || res.name == null || res.id == null) return; name = res.name; id = UUIDTypeAdapter.fromString(res.id); headTexture = PlayerHeadUtils.fetchHead(id); + updating = false; + } + + public boolean headTextureNeedsUpdate() { + return !this.updating && headTexture == null; } @Override diff --git a/src/main/java/meteordevelopment/meteorclient/systems/friends/Friends.java b/src/main/java/meteordevelopment/meteorclient/systems/friends/Friends.java index 065b464739..8df4f22ebe 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/friends/Friends.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/friends/Friends.java @@ -9,6 +9,7 @@ import meteordevelopment.meteorclient.systems.System; import meteordevelopment.meteorclient.systems.Systems; import meteordevelopment.meteorclient.utils.misc.NbtUtils; +import meteordevelopment.meteorclient.utils.network.MeteorExecutor; import net.minecraft.client.network.PlayerListEntry; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.nbt.NbtCompound; @@ -72,7 +73,7 @@ public Friend get(PlayerListEntry player) { } public boolean isFriend(PlayerEntity player) { - return get(player) != null; + return player != null && get(player) != null; } public boolean isFriend(PlayerListEntry player) { @@ -126,6 +127,8 @@ public Friends fromTag(NbtCompound tag) { Collections.sort(friends); + MeteorExecutor.execute(() -> friends.forEach(Friend::updateInfo)); + return this; } } diff --git a/src/main/java/meteordevelopment/meteorclient/systems/hud/Hud.java b/src/main/java/meteordevelopment/meteorclient/systems/hud/Hud.java index 2d20b3da4f..b8abec6eef 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/hud/Hud.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/hud/Hud.java @@ -39,7 +39,7 @@ public class Hud extends System implements Iterable { private final SettingGroup sgGeneral = settings.getDefaultGroup(); private final SettingGroup sgEditor = settings.createGroup("Editor"); - private final SettingGroup sgKeybind = settings.createGroup("Keybindings"); + private final SettingGroup sgKeybind = settings.createGroup("Bind"); // General @@ -89,7 +89,7 @@ public class Hud extends System implements Iterable { // Keybindings private final Setting keybind = sgKeybind.add(new KeybindSetting.Builder() - .name("keybind") + .name("bind") .defaultValue(Keybind.none()) .action(() -> active = !active) .build() diff --git a/src/main/java/meteordevelopment/meteorclient/systems/hud/elements/ActiveModulesHud.java b/src/main/java/meteordevelopment/meteorclient/systems/hud/elements/ActiveModulesHud.java index fad5e70d0f..4c9da3fd77 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/hud/elements/ActiveModulesHud.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/hud/elements/ActiveModulesHud.java @@ -137,7 +137,8 @@ public class ActiveModulesHud extends HudElement { private final List modules = new ArrayList<>(); private final Color rainbow = new Color(255, 255, 255); - private double rainbowHue1, rainbowHue2; + private double rainbowHue1; + private double rainbowHue2; private double prevX; private double prevTextLength; @@ -160,19 +161,10 @@ public void tick(HudRenderer renderer) { if (!hiddenModules.get().contains(module)) modules.add(module); } - modules.sort((o1, o2) -> { - double _1 = getModuleWidth(renderer, o1); - double _2 = getModuleWidth(renderer, o2); - - if (sort.get() == Sort.Smallest) { - double temp = _1; - _1 = _2; - _2 = temp; - } - - int a = Double.compare(_1, _2); - if (a == 0) return 0; - return a < 0 ? 1 : -1; + modules.sort((e1, e2) -> switch (sort.get()) { + case Alphabetical -> e1.title.compareTo(e2.title); + case Biggest -> Double.compare(getModuleWidth(renderer, e2), getModuleWidth(renderer, e1)); + case Smallest -> Double.compare(getModuleWidth(renderer, e1), getModuleWidth(renderer, e2)); }); double width = 0; @@ -220,22 +212,21 @@ private void renderModule(HudRenderer renderer, List modules, int index, Module module = modules.get(index); Color color = flatColor.get(); - ColorMode colorMode = this.colorMode.get(); - if (colorMode == ColorMode.Random) color = module.color; - else if (colorMode == ColorMode.Rainbow) { - rainbowHue2 += rainbowSpread.get(); - int c = java.awt.Color.HSBtoRGB((float) rainbowHue2, rainbowSaturation.get().floatValue(), rainbowBrightness.get().floatValue()); - - rainbow.r = Color.toRGBAR(c); - rainbow.g = Color.toRGBAG(c); - rainbow.b = Color.toRGBAB(c); - - color = rainbow; + switch (colorMode.get()) { + case Random -> color = module.color; + case Rainbow -> { + rainbowHue2 += rainbowSpread.get(); + int c = java.awt.Color.HSBtoRGB((float) rainbowHue2, rainbowSaturation.get().floatValue(), rainbowBrightness.get().floatValue()); + rainbow.r = Color.toRGBAR(c); + rainbow.g = Color.toRGBAG(c); + rainbow.b = Color.toRGBAB(c); + color = rainbow; + } } renderer.text(module.title, x, y, color, shadow.get()); - double emptySpace = renderer.textWidth(" ", shadow.get()); + double emptySpace = renderer.textWidth(" ", shadow.get()); double textHeight = renderer.textHeight(shadow.get()); double textLength = renderer.textWidth(module.title, shadow.get()); @@ -296,6 +287,7 @@ private double getModuleWidth(HudRenderer renderer, Module module) { } public enum Sort { + Alphabetical, Biggest, Smallest } diff --git a/src/main/java/meteordevelopment/meteorclient/systems/hud/elements/CombatHud.java b/src/main/java/meteordevelopment/meteorclient/systems/hud/elements/CombatHud.java index cb475454e5..c86cd5c311 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/hud/elements/CombatHud.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/hud/elements/CombatHud.java @@ -19,7 +19,6 @@ import meteordevelopment.meteorclient.utils.entity.EntityUtils; import meteordevelopment.meteorclient.utils.entity.SortPriority; import meteordevelopment.meteorclient.utils.entity.TargetUtils; -import meteordevelopment.meteorclient.utils.misc.FakeClientPlayer; import meteordevelopment.meteorclient.utils.player.PlayerUtils; import meteordevelopment.meteorclient.utils.render.RenderUtils; import meteordevelopment.meteorclient.utils.render.color.Color; @@ -51,6 +50,8 @@ public class CombatHud extends HudElement { public static final HudElementInfo INFO = new HudElementInfo<>(Hud.GROUP, "combat", "Displays information about your combat target.", CombatHud::new); + private static final MatrixStack MATRICES = new MatrixStack(); + private final SettingGroup sgGeneral = settings.getDefaultGroup(); private final Setting scale = sgGeneral.add(new DoubleSetting.Builder() @@ -196,18 +197,21 @@ public void render(HudRenderer renderer) { Color primaryColor = TextHud.getSectionColor(0); Color secondaryColor = TextHud.getSectionColor(1); - if (isInEditor()) playerEntity = FakeClientPlayer.getPlayer(); + if (isInEditor()) playerEntity = mc.player; else playerEntity = TargetUtils.getPlayerTarget(range.get(), SortPriority.LowestDistance); - if (playerEntity == null) return; + if (playerEntity == null && !isInEditor()) return; // Background Renderer2D.COLOR.begin(); Renderer2D.COLOR.quad(x, y, getWidth(), getHeight(), backgroundColor.get()); Renderer2D.COLOR.render(null); + if (playerEntity == null) return; + // Player Model InventoryScreen.drawEntity( + MATRICES, (int) (x + (25 * scale.get())), (int) (y + (66 * scale.get())), (int) (30 * scale.get()), diff --git a/src/main/java/meteordevelopment/meteorclient/systems/hud/elements/InventoryHud.java b/src/main/java/meteordevelopment/meteorclient/systems/hud/elements/InventoryHud.java index 9f994c72d5..02a77db303 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/hud/elements/InventoryHud.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/hud/elements/InventoryHud.java @@ -81,7 +81,7 @@ public void render(HudRenderer renderer) { drawBackground(renderer, (int) x, (int) y, drawColor); } - if (mc.player != null) { + renderer.post(() -> { for (int row = 0; row < 3; row++) { for (int i = 0; i < 9; i++) { int index = row * 9 + i; @@ -94,7 +94,7 @@ public void render(HudRenderer renderer) { RenderUtils.drawItem(stack, itemX, itemY, scale.get(), true); } } - } + }); } private void drawBackground(HudRenderer renderer, int x, int y, Color color) { diff --git a/src/main/java/meteordevelopment/meteorclient/systems/hud/elements/ItemHud.java b/src/main/java/meteordevelopment/meteorclient/systems/hud/elements/ItemHud.java index d8b959f6ec..ecc82cf955 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/hud/elements/ItemHud.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/hud/elements/ItemHud.java @@ -24,6 +24,8 @@ public class ItemHud extends HudElement { public static HudElementInfo INFO = new HudElementInfo<>(Hud.GROUP, "item", "Displays the item count.", ItemHud::new); + private static final MatrixStack MATRICES = new MatrixStack(); + private final SettingGroup sgGeneral = settings.getDefaultGroup(); private final SettingGroup sgBackground = settings.createGroup("Background"); @@ -127,22 +129,22 @@ public void render(HudRenderer renderer) { private void render(ItemStack itemStack, int x, int y) { switch (noneMode.get()) { case HideItem -> { - mc.getItemRenderer().renderGuiItemIcon(itemStack, x, y); - mc.getItemRenderer().renderGuiItemOverlay(mc.textRenderer, itemStack, x, y, Integer.toString(itemStack.getCount())); + mc.getItemRenderer().renderGuiItemIcon(MATRICES, itemStack, x, y); + mc.getItemRenderer().renderGuiItemOverlay(MATRICES, mc.textRenderer, itemStack, x, y, Integer.toString(itemStack.getCount())); } case HideCount -> { if (itemStack.getCount() == 0) itemStack.setCount(Integer.MAX_VALUE); - mc.getItemRenderer().renderGuiItemIcon(itemStack, x, y); + mc.getItemRenderer().renderGuiItemIcon(MATRICES, itemStack, x, y); if (itemStack.getCount() == Integer.MAX_VALUE) itemStack.setCount(0); if (!itemStack.isEmpty()) { - mc.getItemRenderer().renderGuiItemOverlay(mc.textRenderer, itemStack, x, y, Integer.toString(itemStack.getCount())); + mc.getItemRenderer().renderGuiItemOverlay(MATRICES, mc.textRenderer, itemStack, x, y, Integer.toString(itemStack.getCount())); } } case ShowCount -> { if (itemStack.getCount() == 0) itemStack.setCount(Integer.MAX_VALUE); - mc.getItemRenderer().renderGuiItemIcon(itemStack, x, y); - mc.getItemRenderer().renderGuiItemOverlay(mc.textRenderer, itemStack, x, y, Integer.toString(itemStack.getCount() == Integer.MAX_VALUE ? 0 : itemStack.getCount())); + mc.getItemRenderer().renderGuiItemIcon(MATRICES, itemStack, x, y); + mc.getItemRenderer().renderGuiItemOverlay(MATRICES, mc.textRenderer, itemStack, x, y, Integer.toString(itemStack.getCount() == Integer.MAX_VALUE ? 0 : itemStack.getCount())); if (itemStack.getCount() == Integer.MAX_VALUE) itemStack.setCount(0); } } diff --git a/src/main/java/meteordevelopment/meteorclient/systems/hud/elements/MeteorTextHud.java b/src/main/java/meteordevelopment/meteorclient/systems/hud/elements/MeteorTextHud.java index 2420f14985..9188959a38 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/hud/elements/MeteorTextHud.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/hud/elements/MeteorTextHud.java @@ -50,7 +50,7 @@ public class MeteorTextHud { ROTATION = addPreset("Rotation", "{camera.direction} #1({round(camera.yaw, 1)}, {round(camera.pitch, 1)})", 0); MODULE_ENABLED = addPreset("Module enabled", "Kill Aura: {meteor.is_module_active(\"kill-aura\") ? #2 \"ON\" : #3 \"OFF\"}", 0); MODULE_ENABLED_WITH_INFO = addPreset("Module enabled with info", "Kill Aura: {meteor.is_module_active(\"kill-aura\") ? #2 \"ON\" : #3 \"OFF\"} #1{meteor.get_module_info(\"kill-aura\")}", 0); - WATERMARK = addPreset("Watermark", "Meteor Client #1{version}", Integer.MAX_VALUE); + WATERMARK = addPreset("Watermark", "{meteor.name} #1{meteor.version}"); BARITONE = addPreset("Baritone", "Baritone: #1{baritone.process_name}"); } diff --git a/src/main/java/meteordevelopment/meteorclient/systems/hud/elements/PlayerModelHud.java b/src/main/java/meteordevelopment/meteorclient/systems/hud/elements/PlayerModelHud.java index 66430ab6f2..0ee9f69e78 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/hud/elements/PlayerModelHud.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/hud/elements/PlayerModelHud.java @@ -10,9 +10,9 @@ import meteordevelopment.meteorclient.systems.hud.HudElement; import meteordevelopment.meteorclient.systems.hud.HudElementInfo; import meteordevelopment.meteorclient.systems.hud.HudRenderer; -import meteordevelopment.meteorclient.utils.misc.FakeClientPlayer; import meteordevelopment.meteorclient.utils.render.color.SettingColor; import net.minecraft.client.gui.screen.ingame.InventoryScreen; +import net.minecraft.client.util.math.MatrixStack; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.util.math.MathHelper; @@ -21,6 +21,8 @@ public class PlayerModelHud extends HudElement { public static final HudElementInfo INFO = new HudElementInfo<>(Hud.GROUP, "player-model", "Displays a model of your player.", PlayerModelHud::new); + private static final MatrixStack MATRICES = new MatrixStack(); + private final SettingGroup sgGeneral = settings.getDefaultGroup(); private final SettingGroup sgBackground = settings.createGroup("Background"); @@ -96,12 +98,12 @@ public void render(HudRenderer renderer) { renderer.post(() -> { PlayerEntity player = mc.player; - if (isInEditor()) player = FakeClientPlayer.getPlayer(); + if (player == null) return; float yaw = copyYaw.get() ? MathHelper.wrapDegrees(player.prevYaw + (player.getYaw() - player.prevYaw) * mc.getTickDelta()) : (float) customYaw.get(); float pitch = copyPitch.get() ? player.getPitch() : (float) customPitch.get(); - InventoryScreen.drawEntity((int) (x + (25 * scale.get())), (int) (y + (66 * scale.get())), (int) (30 * scale.get()), -yaw, -pitch, player); + InventoryScreen.drawEntity(MATRICES, (int) (x + (25 * scale.get())), (int) (y + (66 * scale.get())), (int) (30 * scale.get()), -yaw, -pitch, player); }); if (background.get()) { diff --git a/src/main/java/meteordevelopment/meteorclient/systems/hud/elements/PotionTimersHud.java b/src/main/java/meteordevelopment/meteorclient/systems/hud/elements/PotionTimersHud.java index 3ed887bc01..3401bc4aaf 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/hud/elements/PotionTimersHud.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/hud/elements/PotionTimersHud.java @@ -147,7 +147,7 @@ public void render(HudRenderer renderer) { } private String getString(StatusEffectInstance statusEffectInstance) { - return String.format("%s %d (%s)", Names.get(statusEffectInstance.getEffectType()), statusEffectInstance.getAmplifier() + 1, StatusEffectUtil.durationToString(statusEffectInstance, 1)); + return String.format("%s %d (%s)", Names.get(statusEffectInstance.getEffectType()), statusEffectInstance.getAmplifier() + 1, StatusEffectUtil.durationToString(statusEffectInstance, 1).getString()); } private double getScale() { diff --git a/src/main/java/meteordevelopment/meteorclient/systems/hud/elements/TextHud.java b/src/main/java/meteordevelopment/meteorclient/systems/hud/elements/TextHud.java index 0c1a558b34..687276c6c5 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/hud/elements/TextHud.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/hud/elements/TextHud.java @@ -5,6 +5,7 @@ package meteordevelopment.meteorclient.systems.hud.elements; +import meteordevelopment.meteorclient.MeteorClient; import meteordevelopment.meteorclient.gui.utils.StarscriptTextBoxRenderer; import meteordevelopment.meteorclient.settings.*; import meteordevelopment.meteorclient.systems.hud.Hud; @@ -40,7 +41,7 @@ public class TextHud extends HudElement { public final Setting text = sgGeneral.add(new StringSetting.Builder() .name("text") .description("Text to display with Starscript.") - .defaultValue("Meteor Client") + .defaultValue(MeteorClient.NAME) .onChanged(s -> recompile()) .wide() .renderer(StarscriptTextBoxRenderer.class) diff --git a/src/main/java/meteordevelopment/meteorclient/systems/macros/Macro.java b/src/main/java/meteordevelopment/meteorclient/systems/macros/Macro.java index 83eb2c4ace..81d7f31e6a 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/macros/Macro.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/macros/Macro.java @@ -56,7 +56,11 @@ public Macro(NbtElement tag) { } public boolean onAction(boolean isKey, int value) { - if (keybind.get().matches(isKey, value) && mc.currentScreen == null) { + if (!keybind.get().matches(isKey, value) || mc.currentScreen != null) return false; + return onAction(); + } + + public boolean onAction() { if (dirty) { scripts.clear(); @@ -77,9 +81,6 @@ public boolean onAction(boolean isKey, int value) { } return true; - } - - return false; } @Override diff --git a/src/main/java/meteordevelopment/meteorclient/systems/macros/Macros.java b/src/main/java/meteordevelopment/meteorclient/systems/macros/Macros.java index 24f13946db..5cd469baa3 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/macros/Macros.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/macros/Macros.java @@ -37,6 +37,14 @@ public void add(Macro macro) { save(); } + public Macro get(String name) { + for (Macro macro : macros) { + if (macro.name.get().equalsIgnoreCase(name)) return macro; + } + + return null; + } + public List getAll() { return macros; } diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/Module.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/Module.java index 23b1c0ec0b..c837f09970 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/Module.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/Module.java @@ -107,17 +107,17 @@ public void info(Text message) { public void info(String message, Object... args) { ChatUtils.forceNextPrefixClass(getClass()); - ChatUtils.info(title, message, args); + ChatUtils.infoPrefix(title, message, args); } public void warning(String message, Object... args) { ChatUtils.forceNextPrefixClass(getClass()); - ChatUtils.warning(title, message, args); + ChatUtils.warningPrefix(title, message, args); } public void error(String message, Object... args) { ChatUtils.forceNextPrefixClass(getClass()); - ChatUtils.error(title, message, args); + ChatUtils.errorPrefix(title, message, args); } public boolean isActive() { diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/Modules.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/Modules.java index faccfa7b4d..5489afb1a4 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/Modules.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/Modules.java @@ -29,7 +29,7 @@ import meteordevelopment.meteorclient.systems.modules.player.*; import meteordevelopment.meteorclient.systems.modules.render.*; import meteordevelopment.meteorclient.systems.modules.render.marker.Marker; -import meteordevelopment.meteorclient.systems.modules.render.search.Search; +import meteordevelopment.meteorclient.systems.modules.render.blockesp.BlockESP; import meteordevelopment.meteorclient.systems.modules.world.Timer; import meteordevelopment.meteorclient.systems.modules.world.*; import meteordevelopment.meteorclient.utils.Utils; @@ -427,7 +427,7 @@ private void initPlayer() { add(new GhostHand()); add(new LiquidInteract()); add(new MiddleClickExtra()); - add(new NoBreakDelay()); + add(new BreakDelay()); add(new NoInteract()); add(new NoMiningTrace()); add(new NoRotate()); @@ -445,7 +445,6 @@ private void initMovement() { add(new AirJump()); add(new Anchor()); add(new AntiAFK()); - add(new AntiLevitation()); add(new AntiVoid()); add(new AutoJump()); add(new AutoWalk()); @@ -501,7 +500,7 @@ private void initRender() { add(new Marker()); add(new Nametags()); add(new NoRender()); - add(new Search()); + add(new BlockESP()); add(new StorageESP()); add(new TimeChanger()); add(new Tracers()); @@ -522,7 +521,7 @@ private void initRender() { private void initWorld() { add(new AirPlace()); add(new Ambience()); - add(new AntiCactus()); + add(new Collisions()); add(new AutoBreed()); add(new AutoBrewer()); add(new AutoMount()); diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/AnchorAura.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/AnchorAura.java index 2a68ea0f30..c272a4ba7d 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/AnchorAura.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/AnchorAura.java @@ -11,7 +11,6 @@ import meteordevelopment.meteorclient.settings.*; import meteordevelopment.meteorclient.systems.modules.Categories; import meteordevelopment.meteorclient.systems.modules.Module; -import meteordevelopment.meteorclient.utils.Utils; import meteordevelopment.meteorclient.utils.entity.EntityUtils; import meteordevelopment.meteorclient.utils.entity.SortPriority; import meteordevelopment.meteorclient.utils.entity.TargetUtils; @@ -342,11 +341,11 @@ private BlockPos findBreakPos(BlockPos targetPos) { } private boolean getDamagePlace(BlockPos pos) { - return placeMode.get() == Safety.Suicide || DamageUtils.bedDamage(mc.player, Utils.vec3d(pos.add(0.5, 0.5, 0.5))) <= maxDamage.get(); + return placeMode.get() == Safety.Suicide || DamageUtils.bedDamage(mc.player, pos.toCenterPos()) <= maxDamage.get(); } private boolean getDamageBreak(BlockPos pos) { - return breakMode.get() == Safety.Suicide || DamageUtils.anchorDamage(mc.player, Utils.vec3d(pos.add(0.5, 0.5, 0.5))) <= maxDamage.get(); + return breakMode.get() == Safety.Suicide || DamageUtils.anchorDamage(mc.player, pos.toCenterPos()) <= maxDamage.get(); } private boolean isValidPlace(BlockPos pos) { diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/ArrowDodge.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/ArrowDodge.java index b94c859ee1..ed08eee3d5 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/ArrowDodge.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/ArrowDodge.java @@ -172,7 +172,7 @@ private boolean isValid(Vec3d velocity, boolean checkGround) { } if (checkGround) { - BlockPos blockPos = mc.player.getBlockPos().add(velocity.x, velocity.y, velocity.z); + BlockPos blockPos = mc.player.getBlockPos().add(BlockPos.ofFloored(velocity.x, velocity.y, velocity.z)); // check if target pos is air if (!mc.world.getBlockState(blockPos).getCollisionShape(mc.world, blockPos).isEmpty()) return false; diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/AutoCity.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/AutoCity.java index 766bcc2d80..c100c99bcd 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/AutoCity.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/AutoCity.java @@ -1,146 +1,240 @@ -/* - * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). - * Copyright (c) Meteor Development. - */ - -package meteordevelopment.meteorclient.systems.modules.combat; - -import meteordevelopment.meteorclient.events.world.TickEvent; -import meteordevelopment.meteorclient.settings.BoolSetting; -import meteordevelopment.meteorclient.settings.DoubleSetting; -import meteordevelopment.meteorclient.settings.Setting; -import meteordevelopment.meteorclient.settings.SettingGroup; -import meteordevelopment.meteorclient.systems.modules.Categories; -import meteordevelopment.meteorclient.systems.modules.Module; -import meteordevelopment.meteorclient.utils.entity.EntityUtils; -import meteordevelopment.meteorclient.utils.entity.SortPriority; -import meteordevelopment.meteorclient.utils.entity.TargetUtils; -import meteordevelopment.meteorclient.utils.player.FindItemResult; -import meteordevelopment.meteorclient.utils.player.InvUtils; -import meteordevelopment.meteorclient.utils.player.PlayerUtils; -import meteordevelopment.meteorclient.utils.player.Rotations; -import meteordevelopment.meteorclient.utils.world.BlockUtils; -import meteordevelopment.orbit.EventHandler; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.Items; -import net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket; -import net.minecraft.util.Hand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; - -public class AutoCity extends Module { - private final SettingGroup sgGeneral = settings.getDefaultGroup(); - - private final Setting targetRange = sgGeneral.add(new DoubleSetting.Builder() - .name("target-range") - .description("The radius in which players get targeted.") - .defaultValue(4) - .min(0) - .sliderMax(5) - .build() - ); - - private final Setting autoSwitch = sgGeneral.add(new BoolSetting.Builder() - .name("auto-switch") - .description("Auto switches to a pickaxe when AutoCity is enabled.") - .defaultValue(true) - .build() - ); - - private final Setting support = sgGeneral.add(new BoolSetting.Builder() - .name("support") - .description("If there is no block below a city block it will place one before mining.") - .defaultValue(true) - .build() - ); - - private final Setting rotate = sgGeneral.add(new BoolSetting.Builder() - .name("rotate") - .description("Automatically rotates you towards the city block.") - .defaultValue(true) - .build() - ); - - private final Setting selfToggle = sgGeneral.add(new BoolSetting.Builder() - .name("self-toggle") - .description("Automatically toggles off after activation.") - .defaultValue(true) - .build() - ); - - private PlayerEntity target; - private BlockPos blockPosTarget; - private boolean sentMessage; - - public AutoCity() { - super(Categories.Combat, "auto-city", "Automatically cities a target by mining the nearest obsidian next to them."); - } - - @EventHandler - private void onTick(TickEvent.Pre event) { - if (TargetUtils.isBadTarget(target, targetRange.get())) { - PlayerEntity search = TargetUtils.getPlayerTarget(targetRange.get(), SortPriority.LowestDistance); - if (search != target) sentMessage = false; - target = search; - - if (TargetUtils.isBadTarget(target, targetRange.get())) { - target = null; - blockPosTarget = null; - if (selfToggle.get()) toggle(); - return; - } - } - - blockPosTarget = EntityUtils.getCityBlock(target); - - if (blockPosTarget == null) { - if (selfToggle.get()) { - error("No target block found... disabling."); - toggle(); - } - target = null; - return; - } - - if (!PlayerUtils.isWithinReach(blockPosTarget) && selfToggle.get()) { - error("Target block out of reach... disabling."); - toggle(); - return; - } - - if (!sentMessage) { - info("Attempting to city %s.", target.getEntityName()); - sentMessage = true; - } - - FindItemResult pickaxe = InvUtils.find(itemStack -> itemStack.getItem() == Items.DIAMOND_PICKAXE || itemStack.getItem() == Items.NETHERITE_PICKAXE); - - if (!pickaxe.isHotbar()) { - if (selfToggle.get()) { - error("No pickaxe found... disabling."); - toggle(); - } - return; - } - - if (support.get()) BlockUtils.place(blockPosTarget.down(1), InvUtils.findInHotbar(Items.OBSIDIAN), rotate.get(), 0, true); - - if (autoSwitch.get()) InvUtils.swap(pickaxe.slot(), false); - - if (rotate.get()) Rotations.rotate(Rotations.getYaw(blockPosTarget), Rotations.getPitch(blockPosTarget), () -> mine(blockPosTarget)); - else mine(blockPosTarget); - - if (selfToggle.get()) toggle(); - } - - private void mine(BlockPos blockPos) { - mc.getNetworkHandler().sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.START_DESTROY_BLOCK, blockPos, Direction.UP)); - mc.player.swingHand(Hand.MAIN_HAND); - mc.getNetworkHandler().sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.STOP_DESTROY_BLOCK, blockPos, Direction.UP)); - } - - @Override - public String getInfoString() { - return EntityUtils.getName(target); - } -} +/* + * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). + * Copyright (c) Meteor Development. + */ + +package meteordevelopment.meteorclient.systems.modules.combat; + +import meteordevelopment.meteorclient.events.render.Render3DEvent; +import meteordevelopment.meteorclient.events.world.TickEvent; +import meteordevelopment.meteorclient.renderer.ShapeMode; +import meteordevelopment.meteorclient.settings.*; +import meteordevelopment.meteorclient.systems.modules.Categories; +import meteordevelopment.meteorclient.systems.modules.Module; +import meteordevelopment.meteorclient.systems.modules.world.PacketMine; +import meteordevelopment.meteorclient.utils.entity.EntityUtils; +import meteordevelopment.meteorclient.utils.entity.SortPriority; +import meteordevelopment.meteorclient.utils.entity.TargetUtils; +import meteordevelopment.meteorclient.utils.player.FindItemResult; +import meteordevelopment.meteorclient.utils.player.InvUtils; +import meteordevelopment.meteorclient.utils.player.PlayerUtils; +import meteordevelopment.meteorclient.utils.player.Rotations; +import meteordevelopment.meteorclient.utils.render.color.SettingColor; +import meteordevelopment.meteorclient.utils.world.BlockUtils; +import meteordevelopment.orbit.EventHandler; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.Items; +import net.minecraft.network.packet.c2s.play.HandSwingC2SPacket; +import net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket; +import net.minecraft.util.Hand; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Direction; + +public class AutoCity extends Module { + private final SettingGroup sgGeneral = settings.getDefaultGroup(); + private final SettingGroup sgRender = settings.createGroup("Render"); + + + private final Setting targetRange = sgGeneral.add(new DoubleSetting.Builder() + .name("target-range") + .description("The radius in which players get targeted.") + .defaultValue(5.5) + .min(0) + .sliderMax(7) + .build() + ); + + private final Setting breakRange = sgGeneral.add(new DoubleSetting.Builder() + .name("break-range") + .description("How close a block must be to you to be considered.") + .defaultValue(4.5) + .min(0) + .sliderMax(6) + .build() + ); + + private final Setting switchMode = sgGeneral.add(new EnumSetting.Builder() + .name("switch-mode") + .description("How to switch to a pickaxe.") + .defaultValue(SwitchMode.Normal) + .build() + ); + + private final Setting support = sgGeneral.add(new BoolSetting.Builder() + .name("support") + .description("If there is no block below a city block it will place one before mining.") + .defaultValue(true) + .build() + ); + + private final Setting placeRange = sgGeneral.add(new DoubleSetting.Builder() + .name("place-range") + .description("How far away to try and place a block.") + .defaultValue(4.5) + .min(0) + .sliderMax(6) + .visible(support::get) + .build() + ); + + private final Setting rotate = sgGeneral.add(new BoolSetting.Builder() + .name("rotate") + .description("Automatically rotates you towards the city block.") + .defaultValue(true) + .build() + ); + + private final Setting chatInfo = sgGeneral.add(new BoolSetting.Builder() + .name("chat-info") + .description("Whether the module should send messages in chat.") + .defaultValue(true) + .build() + ); + + // Render + + private final Setting swingHand = sgRender.add(new BoolSetting.Builder() + .name("swing-hand") + .description("Whether to render your hand swinging.") + .defaultValue(false) + .build() + ); + + private final Setting renderBlock = sgRender.add(new BoolSetting.Builder() + .name("render-block") + .description("Whether to render the block being broken.") + .defaultValue(true) + .build() + ); + + private final Setting shapeMode = sgRender.add(new EnumSetting.Builder() + .name("shape-mode") + .description("How the shapes are rendered.") + .defaultValue(ShapeMode.Both) + .visible(renderBlock::get) + .build() + ); + + private final Setting sideColor = sgRender.add(new ColorSetting.Builder() + .name("side-color") + .description("The side color of the rendering.") + .defaultValue(new SettingColor(225, 0, 0, 75)) + .visible(() -> renderBlock.get() && shapeMode.get().sides()) + .build() + ); + + private final Setting lineColor = sgRender.add(new ColorSetting.Builder() + .name("line-color") + .description("The line color of the rendering.") + .defaultValue(new SettingColor(225, 0, 0, 255)) + .visible(() -> renderBlock.get() && shapeMode.get().lines()) + .build() + ); + + private PlayerEntity target; + private BlockPos targetPos; + private FindItemResult pick; + private float progress; + + public AutoCity() { + super(Categories.Combat, "auto-city", "Automatically mine blocks next to someone's feet."); + } + + @Override + public void onActivate() { + target = TargetUtils.getPlayerTarget(targetRange.get(), SortPriority.ClosestAngle); + if (TargetUtils.isBadTarget(target, targetRange.get())) { + if (chatInfo.get()) error("Couldn't find a target, disabling."); + toggle(); + return; + } + + targetPos = EntityUtils.getCityBlock(target); + if (targetPos == null || PlayerUtils.distanceTo(targetPos) > breakRange.get()) { + if (chatInfo.get()) error("Couldn't find a good block, disabling."); + toggle(); + return; + } + + if (support.get()) { + BlockPos supportPos = targetPos.down(); + if (!(PlayerUtils.distanceTo(supportPos) > placeRange.get())) { + BlockUtils.place(supportPos, InvUtils.findInHotbar(Items.OBSIDIAN), rotate.get(), 0, true); + } + } + + pick = InvUtils.find(itemStack -> itemStack.getItem() == Items.DIAMOND_PICKAXE || itemStack.getItem() == Items.NETHERITE_PICKAXE); + if (!pick.isHotbar()) { + error("No pickaxe found... disabling."); + toggle(); + return; + } + + progress = 0.0f; + mine(false); + } + + @Override + public void onDeactivate() { + target = null; + targetPos = null; + } + + @EventHandler + private void onTick(TickEvent.Pre event) { + if (TargetUtils.isBadTarget(target, targetRange.get())) { + toggle(); + return; + } + + if (PlayerUtils.distanceTo(targetPos) > breakRange.get()) { + if (chatInfo.get()) error("Couldn't find a target, disabling."); + toggle(); + return; + } + + if (progress < 1.0f) { + pick = InvUtils.find(itemStack -> itemStack.getItem() == Items.DIAMOND_PICKAXE || itemStack.getItem() == Items.NETHERITE_PICKAXE); + if (!pick.isHotbar()) { + error("No pickaxe found... disabling."); + toggle(); + return; + } + progress += BlockUtils.getBreakDelta(pick.slot(), mc.world.getBlockState(targetPos)); + if (progress < 1.0f) return; + } + + mine(true); + toggle(); + } + + public void mine(boolean done) { + InvUtils.swap(pick.slot(), switchMode.get() == SwitchMode.Silent); + if (rotate.get()) Rotations.rotate(Rotations.getYaw(targetPos), Rotations.getPitch(targetPos)); + + Direction direction = (mc.player.getY() > targetPos.getY()) ? Direction.UP : Direction.DOWN; + if (!done) mc.getNetworkHandler().sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.START_DESTROY_BLOCK, targetPos, direction)); + mc.getNetworkHandler().sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.STOP_DESTROY_BLOCK, targetPos, direction)); + + if (swingHand.get()) mc.player.swingHand(Hand.MAIN_HAND); + else mc.getNetworkHandler().sendPacket(new HandSwingC2SPacket(Hand.MAIN_HAND)); + + if (switchMode.get() == SwitchMode.Silent) InvUtils.swapBack(); + } + + @EventHandler + private void onRender3D(Render3DEvent event) { + if (targetPos == null || !renderBlock.get()) return; + event.renderer.box(targetPos, sideColor.get(), lineColor.get(), shapeMode.get(), 0); + } + + @Override + public String getInfoString() { + return EntityUtils.getName(target); + } + + public enum SwitchMode { + Normal, + Silent + } +} diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/BowAimbot.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/BowAimbot.java index 68edf23976..23e682b0ec 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/BowAimbot.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/BowAimbot.java @@ -25,8 +25,7 @@ import net.minecraft.entity.passive.AnimalEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ArrowItem; -import net.minecraft.item.BowItem; -import net.minecraft.item.CrossbowItem; +import net.minecraft.item.Items; import net.minecraft.util.math.Vec3d; public class BowAimbot extends Module { @@ -128,7 +127,7 @@ private void onRender(Render3DEvent event) { } private boolean itemInHand() { - return mc.player.getMainHandStack().getItem() instanceof BowItem || mc.player.getMainHandStack().getItem() instanceof CrossbowItem; + return InvUtils.testInMainHand(Items.BOW, Items.CROSSBOW); } private void aim(double tickDelta) { diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/CrystalAura.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/CrystalAura.java index 79e81e1b26..c6623ebe82 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/CrystalAura.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/CrystalAura.java @@ -24,13 +24,15 @@ import meteordevelopment.meteorclient.systems.modules.Module; import meteordevelopment.meteorclient.utils.entity.EntityUtils; import meteordevelopment.meteorclient.utils.entity.Target; -import meteordevelopment.meteorclient.utils.entity.fakeplayer.FakePlayerManager; import meteordevelopment.meteorclient.utils.misc.Keybind; import meteordevelopment.meteorclient.utils.player.*; import meteordevelopment.meteorclient.utils.render.NametagUtils; +import meteordevelopment.meteorclient.utils.render.RenderUtils; +import meteordevelopment.meteorclient.utils.render.color.Color; import meteordevelopment.meteorclient.utils.render.color.SettingColor; import meteordevelopment.meteorclient.utils.world.BlockIterator; import meteordevelopment.meteorclient.utils.world.BlockUtils; +import meteordevelopment.meteorclient.utils.world.TickRate; import meteordevelopment.orbit.EventHandler; import meteordevelopment.orbit.EventPriority; import net.minecraft.block.Blocks; @@ -55,6 +57,7 @@ public class CrystalAura extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); + private final SettingGroup sgSwitch = settings.createGroup("Switch"); private final SettingGroup sgPlace = settings.createGroup("Place"); private final SettingGroup sgFacePlace = settings.createGroup("Face Place"); private final SettingGroup sgBreak = settings.createGroup("Break"); @@ -104,10 +107,17 @@ public class CrystalAura extends Module { .build() ); - private final Setting autoSwitch = sgGeneral.add(new EnumSetting.Builder() - .name("auto-switch") - .description("Switches to crystals in your hotbar once a target is found.") - .defaultValue(AutoSwitchMode.Normal) + private final Setting antiSuicide = sgGeneral.add(new BoolSetting.Builder() + .name("anti-suicide") + .description("Will not place and break crystals if they will kill you.") + .defaultValue(true) + .build() + ); + + private final Setting ignoreNakeds = sgGeneral.add(new BoolSetting.Builder() + .name("ignore-nakeds") + .description("Ignore players with no items.") + .defaultValue(false) .build() ); @@ -135,9 +145,41 @@ public class CrystalAura extends Module { .build() ); - private final Setting antiSuicide = sgGeneral.add(new BoolSetting.Builder() - .name("anti-suicide") - .description("Will not place and break crystals if they will kill you.") + // Switch + + private final Setting autoSwitch = sgSwitch.add(new EnumSetting.Builder() + .name("auto-switch") + .description("Switches to crystals in your hotbar once a target is found.") + .defaultValue(AutoSwitchMode.Normal) + .build() + ); + + private final Setting switchDelay = sgSwitch.add(new IntSetting.Builder() + .name("switch-delay") + .description("The delay in ticks to wait to break a crystal after switching hotbar slot.") + .defaultValue(0) + .min(0) + .build() + ); + + private final Setting noGapSwitch = sgSwitch.add(new BoolSetting.Builder() + .name("no-gap-switch") + .description("Won't auto switch if you're holding a gapple.") + .defaultValue(true) + .visible(() -> autoSwitch.get() == AutoSwitchMode.Normal) + .build() + ); + + private final Setting noBowSwitch = sgSwitch.add(new BoolSetting.Builder() + .name("no-bow-switch") + .description("Won't auto switch if you're holding a bow.") + .defaultValue(true) + .build() + ); + + private final Setting antiWeakness = sgSwitch.add(new BoolSetting.Builder() + .name("anti-weakness") + .description("Switches to tools with so you can break crystals with the weakness effect.") .defaultValue(true) .build() ); @@ -151,7 +193,7 @@ public class CrystalAura extends Module { .build() ); - private final Setting placeDelay = sgPlace.add(new IntSetting.Builder() + public final Setting placeDelay = sgPlace.add(new IntSetting.Builder() .name("place-delay") .description("The delay in ticks to wait to place a crystal after it's exploded.") .defaultValue(0) @@ -170,7 +212,7 @@ public class CrystalAura extends Module { ); private final Setting placeWallsRange = sgPlace.add(new DoubleSetting.Builder() - .name("place-walls-range") + .name("walls-range") .description("Range in which to place crystals when behind blocks.") .defaultValue(4.5) .min(0) @@ -272,14 +314,6 @@ public class CrystalAura extends Module { .build() ); - private final Setting switchDelay = sgBreak.add(new IntSetting.Builder() - .name("switch-delay") - .description("The delay in ticks to wait to break a crystal after switching hotbar slot.") - .defaultValue(0) - .min(0) - .build() - ); - private final Setting breakRange = sgBreak.add(new DoubleSetting.Builder() .name("break-range") .description("Range in which to break crystals.") @@ -290,7 +324,7 @@ public class CrystalAura extends Module { ); private final Setting breakWallsRange = sgBreak.add(new DoubleSetting.Builder() - .name("break-walls-range") + .name("walls-range") .description("Range in which to break crystals when behind blocks.") .defaultValue(4.5) .min(0) @@ -338,56 +372,124 @@ public class CrystalAura extends Module { .build() ); - private final Setting antiWeakness = sgBreak.add(new BoolSetting.Builder() - .name("anti-weakness") - .description("Switches to tools with high enough damage to explode the crystal with weakness effect.") - .defaultValue(true) + // Pause + + public final Setting pauseOnUse = sgPause.add(new EnumSetting.Builder() + .name("pause-on-use") + .description("Which processes should be paused while using an item.") + .defaultValue(PauseMode.Place) .build() ); - // Pause + public final Setting pauseOnMine = sgPause.add(new EnumSetting.Builder() + .name("pause-on-mine") + .description("Which processes should be paused while mining a block.") + .defaultValue(PauseMode.None) + .build() + ); - private final Setting eatPause = sgPause.add(new BoolSetting.Builder() - .name("pause-on-eat") - .description("Pauses Crystal Aura when eating.") + private final Setting pauseOnLag = sgPause.add(new BoolSetting.Builder() + .name("pause-on-lag") + .description("Whether to pause if the server is not responding.") .defaultValue(true) .build() ); - private final Setting drinkPause = sgPause.add(new BoolSetting.Builder() - .name("pause-on-drink") - .description("Pauses Crystal Aura when drinking.") - .defaultValue(true) + public final Setting> pauseModules = sgPause.add(new ModuleListSetting.Builder() + .name("pause-modules") + .description("Pauses while any of the selected modules are active.") + .defaultValue(BedAura.class) .build() ); - private final Setting minePause = sgPause.add(new BoolSetting.Builder() - .name("pause-on-mine") - .description("Pauses Crystal Aura when mining.") - .defaultValue(false) + public final Setting pauseHealth = sgPause.add(new DoubleSetting.Builder() + .name("pause-health") + .description("Pauses when you go below a certain health.") + .defaultValue(5) + .range(0,36) + .sliderRange(0,36) .build() ); // Render - private final Setting renderSwing = sgRender.add(new BoolSetting.Builder() - .name("swing") - .description("Renders hand swinging client-side.") - .defaultValue(true) + public final Setting swingMode = sgRender.add(new EnumSetting.Builder() + .name("swing-mode") + .description("How to swing when placing.") + .defaultValue(SwingMode.Both) + .build() + ); + + private final Setting renderMode = sgRender.add(new EnumSetting.Builder() + .name("render-mode") + .description("The mode to render in.") + .defaultValue(RenderMode.Normal) .build() ); - private final Setting render = sgRender.add(new BoolSetting.Builder() - .name("render") + private final Setting renderPlace = sgRender.add(new BoolSetting.Builder() + .name("render-place") .description("Renders a block overlay over the block the crystals are being placed on.") .defaultValue(true) + .visible(() -> renderMode.get() == RenderMode.Normal) + .build() + ); + + private final Setting placeRenderTime = sgRender.add(new IntSetting.Builder() + .name("place-time") + .description("How long to render placements.") + .defaultValue(10) + .min(0) + .sliderMax(20) + .visible(() -> renderMode.get() == RenderMode.Normal && renderPlace.get()) .build() ); private final Setting renderBreak = sgRender.add(new BoolSetting.Builder() - .name("break") + .name("render-break") .description("Renders a block overlay over the block the crystals are broken on.") .defaultValue(false) + .visible(() -> renderMode.get() == RenderMode.Normal) + .build() + ); + + private final Setting breakRenderTime = sgRender.add(new IntSetting.Builder() + .name("break-time") + .description("How long to render breaking for.") + .defaultValue(13) + .min(0) + .sliderMax(20) + .visible(() -> renderMode.get() == RenderMode.Normal && renderBreak.get()) + .build() + ); + + private final Setting smoothness = sgRender.add(new IntSetting.Builder() + .name("smoothness") + .description("How smoothly the render should move around.") + .defaultValue(10) + .min(0) + .sliderMax(20) + .visible(() -> renderMode.get() == RenderMode.Smooth) + .build() + ); + + private final Setting height = sgRender.add(new DoubleSetting.Builder() + .name("height") + .description("How tall the gradient should be.") + .defaultValue(0.7) + .min(0) + .sliderMax(1) + .visible(() -> renderMode.get() == RenderMode.Gradient) + .build() + ); + + private final Setting renderTime = sgRender.add(new IntSetting.Builder() + .name("render-time") + .description("How long to render placements.") + .defaultValue(10) + .min(0) + .sliderMax(20) + .visible(() -> renderMode.get() == RenderMode.Smooth || renderMode.get() == RenderMode.Fading) .build() ); @@ -395,6 +497,7 @@ public class CrystalAura extends Module { .name("shape-mode") .description("How the shapes are rendered.") .defaultValue(ShapeMode.Both) + .visible(() -> renderMode.get() != RenderMode.None) .build() ); @@ -402,6 +505,7 @@ public class CrystalAura extends Module { .name("side-color") .description("The side color of the block overlay.") .defaultValue(new SettingColor(255, 255, 255, 45)) + .visible(() -> shapeMode.get().sides() && renderMode.get() != RenderMode.None) .build() ); @@ -409,6 +513,7 @@ public class CrystalAura extends Module { .name("line-color") .description("The line color of the block overlay.") .defaultValue(new SettingColor(255, 255, 255)) + .visible(() -> shapeMode.get().lines() && renderMode.get() != RenderMode.None) .build() ); @@ -416,6 +521,15 @@ public class CrystalAura extends Module { .name("damage") .description("Renders crystal damage text in the block overlay.") .defaultValue(true) + .visible(() -> renderMode.get() != RenderMode.None) + .build() + ); + + private final Setting damageColor = sgRender.add(new ColorSetting.Builder() + .name("damage-color") + .description("The color of the damage text.") + .defaultValue(new SettingColor(255, 255, 255)) + .visible(() -> renderMode.get() != RenderMode.None && renderDamageText.get()) .build() ); @@ -425,31 +539,14 @@ public class CrystalAura extends Module { .defaultValue(1.25) .min(1) .sliderMax(4) - .visible(renderDamageText::get) - .build() - ); - - private final Setting renderTime = sgRender.add(new IntSetting.Builder() - .name("render-time") - .description("How long to render for.") - .defaultValue(10) - .min(0) - .sliderMax(20) - .build() - ); - - private final Setting renderBreakTime = sgRender.add(new IntSetting.Builder() - .name("break-time") - .description("How long to render breaking for.") - .defaultValue(13) - .min(0) - .sliderMax(20) - .visible(renderBreak::get) + .visible(() -> renderMode.get() != RenderMode.None && renderDamageText.get()) .build() ); // Fields + private Item mainItem, offItem; + private int breakTimer, placeTimer, switchTimer, ticksPassed; private final List targets = new ArrayList<>(); @@ -465,6 +562,7 @@ public class CrystalAura extends Module { private final IntSet placedCrystals = new IntOpenHashSet(); private boolean placing; private int placingTimer; + public int kaTimer; private final BlockPos.Mutable placingCrystalBlockPos = new BlockPos.Mutable(); private final IntSet removed = new IntOpenHashSet(); @@ -484,9 +582,11 @@ public class CrystalAura extends Module { private double lastYaw, lastPitch; private int lastRotationTimer; - private int renderTimer, breakRenderTimer; - private final BlockPos.Mutable renderPos = new BlockPos.Mutable(); + private int placeRenderTimer, breakRenderTimer; + private final BlockPos.Mutable placeRenderPos = new BlockPos.Mutable(); private final BlockPos.Mutable breakRenderPos = new BlockPos.Mutable(); + private Box renderBoxOne, renderBoxTwo; + private double renderDamage; public CrystalAura() { @@ -503,6 +603,7 @@ public void onActivate() { placing = false; placingTimer = 0; + kaTimer = 0; attacks = 0; @@ -513,7 +614,7 @@ public void onActivate() { lastRotationTimer = getLastRotationStopDelay(); - renderTimer = 0; + placeRenderTimer = 0; breakRenderTimer = 0; } @@ -547,6 +648,8 @@ private void onPreTick(TickEvent.Pre event) { else placing = false; } + if (kaTimer > 0) kaTimer--; + if (ticksPassed < 20) ticksPassed++; else { ticksPassed = 0; @@ -563,9 +666,12 @@ private void onPreTick(TickEvent.Pre event) { if (switchTimer > 0) switchTimer--; // Decrement render timers - if (renderTimer > 0) renderTimer--; + if (placeRenderTimer > 0) placeRenderTimer--; if (breakRenderTimer > 0) breakRenderTimer--; + mainItem = mc.player.getMainHandStack().getItem(); + offItem = mc.player.getOffHandStack().getItem(); + // Update waiting to explode crystals and mark them as existing if reached threshold for (IntIterator it = waitingToExplode.keySet().iterator(); it.hasNext();) { int id = it.nextInt(); @@ -580,9 +686,6 @@ private void onPreTick(TickEvent.Pre event) { } } - // Check pause settings - if (PlayerUtils.shouldPause(minePause.get(), eatPause.get(), drinkPause.get())) return; - // Set player eye pos ((IVec3d) playerEyePos).set(mc.player.getPos().x, mc.player.getPos().y + mc.player.getEyeHeight(mc.player.getPose()), mc.player.getPos().z); @@ -645,6 +748,7 @@ private void setRotation(boolean isPos, Vec3d pos, double yaw, double pitch) { private void doBreak() { if (!doBreak.get() || breakTimer > 0 || switchTimer > 0 || attacks >= attackFrequency.get()) return; + if (shouldPause(PauseMode.Break)) return; double bestDamage = 0; Entity crystal = null; @@ -688,9 +792,10 @@ private double getBreakDamage(Entity entity, boolean checkCrystalAge) { // Check damage to targets and face place double damage = getDamageToTargets(entity.getPos(), blockPos, true, false); - boolean facePlaced = (facePlace.get() && shouldFacePlace(entity.getBlockPos()) || forceFacePlace.get().isPressed()); + boolean shouldFacePlace = shouldFacePlace(); + double minimumDamage = Math.min(minDamage.get(), shouldFacePlace ? 1.5 : minDamage.get()); - if (!facePlaced && damage < minDamage.get()) return 0; + if (damage < minimumDamage) return 0; return damage; } @@ -744,7 +849,7 @@ private void doBreak(Entity crystal) { // Break render breakRenderPos.set(crystal.getBlockPos().down()); - breakRenderTimer = renderBreakTime.get(); + breakRenderTimer = breakRenderTime.get(); } } @@ -762,8 +867,8 @@ private void attackCrystal(Entity entity) { Hand hand = InvUtils.findInHotbar(Items.END_CRYSTAL).getHand(); if (hand == null) hand = Hand.MAIN_HAND; - if (renderSwing.get()) mc.player.swingHand(hand); - else mc.getNetworkHandler().sendPacket(new HandSwingC2SPacket(hand)); + if (swingMode.get().client()) mc.player.swingHand(hand); + if (swingMode.get().packet()) mc.getNetworkHandler().sendPacket(new HandSwingC2SPacket(hand)); attacks++; } @@ -779,12 +884,21 @@ private void onPacketSend(PacketEvent.Send event) { private void doPlace() { if (!doPlace.get() || placeTimer > 0) return; + if (shouldPause(PauseMode.Place)) return; // Return if there are no crystals in hotbar or offhand if (!InvUtils.testInHotbar(Items.END_CRYSTAL)) return; // Return if there are no crystals in either hand and auto switch mode is none - if (autoSwitch.get() == AutoSwitchMode.None && mc.player.getOffHandStack().getItem() != Items.END_CRYSTAL && mc.player.getMainHandStack().getItem() != Items.END_CRYSTAL) return; + if (autoSwitch.get() != AutoSwitchMode.None) { + if (noGapSwitch.get() && autoSwitch.get() == AutoSwitchMode.Normal && offItem != Items.END_CRYSTAL) { + if (mainItem == Items.ENCHANTED_GOLDEN_APPLE + || offItem == Items.ENCHANTED_GOLDEN_APPLE + || mainItem == Items.GOLDEN_APPLE + || offItem == Items.GOLDEN_APPLE) return; + } + if (noBowSwitch.get() && (mainItem == Items.BOW || offItem == Items.BOW)) return; + } else if (mainItem != Items.END_CRYSTAL && offItem != Items.END_CRYSTAL) return; // Check for multiplace for (Entity entity : mc.world.getEntities()) { @@ -823,9 +937,10 @@ private void doPlace() { // Check damage to targets and face place double damage = getDamageToTargets(vec3d, bp, false, !hasBlock && support.get() == SupportMode.Fast); - boolean facePlaced = (facePlace.get() && shouldFacePlace(blockPos)) || (forceFacePlace.get().isPressed()); + boolean shouldFacePlace = shouldFacePlace(); + double minimumDamage = Math.min(minDamage.get(), shouldFacePlace ? 1.5 : minDamage.get()); - if (!facePlaced && damage < minDamage.get()) return; + if (damage < minimumDamage) return; // Check if it can be placed double x = bp.getX(); @@ -915,20 +1030,34 @@ private void placeCrystal(BlockHitResult result, double damage, BlockPos support // Place crystal mc.player.networkHandler.sendPacket(new PlayerInteractBlockC2SPacket(hand, result, 0)); - if (renderSwing.get()) mc.player.swingHand(hand); - else mc.getNetworkHandler().sendPacket(new HandSwingC2SPacket(hand)); + if (swingMode.get().client()) mc.player.swingHand(hand); + if (swingMode.get().packet()) mc.getNetworkHandler().sendPacket(new HandSwingC2SPacket(hand)); placing = true; placingTimer = 4; + kaTimer = 8; placingCrystalBlockPos.set(result.getBlockPos()).move(0, 1, 0); - renderTimer = renderTime.get(); - renderPos.set(result.getBlockPos()); + placeRenderPos.set(result.getBlockPos()); renderDamage = damage; + + if (renderMode.get() == RenderMode.Normal) { + placeRenderTimer = placeRenderTime.get(); + } else { + placeRenderTimer = renderTime.get(); + if (renderMode.get() == RenderMode.Fading) { + RenderUtils.renderTickingBlock( + placeRenderPos, sideColor.get(), + lineColor.get(), shapeMode.get(), + 0, renderTime.get(), true, + false + ); + } + } } else { // Place support block - BlockUtils.place(supportBlock, item, false, 0, renderSwing.get(), true, false); + BlockUtils.place(supportBlock, item, false, 0, swingMode.get().client(), true, false); placeTimer += supportDelay.get(); if (supportDelay.get() == 0) placeCrystal(result, damage, null); @@ -977,21 +1106,21 @@ private static double distanceBetweenAngles(double alpha, double beta) { // Face place - private boolean shouldFacePlace(BlockPos crystal) { + private boolean shouldFacePlace() { + if (!facePlace.get()) return false; + + if (forceFacePlace.get().isPressed()) return true; + // Checks if the provided crystal position should face place to any target for (PlayerEntity target : targets) { - BlockPos pos = target.getBlockPos(); - - if (crystal.getY() == pos.getY() + 1 && Math.abs(pos.getX() - crystal.getX()) <= 1 && Math.abs(pos.getZ() - crystal.getZ()) <= 1) { - if (EntityUtils.getTotalHealth(target) <= facePlaceHealth.get()) return true; - - for (ItemStack itemStack : target.getArmorItems()) { - if (itemStack == null || itemStack.isEmpty()) { - if (facePlaceArmor.get()) return true; - } - else { - if ((double) (itemStack.getMaxDamage() - itemStack.getDamage()) / itemStack.getMaxDamage() * 100 <= facePlaceDurability.get()) return true; - } + if (EntityUtils.getTotalHealth(target) <= facePlaceHealth.get()) return true; + + for (ItemStack itemStack : target.getArmorItems()) { + if (itemStack == null || itemStack.isEmpty()) { + if (facePlaceArmor.get()) return true; + } + else { + if ((double) (itemStack.getMaxDamage() - itemStack.getDamage()) / itemStack.getMaxDamage() * 100 <= facePlaceDurability.get()) return true; } } } @@ -1001,6 +1130,17 @@ private boolean shouldFacePlace(BlockPos crystal) { // Others + private boolean shouldPause(PauseMode process) { + if (mc.player.isUsingItem() || mc.options.useKey.isPressed()) { + if (pauseOnUse.get().equals(process)) return true; + } + + if (pauseOnLag.get() && TickRate.INSTANCE.getTimeSinceLastTick() >= 1.0f) return true; + for (Module module : pauseModules.get()) if (module.isActive()) return true; + if (pauseOnMine.get().equals(process) && mc.interactionManager.isBreakingBlock()) return true; + return (EntityUtils.getTotalHealth(mc.player) <= pauseHealth.get()); + } + private boolean isOutOfRange(Vec3d vec3d, BlockPos blockPos, boolean place) { ((IRaycastContext) raycastContext).set(playerEyePos, vec3d, RaycastContext.ShapeType.COLLIDER, RaycastContext.FluidHandling.NONE, mc.player); @@ -1065,53 +1205,107 @@ private void findTargets() { // Players for (PlayerEntity player : mc.world.getPlayers()) { if (player.getAbilities().creativeMode || player == mc.player) continue; - - if (!player.isDead() && player.isAlive() && Friends.get().shouldAttack(player) && PlayerUtils.isWithin(player, targetRange.get())) { - targets.add(player); + if (!player.isAlive() || !Friends.get().shouldAttack(player)) continue; + if (player.distanceTo(mc.player) > targetRange.get()) continue; + + if (ignoreNakeds.get()) { + if (player.getOffHandStack().isEmpty() + && player.getMainHandStack().isEmpty() + && player.getInventory().armor.get(0).isEmpty() + && player.getInventory().armor.get(1).isEmpty() + && player.getInventory().armor.get(2).isEmpty() + && player.getInventory().armor.get(3).isEmpty() + ) continue; } - } - // Fake players - FakePlayerManager.forEach(fp -> { - if (!fp.isDead() && fp.isAlive() && Friends.get().shouldAttack(fp) && PlayerUtils.isWithin(fp, targetRange.get())) { - targets.add(fp); - } - }); + targets.add(player); + } } private boolean intersectsWithEntities(Box box) { return EntityUtils.intersectsWithEntity(box, entity -> !entity.isSpectator() && !removed.contains(entity.getId())); } - // Render + // Rendering @EventHandler private void onRender(Render3DEvent event) { - if (renderTimer > 0 && render.get()) { - event.renderer.box(renderPos, sideColor.get(), lineColor.get(), shapeMode.get(), 0); - } + if (renderMode.get() == RenderMode.None) return; + + switch (renderMode.get()) { + case Normal -> { + if (renderPlace.get() && placeRenderTimer > 0) { + event.renderer.box(placeRenderPos, sideColor.get(), lineColor.get(), shapeMode.get(), 0); + } + if (renderBreak.get() && breakRenderTimer > 0) { + event.renderer.box(breakRenderPos, sideColor.get(), lineColor.get(), shapeMode.get(), 0); + } + } + + case Smooth -> { + if (placeRenderTimer <= 0) return; + + if (renderBoxOne == null) renderBoxOne = new Box(placeRenderPos); + if (renderBoxTwo == null) renderBoxTwo = new Box(placeRenderPos); + else ((IBox) renderBoxTwo).set(placeRenderPos); + + double offsetX = (renderBoxTwo.minX - renderBoxOne.minX) / smoothness.get(); + double offsetY = (renderBoxTwo.minY - renderBoxOne.minY) / smoothness.get(); + double offsetZ = (renderBoxTwo.minZ - renderBoxOne.minZ) / smoothness.get(); + + ((IBox) renderBoxOne).set( + renderBoxOne.minX + offsetX, + renderBoxOne.minY + offsetY, + renderBoxOne.minZ + offsetZ, + renderBoxOne.maxX + offsetX, + renderBoxOne.maxY + offsetY, + renderBoxOne.maxZ + offsetZ + ); + + event.renderer.box(renderBoxOne, sideColor.get(), lineColor.get(), shapeMode.get(), 0); + } - if (breakRenderTimer > 0 && renderBreak.get() && !mc.world.getBlockState(breakRenderPos).isAir()) { - int preSideA = sideColor.get().a; - sideColor.get().a -= 20; - sideColor.get().validate(); + case Gradient -> { + if (placeRenderTimer <= 0) return; - int preLineA = lineColor.get().a; - lineColor.get().a -= 20; - lineColor.get().validate(); + Color bottom = new Color(0, 0, 0, 0); - event.renderer.box(breakRenderPos, sideColor.get(), lineColor.get(), shapeMode.get(), 0); + int x = placeRenderPos.getX(); + int y = placeRenderPos.getY() + 1; + int z = placeRenderPos.getZ(); - sideColor.get().a = preSideA; - lineColor.get().a = preLineA; + if (shapeMode.get().sides()) { + event.renderer.quadHorizontal(x, y, z, x + 1, z + 1, sideColor.get()); + event.renderer.gradientQuadVertical(x, y, z, x + 1, y - height.get(), z, bottom, sideColor.get()); + event.renderer.gradientQuadVertical(x, y, z, x, y - height.get(), z + 1, bottom, sideColor.get()); + event.renderer.gradientQuadVertical(x + 1, y, z, x + 1, y - height.get(), z + 1, bottom, sideColor.get()); + event.renderer.gradientQuadVertical(x, y, z + 1, x + 1, y - height.get(), z + 1, bottom, sideColor.get()); + } + + if (shapeMode.get().lines()) { + event.renderer.line(x, y, z, x + 1, y, z, lineColor.get()); + event.renderer.line(x, y, z, x, y, z + 1, lineColor.get()); + event.renderer.line(x + 1, y, z, x + 1, y, z + 1, lineColor.get()); + event.renderer.line(x, y, z + 1, x + 1, y, z + 1, lineColor.get()); + + event.renderer.line(x, y, z, x, y - height.get(), z, lineColor.get(), bottom); + event.renderer.line(x + 1, y, z, x + 1, y - height.get(), z, lineColor.get(), bottom); + event.renderer.line(x, y, z + 1, x, y - height.get(), z + 1, lineColor.get(), bottom); + event.renderer.line(x + 1, y, z + 1, x + 1, y - height.get(), z + 1, lineColor.get(), bottom); + } + } } } @EventHandler private void onRender2D(Render2DEvent event) { - if (!render.get() || renderTimer <= 0 || !renderDamageText.get()) return; + if (renderMode.get() == RenderMode.None || !renderDamageText.get()) return; + if (placeRenderTimer <= 0 && breakRenderTimer <= 0) return; - vec3.set(renderPos.getX() + 0.5, renderPos.getY() + 0.5, renderPos.getZ() + 0.5); + if (renderMode.get() == RenderMode.Smooth) { + if (renderBoxOne == null) return; + vec3.set(renderBoxOne.minX + 0.5, renderBoxOne.minY + 0.5, renderBoxOne.minZ + 0.5); + } else vec3.set(placeRenderPos.getX() + 0.5, placeRenderPos.getY() + 0.5, placeRenderPos.getZ() + 0.5); if (NametagUtils.to2D(vec3, damageTextScale.get())) { NametagUtils.begin(vec3); @@ -1119,7 +1313,7 @@ private void onRender2D(Render2DEvent event) { String text = String.format("%.1f", renderDamage); double w = TextRenderer.get().getWidth(text) / 2; - TextRenderer.get().render(text, -w, 0, lineColor.get(), true); + TextRenderer.get().render(text, -w, 0, damageColor.get(), true); TextRenderer.get().end(); NametagUtils.end(); @@ -1142,4 +1336,38 @@ public enum SupportMode { Accurate, Fast } + + public enum PauseMode { + Both, + Place, + Break, + None; + + public boolean equals(PauseMode process) { + return this == process || this == PauseMode.Both; + } + } + + public enum SwingMode { + Both, + Packet, + Client, + None; + + public boolean packet() { + return this == Packet || this == Both; + } + + public boolean client() { + return this == Client || this == Both; + } + } + + public enum RenderMode { + Normal, + Smooth, + Fading, + Gradient, + None + } } diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/Hitboxes.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/Hitboxes.java index fb8e436a51..15f3d81c4e 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/Hitboxes.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/Hitboxes.java @@ -6,14 +6,18 @@ package meteordevelopment.meteorclient.systems.modules.combat; import it.unimi.dsi.fastutil.objects.Object2BooleanMap; +import meteordevelopment.meteorclient.settings.BoolSetting; import meteordevelopment.meteorclient.settings.DoubleSetting; import meteordevelopment.meteorclient.settings.EntityTypeListSetting; import meteordevelopment.meteorclient.settings.Setting; import meteordevelopment.meteorclient.settings.SettingGroup; import meteordevelopment.meteorclient.systems.modules.Categories; import meteordevelopment.meteorclient.systems.modules.Module; +import meteordevelopment.meteorclient.utils.player.InvUtils; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; +import net.minecraft.item.AxeItem; +import net.minecraft.item.SwordItem; public class Hitboxes extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); @@ -32,13 +36,25 @@ public class Hitboxes extends Module { .build() ); + private final Setting onlyOnWeapon = sgGeneral.add(new BoolSetting.Builder() + .name("only-on-weapon") + .description("Only modifies hitbox when holding a weapon in hand.") + .defaultValue(false) + .build() + ); + public Hitboxes() { super(Categories.Combat, "hitboxes", "Expands an entity's hitboxes."); } public double getEntityValue(Entity entity) { - if (!isActive()) return 0; + if (!(isActive() && testWeapon())) return 0; if (entities.get().getBoolean(entity.getType())) return value.get(); return 0; } + + private boolean testWeapon() { + if (!onlyOnWeapon.get()) return true; + return InvUtils.testInHands(itemStack -> itemStack.getItem() instanceof SwordItem || itemStack.getItem() instanceof AxeItem); + } } diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/HoleFiller.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/HoleFiller.java index 9db3afea09..562b3133c7 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/HoleFiller.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/HoleFiller.java @@ -8,6 +8,7 @@ import meteordevelopment.meteorclient.events.render.Render3DEvent; import meteordevelopment.meteorclient.events.world.TickEvent; import meteordevelopment.meteorclient.mixin.AbstractBlockAccessor; +import meteordevelopment.meteorclient.mixininterface.IBox; import meteordevelopment.meteorclient.renderer.ShapeMode; import meteordevelopment.meteorclient.settings.*; import meteordevelopment.meteorclient.systems.friends.Friends; @@ -26,9 +27,11 @@ import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; +import net.minecraft.entity.TntEntity; +import net.minecraft.entity.decoration.EndCrystalEntity; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.BlockItem; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Box; import net.minecraft.util.math.Direction; import net.minecraft.util.math.Vec3d; @@ -221,6 +224,9 @@ public class HoleFiller extends Module { private final List targets = new ArrayList<>(); private final List holes = new ArrayList<>(); + + private final BlockPos.Mutable testPos = new BlockPos.Mutable(); + private final Box box = new Box(0, 0, 0, 0, 0, 0); private int timer; public HoleFiller() { @@ -276,18 +282,15 @@ else if (obsidian + bedrock == 8 && doubles.get() && air != null) { }); BlockIterator.after(() -> { - if (timer <= 0 && !holes.isEmpty()) { - int bpt = 0; + if (timer > 0 || holes.isEmpty()) return; - for (Hole hole : holes) { - if (bpt >= blocksPerTick.get()) continue; - if (BlockUtils.place(hole.blockPos, block, rotate.get(), 10, swing.get(), true)) { - bpt++; - } - } - - timer = placeDelay.get(); + int bpt = 0; + for (Hole hole : holes) { + if (bpt >= blocksPerTick.get()) continue; + if (BlockUtils.place(hole.blockPos, block, rotate.get(), 10, swing.get(), true)) bpt++; } + + timer = placeDelay.get(); }); timer--; @@ -312,49 +315,43 @@ private void onRender(Render3DEvent event) { } private boolean validHole(BlockPos pos) { - if (mc.player.getBlockPos().equals(pos)) return false; - if (distance(mc.player, pos, false) > placeRange.get()) return false; - if (mc.world.getBlockState(pos).getBlock() == Blocks.COBWEB) return false; - - if (smart.get() && !forceFill.get().isPressed()) { - boolean validHole = false; - for (PlayerEntity target : targets) { - if (target.getY() > pos.getY() - && !target.getBlockPos().equals(pos) - && (distance(target, pos, true) < feetRange.get()) - ) validHole = true; - } - if (!validHole) return false; - } + testPos.set(pos); + + if (mc.player.getBlockPos().equals(testPos)) return false; + if (distance(mc.player, testPos, false) > placeRange.get()) return false; + if (mc.world.getBlockState(testPos).getBlock() == Blocks.COBWEB) return false; + + if (((AbstractBlockAccessor) mc.world.getBlockState(testPos).getBlock()).isCollidable()) return false; + testPos.add(0, 1, 0); + if (((AbstractBlockAccessor) mc.world.getBlockState(testPos).getBlock()).isCollidable()) return false; + testPos.add(0, -1, 0); - if (((AbstractBlockAccessor) mc.world.getBlockState(pos).getBlock()).isCollidable()) return false; - return !((AbstractBlockAccessor) mc.world.getBlockState(pos.up()).getBlock()).isCollidable(); + ((IBox) box).set(pos); + if (!mc.world.getOtherEntities(null, box, entity + -> entity instanceof PlayerEntity + || entity instanceof TntEntity + || entity instanceof EndCrystalEntity).isEmpty()) return false; + + if (!smart.get() || forceFill.get().isPressed()) return true; + + return targets.stream().anyMatch(target + -> target.getY() > testPos.getY() + && (distance(target, testPos, true) < feetRange.get())); } private void setTargets() { targets.clear(); for (PlayerEntity player : mc.world.getPlayers()) { - if (player.distanceTo(mc.player) > targetRange.get()) continue; - - if (player.isCreative() || player == mc.player - || player.isDead() || !Friends.get().shouldAttack(player) - || (isSurrounded(player) && ignoreSafe.get()) + if (player.distanceTo(mc.player) > targetRange.get() || + player.isCreative() || + player == mc.player || + player.isDead() || + !Friends.get().shouldAttack(player) || + (ignoreSafe.get() && isSurrounded(player)) || + (onlyMoving.get() && (player.getX() - player.prevX != 0 || player.getY() - player.prevY != 0 || player.getZ() - player.prevZ != 0)) ) continue; - if (onlyMoving.get()) { - Vec3d velocity = new Vec3d( - player.getX() - player.prevX, - player.getY() - player.prevY, - player.getZ() - player.prevZ - ); - if (velocity.length() == 0) continue; - } - - if (ignoreSafe.get()) { - if (isSurrounded(player)) continue; - } - targets.add(player); } } @@ -363,40 +360,40 @@ private boolean isSurrounded(PlayerEntity target) { for (Direction dir : Direction.values()) { if (dir == Direction.UP || dir == Direction.DOWN) continue; - Block block = mc.world.getBlockState(target.getBlockPos().offset(dir)).getBlock(); - if (block != Blocks.OBSIDIAN && block != Blocks.BEDROCK && block != Blocks.RESPAWN_ANCHOR - && block != Blocks.CRYING_OBSIDIAN && block != Blocks.NETHERITE_BLOCK) { - return false; - } + testPos.set(target.getBlockPos().offset(dir)); + Block block = mc.world.getBlockState(testPos).getBlock(); + if (block != Blocks.OBSIDIAN && + block != Blocks.BEDROCK && + block != Blocks.RESPAWN_ANCHOR && + block != Blocks.CRYING_OBSIDIAN && + block != Blocks.NETHERITE_BLOCK) return false; } return true; } private double distance(PlayerEntity player, BlockPos pos, boolean feet) { - Vec3d center = new Vec3d(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5); - if (feet) center.add(0, 0.5, 0); + Vec3d testVec = player.getPos(); + if (!feet) testVec.add(0, player.getEyeHeight(mc.player.getPose()), 0); - Vec3d playerPos = player.getPos(); - if (!feet) playerPos.add(0, player.getEyeHeight(mc.player.getPose()), 0); else if (predict.get()) { - playerPos.add( + testVec.add( player.getX() - player.prevX, player.getY() - player.prevY, player.getZ() - player.prevZ ); } - double i = playerPos.x - center.x; - double j = playerPos.y - center.y; - double k = playerPos.z - center.z; + double i = testVec.x - (pos.getX() + 0.5); + double j = testVec.y - (pos.getY() + ((feet) ? 1 : 0.5)); + double k = testVec.z - (pos.getZ() + 0.5); - return (Math.sqrt(i * i + j * j + k * k)); + return Math.sqrt(i * i + j * j + k * k); } private static class Hole { - public BlockPos.Mutable blockPos = new BlockPos.Mutable(); - public byte exclude; + private final BlockPos.Mutable blockPos = new BlockPos.Mutable(); + private final byte exclude; public Hole(BlockPos blockPos, byte exclude) { this.blockPos.set(blockPos); diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/KillAura.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/KillAura.java index f008c599f2..ec6a130fe6 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/KillAura.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/KillAura.java @@ -9,10 +9,12 @@ import it.unimi.dsi.fastutil.objects.Object2BooleanMap; import meteordevelopment.meteorclient.events.packets.PacketEvent; import meteordevelopment.meteorclient.events.world.TickEvent; +import meteordevelopment.meteorclient.mixininterface.IVec3d; import meteordevelopment.meteorclient.settings.*; import meteordevelopment.meteorclient.systems.friends.Friends; import meteordevelopment.meteorclient.systems.modules.Categories; import meteordevelopment.meteorclient.systems.modules.Module; +import meteordevelopment.meteorclient.systems.modules.Modules; import meteordevelopment.meteorclient.utils.entity.EntityUtils; import meteordevelopment.meteorclient.utils.entity.SortPriority; import meteordevelopment.meteorclient.utils.entity.Target; @@ -21,22 +23,24 @@ import meteordevelopment.meteorclient.utils.player.InvUtils; import meteordevelopment.meteorclient.utils.player.PlayerUtils; import meteordevelopment.meteorclient.utils.player.Rotations; +import meteordevelopment.meteorclient.utils.world.TickRate; import meteordevelopment.orbit.EventHandler; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.Tameable; -import net.minecraft.entity.damage.DamageSource; import net.minecraft.entity.mob.EndermanEntity; import net.minecraft.entity.mob.ZombifiedPiglinEntity; import net.minecraft.entity.passive.AnimalEntity; +import net.minecraft.entity.passive.LlamaEntity; import net.minecraft.entity.passive.WolfEntity; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.AxeItem; -import net.minecraft.item.Item; -import net.minecraft.item.SwordItem; +import net.minecraft.item.*; import net.minecraft.network.packet.c2s.play.UpdateSelectedSlotC2SPacket; import net.minecraft.util.Hand; +import net.minecraft.util.math.Box; +import net.minecraft.util.math.MathHelper; +import net.minecraft.util.math.Vec3d; import net.minecraft.world.GameMode; import java.util.ArrayList; @@ -45,7 +49,7 @@ public class KillAura extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); private final SettingGroup sgTargeting = settings.createGroup("Targeting"); - private final SettingGroup sgDelay = settings.createGroup("Delay"); + private final SettingGroup sgTiming = settings.createGroup("Timing"); // General @@ -56,6 +60,13 @@ public class KillAura extends Module { .build() ); + private final Setting rotation = sgGeneral.add(new EnumSetting.Builder() + .name("rotate") + .description("Determines when you should rotate towards the target.") + .defaultValue(RotationMode.Always) + .build() + ); + private final Setting autoSwitch = sgGeneral.add(new BoolSetting.Builder() .name("auto-switch") .description("Switches to your selected weapon when attacking the target.") @@ -70,73 +81,52 @@ public class KillAura extends Module { .build() ); - private final Setting onlyWhenLook = sgGeneral.add(new BoolSetting.Builder() - .name("only-when-look") - .description("Only attacks when you are looking at the entity.") + private final Setting onlyOnLook = sgGeneral.add(new BoolSetting.Builder() + .name("only-on-look") + .description("Only attacks when looking at an entity.") .defaultValue(false) .build() ); - private final Setting randomTeleport = sgGeneral.add(new BoolSetting.Builder() - .name("random-teleport") - .description("Randomly teleport around the target.") - .defaultValue(false) - .visible(() -> !onlyWhenLook.get()) - .build() - ); - - private final Setting rotation = sgGeneral.add(new EnumSetting.Builder() - .name("rotate") - .description("Determines when you should rotate towards the target.") - .defaultValue(RotationMode.Always) - .build() - ); - - private final Setting hitChance = sgGeneral.add(new DoubleSetting.Builder() - .name("hit-chance") - .description("The probability of your hits landing.") - .defaultValue(100) - .range(1, 100) - .sliderRange(1, 100) - .build() - ); - private final Setting pauseOnCombat = sgGeneral.add(new BoolSetting.Builder() - .name("pause-on-combat") + .name("pause-baritone") .description("Freezes Baritone temporarily until you are finished attacking the entity.") .defaultValue(true) .build() ); - private final Setting noRightClick = sgGeneral.add(new BoolSetting.Builder() - .name("pause-on-use") - .description("Does not attack if using an item.") - .defaultValue(true) + private final Setting shieldMode = sgGeneral.add(new EnumSetting.Builder() + .name("shield-mode") + .description("Will try and use an axe to break target shields.") + .defaultValue(ShieldMode.Break) + .visible(() -> autoSwitch.get() && weapon.get() != Weapon.Axe) .build() ); // Targeting - private final Setting ignorePassive = sgGeneral.add(new BoolSetting.Builder() - .name("ignore-passive") - .description("Will only attack sometimes passive mobs if they are targeting you.") - .defaultValue(true) + private final Setting>> entities = sgTargeting.add(new EntityTypeListSetting.Builder() + .name("entities") + .description("Entities to attack.") + .onlyAttackable() + .defaultEnemies() .build() ); - private final Setting ignoreTamed = sgGeneral.add(new BoolSetting.Builder() - .name("ignore-tamed") - .description("Will avoid attacking mobs you tamed.") - .defaultValue(false) + private final Setting priority = sgTargeting.add(new EnumSetting.Builder() + .name("priority") + .description("How to filter targets within range.") + .defaultValue(SortPriority.ClosestAngle) .build() ); - - private final Setting>> entities = sgTargeting.add(new EntityTypeListSetting.Builder() - .name("entities") - .description("Entities to attack.") - .onlyAttackable() - .defaultEnemies() + private final Setting maxTargets = sgTargeting.add(new IntSetting.Builder() + .name("max-targets") + .description("How many entities to target at once.") + .defaultValue(1) + .min(1) + .sliderRange(1, 5) + .visible(() -> !onlyOnLook.get()) .build() ); @@ -158,90 +148,94 @@ public class KillAura extends Module { .build() ); - private final Setting priority = sgTargeting.add(new EnumSetting.Builder() - .name("priority") - .description("How to filter targets within range.") - .defaultValue(SortPriority.LowestHealth) + private final Setting ignoreBabies = sgTargeting.add(new BoolSetting.Builder() + .name("ignore-babies") + .description("Whether or not to attack baby variants of the entity.") + .defaultValue(true) .build() ); - private final Setting maxTargets = sgTargeting.add(new IntSetting.Builder() - .name("max-targets") - .description("How many entities to target at once.") - .defaultValue(1) - .min(1) - .sliderRange(1, 5) + private final Setting ignoreNamed = sgTargeting.add(new BoolSetting.Builder() + .name("ignore-named") + .description("Whether or not to attack mobs with a name.") + .defaultValue(false) .build() ); - private final Setting babies = sgTargeting.add(new BoolSetting.Builder() - .name("babies") - .description("Whether or not to attack baby variants of the entity.") + private final Setting ignorePassive = sgTargeting.add(new BoolSetting.Builder() + .name("ignore-passive") + .description("Will only attack sometimes passive mobs if they are targeting you.") .defaultValue(true) .build() ); - private final Setting nametagged = sgTargeting.add(new BoolSetting.Builder() - .name("nametagged") - .description("Whether or not to attack mobs with a name tag.") + private final Setting ignoreTamed = sgTargeting.add(new BoolSetting.Builder() + .name("ignore-tamed") + .description("Will avoid attacking mobs you tamed.") .defaultValue(false) .build() ); - private final Setting ignoreShield = sgGeneral.add(new BoolSetting.Builder() - .name("ignore-shield") - .description("Attacks only if the blow is not blocked by a shield.") + // Timing + + private final Setting pauseOnLag = sgTiming.add(new BoolSetting.Builder() + .name("pause-on-lag") + .description("Pauses if the server is lagging.") .defaultValue(true) .build() ); - // Delay + private final Setting pauseOnUse = sgTiming.add(new BoolSetting.Builder() + .name("pause-on-use") + .description("Does not attack while using an item.") + .defaultValue(false) + .build() + ); - private final Setting smartDelay = sgDelay.add(new BoolSetting.Builder() - .name("smart-delay") - .description("Uses the vanilla cooldown to attack entities.") + private final Setting pauseOnCA = sgTiming.add(new BoolSetting.Builder() + .name("pause-on-CA") + .description("Does not attack while CA is placing.") .defaultValue(true) .build() ); - private final Setting hitDelay = sgDelay.add(new IntSetting.Builder() - .name("hit-delay") - .description("How fast you hit the entity in ticks.") - .defaultValue(0) - .min(0) - .sliderMax(60) - .visible(() -> !smartDelay.get()) + private final Setting tpsSync = sgTiming.add(new BoolSetting.Builder() + .name("TPS-sync") + .description("Tries to sync attack delay with the server's TPS.") + .defaultValue(true) .build() ); - private final Setting randomDelayEnabled = sgDelay.add(new BoolSetting.Builder() - .name("random-delay-enabled") - .description("Adds a random delay between hits to attempt to bypass anti-cheats.") + private final Setting customDelay = sgTiming.add(new BoolSetting.Builder() + .name("custom-delay") + .description("Use a custom delay instead of the vanilla cooldown.") .defaultValue(false) - .visible(() -> !smartDelay.get()) .build() ); - private final Setting randomDelayMax = sgDelay.add(new IntSetting.Builder() - .name("random-delay-max") - .description("The maximum value for random delay.") - .defaultValue(4) + private final Setting hitDelay = sgTiming.add(new IntSetting.Builder() + .name("hit-delay") + .description("How fast you hit the entity in ticks.") + .defaultValue(11) .min(0) - .sliderMax(20) - .visible(() -> randomDelayEnabled.get() && !smartDelay.get()) + .sliderMax(60) + .visible(customDelay::get) .build() ); - private final Setting switchDelay = sgDelay.add(new IntSetting.Builder() + private final Setting switchDelay = sgTiming.add(new IntSetting.Builder() .name("switch-delay") .description("How many ticks to wait before hitting an entity after switching hotbar slots.") .defaultValue(0) .min(0) + .sliderMax(10) .build() ); + CrystalAura ca = Modules.get().get(CrystalAura.class); private final List targets = new ArrayList<>(); - private int hitDelayTimer, switchTimer; + private final Vec3d hitVec = new Vec3d(0, 0, 0); + private int switchTimer, hitTimer; private boolean wasPathing = false; public KillAura() { @@ -250,15 +244,29 @@ public KillAura() { @Override public void onDeactivate() { - hitDelayTimer = 0; targets.clear(); } @EventHandler private void onTick(TickEvent.Pre event) { if (!mc.player.isAlive() || PlayerUtils.getGameMode() == GameMode.SPECTATOR) return; + if (pauseOnUse.get() && (mc.interactionManager.isBreakingBlock() || mc.player.isUsingItem())) return; + if (onlyOnClick.get() && !mc.options.attackKey.isPressed()) return; + if (TickRate.INSTANCE.getTimeSinceLastTick() >= 1f && pauseOnLag.get()) return; + if (pauseOnCA.get() && ca.isActive() && ca.kaTimer > 0) return; + + if (onlyOnLook.get()) { + Entity targeted = mc.targetedEntity; - TargetUtils.getList(targets, this::entityCheck, priority.get(), maxTargets.get()); + if (targeted == null) return; + if (!entityCheck(targeted)) return; + + targets.clear(); + targets.add(mc.targetedEntity); + } else { + targets.clear(); + TargetUtils.getList(targets, this::entityCheck, priority.get(), maxTargets.get()); + } if (targets.isEmpty()) { if (wasPathing) { @@ -270,20 +278,6 @@ private void onTick(TickEvent.Pre event) { Entity primary = targets.get(0); - if (rotation.get() == RotationMode.Always) rotate(primary, null); - - if (onlyOnClick.get() && !mc.options.attackKey.isPressed()) return; - - if (onlyWhenLook.get()) { - primary = mc.targetedEntity; - - if (primary == null) return; - if (!entityCheck(primary)) return; - - targets.clear(); - targets.add(primary); - } - if (autoSwitch.get()) { FindItemResult weaponResult = InvUtils.findInHotbar(itemStack -> { Item item = itemStack.getItem(); @@ -296,21 +290,30 @@ private void onTick(TickEvent.Pre event) { }; }); + if (shouldShieldBreak()) { + FindItemResult axeResult = InvUtils.findInHotbar(itemStack -> itemStack.getItem() instanceof AxeItem); + if (axeResult.found()) weaponResult = axeResult; + } + InvUtils.swap(weaponResult.slot(), false); } if (!itemInHand()) return; + Box hitbox = primary.getBoundingBox(); + ((IVec3d) hitVec).set( + MathHelper.clamp(mc.player.getX(), hitbox.minX, hitbox.maxX), + MathHelper.clamp(mc.player.getY(), hitbox.minY, hitbox.maxY), + MathHelper.clamp(mc.player.getZ(), hitbox.minZ, hitbox.maxZ) + ); + + if (rotation.get() == RotationMode.Always) Rotations.rotate(Rotations.getYaw(primary), Rotations.getPitch(primary, Target.Body)); if (pauseOnCombat.get() && BaritoneAPI.getProvider().getPrimaryBaritone().getPathingBehavior().isPathing() && !wasPathing) { BaritoneAPI.getProvider().getPrimaryBaritone().getCommandManager().execute("pause"); wasPathing = true; } if (delayCheck()) targets.forEach(this::attack); - - if (randomTeleport.get() && !onlyWhenLook.get()) { - mc.player.setPosition(primary.getX() + randomOffset(), primary.getY(), primary.getZ() + randomOffset()); - } } @EventHandler @@ -320,17 +323,32 @@ private void onSendPacket(PacketEvent.Send event) { } } - private double randomOffset() { - return Math.random() * 4 - 2; + private boolean shouldShieldBreak() { + for (Entity target : targets) { + if (target instanceof PlayerEntity player) { + if (player.blockedByShield(mc.world.getDamageSources().playerAttack(mc.player)) && shieldMode.get() == ShieldMode.Break) { + return true; + } + } + } + + return false; } private boolean entityCheck(Entity entity) { if (entity.equals(mc.player) || entity.equals(mc.cameraEntity)) return false; if ((entity instanceof LivingEntity && ((LivingEntity) entity).isDead()) || !entity.isAlive()) return false; - if (noRightClick.get() && (mc.interactionManager.isBreakingBlock() || mc.player.isUsingItem())) return false; - if (!PlayerUtils.isWithin(entity, range.get())) return false; + + Box hitbox = entity.getBoundingBox(); + ((IVec3d)hitVec).set( + MathHelper.clamp(mc.player.getX(), hitbox.minX, hitbox.maxX), + MathHelper.clamp(mc.player.getY(), hitbox.minY, hitbox.maxY), + MathHelper.clamp(mc.player.getZ(), hitbox.minZ, hitbox.maxZ) + ); + if (!PlayerUtils.isWithin(hitVec, range.get())) return false; + if (!entities.get().getBoolean(entity.getType())) return false; - if (!nametagged.get() && entity.hasCustomName()) return false; + if (ignoreNamed.get() && entity.hasCustomName()) return false; if (!PlayerUtils.canSeeEntity(entity) && !PlayerUtils.isWithin(entity, wallsRange.get())) return false; if (ignoreTamed.get()) { if (entity instanceof Tameable tameable @@ -342,13 +360,14 @@ private boolean entityCheck(Entity entity) { if (entity instanceof EndermanEntity enderman && !enderman.isAngryAt(mc.player)) return false; if (entity instanceof ZombifiedPiglinEntity piglin && !piglin.isAngryAt(mc.player)) return false; if (entity instanceof WolfEntity wolf && !wolf.isAttacking()) return false; + if (entity instanceof LlamaEntity llama && !llama.isAttacking()) return false; } if (entity instanceof PlayerEntity player) { if (player.isCreative()) return false; if (!Friends.get().shouldAttack(player)) return false; - if (ignoreShield.get() && player.blockedByShield(DamageSource.player(mc.player))) return false; + if (shieldMode.get() == ShieldMode.Ignore && player.blockedByShield(mc.world.getDamageSources().playerAttack(mc.player))) return false; } - return !(entity instanceof AnimalEntity animal) || babies.get() || !animal.isBaby(); + return !(entity instanceof AnimalEntity animal) || !ignoreBabies.get() || !animal.isBaby(); } private boolean delayCheck() { @@ -357,35 +376,29 @@ private boolean delayCheck() { return false; } - if (smartDelay.get()) return mc.player.getAttackCooldownProgress(0.5f) >= 1; + float delay = (customDelay.get()) ? hitDelay.get() : 0.5f; + if (tpsSync.get()) delay /= (TickRate.INSTANCE.getTickRate() / 20); - if (hitDelayTimer > 0) { - hitDelayTimer--; - return false; - } else { - hitDelayTimer = hitDelay.get(); - if (randomDelayEnabled.get()) hitDelayTimer += Math.round(Math.random() * randomDelayMax.get()); - return true; - } + if (customDelay.get()) { + if (hitTimer < delay) { + hitTimer++; + return false; + } else return true; + } else return mc.player.getAttackCooldownProgress(delay) >= 1; } private void attack(Entity target) { - if (Math.random() > hitChance.get() / 100) return; + if (rotation.get() == RotationMode.OnHit) Rotations.rotate(Rotations.getYaw(target), Rotations.getPitch(target, Target.Body)); - if (rotation.get() == RotationMode.OnHit) rotate(target, () -> hitEntity(target)); - else hitEntity(target); - } - - private void hitEntity(Entity target) { mc.interactionManager.attackEntity(mc.player, target); mc.player.swingHand(Hand.MAIN_HAND); - } - private void rotate(Entity target, Runnable callback) { - Rotations.rotate(Rotations.getYaw(target), Rotations.getPitch(target, Target.Body), callback); + hitTimer = 0; } private boolean itemInHand() { + if (shouldShieldBreak()) return mc.player.getMainHandStack().getItem() instanceof AxeItem; + return switch (weapon.get()) { case Axe -> mc.player.getMainHandStack().getItem() instanceof AxeItem; case Sword -> mc.player.getMainHandStack().getItem() instanceof SwordItem; @@ -417,4 +430,10 @@ public enum RotationMode { OnHit, None } + + public enum ShieldMode { + Ignore, + Break, + None + } } diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/Quiver.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/Quiver.java index babab71dfe..c0efef35bd 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/Quiver.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/Quiver.java @@ -6,29 +6,36 @@ package meteordevelopment.meteorclient.systems.modules.combat; import meteordevelopment.meteorclient.events.world.TickEvent; -import meteordevelopment.meteorclient.settings.BoolSetting; -import meteordevelopment.meteorclient.settings.Setting; -import meteordevelopment.meteorclient.settings.SettingGroup; -import meteordevelopment.meteorclient.settings.StatusEffectListSetting; +import meteordevelopment.meteorclient.mixin.AbstractBlockAccessor; +import meteordevelopment.meteorclient.settings.*; import meteordevelopment.meteorclient.systems.modules.Categories; import meteordevelopment.meteorclient.systems.modules.Module; +import meteordevelopment.meteorclient.utils.entity.EntityUtils; import meteordevelopment.meteorclient.utils.player.FindItemResult; import meteordevelopment.meteorclient.utils.player.InvUtils; import meteordevelopment.orbit.EventHandler; +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; import net.minecraft.entity.effect.StatusEffect; import net.minecraft.entity.effect.StatusEffectInstance; import net.minecraft.entity.effect.StatusEffects; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.BowItem; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket; import net.minecraft.potion.PotionUtil; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Direction; import java.util.ArrayList; import java.util.List; public class Quiver extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); + private final SettingGroup sgSafety = settings.createGroup("Safety"); + private final Setting> effects = sgGeneral.add(new StatusEffectListSetting.Builder() .name("effects") @@ -37,14 +44,66 @@ public class Quiver extends Module { .build() ); + private final Setting cooldown = sgGeneral.add(new IntSetting.Builder() + .name("cooldown") + .description("How many ticks between shooting effects (19 minimum for NCP).") + .defaultValue(10) + .range(0,40) + .sliderRange(0,40) + .build() + ); + private final Setting checkEffects = sgGeneral.add(new BoolSetting.Builder() - .name("check-existing-effects") + .name("check-effects") .description("Won't shoot you with effects you already have.") .defaultValue(true) .build() ); + private final Setting silentBow = sgGeneral.add(new BoolSetting.Builder() + .name("silent-bow") + .description("Takes a bow from your inventory to quiver.") + .defaultValue(true) + .build() + ); + + private final Setting chatInfo = sgGeneral.add(new BoolSetting.Builder() + .name("chat-info") + .description("Sends info about quiver checks in chat.") + .defaultValue(false) + .build() + ); + + // Safety + + private final Setting onlyInHoles = sgSafety.add(new BoolSetting.Builder() + .name("only-in-holes") + .description("Only quiver when you're in a hole.") + .defaultValue(true) + .build() + ); + + private final Setting onlyOnGround = sgSafety.add(new BoolSetting.Builder() + .name("only-on-ground") + .description("Only quiver when you're on the ground.") + .defaultValue(true) + .build() + ); + + private final Setting minHealth = sgSafety.add(new DoubleSetting.Builder() + .name("min-health") + .description("How much health you must have to quiver.") + .defaultValue(10) + .range(0,36) + .sliderRange(0,36) + .build() + ); + private final List arrowSlots = new ArrayList<>(); + private FindItemResult bow; + private boolean wasMainhand, wasHotbar; + private int timer, prevSlot; + private final BlockPos.Mutable testPos = new BlockPos.Mutable(); public Quiver() { super(Categories.Combat, "quiver", "Shoots arrows at yourself."); @@ -52,21 +111,22 @@ public Quiver() { @Override public void onActivate() { - - FindItemResult bow = InvUtils.findInHotbar(Items.BOW); - - if (!bow.isHotbar()) { - error("No bow found... disabling."); - toggle(); - } + bow = InvUtils.find(Items.BOW); + if (!shouldQuiver()) return; mc.options.useKey.setPressed(false); mc.interactionManager.stopUsingItem(mc.player); - InvUtils.swap(bow.slot(), true); + prevSlot = bow.slot(); + wasHotbar = bow.isHotbar(); + timer = 0; - arrowSlots.clear(); + if (!bow.isMainHand()) { + if (wasHotbar) InvUtils.swap(bow.slot(), true); + else InvUtils.move().from(mc.player.getInventory().selectedSlot).to(prevSlot); + } else wasMainhand = true; + arrowSlots.clear(); List usedEffects = new ArrayList<>(); for (int i = mc.player.getInventory().size(); i > 0; i--) { @@ -91,33 +151,34 @@ public void onActivate() { } } - private boolean hasEffect(StatusEffect effect) { - for (StatusEffectInstance statusEffect : mc.player.getStatusEffects()) { - if (statusEffect.getEffectType() == effect) return true; - } - - return false; - } - @Override public void onDeactivate() { - InvUtils.swapBack(); + if (!wasMainhand) { + if (wasHotbar) InvUtils.swapBack(); + else InvUtils.move().from(mc.player.getInventory().selectedSlot).to(prevSlot); + } } @EventHandler private void onTick(TickEvent.Pre event) { - if (arrowSlots.isEmpty() || !InvUtils.testInMainHand(Items.BOW)) { + bow = InvUtils.find(Items.BOW); + if (!shouldQuiver()) return; + if (arrowSlots.isEmpty()) { toggle(); return; } + if (timer > 0) { + timer--; + return; + } + boolean charging = mc.options.useKey.isPressed(); if (!charging) { InvUtils.move().from(arrowSlots.get(0)).to(9); mc.options.useKey.setPressed(true); - } - else { + } else { if (BowItem.getPullProgress(mc.player.getItemUseTime()) >= 0.12) { int targetSlot = arrowSlots.get(0); arrowSlots.remove(0); @@ -126,7 +187,77 @@ private void onTick(TickEvent.Pre event) { mc.options.useKey.setPressed(false); mc.interactionManager.stopUsingItem(mc.player); if (targetSlot != 9) InvUtils.move().from(9).to(targetSlot); + + timer = cooldown.get(); } } } + + private boolean shouldQuiver() { + if (!bow.found() || !bow.isHotbar() && !silentBow.get()) { + if (chatInfo.get()) error("Couldn't find a usable bow, disabling."); + toggle(); + return false; + } + + if (!headIsOpen()) { + if (chatInfo.get()) error("Not enough space to quiver, disabling."); + toggle(); + return false; + } + + if (EntityUtils.getTotalHealth(mc.player) < minHealth.get()) { + if (chatInfo.get()) error("Not enough health to quiver, disabling."); + toggle(); + return false; + } + + if (onlyOnGround.get() && !mc.player.isOnGround()) { + if (chatInfo.get()) error("You are not on the ground, disabling."); + toggle(); + return false; + } + + if (onlyInHoles.get() && !isSurrounded(mc.player)) { + if (chatInfo.get()) error("You are not in a hole, disabling."); + toggle(); + return false; + } + + return true; + } + + private boolean headIsOpen() { + testPos.set(mc.player.getBlockPos().add(0, 1, 0)); + BlockState pos1 = mc.world.getBlockState(testPos); + if (((AbstractBlockAccessor) pos1.getBlock()).isCollidable()) return false; + + testPos.add(0, 1, 0); + BlockState pos2 = mc.world.getBlockState(testPos); + return !((AbstractBlockAccessor) pos2.getBlock()).isCollidable(); + } + + private boolean hasEffect(StatusEffect effect) { + for (StatusEffectInstance statusEffect : mc.player.getStatusEffects()) { + if (statusEffect.getEffectType() == effect) return true; + } + + return false; + } + + private boolean isSurrounded(PlayerEntity target) { + for (Direction dir : Direction.values()) { + if (dir == Direction.UP || dir == Direction.DOWN) continue; + + testPos.set(target.getBlockPos()).offset(dir); + Block block = mc.world.getBlockState(testPos).getBlock(); + + if (block != Blocks.OBSIDIAN && block != Blocks.BEDROCK && block != Blocks.RESPAWN_ANCHOR + && block != Blocks.CRYING_OBSIDIAN && block != Blocks.NETHERITE_BLOCK) { + return false; + } + } + + return true; + } } diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/AntiPacketKick.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/AntiPacketKick.java index ebca15adfc..cf23ec9f5d 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/AntiPacketKick.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/AntiPacketKick.java @@ -5,11 +5,35 @@ package meteordevelopment.meteorclient.systems.modules.misc; +import meteordevelopment.meteorclient.settings.BoolSetting; +import meteordevelopment.meteorclient.settings.Setting; +import meteordevelopment.meteorclient.settings.SettingGroup; import meteordevelopment.meteorclient.systems.modules.Categories; import meteordevelopment.meteorclient.systems.modules.Module; public class AntiPacketKick extends Module { + private final SettingGroup sgGeneral = settings.getDefaultGroup(); + + public final Setting catchExceptions = sgGeneral.add(new BoolSetting.Builder() + .name("catch-exceptions") + .description("Drops corrupted packets.") + .defaultValue(false) + .build() + ); + + public final Setting logExceptions = sgGeneral.add(new BoolSetting.Builder() + .name("log-exceptions") + .description("Logs caught exceptions.") + .defaultValue(false) + .visible(catchExceptions::get) + .build() + ); + public AntiPacketKick() { super(Categories.Misc, "anti-packet-kick", "Attempts to prevent you from being disconnected by large packets."); } + + public boolean catchExceptions() { + return isActive() && catchExceptions.get(); + } } diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/BetterChat.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/BetterChat.java index a9e31d7217..5e87f92cfb 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/BetterChat.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/BetterChat.java @@ -12,7 +12,6 @@ import meteordevelopment.meteorclient.mixin.ChatHudAccessor; import meteordevelopment.meteorclient.settings.*; import meteordevelopment.meteorclient.systems.commands.Commands; -import meteordevelopment.meteorclient.systems.commands.commands.SayCommand; import meteordevelopment.meteorclient.systems.modules.Categories; import meteordevelopment.meteorclient.systems.modules.Module; import meteordevelopment.meteorclient.utils.Utils; @@ -74,6 +73,13 @@ public class BetterChat extends Module { .build() ); + public final Setting antiHistClear = sgGeneral.add(new BoolSetting.Builder() + .name("keep-history") + .description("Prevents the chat history from being cleared when disconnecting.") + .defaultValue(true) + .build() + ); + // Filter private final Setting antiSpam = sgFilter.add(new BoolSetting.Builder() @@ -298,10 +304,11 @@ private Text appendAntiSpam(Text text) { ((ChatHudAccessor) mc.inGameHud.getChatHud()).getMessages().remove(messageIndex); List list = ChatMessages.breakRenderedChatMessageLines(originalMessage, MathHelper.floor((double)mc.inGameHud.getChatHud().getWidth() / mc.inGameHud.getChatHud().getChatScale()), mc.textRenderer); - int lines = list.size(); + List visibleMessages = ((ChatHudAccessor) mc.inGameHud.getChatHud()).getVisibleMessages(); + int lines = Math.min(list.size(), visibleMessages.size()); for (int i = 0; i < lines; i++) { - ((ChatHudAccessor) mc.inGameHud.getChatHud()).getVisibleMessages().remove(messageIndex); + visibleMessages.remove(messageIndex); } } @@ -414,7 +421,7 @@ private MutableText getSendButton(String message) { .withFormatting(Formatting.DARK_RED) .withClickEvent(new ClickEvent( ClickEvent.Action.RUN_COMMAND, - Commands.get().get(SayCommand.class).toString(message) + Commands.get().get("say").toString(message) )) .withHoverEvent(new HoverEvent( HoverEvent.Action.SHOW_TEXT, diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/BetterTab.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/BetterTab.java index cc68abe870..de5b3bd10b 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/BetterTab.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/BetterTab.java @@ -96,7 +96,7 @@ else if (friends.get() && Friends.get().isFriend(playerListEntry)) { if (format.isColor()) nameString = nameString.replace(format.toString(), ""); } - name = Text.literal(nameString).setStyle(name.getStyle().withColor(new TextColor(color.getPacked()))); + name = Text.literal(nameString).setStyle(name.getStyle().withColor(TextColor.fromRgb(color.getPacked()))); } if (gamemode.get()) { diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/InventoryTweaks.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/InventoryTweaks.java index 7b8feb2ce5..729e372a65 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/InventoryTweaks.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/InventoryTweaks.java @@ -26,18 +26,17 @@ import net.minecraft.block.AbstractSkullBlock; import net.minecraft.block.CarvedPumpkinBlock; import net.minecraft.client.gui.screen.ingame.HandledScreen; -import net.minecraft.client.gui.screen.ingame.InventoryScreen; -import net.minecraft.entity.EquipmentSlot; -import net.minecraft.entity.LivingEntity; -import net.minecraft.item.*; +import net.minecraft.item.BlockItem; +import net.minecraft.item.Equipment; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; import net.minecraft.network.packet.c2s.play.CloseHandledScreenC2SPacket; -import net.minecraft.screen.GenericContainerScreenHandler; import net.minecraft.screen.ScreenHandler; -import net.minecraft.screen.ShulkerBoxScreenHandler; +import net.minecraft.screen.ScreenHandlerType; import net.minecraft.screen.slot.Slot; -import net.minecraft.screen.slot.SlotActionType; import org.lwjgl.glfw.GLFW; +import java.util.Arrays; import java.util.List; import java.util.concurrent.ThreadLocalRandom; @@ -45,27 +44,21 @@ public class InventoryTweaks extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); private final SettingGroup sgSorting = settings.createGroup("Sorting"); private final SettingGroup sgAutoDrop = settings.createGroup("Auto Drop"); + private final SettingGroup sgStealDump = settings.createGroup("Steal and Dump"); private final SettingGroup sgAutoSteal = settings.createGroup("Auto Steal"); // General private final Setting mouseDragItemMove = sgGeneral.add(new BoolSetting.Builder() - .name("mouse-drag-item-move") - .description("Moving mouse over items while holding shift will transfer it to the other container.") - .defaultValue(true) - .build() + .name("mouse-drag-item-move") + .description("Moving mouse over items while holding shift will transfer it to the other container.") + .defaultValue(true) + .build() ); private final Setting> antiDropItems = sgGeneral.add(new ItemListSetting.Builder() - .name("anti-drop-items") - .description("Items to prevent dropping. Doesn't work in creative inventory screen.") - .build() - ); - - private final Setting buttons = sgGeneral.add(new BoolSetting.Builder() - .name("inventory-buttons") - .description("Shows steal and dump buttons in container guis.") - .defaultValue(true) + .name("anti-drop-items") + .description("Items to prevent dropping. Doesn't work in creative inventory screen.") .build() ); @@ -88,13 +81,6 @@ public class InventoryTweaks extends Module { .build() ); - private final Setting armorSwap = sgGeneral.add(new BoolSetting.Builder() - .name("armor-swap") - .description("Lets you swap between pieces of armor by right clicking on it.") - .defaultValue(true) - .build() - ); - // Sorting private final Setting sortingEnabled = sgSorting.add(new BoolSetting.Builder() @@ -129,21 +115,85 @@ public class InventoryTweaks extends Module { .build() ); + private final Setting autoDropExcludeEquipped = sgAutoDrop.add(new BoolSetting.Builder() + .name("exclude-equipped") + .description("Whether or not to drop items equipped in armor slots.") + .defaultValue(true) + .build() + ); + private final Setting autoDropExcludeHotbar = sgAutoDrop.add(new BoolSetting.Builder() - .name("auto-drop-exclude-hotbar") + .name("exclude-hotbar") .description("Whether or not to drop items from your hotbar.") .defaultValue(false) .build() ); private final Setting autoDropOnlyFullStacks = sgAutoDrop.add(new BoolSetting.Builder() - .name("auto-drop-only-full-stacks") + .name("only-full-stacks") .description("Only drops the items if the stack is full.") .defaultValue(false) .build() ); - // Auto steal + // Steal & Dump + + public final Setting>> stealScreens = sgStealDump.add(new ScreenHandlerListSetting.Builder() + .name("steal-screens") + .description("Select the screens to display buttons and auto steal.") + .defaultValue(Arrays.asList(ScreenHandlerType.GENERIC_9X3, ScreenHandlerType.GENERIC_9X6)) + .build() + ); + + private final Setting buttons = sgStealDump.add(new BoolSetting.Builder() + .name("inventory-buttons") + .description("Shows steal and dump buttons in container guis.") + .defaultValue(true) + .build() + ); + + private final Setting stealDrop = sgStealDump.add(new BoolSetting.Builder() + .name("steal-drop") + .description("Drop items to the ground instead of stealing them.") + .defaultValue(false) + .build() + ); + + private final Setting dropBackwards = sgStealDump.add(new BoolSetting.Builder() + .name("drop-backwards") + .description("Drop items behind you.") + .defaultValue(false) + .visible(stealDrop::get) + .build() + ); + + private final Setting dumpFilter = sgStealDump.add(new EnumSetting.Builder() + .name("dump-filter") + .description("Dump mode.") + .defaultValue(ListMode.None) + .build() + ); + + private final Setting> dumpItems = sgStealDump.add(new ItemListSetting.Builder() + .name("dump-items") + .description("Items to dump.") + .build() + ); + + private final Setting stealFilter = sgStealDump.add(new EnumSetting.Builder() + .name("steal-filter") + .description("Steal mode.") + .defaultValue(ListMode.None) + .build() + ); + + private final Setting> stealItems = sgStealDump.add(new ItemListSetting.Builder() + .name("steal-items") + .description("Items to steal.") + .build() + ); + + // Auto Steal private final Setting autoSteal = sgAutoSteal.add(new BoolSetting.Builder() .name("auto-steal") @@ -169,6 +219,14 @@ public class InventoryTweaks extends Module { .build() ); + private final Setting autoStealInitDelay = sgAutoSteal.add(new IntSetting.Builder() + .name("initial-delay") + .description("The initial delay before stealing in milliseconds. 0 to use normal delay instead.") + .defaultValue(50) + .sliderMax(1000) + .build() + ); + private final Setting autoStealRandomDelay = sgAutoSteal.add(new IntSetting.Builder() .name("random") .description("Randomly adds a delay of up to the specified time in milliseconds.") @@ -178,7 +236,6 @@ public class InventoryTweaks extends Module { .build() ); - private InventorySorter sorter; private boolean invOpened; @@ -209,9 +266,6 @@ private void onKey(KeyEvent event) { if (sortingKey.get().matches(true, event.key)) { if (sort()) event.cancel(); } - if (mc.options.useKey.matchesKey(event.key, 0) && armorSwap()) { - if (swapArmor()) event.cancel(); - } } @EventHandler @@ -221,13 +275,11 @@ private void onMouseButton(MouseButtonEvent event) { if (sortingKey.get().matches(false, event.button)) { if (sort()) event.cancel(); } - if (mc.options.useKey.matchesMouse(event.button) && armorSwap()) { - if (swapArmor()) event.cancel(); - } } private boolean sort() { - if (!sortingEnabled.get() || !(mc.currentScreen instanceof HandledScreen screen) || sorter != null) return false; + if (!sortingEnabled.get() || !(mc.currentScreen instanceof HandledScreen screen) || sorter != null) + return false; if (!mc.player.currentScreenHandler.getCursorStack().isEmpty()) { FindItemResult empty = InvUtils.findEmpty(); @@ -242,35 +294,10 @@ private boolean sort() { return true; } - private boolean swapArmor() { // would mixin to use method in ArmorItem, but it's buggy and unreliable on servers - if (mc.currentScreen != null) { - if (!(mc.currentScreen instanceof InventoryScreen screen)) return false; - Slot focusedSlot = ((HandledScreenAccessor) screen).getFocusedSlot(); - if (focusedSlot == null || !isWearable(focusedSlot.getStack())) return false; - - ItemStack itemStack = focusedSlot.getStack(); - EquipmentSlot equipmentSlot = LivingEntity.getPreferredEquipmentSlot(itemStack); - - //the way mojang handles the inventory is awful, and it took me too long to figure this out - mc.interactionManager.clickSlot(mc.player.currentScreenHandler.syncId, SlotUtils.indexToId(focusedSlot.getIndex()), - SlotUtils.ARMOR_START + equipmentSlot.getEntitySlotId(), SlotActionType.SWAP, mc.player); - - } else { - ItemStack itemStack = mc.player.getMainHandStack(); - if (!isWearable(itemStack)) return false; - EquipmentSlot equipmentSlot = LivingEntity.getPreferredEquipmentSlot(itemStack); - - mc.interactionManager.clickSlot(mc.player.currentScreenHandler.syncId, SlotUtils.indexToId(SlotUtils.ARMOR_START + (3 - equipmentSlot.getEntitySlotId())), - mc.player.getInventory().selectedSlot, SlotActionType.SWAP, mc.player); - - } - return true; - } - private boolean isWearable(ItemStack itemStack) { Item item = itemStack.getItem(); - if (item instanceof Wearable) return true; + if (item instanceof Equipment) return true; return item instanceof BlockItem blockItem && (blockItem.getBlock() instanceof AbstractSkullBlock || blockItem.getBlock() instanceof CarvedPumpkinBlock); } @@ -296,7 +323,8 @@ private void onTickPost(TickEvent.Post event) { ItemStack itemStack = mc.player.getInventory().getStack(i); if (autoDropItems.get().contains(itemStack.getItem())) { - if (!autoDropOnlyFullStacks.get() || itemStack.getCount() == itemStack.getMaxCount()) InvUtils.drop().slot(i); + if ((!autoDropOnlyFullStacks.get() || itemStack.getCount() == itemStack.getMaxCount()) && + !(autoDropExcludeEquipped.get() && SlotUtils.isArmor(i))) InvUtils.drop().slot(i); } } } @@ -322,7 +350,7 @@ private void onSendPacket(PacketEvent.Send event) { private void checkAutoStealSettings() { if (autoSteal.get() && autoDump.get()) { - ChatUtils.error("You can't enable Auto Steal and Auto Dump at the same time!"); + error("You can't enable Auto Steal and Auto Dump at the same time!"); autoDump.set(false); } } @@ -331,15 +359,16 @@ private int getSleepTime() { return autoStealDelay.get() + (autoStealRandomDelay.get() > 0 ? ThreadLocalRandom.current().nextInt(0, autoStealRandomDelay.get()) : 0); } - private int getRows(ScreenHandler handler) { - return (handler instanceof GenericContainerScreenHandler ? ((GenericContainerScreenHandler) handler).getRows() : 3); - } - - private void moveSlots(ScreenHandler handler, int start, int end) { + private void moveSlots(ScreenHandler handler, int start, int end, boolean steal) { + boolean initial = autoStealInitDelay.get() != 0; for (int i = start; i < end; i++) { if (!handler.getSlot(i).hasStack()) continue; - int sleep = getSleepTime(); + int sleep; + if (initial) { + sleep = autoStealInitDelay.get(); + initial = false; + } else sleep = getSleepTime(); if (sleep > 0) { try { Thread.sleep(sleep); @@ -348,20 +377,38 @@ private void moveSlots(ScreenHandler handler, int start, int end) { } } - // Exit if user closes screen - if (mc.currentScreen == null) break; + // Exit if user closes screen or exit world + if (mc.currentScreen == null || !Utils.canUpdate()) break; + + Item item = handler.getSlot(i).getStack().getItem(); + if (steal) { + if (stealFilter.get() == ListMode.Whitelist && !stealItems.get().contains(item)) + continue; + if (stealFilter.get() == ListMode.Blacklist && stealItems.get().contains(item)) + continue; + } else { + if (dumpFilter.get() == ListMode.Whitelist && !dumpItems.get().contains(item)) + continue; + if (dumpFilter.get() == ListMode.Blacklist && dumpItems.get().contains(item)) + continue; + } - InvUtils.quickMove().slotId(i); + if (steal && stealDrop.get()) { + if (dropBackwards.get()) { + int iCopy = i; + Rotations.rotate(mc.player.getYaw() - 180, mc.player.getPitch(), () -> InvUtils.drop().slotId(iCopy)); + } + } else InvUtils.quickMove().slotId(i); } } public void steal(ScreenHandler handler) { - MeteorExecutor.execute(() -> moveSlots(handler, 0, getRows(handler) * 9)); + MeteorExecutor.execute(() -> moveSlots(handler, 0, SlotUtils.indexToId(SlotUtils.MAIN_START), true)); } public void dump(ScreenHandler handler) { - int playerInvOffset = getRows(handler) * 9; - MeteorExecutor.execute(() -> moveSlots(handler, playerInvOffset, playerInvOffset + 4 * 9)); + int playerInvOffset = SlotUtils.indexToId(SlotUtils.MAIN_START); + MeteorExecutor.execute(() -> moveSlots(handler, playerInvOffset, playerInvOffset + 4 * 9, false)); } public boolean showButtons() { @@ -376,21 +423,29 @@ public boolean armorStorage() { return isActive() && armorStorage.get(); } - public boolean armorSwap() { - return isActive() && armorSwap.get(); + public boolean canSteal(ScreenHandler handler) { + try { + return (stealScreens.get().contains(handler.getType())); + } catch (UnsupportedOperationException e) { + return false; + } } @EventHandler private void onInventory(InventoryEvent event) { ScreenHandler handler = mc.player.currentScreenHandler; - if (event.packet.getSyncId() == handler.syncId) { - if (handler instanceof GenericContainerScreenHandler || handler instanceof ShulkerBoxScreenHandler) { - if (autoSteal.get()) { - steal(handler); - } else if (autoDump.get()) { - dump(handler); - } + if (canSteal(handler) && event.packet.getSyncId() == handler.syncId) { + if (autoSteal.get()) { + steal(handler); + } else if (autoDump.get()) { + dump(handler); } } } + + public enum ListMode { + Whitelist, + Blacklist, + None + } } diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/NameProtect.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/NameProtect.java index a7cb5e7674..a3bfdbd8cd 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/NameProtect.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/NameProtect.java @@ -5,6 +5,7 @@ package meteordevelopment.meteorclient.systems.modules.misc; +import meteordevelopment.meteorclient.settings.BoolSetting; import meteordevelopment.meteorclient.settings.Setting; import meteordevelopment.meteorclient.settings.SettingGroup; import meteordevelopment.meteorclient.settings.StringSetting; @@ -14,17 +15,32 @@ public class NameProtect extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); + private final Setting nameProtect = sgGeneral.add(new BoolSetting.Builder() + .name("name-protect") + .description("Hides your name client-side.") + .defaultValue(true) + .build() + ); + private final Setting name = sgGeneral.add(new StringSetting.Builder() .name("name") .description("Name to be replaced with.") .defaultValue("seasnail") + .visible(nameProtect::get) .build() ); + private final Setting skinProtect = sgGeneral.add(new BoolSetting.Builder() + .name("skin-protect") + .description("Make players become Steves.") + .defaultValue(true) + .build() + ); + private String username = "If you see this, something is wrong."; public NameProtect() { - super(Categories.Player, "name-protect", "Hides your name client-side."); + super(Categories.Player, "name-protect", "Hide player names and skins."); } @Override @@ -47,4 +63,8 @@ public String getName(String original) { return original; } + + public boolean skinProtect() { + return isActive() && skinProtect.get(); + } } diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/Notebot.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/Notebot.java index 9203afc208..772b97bbb5 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/Notebot.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/Notebot.java @@ -24,6 +24,7 @@ import meteordevelopment.meteorclient.utils.notebot.NotebotUtils; import meteordevelopment.meteorclient.utils.notebot.decoder.SongDecoder; import meteordevelopment.meteorclient.utils.notebot.decoder.SongDecoders; +import meteordevelopment.meteorclient.utils.notebot.instrumentdetect.InstrumentDetectMode; import meteordevelopment.meteorclient.utils.notebot.song.Note; import meteordevelopment.meteorclient.utils.notebot.song.Song; import meteordevelopment.meteorclient.utils.player.Rotations; @@ -45,11 +46,13 @@ import net.minecraft.util.math.Direction; import net.minecraft.util.math.Vec3d; import org.apache.commons.io.FilenameUtils; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.joml.Vector3d; import java.io.File; import java.util.*; +import java.util.concurrent.CancellationException; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.TimeUnit; @@ -87,6 +90,13 @@ public class Notebot extends Module { .build() ); + public final Setting instrumentDetectMode = sgGeneral.add(new EnumSetting.Builder() + .name("instrument-detect-mode") + .description("Select an instrument detect mode. Can be useful when server has a plugin that modifies noteblock state (e.g ItemsAdder) but noteblock can still play the right note") + .defaultValue(InstrumentDetectMode.BlockState) + .build() + ); + public final Setting polyphonic = sgGeneral.add(new BoolSetting.Builder() .name("polyphonic") .description("Whether or not to allow multiple notes to be played at the same time") @@ -230,6 +240,7 @@ public class Notebot extends Module { private final Multimap scannedNoteblocks = MultimapBuilder.linkedHashKeys().arrayListValues().build(); // Found noteblocks private final List clickedBlocks = new ArrayList<>(); private Stage stage = Stage.None; + private PlayingMode playingMode = PlayingMode.None; private boolean isPlaying = false; private int currentTick = 0; private int ticks = 0; @@ -259,7 +270,11 @@ public Notebot() { @Override public String getInfoString() { - return stage.toString(); + if (stage == Stage.None) { + return "None"; + } else { + return playingMode.toString() + " | " + stage.toString(); + } } @Override @@ -277,6 +292,7 @@ private void resetVariables() { tuneHits.clear(); anyNoteblockTuned = false; currentTick = 0; + playingMode = PlayingMode.None; isPlaying = false; stage = Stage.None; song = null; @@ -424,7 +440,7 @@ else if (stage == Stage.SetUp) { else if (stage == Stage.Tune) { tune(); } - else if (stage == Stage.Preview || stage == Stage.Playing) { + else if (stage == Stage.Playing) { if (!isPlaying) return; if (mc.player == null || currentTick > song.getLastTick()) { @@ -434,7 +450,7 @@ else if (stage == Stage.Preview || stage == Stage.Playing) { } if (song.getNotesMap().containsKey(currentTick)) { - if (stage == Stage.Preview) onTickPreview(); + if (playingMode == PlayingMode.Preview) onTickPreview(); else if (mc.player.getAbilities().creativeMode) { error("You need to be in survival mode."); stop(); @@ -455,7 +471,9 @@ else if (mc.player.getAbilities().creativeMode) { private void setupNoteblocksMap() { noteBlockPositions.clear(); + // Modifiable list of unique notes List uniqueNotesToUse = new ArrayList<>(song.getRequirements()); + // A map with noteblocks that have incorrect note level Map> incorrectNoteBlocks = new HashMap<>(); // Check if there are already tuned noteblocks @@ -464,12 +482,13 @@ private void setupNoteblocksMap() { List noteblocks = new ArrayList<>(entry.getValue()); if (uniqueNotesToUse.contains(note)) { + // Add correct noteblock position to a noteBlockPositions noteBlockPositions.put(note, noteblocks.remove(0)); uniqueNotesToUse.remove(note); } if (!noteblocks.isEmpty()) { - // Add excess for mapping process note -> block pos + // Add excess noteblocks for mapping process [note -> block pos] if (!incorrectNoteBlocks.containsKey(note.getInstrument())) { incorrectNoteBlocks.put(note.getInstrument(), new ArrayList<>()); @@ -479,7 +498,7 @@ private void setupNoteblocksMap() { } } - // Map note -> block pos + // Map [note -> block pos] for (var entry : incorrectNoteBlocks.entrySet()) { List positions = entry.getValue(); @@ -584,7 +603,7 @@ public String getStatus() { if (!this.isActive()) return "Module disabled."; if (song == null) return "No song loaded."; if (isPlaying) return String.format("Playing song. %d/%d", currentTick, song.getLastTick()); - if (stage == Stage.Playing || stage == Stage.Preview) return "Ready to play."; + if (stage == Stage.Playing) return "Ready to play."; if (stage == Stage.SetUp || stage == Stage.Tune || stage == Stage.WaitingToCheckNoteblocks) return "Setting up the noteblocks."; else return String.format("Stage: %s.", stage.toString()); } @@ -594,9 +613,9 @@ public String getStatus() { */ public void play() { if (mc.player == null) return; - if (mc.player.getAbilities().creativeMode && stage != Stage.Preview) { + if (mc.player.getAbilities().creativeMode && playingMode != PlayingMode.Preview) { error("You need to be in survival mode."); - } else if (stage == Stage.Preview || stage == Stage.Playing) { + } else if (stage == Stage.Playing) { isPlaying = true; info("Playing."); } else { @@ -617,18 +636,12 @@ public void pause() { public void stop() { info("Stopping."); - if (stage == Stage.SetUp || stage == Stage.Tune || stage == Stage.WaitingToCheckNoteblocks || stage == Stage.LoadingSong) { - resetVariables(); - } else { - isPlaying = false; - currentTick = 0; - } - updateStatus(); disable(); + updateStatus(); } public void onSongEnd() { - if (autoPlay.get() && stage != Stage.Preview) { + if (autoPlay.get() && playingMode != PlayingMode.Preview) { playRandomSong(); } else { stop(); @@ -659,10 +672,12 @@ public void disable() { */ public void loadSong(File file) { if (!isActive()) toggle(); + resetVariables(); + + this.playingMode = PlayingMode.Noteblocks; if (!loadFileToMap(file, () -> stage = Stage.SetUp)) { - if (autoPlay.get()) { - playRandomSong(); - } + onSongEnd(); + return; } updateStatus(); } @@ -674,8 +689,11 @@ public void loadSong(File file) { */ public void previewSong(File file) { if (!isActive()) toggle(); + resetVariables(); + + this.playingMode = PlayingMode.Preview; loadFileToMap(file, () -> { - stage = Stage.Preview; + stage = Stage.Playing; play(); }); updateStatus(); @@ -698,26 +716,43 @@ public boolean loadFileToMap(File file, Runnable callback) { error("File is in wrong format. Decoder not found."); return false; } - resetVariables(); + info("Loading song \"%s\".", FilenameUtils.getBaseName(file.getName())); - loadingSongFuture = CompletableFuture.supplyAsync(() -> SongDecoders.parse(file)); - loadingSongFuture.completeOnTimeout(null, 10, TimeUnit.SECONDS); + // Start loading song + loadingSongFuture = CompletableFuture.supplyAsync(() -> { + try { + return SongDecoders.parse(file); + } catch (Exception e) { + throw new RuntimeException(e); + } + }); + loadingSongFuture.completeOnTimeout(null, 60, TimeUnit.SECONDS); stage = Stage.LoadingSong; long time1 = System.currentTimeMillis(); - loadingSongFuture.thenAccept(song -> { - if (song != null) { + loadingSongFuture.whenComplete((song ,ex) -> { + if (ex == null) { + // Song is null only when it times out + if (song == null) { + error("Loading song '" + FilenameUtils.getBaseName(file.getName()) + "' timed out."); + onSongEnd(); + return; + } + this.song = song; long time2 = System.currentTimeMillis(); long diff = time2 - time1; - info("Song '"+FilenameUtils.getBaseName(file.getName())+"' has been loaded to the memory! Took "+diff+"ms"); + info("Song '" + FilenameUtils.getBaseName(file.getName()) + "' has been loaded to the memory! Took "+diff+"ms"); callback.run(); } else { - error("Could not load song '"+FilenameUtils.getBaseName(file.getName())+"'"); - if (autoPlay.get()) { - playRandomSong(); + if (ex instanceof CancellationException) { + error("Loading song '" + FilenameUtils.getBaseName(file.getName()) + "' was cancelled."); + } else { + error("An error occurred while loading song '" + FilenameUtils.getBaseName(file.getName()) + "'. See the logs for more details"); + MeteorClient.LOG.error("An error occurred while loading song '" + FilenameUtils.getBaseName(file.getName()) + "'", ex); + onSongEnd(); } } }); @@ -750,7 +785,7 @@ private void scanForNoteblocks() { if (!isValidScanSpot(pos)) continue; - Note note = NotebotUtils.getNoteFromNoteBlock(blockState, mode.get()); + Note note = NotebotUtils.getNoteFromNoteBlock(blockState, pos, mode.get(), instrumentDetectMode.get().getInstrumentDetectFunction()); scannedNoteblocks.put(note, pos); } } @@ -856,6 +891,8 @@ private static int calcNumberOfHits(int from, int to) { private void onTickPlay() { Collection notes = song.getNotesMap().get(this.currentTick); if (!notes.isEmpty()) { + + // Rotate player's head if (autoRotate.get()) { Optional firstNote = notes.stream().findFirst(); if (firstNote.isPresent()) { @@ -867,10 +904,12 @@ private void onTickPlay() { } } + // Swing arm if (swingArm.get()) { mc.player.swingHand(Hand.MAIN_HAND); } + // Play notes for (Note note : notes) { BlockPos pos = noteBlockPositions.get(note); if (pos == null) { @@ -899,10 +938,17 @@ private boolean isValidScanSpot(BlockPos pos) { return mc.world.getBlockState(pos.up()).isAir(); } + /** + * Gets an Instrument from Note Map + * + * @param inst An instrument + * @return A new instrument mapped by instrument given in parameters + */ @Nullable - public Instrument getMappedInstrument(Instrument inst) { + public Instrument getMappedInstrument(@NotNull Instrument inst) { if (mode.get() == NotebotUtils.NotebotMode.ExactInstruments) { - return ((NotebotUtils.OptionalInstrument) sgNoteMap.getByIndex(inst.ordinal()).get()).toMinecraftInstrument(); + NotebotUtils.OptionalInstrument optionalInstrument = (NotebotUtils.OptionalInstrument) sgNoteMap.getByIndex(inst.ordinal()).get(); + return optionalInstrument.toMinecraftInstrument(); } else { return inst; } @@ -927,7 +973,12 @@ public enum Stage { SetUp, Tune, WaitingToCheckNoteblocks, - Playing, - Preview + Playing + } + + public enum PlayingMode { + None, + Preview, + Noteblocks } } diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/Notifier.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/Notifier.java index ac64f81e2c..8a18a6ec93 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/Notifier.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/Notifier.java @@ -23,11 +23,15 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.projectile.thrown.EnderPearlEntity; import net.minecraft.network.packet.s2c.play.EntityStatusS2CPacket; import net.minecraft.text.MutableText; import net.minecraft.text.Text; import net.minecraft.util.Formatting; +import net.minecraft.util.math.Vec3d; +import java.util.HashMap; +import java.util.Map; import java.util.Random; import java.util.UUID; @@ -36,6 +40,7 @@ public class Notifier extends Module { private final SettingGroup sgTotemPops = settings.createGroup("Totem Pops"); private final SettingGroup sgVisualRange = settings.createGroup("Visual Range"); + private final SettingGroup sgPearl = settings.createGroup("Pearl"); // Totem Pops @@ -85,7 +90,7 @@ public class Notifier extends Module { private final Setting>> entities = sgVisualRange.add(new EntityTypeListSetting.Builder() .name("entities") - .description("Which entities to nofity about.") + .description("Which entities to notify about.") .defaultValue(EntityType.PLAYER) .build() ); @@ -104,8 +109,32 @@ public class Notifier extends Module { .build() ); + // Pearl + + private final Setting pearl = sgPearl.add(new BoolSetting.Builder() + .name("pearl") + .description("Notifies you when a player is teleported using an ender pearl.") + .defaultValue(true) + .build() + ); + + private final Setting pearlIgnoreOwn = sgPearl.add(new BoolSetting.Builder() + .name("ignore-own") + .description("Ignores your own pearls.") + .defaultValue(false) + .build() + ); + + private final Setting pearlIgnoreFriends = sgPearl.add(new BoolSetting.Builder() + .name("ignore-friends") + .description("Ignores friends pearls.") + .defaultValue(false) + .build() + ); + private final Object2IntMap totemPopMap = new Object2IntOpenHashMap<>(); private final Object2IntMap chatIdMap = new Object2IntOpenHashMap<>(); + private final Map pearlStartPosMap = new HashMap<>(); private final Random random = new Random(); @@ -117,36 +146,56 @@ public Notifier() { @EventHandler private void onEntityAdded(EntityAddedEvent event) { - if (event.entity.getUuid().equals(mc.player.getUuid()) || !entities.get().getBoolean(event.entity.getType()) || !visualRange.get() || this.event.get() == Event.Despawn) return; - - if (event.entity instanceof PlayerEntity) { - if ((!visualRangeIgnoreFriends.get() || !Friends.get().isFriend(((PlayerEntity) event.entity))) && (!visualRangeIgnoreFakes.get() || !(event.entity instanceof FakePlayerEntity))) { - ChatUtils.sendMsg(event.entity.getId() + 100, Formatting.GRAY, "(highlight)%s(default) has entered your visual range!", event.entity.getEntityName()); + if (!event.entity.getUuid().equals(mc.player.getUuid()) && entities.get().getBoolean(event.entity.getType()) && visualRange.get() && this.event.get() != Event.Despawn) { + if (event.entity instanceof PlayerEntity) { + if ((!visualRangeIgnoreFriends.get() || !Friends.get().isFriend(((PlayerEntity) event.entity))) && (!visualRangeIgnoreFakes.get() || !(event.entity instanceof FakePlayerEntity))) { + ChatUtils.sendMsg(event.entity.getId() + 100, Formatting.GRAY, "(highlight)%s(default) has entered your visual range!", event.entity.getEntityName()); + } + } else { + MutableText text = Text.literal(event.entity.getType().getName().getString()).formatted(Formatting.WHITE); + text.append(Text.literal(" has spawned at ").formatted(Formatting.GRAY)); + text.append(formatCoords(event.entity.getPos())); + text.append(Text.literal(".").formatted(Formatting.GRAY)); + info(text); } } - else { - MutableText text = Text.literal(event.entity.getType().getName().getString()).formatted(Formatting.WHITE); - text.append(Text.literal(" has spawned at ").formatted(Formatting.GRAY)); - text.append(formatCoords(event.entity.getPos())); - text.append(Text.literal(".").formatted(Formatting.GRAY)); - info(text); + + if (pearl.get()) { + if (event.entity instanceof EnderPearlEntity pearl) { + pearlStartPosMap.put(pearl.getId(), new Vec3d(pearl.getX(), pearl.getY(), pearl.getZ())); + } } } @EventHandler private void onEntityRemoved(EntityRemovedEvent event) { - if (event.entity.getUuid().equals(mc.player.getUuid()) || !entities.get().getBoolean(event.entity.getType()) || !visualRange.get() || this.event.get() == Event.Spawn) return; + if (!event.entity.getUuid().equals(mc.player.getUuid()) && entities.get().getBoolean(event.entity.getType()) && visualRange.get() && this.event.get() != Event.Spawn) { + if (event.entity instanceof PlayerEntity) { + if ((!visualRangeIgnoreFriends.get() || !Friends.get().isFriend(((PlayerEntity) event.entity))) && (!visualRangeIgnoreFakes.get() || !(event.entity instanceof FakePlayerEntity))) { + ChatUtils.sendMsg(event.entity.getId() + 100, Formatting.GRAY, "(highlight)%s(default) has left your visual range!", event.entity.getEntityName()); + } + } else { + MutableText text = Text.literal(event.entity.getType().getName().getString()).formatted(Formatting.WHITE); + text.append(Text.literal(" has despawned at ").formatted(Formatting.GRAY)); + text.append(formatCoords(event.entity.getPos())); + text.append(Text.literal(".").formatted(Formatting.GRAY)); + info(text); + } + } - if (event.entity instanceof PlayerEntity) { - if ((!visualRangeIgnoreFriends.get() || !Friends.get().isFriend(((PlayerEntity) event.entity))) && (!visualRangeIgnoreFakes.get() || !(event.entity instanceof FakePlayerEntity))) { - ChatUtils.sendMsg(event.entity.getId() + 100, Formatting.GRAY, "(highlight)%s(default) has left your visual range!", event.entity.getEntityName()); + if (pearl.get()) { + Entity e = event.entity; + int i = e.getId(); + if (pearlStartPosMap.containsKey(i)) { + EnderPearlEntity pearl = (EnderPearlEntity) e; + if (pearl.getOwner() != null && pearl.getOwner() instanceof PlayerEntity p) { + double d = pearlStartPosMap.get(i).distanceTo(e.getPos()); + if ((!Friends.get().isFriend(p) || !pearlIgnoreFriends.get()) && (!p.equals(mc.player) || !pearlIgnoreOwn.get())) { + info("(highlight)%s's(default) pearl landed at %d, %d, %d (highlight)(%.1fm away, travelled %.1fm)(default).", pearl.getOwner().getEntityName(), pearl.getBlockPos().getX(), pearl.getBlockPos().getY(), pearl.getBlockPos().getZ(), pearl.distanceTo(mc.player), d); + } + } + pearlStartPosMap.remove(i); } - } else { - MutableText text = Text.literal(event.entity.getType().getName().getString()).formatted(Formatting.WHITE); - text.append(Text.literal(" has despawned at ").formatted(Formatting.GRAY)); - text.append(formatCoords(event.entity.getPos())); - text.append(Text.literal(".").formatted(Formatting.GRAY)); - info(text); } } @@ -156,12 +205,14 @@ private void onEntityRemoved(EntityRemovedEvent event) { public void onActivate() { totemPopMap.clear(); chatIdMap.clear(); + pearlStartPosMap.clear(); } @EventHandler private void onGameJoin(GameJoinedEvent event) { totemPopMap.clear(); chatIdMap.clear(); + pearlStartPosMap.clear(); } @EventHandler diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/PacketCanceller.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/PacketCanceller.java index 7c2410bccd..219b9395c6 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/PacketCanceller.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/PacketCanceller.java @@ -14,7 +14,7 @@ import meteordevelopment.meteorclient.utils.network.PacketUtils; import meteordevelopment.orbit.EventHandler; import meteordevelopment.orbit.EventPriority; -import net.minecraft.network.Packet; +import net.minecraft.network.packet.Packet; import java.util.Set; diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/swarm/SwarmConnection.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/swarm/SwarmConnection.java index b5a7c51e53..0ba20420bf 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/swarm/SwarmConnection.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/swarm/SwarmConnection.java @@ -22,7 +22,7 @@ public SwarmConnection(Socket socket) { @Override public void run() { - ChatUtils.info("Swarm", "New worker connected on %s.", getIp(socket.getInetAddress().getHostAddress())); + ChatUtils.infoPrefix("Swarm", "New worker connected on %s.", getIp(socket.getInetAddress().getHostAddress())); try { DataOutputStream out = new DataOutputStream(socket.getOutputStream()); @@ -33,7 +33,7 @@ public void run() { out.writeUTF(messageToSend); out.flush(); } catch (Exception e) { - ChatUtils.error("Swarm", "Encountered error when sending command."); + ChatUtils.errorPrefix("Swarm", "Encountered error when sending command."); e.printStackTrace(); } @@ -43,7 +43,7 @@ public void run() { out.close(); } catch (IOException e) { - ChatUtils.info("Swarm", "Error creating a connection with %s on port %s.", getIp(socket.getInetAddress().getHostAddress()), socket.getPort()); + ChatUtils.infoPrefix("Swarm", "Error creating a connection with %s on port %s.", getIp(socket.getInetAddress().getHostAddress()), socket.getPort()); e.printStackTrace(); } } @@ -55,7 +55,7 @@ public void disconnect() { e.printStackTrace(); } - ChatUtils.info("Swarm", "Worker disconnected on ip: %s.", socket.getInetAddress().getHostAddress()); + ChatUtils.infoPrefix("Swarm", "Worker disconnected on ip: %s.", socket.getInetAddress().getHostAddress()); interrupt(); } diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/swarm/SwarmHost.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/swarm/SwarmHost.java index 1e2af763a2..6e645760a8 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/swarm/SwarmHost.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/swarm/SwarmHost.java @@ -21,7 +21,7 @@ public SwarmHost(int port) { socket = new ServerSocket(port); } catch (IOException e) { socket = null; - ChatUtils.error("Swarm", "Couldn't start a server on port %s.", port); + ChatUtils.errorPrefix("Swarm", "Couldn't start a server on port %s.", port); e.printStackTrace(); } @@ -30,14 +30,14 @@ public SwarmHost(int port) { @Override public void run() { - ChatUtils.info("Swarm", "Listening for incoming connections on port %s.", socket.getLocalPort()); + ChatUtils.infoPrefix("Swarm", "Listening for incoming connections on port %s.", socket.getLocalPort()); while (!isInterrupted()) { try { Socket connection = socket.accept(); assignConnectionToSubServer(connection); } catch (IOException e) { - ChatUtils.error("Swarm", "Error making a connection to worker."); + ChatUtils.errorPrefix("Swarm", "Error making a connection to worker."); e.printStackTrace(); } } @@ -63,7 +63,7 @@ public void disconnect() { e.printStackTrace(); } - ChatUtils.info("Swarm", "Server closed on port %s.", socket.getLocalPort()); + ChatUtils.infoPrefix("Swarm", "Server closed on port %s.", socket.getLocalPort()); interrupt(); } diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/swarm/SwarmWorker.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/swarm/SwarmWorker.java index a5055fdff6..0946071251 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/swarm/SwarmWorker.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/swarm/SwarmWorker.java @@ -23,7 +23,7 @@ public SwarmWorker(String ip, int port) { socket = new Socket(ip, port); } catch (Exception e) { socket = null; - ChatUtils.warning("Swarm", "Server not found at %s on port %s.", ip, port); + ChatUtils.warningPrefix("Swarm", "Server not found at %s on port %s.", ip, port); e.printStackTrace(); } @@ -32,7 +32,7 @@ public SwarmWorker(String ip, int port) { @Override public void run() { - ChatUtils.info("Swarm", "Connected to Swarm host on at %s on port %s.", getIp(socket.getInetAddress().getHostAddress()), socket.getPort()); + ChatUtils.infoPrefix("Swarm", "Connected to Swarm host on at %s on port %s.", getIp(socket.getInetAddress().getHostAddress()), socket.getPort()); try { DataInputStream in = new DataInputStream(socket.getInputStream()); @@ -42,7 +42,7 @@ public void run() { String read = in.readUTF(); if (!read.equals("")) { - ChatUtils.info("Swarm", "Received command: (highlight)%s", read); + ChatUtils.infoPrefix("Swarm", "Received command: (highlight)%s", read); try { Commands.get().dispatch(read); @@ -55,7 +55,7 @@ public void run() { in.close(); } catch (IOException e) { - ChatUtils.error("Swarm", "Error in connection to host."); + ChatUtils.errorPrefix("Swarm", "Error in connection to host."); e.printStackTrace(); disconnect(); } @@ -70,7 +70,7 @@ public void disconnect() { BaritoneAPI.getProvider().getPrimaryBaritone().getPathingBehavior().cancelEverything(); - ChatUtils.info("Swarm", "Disconnected from host."); + ChatUtils.infoPrefix("Swarm", "Disconnected from host."); interrupt(); } diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/AntiAFK.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/AntiAFK.java index d3f9a4a8ca..1ab24dfebe 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/AntiAFK.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/AntiAFK.java @@ -230,6 +230,7 @@ public WWidget getWidget(GuiTheme theme) { private void fillTable(GuiTheme theme, WTable table) { table.add(theme.horizontalSeparator("Message List")).expandX(); + table.row(); // Messages for (int i = 0; i < messages.size(); i++) { diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/AntiLevitation.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/AntiLevitation.java deleted file mode 100644 index c27339daeb..0000000000 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/AntiLevitation.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). - * Copyright (c) Meteor Development. - */ - -package meteordevelopment.meteorclient.systems.modules.movement; - -import meteordevelopment.meteorclient.settings.BoolSetting; -import meteordevelopment.meteorclient.settings.Setting; -import meteordevelopment.meteorclient.settings.SettingGroup; -import meteordevelopment.meteorclient.systems.modules.Categories; -import meteordevelopment.meteorclient.systems.modules.Module; - -public class AntiLevitation extends Module { - private final SettingGroup sgGeneral = settings.getDefaultGroup(); - - private final Setting applyGravity = sgGeneral.add(new BoolSetting.Builder() - .name("gravity") - .description("Applies gravity.") - .defaultValue(false) - .build() - ); - - public AntiLevitation() { - super(Categories.Movement, "anti-levitation", "Prevents the levitation effect from working."); - } - - public boolean isApplyGravity() { - return applyGravity.get(); - } -} diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/BoatFly.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/BoatFly.java index 6995ca4b9c..445cd4b1a7 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/BoatFly.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/BoatFly.java @@ -61,7 +61,7 @@ public BoatFly() { @EventHandler private void onBoatMove(BoatMoveEvent event) { - if (event.boat.getPrimaryPassenger() != mc.player) return; + if (event.boat.getControllingPassenger() != mc.player) return; event.boat.setYaw(mc.player.getYaw()); diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/EntitySpeed.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/EntitySpeed.java index f89be6dcc3..e7f54194bf 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/EntitySpeed.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/EntitySpeed.java @@ -50,7 +50,7 @@ public EntitySpeed() { @EventHandler private void onLivingEntityMove(LivingEntityMoveEvent event) { - if (event.entity.getPrimaryPassenger() != mc.player) return; + if (event.entity.getControllingPassenger() != mc.player) return; // Check for onlyOnGround and inWater LivingEntity entity = event.entity; diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/FastClimb.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/FastClimb.java index 94a68a47c4..4877a77d6e 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/FastClimb.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/FastClimb.java @@ -6,35 +6,82 @@ package meteordevelopment.meteorclient.systems.modules.movement; import meteordevelopment.meteorclient.events.world.TickEvent; +import meteordevelopment.meteorclient.mixin.LivingEntityAccessor; +import meteordevelopment.meteorclient.settings.BoolSetting; import meteordevelopment.meteorclient.settings.DoubleSetting; import meteordevelopment.meteorclient.settings.Setting; import meteordevelopment.meteorclient.settings.SettingGroup; import meteordevelopment.meteorclient.systems.modules.Categories; import meteordevelopment.meteorclient.systems.modules.Module; +import meteordevelopment.meteorclient.systems.modules.Modules; +import meteordevelopment.meteorclient.systems.modules.world.Timer; import meteordevelopment.orbit.EventHandler; +import net.minecraft.block.Blocks; +import net.minecraft.block.PowderSnowBlock; import net.minecraft.util.math.Vec3d; public class FastClimb extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); + private final Setting timerMode = sgGeneral.add(new BoolSetting.Builder() + .name("timer-mode") + .description("Use timer.") + .defaultValue(false) + .build() + ); + private final Setting speed = sgGeneral.add(new DoubleSetting.Builder() - .name("climb-speed") - .description("Your climb speed.") - .defaultValue(0.2872) - .min(0.0) - .build() + .name("climb-speed") + .description("Your climb speed.") + .defaultValue(0.2872) + .min(0.0) + .visible(() -> !timerMode.get()) + .build() + ); + + private final Setting timer = sgGeneral.add(new DoubleSetting.Builder() + .name("timer") + .description("The timer value for Timer.") + .defaultValue(1.436) + .min(1) + .sliderMin(1) + .visible(timerMode::get) + .build() ); + private boolean resetTimer; + public FastClimb() { super(Categories.Movement, "fast-climb", "Allows you to climb faster.", "ladder"); } + @Override + public void onActivate() { + resetTimer = false; + } + + @EventHandler + private void onPreTick(TickEvent.Pre event) { + if (timerMode.get()) { + if (climbing()) { + resetTimer = false; + Modules.get().get(Timer.class).setOverride(timer.get()); + } else if (!resetTimer) { + Modules.get().get(Timer.class).setOverride(Timer.OFF); + resetTimer = true; + } + } + } + @EventHandler private void onTick(TickEvent.Post event) { - if (!mc.player.isClimbing() || !mc.player.horizontalCollision) return; - if (mc.player.input.movementForward == 0 && mc.player.input.movementSideways == 0) return; + if (!timerMode.get() && climbing()) { + Vec3d velocity = mc.player.getVelocity(); + mc.player.setVelocity(velocity.x, speed.get(), velocity.z); + } + } - Vec3d velocity = mc.player.getVelocity(); - mc.player.setVelocity(velocity.x, speed.get(), velocity.z); + private boolean climbing() { + return (mc.player.horizontalCollision || ((LivingEntityAccessor) mc.player).isJumping()) && (mc.player.isClimbing() || mc.player.getBlockStateAtPos().isOf(Blocks.POWDER_SNOW) && PowderSnowBlock.canWalkOnPowderSnow(mc.player)); } } diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/Flight.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/Flight.java index 3f229010e1..8eda9a71c5 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/Flight.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/Flight.java @@ -22,7 +22,7 @@ public class Flight extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); private final SettingGroup sgAntiKick = settings.createGroup("Anti Kick"); //Pog - + private final Setting mode = sgGeneral.add(new EnumSetting.Builder() .name("mode") .description("The mode for Flight.") @@ -33,6 +33,7 @@ public class Flight extends Module { }) .build() ); + private final Setting speed = sgGeneral.add(new DoubleSetting.Builder() .name("speed") .description("Your speed when flying.") @@ -40,18 +41,21 @@ public class Flight extends Module { .min(0.0) .build() ); + private final Setting verticalSpeedMatch = sgGeneral.add(new BoolSetting.Builder() .name("vertical-speed-match") .description("Matches your vertical speed to your horizontal speed, otherwise uses vanilla ratio.") .defaultValue(false) .build() ); + private final Setting antiKickMode = sgAntiKick.add(new EnumSetting.Builder() .name("mode") .description("The mode for anti kick.") .defaultValue(AntiKickMode.Packet) .build() ); + private final Setting delay = sgAntiKick.add(new IntSetting.Builder() .name("delay") .description("The amount of delay, in ticks, between flying down a bit and return to original position") @@ -70,7 +74,7 @@ public class Flight extends Module { .sliderRange(1, 20) .build() ); - + private int delayLeft = delay.get(); private int offLeft = offTime.get(); private boolean flip; @@ -141,13 +145,9 @@ private void onPostTick(TickEvent.Post event) { switch (mode.get()) { case Velocity -> { - - /*TODO: deal with underwater movement, find a way to "spoof" not being in water - also, all of the multiplication below is to get the speed to roughly match the speed - you get when using vanilla fly*/ + // TODO: deal with underwater movement, find a way to "spoof" not being in water mc.player.getAbilities().flying = false; - mc.player.airStrafingSpeed = speed.get().floatValue() * (mc.player.isSprinting() ? 15f : 10f); mc.player.setVelocity(0, 0, 0); Vec3d initialVelocity = mc.player.getVelocity(); if (mc.options.jumpKey.isPressed()) @@ -232,6 +232,13 @@ private boolean isEntityOnAir(Entity entity) { return entity.world.getStatesInBox(entity.getBoundingBox().expand(0.0625).stretch(0.0, -0.55, 0.0)).allMatch(AbstractBlock.AbstractBlockState::isAir); } + public float getOffGroundSpeed() { + // All the multiplication below is to get the speed to roughly match the speed you get when using vanilla fly + + if (!isActive() || mode.get() != Mode.Velocity) return -1; + return speed.get().floatValue() * (mc.player.isSprinting() ? 15f : 10f); + } + public enum Mode { Abilities, Velocity diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/Jesus.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/Jesus.java index 48942da331..d59b3d833d 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/Jesus.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/Jesus.java @@ -22,7 +22,7 @@ import net.minecraft.enchantment.ProtectionEnchantment; import net.minecraft.entity.effect.StatusEffects; import net.minecraft.fluid.Fluids; -import net.minecraft.network.Packet; +import net.minecraft.network.packet.Packet; import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket; import net.minecraft.registry.tag.FluidTags; import net.minecraft.util.math.BlockPos; @@ -213,7 +213,8 @@ else if ((event.fluidState.getFluid() == Fluids.LAVA || event.fluidState.getFlui @EventHandler private void onFluidCollisionShape(CollisionShapeEvent event) { - if (event.type != CollisionShapeEvent.CollisionType.FLUID) return; + if (event.state.getFluidState().isEmpty()) return; + if (event.state.getMaterial() == Material.WATER && !mc.player.isTouchingWater() && waterShouldBeSolid()) { event.shape = VoxelShapes.fullCube(); } diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/NoFall.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/NoFall.java index 821d3e6edc..6bc05b35bb 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/NoFall.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/NoFall.java @@ -82,6 +82,13 @@ public class NoFall extends Module { .build() ); + private final Setting antiBounce = sgGeneral.add(new BoolSetting.Builder() + .name("anti-bounce") + .description("Disables bouncing on slime-block and bed upon landing.") + .defaultValue(true) + .build() + ); + private boolean placedWater; private BlockPos targetPos; private int timer; @@ -184,6 +191,10 @@ else if (mode.get() == Mode.Place) { } } + public boolean cancelBounce() { + return isActive() && antiBounce.get(); + } + private void useItem(FindItemResult item, boolean placedWater, BlockPos blockPos, boolean interactItem) { if (!item.found()) return; diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/NoSlow.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/NoSlow.java index 95d05cc648..331b5d02fb 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/NoSlow.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/NoSlow.java @@ -5,7 +5,6 @@ package meteordevelopment.meteorclient.systems.modules.movement; -import meteordevelopment.meteorclient.events.entity.player.CobwebEntityCollisionEvent; import meteordevelopment.meteorclient.events.world.TickEvent; import meteordevelopment.meteorclient.settings.*; import meteordevelopment.meteorclient.systems.modules.Categories; @@ -25,14 +24,14 @@ public class NoSlow extends Module { .build() ); - public final Setting web = sgGeneral.add(new EnumSetting.Builder() + private final Setting web = sgGeneral.add(new EnumSetting.Builder() .name("web") .description("Whether or not cobwebs will not slow you down.") .defaultValue(WebMode.Vanilla) .build() ); - public final Setting webTimer = sgGeneral.add(new IntSetting.Builder() + private final Setting webTimer = sgGeneral.add(new DoubleSetting.Builder() .name("web-timer") .description("The timer value for WebMode Timer.") .defaultValue(10) @@ -44,14 +43,14 @@ public class NoSlow extends Module { private final Setting honeyBlock = sgGeneral.add(new BoolSetting.Builder() .name("honey-block") - .description("Whether or not Honey Block will not slow you down.") + .description("Whether or not honey blocks will not slow you down.") .defaultValue(true) .build() ); private final Setting soulSand = sgGeneral.add(new BoolSetting.Builder() .name("soul-sand") - .description("Whether or not Soul Sand will not slow you down.") + .description("Whether or not soul sand will not slow you down.") .defaultValue(true) .build() ); @@ -63,6 +62,13 @@ public class NoSlow extends Module { .build() ); + private final Setting berryBush = sgGeneral.add(new BoolSetting.Builder() + .name("berry-bush") + .description("Whether or not berry bushes will not slow you down.") + .defaultValue(true) + .build() + ); + private final Setting airStrict = sgGeneral.add(new BoolSetting.Builder() .name("air-strict") .description("Will attempt to bypass anti-cheats like 2b2t's. Only works while in air.") @@ -77,6 +83,20 @@ public class NoSlow extends Module { .build() ); + private final Setting hunger = sgGeneral.add(new BoolSetting.Builder() + .name("hunger") + .description("Whether or not hunger will not slow you down.") + .defaultValue(false) + .build() + ); + + private final Setting slowness = sgGeneral.add(new BoolSetting.Builder() + .name("slowness") + .description("Whether or not slowness will not slow you down.") + .defaultValue(false) + .build() + ); + private boolean resetTimer; public NoSlow() { @@ -108,13 +128,24 @@ public boolean slimeBlock() { return isActive() && slimeBlock.get(); } + public boolean cobweb() { + return isActive() && web.get() == WebMode.Vanilla; + } + + public boolean berryBush() { + return isActive() && berryBush.get(); + } + public boolean sneaking() { return isActive() && sneaking.get(); } - @EventHandler - private void onWebEntityCollision(CobwebEntityCollisionEvent event) { - if (web.get() == WebMode.Vanilla) event.cancel(); + public boolean hunger() { + return isActive() && hunger.get(); + } + + public boolean slowness() { + return isActive() && slowness.get(); } @EventHandler diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/SafeWalk.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/SafeWalk.java index 8db34ac51f..4c0118cf31 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/SafeWalk.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/SafeWalk.java @@ -6,80 +6,17 @@ package meteordevelopment.meteorclient.systems.modules.movement; import meteordevelopment.meteorclient.events.entity.player.ClipAtLedgeEvent; -import meteordevelopment.meteorclient.events.world.CollisionShapeEvent; -import meteordevelopment.meteorclient.settings.BlockListSetting; -import meteordevelopment.meteorclient.settings.BoolSetting; -import meteordevelopment.meteorclient.settings.Setting; -import meteordevelopment.meteorclient.settings.SettingGroup; import meteordevelopment.meteorclient.systems.modules.Categories; import meteordevelopment.meteorclient.systems.modules.Module; import meteordevelopment.orbit.EventHandler; -import net.minecraft.block.*; -import net.minecraft.util.shape.VoxelShapes; - -import java.util.List; public class SafeWalk extends Module { - private final SettingGroup sgGeneral = settings.getDefaultGroup(); - - private final Setting ledge = sgGeneral.add(new BoolSetting.Builder() - .name("ledge") - .description("Prevents you from walking of blocks, like pressing shift.") - .defaultValue(true) - .build() - ); - - private final Setting> blocks = sgGeneral.add(new BlockListSetting.Builder() - .name("blocks") - .description("Which blocks to prevent on walking") - .filter(this::blockFilter) - .build() - ); - - private final Setting magma = sgGeneral.add(new BoolSetting.Builder() - .name("magma") - .description("Prevents you from walking over magma blocks.") - .defaultValue(false) - .build() - ); - public SafeWalk() { - super(Categories.Movement, "safe-walk", "Prevents you from walking off blocks or on blocks that you dont want."); + super(Categories.Movement, "safe-walk", "Prevents you from walking off blocks."); } @EventHandler private void onClipAtLedge(ClipAtLedgeEvent event) { - if (!mc.player.isSneaking()) event.setClip(ledge.get()); - } - - @EventHandler - private void onCollisionShape(CollisionShapeEvent event) { - if (mc.world == null || mc.player == null) return; - if (event.type != CollisionShapeEvent.CollisionType.BLOCK) return; - if (blocks.get().contains(event.state.getBlock())) { - event.shape = VoxelShapes.fullCube(); - } - else if (magma.get() && !mc.player.isSneaking() - && event.state.isAir() - && mc.world.getBlockState(event.pos.down()).getBlock() == Blocks.MAGMA_BLOCK) { - event.shape = VoxelShapes.fullCube(); - } - } - - private boolean blockFilter(Block block) { - return (block instanceof AbstractFireBlock - || block instanceof AbstractPressurePlateBlock - || block instanceof TripwireBlock - || block instanceof TripwireHookBlock - || block instanceof CobwebBlock - || block instanceof CampfireBlock - || block instanceof SweetBerryBushBlock - || block instanceof CactusBlock - || block instanceof AbstractRailBlock - || block instanceof TrapdoorBlock - || block instanceof PowderSnowBlock - || block instanceof AbstractCauldronBlock - || block instanceof HoneyBlock - ); + if (!mc.player.isSneaking()) event.setClip(true); } } diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/Scaffold.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/Scaffold.java index 880959248a..8ae2c1221d 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/Scaffold.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/Scaffold.java @@ -5,7 +5,6 @@ package meteordevelopment.meteorclient.systems.modules.movement; -import meteordevelopment.meteorclient.events.render.Render3DEvent; import meteordevelopment.meteorclient.events.world.TickEvent; import meteordevelopment.meteorclient.renderer.ShapeMode; import meteordevelopment.meteorclient.settings.*; @@ -15,7 +14,6 @@ import meteordevelopment.meteorclient.utils.player.InvUtils; import meteordevelopment.meteorclient.utils.player.PlayerUtils; import meteordevelopment.meteorclient.utils.render.RenderUtils; -import meteordevelopment.meteorclient.utils.render.color.Color; import meteordevelopment.meteorclient.utils.render.color.SettingColor; import meteordevelopment.meteorclient.utils.world.BlockUtils; import meteordevelopment.orbit.EventHandler; @@ -55,6 +53,21 @@ public class Scaffold extends Module { .build() ); + private final Setting cancelVelocity = sgGeneral.add(new BoolSetting.Builder() + .name("cancel-velocity") + .description("Whether or not to cancel velocity when towering.") + .defaultValue(false) + .visible(fastTower::get) + .build() + ); + + private final Setting onlyOnClick = sgGeneral.add(new BoolSetting.Builder() + .name("only-on-click") + .description("Only places blocks when holding right click.") + .defaultValue(false) + .build() + ); + private final Setting renderSwing = sgGeneral.add(new BoolSetting.Builder() .name("swing") .description("Renders your client-side swing.") @@ -78,14 +91,14 @@ public class Scaffold extends Module { private final Setting airPlace = sgGeneral.add(new BoolSetting.Builder() .name("air-place") - .description("Allow air place.") + .description("Allow air place. This also allows you to modify scaffold radius.") .defaultValue(false) .build() ); private final Setting placeRange = sgGeneral.add(new DoubleSetting.Builder() .name("closest-block-range") - .description("How far can scaffold place blocks.") + .description("How far can scaffold place blocks when you are in air.") .defaultValue(4) .min(0) .sliderMax(8) @@ -93,6 +106,25 @@ public class Scaffold extends Module { .build() ); + private final Setting radius = sgGeneral.add(new DoubleSetting.Builder() + .name("radius") + .description("Scaffold radius.") + .defaultValue(0) + .min(0) + .max(6) + .visible(() -> airPlace.get()) + .build() + ); + + private final Setting blocksPerTick = sgGeneral.add(new IntSetting.Builder() + .name("blocks-per-tick") + .description("How many blocks to place in one tick.") + .defaultValue(3) + .min(1) + .visible(() -> airPlace.get()) + .build() + ); + // Render private final Setting render = sgRender.add(new BoolSetting.Builder() @@ -126,15 +158,6 @@ public class Scaffold extends Module { .build() ); - private final Setting fadeDuration = sgRender.add(new IntSetting.Builder() - .name("fade-duration") - .description("How long for the rendered blocks to fade in ticks.") - .min(2) - .defaultValue(10) - .visible(render::get) - .build() - ); - private final BlockPos.Mutable bp = new BlockPos.Mutable(); private final BlockPos.Mutable prevBp = new BlockPos.Mutable(); @@ -153,60 +176,52 @@ public void onActivate() { @EventHandler private void onTick(TickEvent.Pre event) { + if (onlyOnClick.get() && !mc.options.useKey.isPressed()) return; + if (airPlace.get()) { Vec3d vec = mc.player.getPos().add(mc.player.getVelocity()).add(0, -0.5f, 0); bp.set(vec.getX(), vec.getY(), vec.getZ()); - + } else if (BlockUtils.getPlaceSide(mc.player.getBlockPos().down()) != null) { + bp.set(mc.player.getBlockPos().down()); } else { - if (BlockUtils.getPlaceSide(mc.player.getBlockPos().down()) != null) { - bp.set(mc.player.getBlockPos().down()); - - } else { - Vec3d pos = mc.player.getPos(); - pos = pos.add(0, -0.98f, 0); - pos.add(mc.player.getVelocity()); - - if (!PlayerUtils.isWithin(prevBp, placeRange.get())) { - List blockPosArray = new ArrayList<>(); - - for (int x = (int) (mc.player.getX() - placeRange.get()); x < mc.player.getX() + placeRange.get(); x++) { - for (int z = (int) (mc.player.getZ() - placeRange.get()); z < mc.player.getZ() + placeRange.get(); z++) { - for (int y = (int) Math.max(mc.world.getBottomY(), mc.player.getY() - placeRange.get()); y < Math.min(mc.world.getTopY(), mc.player.getY() + placeRange.get()); y++) { - bp.set(x, y, z); - if (!mc.world.getBlockState(bp).isAir()) blockPosArray.add(new BlockPos(bp)); - } + Vec3d pos = mc.player.getPos(); + pos = pos.add(0, -0.98f, 0); + pos.add(mc.player.getVelocity()); + + if (!PlayerUtils.isWithin(prevBp, placeRange.get())) { + List blockPosArray = new ArrayList<>(); + + for (int x = (int) (mc.player.getX() - placeRange.get()); x < mc.player.getX() + placeRange.get(); x++) { + for (int z = (int) (mc.player.getZ() - placeRange.get()); z < mc.player.getZ() + placeRange.get(); z++) { + for (int y = (int) Math.max(mc.world.getBottomY(), mc.player.getY() - placeRange.get()); y < Math.min(mc.world.getTopY(), mc.player.getY() + placeRange.get()); y++) { + bp.set(x, y, z); + if (!mc.world.getBlockState(bp).isAir()) blockPosArray.add(new BlockPos(bp)); } } - if (blockPosArray.size() == 0) { - return; - } - - blockPosArray.sort(Comparator.comparingDouble(PlayerUtils::squaredDistanceTo)); - - prevBp.set(blockPosArray.get(0)); + } + if (blockPosArray.size() == 0) { + return; } - Vec3d vecPrevBP = new Vec3d((double) prevBp.getX() + 0.5f, - (double) prevBp.getY() + 0.5f, - (double) prevBp.getZ() + 0.5f); - - Vec3d sub = pos.subtract(vecPrevBP); - Direction facing; - if (sub.getY() < -0.5f) { - facing = Direction.DOWN; - } else if (sub.getY() > 0.5f) { - facing = Direction.UP; - } else facing = Direction.getFacing(sub.getX(), 0, sub.getZ()); + blockPosArray.sort(Comparator.comparingDouble(PlayerUtils::squaredDistanceTo)); - bp.set(prevBp.offset(facing)); + prevBp.set(blockPosArray.get(0)); } - } - FindItemResult item = InvUtils.findInHotbar(itemStack -> validItem(itemStack, bp)); - if (!item.found()) return; + Vec3d vecPrevBP = new Vec3d((double) prevBp.getX() + 0.5f, + (double) prevBp.getY() + 0.5f, + (double) prevBp.getZ() + 0.5f); + Vec3d sub = pos.subtract(vecPrevBP); + Direction facing; + if (sub.getY() < -0.5f) { + facing = Direction.DOWN; + } else if (sub.getY() > 0.5f) { + facing = Direction.UP; + } else facing = Direction.getFacing(sub.getX(), 0, sub.getZ()); - if (item.getHand() == null && !autoSwitch.get()) return; + bp.set(prevBp.offset(facing)); + } // Move down if shifting if (mc.options.sneakKey.isPressed() && !mc.options.jumpKey.isPressed()) { @@ -219,23 +234,40 @@ private void onTick(TickEvent.Pre event) { } if (!lastWasSneaking) lastSneakingY = mc.player.getY(); - if (mc.options.jumpKey.isPressed() && !mc.options.sneakKey.isPressed() && fastTower.get()) { - mc.player.setVelocity(0, 0.42f, 0); - } + fastTower(false, null); - if (BlockUtils.place(bp, item, rotate.get(), 50, renderSwing.get(), true)) { - // Render block if was placed - if (render.get()) RenderUtils.renderTickingBlock(bp.toImmutable(), sideColor.get(), lineColor.get(), shapeMode.get(), 0, 8, true, false); + if (airPlace.get()) { + List blocks = new ArrayList<>(); + for (int x = (int) (mc.player.getX() - radius.get()); x < mc.player.getX() + radius.get(); x++) { + for (int z = (int) (mc.player.getZ() - radius.get()); z < mc.player.getZ() + radius.get(); z++) { + blocks.add(BlockPos.ofFloored(x, mc.player.getY() - 0.5, z)); + } + } - // Move player down so they are on top of the placed block ready to jump again - if (mc.options.jumpKey.isPressed() && !mc.options.sneakKey.isPressed() && !mc.player.isOnGround() && !mc.world.getBlockState(bp).isAir() && fastTower.get()) { - mc.player.setVelocity(0, -0.28f, 0); + if (!blocks.isEmpty()) { + blocks.sort(Comparator.comparingDouble(PlayerUtils::squaredDistanceTo)); + int counter = 0; + for (BlockPos block : blocks) { + if (place(block)) { + fastTower(true, block); + counter++; + } + + if (counter >= blocksPerTick.get()) { + break; + } + } + } + } else { + if (place(bp)) fastTower(true, bp); + if (!mc.world.getBlockState(bp).isAir()) { + prevBp.set(bp); } } + } - if (!mc.world.getBlockState(bp).isAir()) { - prevBp.set(bp); - } + public boolean scaffolding() { + return isActive() && (!onlyOnClick.get() || (onlyOnClick.get() && mc.options.useKey.isPressed())); } private boolean validItem(ItemStack itemStack, BlockPos pos) { @@ -250,39 +282,39 @@ private boolean validItem(ItemStack itemStack, BlockPos pos) { return !(block instanceof FallingBlock) || !FallingBlock.canFallThrough(mc.world.getBlockState(pos)); } - // Rendering - - public enum ListMode { - Whitelist, - Blacklist - } - - public static class RenderBlock { - public BlockPos.Mutable pos = new BlockPos.Mutable(); - public int ticks; + private boolean place(BlockPos bp) { + FindItemResult item = InvUtils.findInHotbar(itemStack -> validItem(itemStack, bp)); + if (!item.found()) return false; - public RenderBlock set(BlockPos blockPos) { - pos.set(blockPos); - ticks = 8; + if (item.getHand() == null && !autoSwitch.get()) return false; - return this; + if (BlockUtils.place(bp, item, rotate.get(), 50, renderSwing.get(), true)) { + // Render block if was placed + if (render.get()) + RenderUtils.renderTickingBlock(bp.toImmutable(), sideColor.get(), lineColor.get(), shapeMode.get(), 0, 8, true, false); + return true; } + return false; + } - public void tick() { - ticks--; + private void fastTower(boolean down, BlockPos checkBlock) { + if (down) { + // Move player down so they are on top of the placed block ready to jump again + if (fastTower.get() && mc.options.jumpKey.isPressed() && !mc.options.sneakKey.isPressed() && !mc.player.isOnGround()) { + // The chunk hasn't updated yet so we check the block we were standing on + if (!mc.world.getBlockState(checkBlock.down()).isReplaceable()) + mc.player.setVelocity(0, -0.28f, 0); + } + } else { + if (mc.options.jumpKey.isPressed() && !mc.options.sneakKey.isPressed() && fastTower.get()) { + Vec3d vel = mc.player.getVelocity(); + mc.player.setVelocity(cancelVelocity.get() ? 0 : vel.x, 0.42, cancelVelocity.get() ? 0 : vel.z); + } } + } - public void render(Render3DEvent event, Color sides, Color lines, ShapeMode shapeMode) { - int preSideA = sides.a; - int preLineA = lines.a; - - sides.a *= (double) ticks / 8; - lines.a *= (double) ticks / 8; - - event.renderer.box(pos, sides, lines, shapeMode, 0); - - sides.a = preSideA; - lines.a = preLineA; - } + public enum ListMode { + Whitelist, + Blacklist } } diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/Step.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/Step.java index e05adc6496..63b2994f3d 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/Step.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/Step.java @@ -63,7 +63,7 @@ public Step() { @Override public void onActivate() { - prevStepHeight = mc.player.stepHeight; + prevStepHeight = mc.player.getStepHeight(); prevBaritoneAssumeStep = BaritoneAPI.getSettings().assumeStep.value; BaritoneAPI.getSettings().assumeStep.value = true; @@ -74,16 +74,16 @@ private void onTick(TickEvent.Post event) { boolean work = (activeWhen.get() == ActiveWhen.Always) || (activeWhen.get() == ActiveWhen.Sneaking && mc.player.isSneaking()) || (activeWhen.get() == ActiveWhen.NotSneaking && !mc.player.isSneaking()); mc.player.setBoundingBox(mc.player.getBoundingBox().offset(0, 1, 0)); if (work && (!safeStep.get() || (getHealth() > stepHealth.get() && getHealth() - getExplosionDamage() > stepHealth.get()))){ - mc.player.stepHeight = height.get().floatValue(); + mc.player.setStepHeight(height.get().floatValue()); } else { - mc.player.stepHeight = prevStepHeight; + mc.player.setStepHeight(prevStepHeight); } mc.player.setBoundingBox(mc.player.getBoundingBox().offset(0, -1, 0)); } @Override public void onDeactivate() { - mc.player.stepHeight = prevStepHeight; + mc.player.setStepHeight(prevStepHeight); BaritoneAPI.getSettings().assumeStep.value = prevBaritoneAssumeStep; } diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/player/AutoEat.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/player/AutoEat.java index d48997ef43..57725b8cd8 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/player/AutoEat.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/player/AutoEat.java @@ -18,6 +18,7 @@ import meteordevelopment.meteorclient.systems.modules.combat.KillAura; import meteordevelopment.meteorclient.utils.Utils; import meteordevelopment.meteorclient.utils.player.InvUtils; +import meteordevelopment.meteorclient.utils.player.SlotUtils; import meteordevelopment.orbit.EventHandler; import meteordevelopment.orbit.EventPriority; import net.minecraft.item.Item; @@ -231,6 +232,9 @@ private int findSlot() { } } + Item offHandItem = mc.player.getOffHandStack().getItem(); + if (offHandItem.isFood() && !blacklist.get().contains(offHandItem) && offHandItem.getFoodComponent().getHunger() > bestHunger) slot = SlotUtils.OFFHAND; + return slot; } } diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/player/AutoFish.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/player/AutoFish.java index cf51c8b5b3..cac2bb83fd 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/player/AutoFish.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/player/AutoFish.java @@ -12,10 +12,11 @@ import meteordevelopment.meteorclient.systems.modules.Categories; import meteordevelopment.meteorclient.systems.modules.Module; import meteordevelopment.meteorclient.utils.Utils; +import meteordevelopment.meteorclient.utils.player.InvUtils; import meteordevelopment.orbit.EventHandler; import net.minecraft.client.sound.SoundInstance; import net.minecraft.entity.projectile.FishingBobberEntity; -import net.minecraft.item.FishingRodItem; +import net.minecraft.item.Items; public class AutoFish extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); @@ -57,6 +58,13 @@ public class AutoFish extends Module { .build() ); + private final Setting antiBreak = sgGeneral.add(new BoolSetting.Builder() + .name("anti-break") + .description("Prevents fishing rod from being broken.") + .defaultValue(false) + .build() + ); + // Splash Detection private final Setting splashDetectionRangeEnabled = sgSplashRangeDetection.add(new BoolSetting.Builder() @@ -114,7 +122,7 @@ private void onTick(TickEvent.Post event) { if (autoCastCheckTimer <= 0) { autoCastCheckTimer = 30; - if (autoCast.get() && !ticksEnabled && !autoCastEnabled && mc.player.fishHook == null && mc.player.getMainHandStack().getItem() instanceof FishingRodItem) { + if (autoCast.get() && !ticksEnabled && !autoCastEnabled && mc.player.fishHook == null && hasFishingRod()) { autoCastTimer = 0; autoCastEnabled = true; } @@ -152,4 +160,8 @@ else if (ticksData == 1) { private void onKey(KeyEvent event) { if (mc.options.useKey.isPressed()) ticksEnabled = false; } + + private boolean hasFishingRod() { + return InvUtils.swap(InvUtils.findInHotbar(itemStack -> itemStack.getItem() == Items.FISHING_ROD && (!antiBreak.get() || itemStack.getDamage() < itemStack.getMaxDamage() - 1)).slot(), false); + } } diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/player/AutoGap.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/player/AutoGap.java index 0811c469cf..988767ddc4 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/player/AutoGap.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/player/AutoGap.java @@ -42,9 +42,9 @@ public class AutoGap extends Module { // General - private final Setting preferEGap = sgGeneral.add(new BoolSetting.Builder() - .name("prefer-egap") - .description("Prefers to eat E-Gap over Gaps if found.") + private final Setting allowEgap = sgGeneral.add(new BoolSetting.Builder() + .name("allow-egap") + .description("Allow eating E-Gaps over Gaps if found.") .defaultValue(true) .build() ); @@ -83,6 +83,7 @@ public class AutoGap extends Module { .name("potions-fire-resistance") .description("If it should eat when Fire Resistance runs out. Requires E-Gaps.") .defaultValue(true) + .visible(allowEgap::get) .build() ); @@ -90,6 +91,7 @@ public class AutoGap extends Module { .name("potions-absorption") .description("If it should eat when Resistance runs out. Requires E-Gaps.") .defaultValue(false) + .visible(allowEgap::get) .build() ); @@ -276,11 +278,8 @@ private boolean shouldEatHealth() { } private int findSlot() { - boolean preferEGap = this.preferEGap.get(); - if (requiresEGap) preferEGap = true; - + boolean preferEGap = this.allowEgap.get() || requiresEGap; int slot = -1; - Item currentItem = null; for (int i = 0; i < 9; i++) { // Skip if item stack is empty @@ -291,35 +290,18 @@ private int findSlot() { if (isNotGapOrEGap(stack)) continue; Item item = stack.getItem(); - // If this is the first apple found then set it without looking at preferEGap setting - if (currentItem == null) { + // If egap was found and preferEGap is true we can return the current slot + if (item == Items.ENCHANTED_GOLDEN_APPLE && preferEGap) { slot = i; - currentItem = item; + break; } - else { - // Skip if current item and item are the same - if (currentItem == item) continue; - - // If egap was found and preferEGap is true we can return the current slot - if (item == Items.ENCHANTED_GOLDEN_APPLE && preferEGap) { - slot = i; - currentItem = item; - - break; - } - // If gap was found and preferEGap is false we can return the current slot - else if (item == Items.GOLDEN_APPLE && !preferEGap) { - slot = i; - currentItem = item; - - break; - } + // If gap was found and egap is not required we can return the current slot + else if (item == Items.GOLDEN_APPLE && !requiresEGap) { + slot = i; + if (!preferEGap) break; } } - // If requiresEGap is true but no egap was found return -1 - if (requiresEGap && currentItem != Items.ENCHANTED_GOLDEN_APPLE) return -1; - return slot; } diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/player/AutoTool.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/player/AutoTool.java index 8a00f9cf3f..0904dd9f6c 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/player/AutoTool.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/player/AutoTool.java @@ -183,7 +183,7 @@ private boolean shouldStopUsing(ItemStack itemStack) { } public static double getScore(ItemStack itemStack, BlockState state, boolean silkTouchEnderChest, EnchantPreference enchantPreference, Predicate good) { - if (!good.test(itemStack) || !isTool(itemStack) || !(itemStack.getItem() instanceof MiningToolItem mti) || !mti.isSuitableFor(state)) return -1; + if (!itemStack.isSuitableFor(state) || !good.test(itemStack) || !isTool(itemStack)) return -1; if (silkTouchEnderChest && state.getBlock() == Blocks.ENDER_CHEST diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/player/BreakDelay.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/player/BreakDelay.java new file mode 100644 index 0000000000..8c03db2ad6 --- /dev/null +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/player/BreakDelay.java @@ -0,0 +1,44 @@ +/* + * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). + * Copyright (c) Meteor Development. + */ + +package meteordevelopment.meteorclient.systems.modules.player; + +import meteordevelopment.meteorclient.events.entity.player.BlockBreakingCooldownEvent; +import meteordevelopment.meteorclient.settings.BoolSetting; +import meteordevelopment.meteorclient.settings.IntSetting; +import meteordevelopment.meteorclient.settings.Setting; +import meteordevelopment.meteorclient.settings.SettingGroup; +import meteordevelopment.meteorclient.systems.modules.Categories; +import meteordevelopment.meteorclient.systems.modules.Module; +import meteordevelopment.orbit.EventHandler; + +public class BreakDelay extends Module { + SettingGroup sgGeneral = settings.getDefaultGroup(); + + private final Setting cooldown = sgGeneral.add(new IntSetting.Builder() + .name("cooldown") + .description("Block break cooldown in ticks.") + .defaultValue(0) + .min(0) + .sliderMax(5) + .build() + ); + + public final Setting noInstaBreak = sgGeneral.add(new BoolSetting.Builder() + .name("no-insta-break") + .description("Prevent you from breaking blocks instantly.") + .defaultValue(false) + .build() + ); + + public BreakDelay() { + super(Categories.Player, "break-delay", "Changes the delay between breaking blocks."); + } + + @EventHandler() + private void onBlockBreakingCooldown(BlockBreakingCooldownEvent event) { + event.cooldown = cooldown.get(); + } +} diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/player/ChestSwap.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/player/ChestSwap.java index a4098e097c..92e12dbc9f 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/player/ChestSwap.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/player/ChestSwap.java @@ -132,6 +132,6 @@ private void equip(int slot) { @Override public void sendToggledMsg() { if (stayOn.get()) super.sendToggledMsg(); - else if (Config.get().chatFeedback.get()) info("Triggered (highlight)%s(default).", title); + else if (Config.get().chatFeedback.get() && chatFeedback) info("Triggered (highlight)%s(default).", title); } } diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/player/FakePlayer.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/player/FakePlayer.java index 94e79e70d9..6946dfddf7 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/player/FakePlayer.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/player/FakePlayer.java @@ -7,11 +7,13 @@ import meteordevelopment.meteorclient.gui.GuiTheme; import meteordevelopment.meteorclient.gui.widgets.WWidget; -import meteordevelopment.meteorclient.gui.widgets.containers.WHorizontalList; +import meteordevelopment.meteorclient.gui.widgets.containers.WTable; import meteordevelopment.meteorclient.gui.widgets.pressable.WButton; +import meteordevelopment.meteorclient.gui.widgets.pressable.WMinus; import meteordevelopment.meteorclient.settings.*; import meteordevelopment.meteorclient.systems.modules.Categories; import meteordevelopment.meteorclient.systems.modules.Module; +import meteordevelopment.meteorclient.utils.entity.fakeplayer.FakePlayerEntity; import meteordevelopment.meteorclient.utils.entity.fakeplayer.FakePlayerManager; public class FakePlayer extends Module { @@ -46,19 +48,37 @@ public FakePlayer() { @Override public WWidget getWidget(GuiTheme theme) { - WHorizontalList w = theme.horizontalList(); + WTable table = theme.table(); + fillTable(theme, table); - WButton spawn = w.add(theme.button("Spawn")).widget(); + return table; + } + + private void fillTable(GuiTheme theme, WTable table) { + for (FakePlayerEntity fakePlayer : FakePlayerManager.getFakePlayers()) { + table.add(theme.label(fakePlayer.getEntityName())); + WMinus delete = table.add(theme.minus()).expandCellX().right().widget(); + delete.action = () -> { + FakePlayerManager.remove(fakePlayer); + table.clear(); + fillTable(theme, table); + }; + table.row(); + } + + WButton spawn = table.add(theme.button("Spawn")).expandCellX().right().widget(); spawn.action = () -> { FakePlayerManager.add(name.get(), health.get(), copyInv.get()); + table.clear(); + fillTable(theme, table); }; - WButton clear = w.add(theme.button("Clear")).widget(); + WButton clear = table.add(theme.button("Clear All")).right().widget(); clear.action = () -> { FakePlayerManager.clear(); + table.clear(); + fillTable(theme, table); }; - - return w; } @Override diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/player/GhostHand.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/player/GhostHand.java index 42d9c94600..e098bb4d30 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/player/GhostHand.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/player/GhostHand.java @@ -32,7 +32,7 @@ private void onTick(TickEvent.Pre event) { if (!mc.options.useKey.isPressed() || mc.player.isSneaking()) return; for (BlockEntity blockEntity : Utils.blockEntities()) { - if (new BlockPos(mc.player.raycast(mc.interactionManager.getReachDistance(), mc.getTickDelta(), false).getPos()).equals(blockEntity.getPos())) return; + if (BlockPos.ofFloored(mc.player.raycast(mc.interactionManager.getReachDistance(), mc.getTickDelta(), false).getPos()).equals(blockEntity.getPos())) return; } Vec3d direction = new Vec3d(0, 0, 0.1) @@ -42,7 +42,7 @@ private void onTick(TickEvent.Pre event) { posList.clear(); for (int i = 1; i < mc.interactionManager.getReachDistance() * 10; i++) { - BlockPos pos = new BlockPos(mc.player.getCameraPosVec(mc.getTickDelta()).add(direction.multiply(i))); + BlockPos pos = BlockPos.ofFloored(mc.player.getCameraPosVec(mc.getTickDelta()).add(direction.multiply(i))); if (posList.contains(pos)) continue; posList.add(pos); diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/player/MiddleClickExtra.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/player/MiddleClickExtra.java index 797b85542b..692073fbcf 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/player/MiddleClickExtra.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/player/MiddleClickExtra.java @@ -85,7 +85,7 @@ public void onDeactivate() { @EventHandler private void onMouseButton(MouseButtonEvent event) { - if (event.action != KeyAction.Press || event.button != GLFW_MOUSE_BUTTON_MIDDLE) return; + if (event.action != KeyAction.Press || event.button != GLFW_MOUSE_BUTTON_MIDDLE || mc.currentScreen != null) return; FindItemResult result = InvUtils.findInHotbar(mode.get().item); diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/player/NoBreakDelay.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/player/NoBreakDelay.java deleted file mode 100644 index 089e77ac6f..0000000000 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/player/NoBreakDelay.java +++ /dev/null @@ -1,15 +0,0 @@ -/* - * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). - * Copyright (c) Meteor Development. - */ - -package meteordevelopment.meteorclient.systems.modules.player; - -import meteordevelopment.meteorclient.systems.modules.Categories; -import meteordevelopment.meteorclient.systems.modules.Module; - -public class NoBreakDelay extends Module { - public NoBreakDelay() { - super(Categories.Player, "no-break-delay", "Completely removes the delay between breaking blocks."); - } -} diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/player/PotionSpoof.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/player/PotionSpoof.java index 8cb896553a..24af8ac2b4 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/player/PotionSpoof.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/player/PotionSpoof.java @@ -8,10 +8,7 @@ import it.unimi.dsi.fastutil.objects.Object2IntMap; import meteordevelopment.meteorclient.events.world.TickEvent; import meteordevelopment.meteorclient.mixin.StatusEffectInstanceAccessor; -import meteordevelopment.meteorclient.settings.BoolSetting; -import meteordevelopment.meteorclient.settings.Setting; -import meteordevelopment.meteorclient.settings.SettingGroup; -import meteordevelopment.meteorclient.settings.StatusEffectAmplifierMapSetting; +import meteordevelopment.meteorclient.settings.*; import meteordevelopment.meteorclient.systems.modules.Categories; import meteordevelopment.meteorclient.systems.modules.Module; import meteordevelopment.meteorclient.utils.Utils; @@ -19,14 +16,18 @@ import net.minecraft.entity.effect.StatusEffect; import net.minecraft.entity.effect.StatusEffectInstance; +import java.util.List; + +import static net.minecraft.entity.effect.StatusEffects.*; + public class PotionSpoof extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); - private final Setting> potions = sgGeneral.add(new StatusEffectAmplifierMapSetting.Builder() - .name("potions") - .description("Potions to add.") - .defaultValue(Utils.createStatusEffectMap()) - .build() + private final Setting> spoofPotions = sgGeneral.add(new StatusEffectAmplifierMapSetting.Builder() + .name("spoofed-potions") + .description("Potions to add.") + .defaultValue(Utils.createStatusEffectMap()) + .build() ); private final Setting clearEffects = sgGeneral.add(new BoolSetting.Builder() @@ -36,24 +37,43 @@ public class PotionSpoof extends Module { .build() ); + private final Setting> antiPotion = sgGeneral.add(new StatusEffectListSetting.Builder() + .name("blocked-potions") + .description("Potions to block.") + .defaultValue( + LEVITATION, + JUMP_BOOST, + SLOW_FALLING, + DOLPHINS_GRACE + ) + .build() + ); + + public final Setting applyGravity = sgGeneral.add(new BoolSetting.Builder() + .name("gravity") + .description("Applies gravity when levitating.") + .defaultValue(false) + .build() + ); + public PotionSpoof() { - super(Categories.Player, "potion-spoof", "Spoofs specified potion effects for you. SOME effects DO NOT work."); + super(Categories.Player, "potion-spoof", "Spoofs potion statuses for you. SOME effects DO NOT work."); } @Override public void onDeactivate() { if (!clearEffects.get() || !Utils.canUpdate()) return; - for (StatusEffect effect : potions.get().keySet()) { - if (potions.get().getInt(effect) <= 0) continue; + for (StatusEffect effect : spoofPotions.get().keySet()) { + if (spoofPotions.get().getInt(effect) <= 0) continue; if (mc.player.hasStatusEffect(effect)) mc.player.removeStatusEffect(effect); } } @EventHandler private void onTick(TickEvent.Post event) { - for (StatusEffect statusEffect : potions.get().keySet()) { - int level = potions.get().getInt(statusEffect); + for (StatusEffect statusEffect : spoofPotions.get().keySet()) { + int level = spoofPotions.get().getInt(statusEffect); if (level <= 0) continue; if (mc.player.hasStatusEffect(statusEffect)) { @@ -65,4 +85,8 @@ private void onTick(TickEvent.Post event) { } } } + + public boolean shouldBlock(StatusEffect effect) { + return isActive() && antiPotion.get().contains(effect); + } } diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/player/Rotation.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/player/Rotation.java index ad2c01db5b..3f5d5fb8bd 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/player/Rotation.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/player/Rotation.java @@ -33,6 +33,7 @@ public class Rotation extends Module { .defaultValue(0) .sliderMax(360) .max(360) + .visible(() -> yawLockMode.get() == LockMode.Simple) .build() ); @@ -51,6 +52,7 @@ public class Rotation extends Module { .defaultValue(0) .range(-90, 90) .sliderRange(-90, 90) + .visible(() -> pitchLockMode.get() == LockMode.Simple) .build() ); diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/player/SpeedMine.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/player/SpeedMine.java index a6babad216..a0880e13de 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/player/SpeedMine.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/player/SpeedMine.java @@ -7,6 +7,7 @@ import meteordevelopment.meteorclient.events.world.TickEvent; import meteordevelopment.meteorclient.mixin.StatusEffectInstanceAccessor; +import meteordevelopment.meteorclient.settings.BlockListSetting; import meteordevelopment.meteorclient.settings.DoubleSetting; import meteordevelopment.meteorclient.settings.EnumSetting; import meteordevelopment.meteorclient.settings.Setting; @@ -14,13 +15,30 @@ import meteordevelopment.meteorclient.systems.modules.Categories; import meteordevelopment.meteorclient.systems.modules.Module; import meteordevelopment.orbit.EventHandler; +import net.minecraft.block.Block; import net.minecraft.entity.effect.StatusEffectInstance; +import java.util.List; + import static net.minecraft.entity.effect.StatusEffects.HASTE; public class SpeedMine extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); + private final Setting> blocks = sgGeneral.add(new BlockListSetting.Builder() + .name("blocks") + .description("Selected blocks.") + .filter(block -> block.getHardness() > 0) + .build() + ); + + private final Setting blocksFilter = sgGeneral.add(new EnumSetting.Builder() + .name("blocks-filter") + .description("How to use the blocks setting.") + .defaultValue(ListMode.Blacklist) + .build() + ); + public final Setting mode = sgGeneral.add(new EnumSetting.Builder() .name("mode") .defaultValue(Mode.Normal) @@ -53,9 +71,21 @@ private void onTick(TickEvent.Post event) { if (effect.getDuration() < 20) ((StatusEffectInstanceAccessor) effect).setDuration(20); } + public boolean filter(Block block) { + if (blocksFilter.get() == ListMode.Blacklist && !blocks.get().contains(block)) return true; + else if (blocksFilter.get() == ListMode.Whitelist && blocks.get().contains(block)) return true; + + return false; + } + public enum Mode { Normal, Haste1, Haste2 } + + public enum ListMode { + Whitelist, + Blacklist + } } diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/BetterTooltips.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/BetterTooltips.java index ccdd6a035b..dadaa19f96 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/BetterTooltips.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/BetterTooltips.java @@ -414,10 +414,10 @@ public void applyCompactShulkerTooltip(ItemStack stack, List tooltip) { private MutableText getStatusText(StatusEffectInstance effect) { MutableText text = Text.translatable(effect.getTranslationKey()); if (effect.getAmplifier() != 0) { - text.append(String.format(" %d (%s)", effect.getAmplifier() + 1, StatusEffectUtil.durationToString(effect, 1))); + text.append(String.format(" %d (%s)", effect.getAmplifier() + 1, StatusEffectUtil.durationToString(effect, 1).getString())); } else { - text.append(String.format(" (%s)", StatusEffectUtil.durationToString(effect, 1))); + text.append(String.format(" (%s)", StatusEffectUtil.durationToString(effect, 1).getString())); } if (effect.getEffectType().isBeneficial()) return text.formatted(Formatting.BLUE); diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/ESP.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/ESP.java index cf63bdc65c..d2200bb76a 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/ESP.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/ESP.java @@ -81,7 +81,7 @@ public class ESP extends Module { .name("fill-opacity") .description("The opacity of the shape fill.") .visible(() -> shapeMode.get() != ShapeMode.Lines) - .defaultValue(0.8) + .defaultValue(0.3) .range(0, 1) .sliderMax(1) .build() @@ -200,8 +200,10 @@ private void onRender3D(Render3DEvent event) { private void drawBoundingBox(Render3DEvent event, Entity entity) { Color color = getColor(entity); - lineColor.set(color); - sideColor.set(color).a((int) (sideColor.a * fillOpacity.get())); + if (color != null) { + lineColor.set(color); + sideColor.set(color).a((int) (sideColor.a * fillOpacity.get())); + } if (mode.get() == Mode.Box) { double x = MathHelper.lerp(event.tickDelta, entity.lastRenderX, entity.getX()) - entity.getX(); @@ -210,8 +212,7 @@ private void drawBoundingBox(Render3DEvent event, Entity entity) { Box box = entity.getBoundingBox(); event.renderer.box(x + box.minX, y + box.minY, z + box.minZ, x + box.maxX, y + box.maxY, z + box.maxZ, sideColor, lineColor, shapeMode.get(), 0); - } - else { + } else { WireframeEntityRenderer.render(event, entity, 1, sideColor, lineColor, shapeMode.get()); } } @@ -252,8 +253,10 @@ private void onRender2D(Render2DEvent event) { // Setup color Color color = getColor(entity); - lineColor.set(color); - sideColor.set(color).a((int) (sideColor.a * fillOpacity.get())); + if (color != null) { + lineColor.set(color); + sideColor.set(color).a((int) (sideColor.a * fillOpacity.get())); + } // Render if (shapeMode.get() != ShapeMode.Lines && sideColor.a > 0) { @@ -296,7 +299,7 @@ public boolean shouldSkip(Entity entity) { if (!entities.get().getBoolean(entity.getType())) return true; if (entity == mc.player && ignoreSelf.get()) return true; if (entity == mc.cameraEntity && mc.options.getPerspective().isFirstPerson()) return true; - return !EntityUtils.isInRenderDistance(entity) || getFadeAlpha(entity) == 0; + return !EntityUtils.isInRenderDistance(entity); } public Color getColor(Entity entity) { diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/HoleESP.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/HoleESP.java index 16bf43e1ba..e3df88edc6 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/HoleESP.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/HoleESP.java @@ -20,10 +20,13 @@ import meteordevelopment.meteorclient.utils.world.BlockIterator; import meteordevelopment.meteorclient.utils.world.Dir; import meteordevelopment.orbit.EventHandler; +import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.ChunkSectionPos; import net.minecraft.util.math.Direction; +import net.minecraft.world.chunk.WorldChunk; import java.util.ArrayList; import java.util.List; @@ -177,17 +180,17 @@ private void onTick(TickEvent.Pre event) { for (Direction direction : Direction.values()) { if (direction == Direction.UP) continue; - - BlockState state = mc.world.getBlockState(blockPos.offset(direction)); + BlockPos offsetPos = blockPos.offset(direction); + BlockState state = mc.world.getBlockState(offsetPos); if (state.getBlock() == Blocks.BEDROCK) bedrock++; else if (state.getBlock() == Blocks.OBSIDIAN) obsidian++; else if (direction == Direction.DOWN) return; - else if (validHole(blockPos.offset(direction)) && air == null) { + else if (doubles.get() && air == null && validHole(offsetPos)) { for (Direction dir : Direction.values()) { if (dir == direction.getOpposite() || dir == Direction.UP) continue; - BlockState blockState1 = mc.world.getBlockState(blockPos.offset(direction).offset(dir)); + BlockState blockState1 = mc.world.getBlockState(offsetPos.offset(dir)); if (blockState1.getBlock() == Blocks.BEDROCK) bedrock++; else if (blockState1.getBlock() == Blocks.OBSIDIAN) obsidian++; @@ -208,14 +211,16 @@ else if (obsidian + bedrock == 8 && doubles.get() && air != null) { } private boolean validHole(BlockPos pos) { - if ((ignoreOwn.get() && (mc.player.getBlockPos().equals(pos)))) return false; + if (ignoreOwn.get() && mc.player.getBlockPos().equals(pos)) return false; - if (!webs.get() && mc.world.getBlockState(pos).getBlock() == Blocks.COBWEB) return false; + WorldChunk chunk = mc.world.getChunk(ChunkSectionPos.getSectionCoord(pos.getX()), ChunkSectionPos.getSectionCoord(pos.getZ())); + Block block = chunk.getBlockState(pos).getBlock(); + if (!webs.get() && block == Blocks.COBWEB) return false; - if (((AbstractBlockAccessor) mc.world.getBlockState(pos).getBlock()).isCollidable()) return false; + if (((AbstractBlockAccessor) block).isCollidable()) return false; for (int i = 0; i < holeHeight.get(); i++) { - if (((AbstractBlockAccessor) mc.world.getBlockState(pos.up(i)).getBlock()).isCollidable()) return false; + if (((AbstractBlockAccessor) chunk.getBlockState(pos.up(i)).getBlock()).isCollidable()) return false; } return true; diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/ItemHighlight.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/ItemHighlight.java index d8b62961bf..617efca004 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/ItemHighlight.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/ItemHighlight.java @@ -38,7 +38,7 @@ public ItemHighlight() { } public int getColor(ItemStack stack) { - if (items.get().contains(stack.getItem()) && isActive()) return color.get().getPacked(); + if (stack != null && items.get().contains(stack.getItem()) && isActive()) return color.get().getPacked(); return -1; } } diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/ItemPhysics.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/ItemPhysics.java index fb98497672..0a7febe06c 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/ItemPhysics.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/ItemPhysics.java @@ -16,7 +16,7 @@ import net.minecraft.block.SkullBlock; import net.minecraft.client.render.OverlayTexture; import net.minecraft.client.render.model.BakedModel; -import net.minecraft.client.render.model.json.ModelTransformation; +import net.minecraft.client.render.model.json.ModelTransformationMode; import net.minecraft.item.AliasedBlockItem; import net.minecraft.item.BlockItem; import net.minecraft.item.Item; @@ -141,7 +141,7 @@ private void onRenderItemEntity(RenderItemEntityEvent event) { } } - event.itemRenderer.renderItem(itemStack, ModelTransformation.Mode.GROUND, false, event.matrixStack, event.vertexConsumerProvider, event.light, OverlayTexture.DEFAULT_UV, bakedModel); + event.itemRenderer.renderItem(itemStack, ModelTransformationMode.GROUND, false, event.matrixStack, event.vertexConsumerProvider, event.light, OverlayTexture.DEFAULT_UV, bakedModel); event.matrixStack.pop(); diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/Nametags.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/Nametags.java index d81d50c76e..aaf3e645e3 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/Nametags.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/Nametags.java @@ -12,6 +12,7 @@ import meteordevelopment.meteorclient.renderer.text.TextRenderer; import meteordevelopment.meteorclient.settings.*; import meteordevelopment.meteorclient.systems.config.Config; +import meteordevelopment.meteorclient.systems.friends.Friends; import meteordevelopment.meteorclient.systems.modules.Categories; import meteordevelopment.meteorclient.systems.modules.Module; import meteordevelopment.meteorclient.systems.modules.Modules; @@ -26,6 +27,7 @@ import meteordevelopment.orbit.EventHandler; import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.enchantment.Enchantments; import net.minecraft.entity.*; import net.minecraft.entity.decoration.ItemFrameEntity; import net.minecraft.entity.player.PlayerEntity; @@ -41,6 +43,7 @@ public class Nametags extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); private final SettingGroup sgPlayers = settings.createGroup("Players"); private final SettingGroup sgItems = settings.createGroup("Items"); + private final SettingGroup sgRender = settings.createGroup("Render"); // General @@ -54,29 +57,29 @@ public class Nametags extends Module { private final Setting scale = sgGeneral.add(new DoubleSetting.Builder() .name("scale") .description("The scale of the nametag.") - .defaultValue(1.5) + .defaultValue(1.1) .min(0.1) .build() ); - private final Setting yourself = sgGeneral.add(new BoolSetting.Builder() - .name("self") - .description("Displays a nametag on your player if you're in Freecam or third person.") + private final Setting ignoreSelf = sgGeneral.add(new BoolSetting.Builder() + .name("ignore-self") + .description("Ignore yourself when in third person or freecam.") .defaultValue(true) .build() ); - private final Setting background = sgGeneral.add(new ColorSetting.Builder() - .name("background-color") - .description("The color of the nametag background.") - .defaultValue(new SettingColor(0, 0, 0, 75)) + private final Setting ignoreFriends = sgGeneral.add(new BoolSetting.Builder() + .name("ignore-friends") + .description("Ignore rendering nametags for friends.") + .defaultValue(false) .build() ); - private final Setting names = sgGeneral.add(new ColorSetting.Builder() - .name("primary-color") - .description("The color of the nametag names.") - .defaultValue(new SettingColor()) + private final Setting ignoreBots = sgGeneral.add(new BoolSetting.Builder() + .name("ignore-bots") + .description("Only render non-bot nametags.") + .defaultValue(true) .build() ); @@ -109,16 +112,29 @@ public class Nametags extends Module { //Players - private final Setting excludeBots = sgPlayers.add(new BoolSetting.Builder() - .name("exclude-bots") - .description("Only render non-bot nametags.") - .defaultValue(true) + private final Setting displayGameMode = sgPlayers.add(new BoolSetting.Builder() + .name("gamemode") + .description("Shows the player's GameMode.") + .defaultValue(false) + .build() + ); + + private final Setting displayDistance = sgPlayers.add(new BoolSetting.Builder() + .name("distance") + .description("Shows the distance between you and the player.") + .defaultValue(false) .build() ); + private final Setting displayPing = sgPlayers.add(new BoolSetting.Builder() + .name("ping") + .description("Shows the player's ping.") + .defaultValue(true) + .build() + ); private final Setting displayItems = sgPlayers.add(new BoolSetting.Builder() - .name("display-items") + .name("items") .description("Displays armor and hand items above the name tags.") .defaultValue(true) .build() @@ -141,19 +157,32 @@ public class Nametags extends Module { .build() ); - private final Setting displayItemEnchants = sgPlayers.add(new BoolSetting.Builder() + private final Setting displayEnchants = sgPlayers.add(new BoolSetting.Builder() .name("display-enchants") .description("Displays item enchantments on the items.") - .defaultValue(true) + .defaultValue(false) .visible(displayItems::get) .build() ); + private final Setting> shownEnchantments = sgPlayers.add(new EnchantmentListSetting.Builder() + .name("shown-enchantments") + .description("The enchantments that are shown on nametags.") + .visible(() -> displayItems.get() && displayEnchants.get()) + .defaultValue( + Enchantments.PROTECTION, + Enchantments.BLAST_PROTECTION, + Enchantments.FIRE_PROTECTION, + Enchantments.PROJECTILE_PROTECTION + ) + .build() + ); + private final Setting enchantPos = sgPlayers.add(new EnumSetting.Builder() .name("enchantment-position") .description("Where the enchantments are rendered.") .defaultValue(Position.Above) - .visible(displayItemEnchants::get) + .visible(() -> displayItems.get() && displayEnchants.get()) .build() ); @@ -163,14 +192,7 @@ public class Nametags extends Module { .defaultValue(3) .range(1, 5) .sliderRange(1, 5) - .visible(displayItemEnchants::get) - .build() - ); - - private final Setting> ignoredEnchantments = sgPlayers.add(new EnchantmentListSetting.Builder() - .name("ignored-enchantments") - .description("The enchantments that aren't shown on nametags.") - .visible(displayItemEnchants::get) + .visible(() -> displayItems.get() && displayEnchants.get()) .build() ); @@ -180,37 +202,64 @@ public class Nametags extends Module { .defaultValue(1) .range(0.1, 2) .sliderRange(0.1, 2) - .visible(displayItemEnchants::get) + .visible(() -> displayItems.get() && displayEnchants.get()) .build() ); - private final Setting displayGameMode = sgPlayers.add(new BoolSetting.Builder() - .name("gamemode") - .description("Shows the player's GameMode.") + //Items + + private final Setting itemCount = sgItems.add(new BoolSetting.Builder() + .name("show-count") + .description("Displays the number of items in the stack.") .defaultValue(true) .build() ); - private final Setting displayPing = sgPlayers.add(new BoolSetting.Builder() - .name("ping") - .description("Shows the player's ping.") - .defaultValue(true) + // Render + + private final Setting background = sgRender.add(new ColorSetting.Builder() + .name("background-color") + .description("The color of the nametag background.") + .defaultValue(new SettingColor(0, 0, 0, 75)) .build() ); - private final Setting displayDistance = sgPlayers.add(new BoolSetting.Builder() - .name("distance") - .description("Shows the distance between you and the player.") - .defaultValue(true) + private final Setting nameColor = sgRender.add(new ColorSetting.Builder() + .name("name-color") + .description("The color of the nametag names.") + .defaultValue(new SettingColor()) .build() ); - //Items + private final Setting pingColor = sgRender.add(new ColorSetting.Builder() + .name("ping-color") + .description("The color of the nametag ping.") + .defaultValue(new SettingColor(20, 170, 170)) + .visible(displayPing::get) + .build() + ); - private final Setting itemCount = sgItems.add(new BoolSetting.Builder() - .name("show-count") - .description("Displays the number of items in the stack.") - .defaultValue(true) + private final Setting gamemodeColor = sgRender.add(new ColorSetting.Builder() + .name("gamemode-color") + .description("The color of the nametag gamemode.") + .defaultValue(new SettingColor(232, 185, 35)) + .visible(displayGameMode::get) + .build() + ); + + private final Setting distanceColorMode = sgRender.add(new EnumSetting.Builder() + .name("distance-color-mode") + .description("The mode to color the nametag distance with.") + .defaultValue(DistanceColorMode.Gradient) + .visible(displayDistance::get) + .build() + ); + + private final Setting distanceColor = sgRender.add(new ColorSetting.Builder() + .name("distance-color") + .description("The color of the nametag distance.") + .defaultValue(new SettingColor(150, 150, 150)) + .visible(() -> displayDistance.get() && distanceColorMode.get() == DistanceColorMode.Flat) .build() ); @@ -219,8 +268,6 @@ public class Nametags extends Module { private final Color AMBER = new Color(255, 105, 25); private final Color GREEN = new Color(25, 252, 25); private final Color GOLD = new Color(232, 185, 35); - private final Color GREY = new Color(150, 150, 150); - private final Color BLUE = new Color(20, 170, 170); private final Vector3d pos = new Vector3d(); private final double[] itemWidths = new double[6]; @@ -258,8 +305,9 @@ private void onTick(TickEvent.Post event) { if (!entities.get().containsKey(type)) continue; if (type == EntityType.PLAYER) { - if ((!yourself.get() || (freecamNotActive && notThirdPerson)) && entity == mc.player) continue; - if (EntityUtils.getGameMode((PlayerEntity) entity) == null && excludeBots.get()) continue; + if ((ignoreSelf.get() || (freecamNotActive && notThirdPerson)) && entity == mc.player) continue; + if (EntityUtils.getGameMode((PlayerEntity) entity) == null && ignoreBots.get()) continue; + if (Friends.get().isFriend((PlayerEntity) entity) && ignoreFriends.get()) continue; } if (!culling.get() || PlayerUtils.isWithinCamera(entity, maxCullRange.get())) { @@ -335,7 +383,7 @@ private void renderNametagPlayer(PlayerEntity player, boolean shadow) { // Name String name; - Color nameColor = PlayerUtils.getPlayerColor(player, names.get()); + Color nameColor = PlayerUtils.getPlayerColor(player, this.nameColor.get()); if (player == mc.player) name = Modules.get().get(NameProtect.class).getName(player.getEntityName()); else name = player.getEntityName(); @@ -374,8 +422,7 @@ private void renderNametagPlayer(PlayerEntity player, boolean shadow) { if (displayGameMode.get()) width += gmWidth; if (displayPing.get()) width += pingWidth; - if (displayDistance.get() && renderPlayerDistance) - width += distWidth; + if (displayDistance.get() && renderPlayerDistance) width += distWidth; double widthHalf = width / 2; double heightDown = text.getHeight(shadow); @@ -387,13 +434,18 @@ private void renderNametagPlayer(PlayerEntity player, boolean shadow) { double hX = -widthHalf; double hY = -heightDown; - if (displayGameMode.get()) hX = text.render(gmText, hX, hY, GOLD, shadow); + if (displayGameMode.get()) hX = text.render(gmText, hX, hY, gamemodeColor.get(), shadow); hX = text.render(name, hX, hY, nameColor, shadow); hX = text.render(healthText, hX, hY, healthColor, shadow); - if (displayPing.get()) hX = text.render(pingText, hX, hY, BLUE, shadow); - if (displayDistance.get() && renderPlayerDistance) - text.render(distText, hX, hY, GREY, shadow); + if (displayPing.get()) hX = text.render(pingText, hX, hY, pingColor.get(), shadow); + if (displayDistance.get() && renderPlayerDistance) { + switch (distanceColorMode.get()) { + case Flat -> text.render(distText, hX, hY, distanceColor.get(), shadow); + case Gradient -> text.render(distText, hX, hY, EntityUtils.getColorFromDistance(player), shadow); + } + } + text.end(); if (displayItems.get()) { @@ -411,12 +463,12 @@ private void renderNametagPlayer(PlayerEntity player, boolean shadow) { if (!itemStack.isEmpty()) hasItems = true; - if (displayItemEnchants.get()) { + if (displayEnchants.get()) { Map enchantments = EnchantmentHelper.get(itemStack); int size = 0; for (var enchantment : enchantments.keySet()) { - if (ignoredEnchantments.get().contains(enchantment)) continue; + if (!shownEnchantments.get().contains(enchantment)) continue; String enchantName = Utils.getEnchantSimpleName(enchantment, enchantLength.get()) + " " + enchantments.get(enchantment); itemWidths[i] = Math.max(itemWidths[i], (text.getWidth(enchantName, shadow) / 2)); size++; @@ -440,14 +492,14 @@ private void renderNametagPlayer(PlayerEntity player, boolean shadow) { RenderUtils.drawItem(stack, (int) x, (int) y, 2, true); - if (maxEnchantCount > 0 && displayItemEnchants.get()) { + if (maxEnchantCount > 0 && displayEnchants.get()) { text.begin(0.5 * enchantTextScale.get(), false, true); Map enchantments = EnchantmentHelper.get(stack); Map enchantmentsToShow = new HashMap<>(); for (Enchantment enchantment : enchantments.keySet()) { - if (!ignoredEnchantments.get().contains(enchantment)) { + if (shownEnchantments.get().contains(enchantment)) { enchantmentsToShow.put(enchantment, enchantments.get(enchantment)); } } @@ -483,7 +535,7 @@ private void renderNametagPlayer(PlayerEntity player, boolean shadow) { x += itemWidths[i]; } - } else if (displayItemEnchants.get()) displayItemEnchants.set(false); + } else if (displayEnchants.get()) displayEnchants.set(false); NametagUtils.end(); } @@ -509,7 +561,7 @@ private void renderNametagItem(ItemStack stack, boolean shadow) { double hX = -widthHalf; double hY = -heightDown; - hX = text.render(name, hX, hY, names.get(), shadow); + hX = text.render(name, hX, hY, nameColor.get(), shadow); if (itemCount.get()) text.render(count, hX, hY, GOLD, shadow); text.end(); @@ -549,7 +601,7 @@ private void renderGenericNametag(LivingEntity entity, boolean shadow) { double hX = -widthHalf; double hY = -heightDown; - hX = text.render(nameText, hX, hY, names.get(), shadow); + hX = text.render(nameText, hX, hY, nameColor.get(), shadow); text.render(healthText, hX, hY, healthColor, shadow); text.end(); @@ -573,7 +625,7 @@ private void renderTntNametag(TntEntity entity, boolean shadow) { double hX = -widthHalf; double hY = -heightDown; - text.render(fuseText, hX, hY, names.get(), shadow); + text.render(fuseText, hX, hY, nameColor.get(), shadow); text.end(); NametagUtils.end(); @@ -602,8 +654,13 @@ public enum Position { OnTop } + public enum DistanceColorMode { + Gradient, + Flat; + } + public boolean excludeBots() { - return excludeBots.get(); + return ignoreBots.get(); } public boolean playerNametags() { diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/NoRender.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/NoRender.java index 2f12c15eb1..2c5a1c3f01 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/NoRender.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/NoRender.java @@ -27,13 +27,6 @@ public class NoRender extends Module { // Overlay - private final Setting noHurtCam = sgOverlay.add(new BoolSetting.Builder() - .name("hurt-cam") - .description("Disables rendering of the hurt camera effect.") - .defaultValue(false) - .build() - ); - private final Setting noPortalOverlay = sgOverlay.add(new BoolSetting.Builder() .name("portal-overlay") .description("Disables rendering of the nether portal overlay.") @@ -118,6 +111,13 @@ public class NoRender extends Module { .build() ); + private final Setting noEnchantGlint = sgOverlay.add(new BoolSetting.Builder() + .name("enchantment-glint") + .description("Disables rending of the enchantment glint.") + .defaultValue(false) + .build() + ); + // HUD private final Setting noBossBar = sgHUD.add(new BoolSetting.Builder() @@ -148,6 +148,13 @@ public class NoRender extends Module { .build() ); + private final Setting noObfuscation = sgHUD.add(new BoolSetting.Builder() + .name("obfuscation") + .description("Disables obfuscation styling of characters.") + .defaultValue(false) + .build() + ); + private final Setting noPotionIcons = sgHUD.add(new BoolSetting.Builder() .name("potion-icons") .description("Disables rendering of status effect icons.") @@ -227,6 +234,13 @@ public class NoRender extends Module { .build() ); + private final Setting noBeaconBeams = sgWorld.add(new BoolSetting.Builder() + .name("beacon-beams") + .description("Disables rendering of beacon beams.") + .defaultValue(false) + .build() + ); + private final Setting noFallingBlocks = sgWorld.add(new BoolSetting.Builder() .name("falling-blocks") .description("Disables rendering of falling blocks.") @@ -338,10 +352,6 @@ public NoRender() { // Overlay - public boolean noHurtCam() { - return isActive() && noHurtCam.get(); - } - public boolean noPortalOverlay() { return isActive() && noPortalOverlay.get(); } @@ -390,6 +400,10 @@ public boolean noEatParticles() { return isActive() && noEatParticles.get(); } + public boolean noEnchantGlint() { + return isActive() && noEnchantGlint.get(); + } + // HUD public boolean noBossBar() { @@ -408,6 +422,10 @@ public boolean noHeldItemName() { return isActive() && noHeldItemName.get(); } + public boolean noObfuscation() { + return isActive() && noObfuscation.get(); + } + public boolean noPotionIcons() { return isActive() && noPotionIcons.get(); } @@ -454,6 +472,10 @@ public boolean noSkylightUpdates() { return isActive() && noSkylightUpdates.get(); } + public boolean noBeaconBeams() { + return isActive() && noBeaconBeams.get(); + } + public boolean noFallingBlocks() { return isActive() && noFallingBlocks.get(); } diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/Tracers.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/Tracers.java index 7313e9c492..91eb51e149 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/Tracers.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/Tracers.java @@ -32,7 +32,7 @@ public class Tracers extends Module { // General private final Setting>> entities = sgGeneral.add(new EntityTypeListSetting.Builder() - .name("entites") + .name("entities") .description("Select specific entities.") .defaultValue(EntityType.PLAYER) .build() diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/WaypointsModule.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/WaypointsModule.java index 52e754f94c..45b64bf019 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/WaypointsModule.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/WaypointsModule.java @@ -98,7 +98,7 @@ public void addDeath(Vec3d deathPos) { Waypoint waypoint = new Waypoint.Builder() .name("Death " + time) .icon("skull") - .pos(new BlockPos(deathPos).up(2)) + .pos(BlockPos.ofFloored(deathPos).up(2)) .dimension(PlayerUtils.getDimension()) .build(); diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/search/Search.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/blockesp/BlockESP.java similarity index 80% rename from src/main/java/meteordevelopment/meteorclient/systems/modules/render/search/Search.java rename to src/main/java/meteordevelopment/meteorclient/systems/modules/render/blockesp/BlockESP.java index 9e377fb4eb..36e27a477c 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/search/Search.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/blockesp/BlockESP.java @@ -3,7 +3,7 @@ * Copyright (c) Meteor Development. */ -package meteordevelopment.meteorclient.systems.modules.render.search; +package meteordevelopment.meteorclient.systems.modules.render.blockesp; import it.unimi.dsi.fastutil.longs.Long2ObjectMap; import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; @@ -32,7 +32,7 @@ import java.util.List; import java.util.Map; -public class Search extends Module { +public class BlockESP extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); // General @@ -46,11 +46,11 @@ public class Search extends Module { .build() ); - private final Setting defaultBlockConfig = sgGeneral.add(new GenericSetting.Builder() + private final Setting defaultBlockConfig = sgGeneral.add(new GenericSetting.Builder() .name("default-block-config") .description("Default block config.") .defaultValue( - new SBlockData( + new ESPBlockData( ShapeMode.Lines, new SettingColor(0, 255, 200), new SettingColor(0, 255, 200, 25), @@ -61,7 +61,7 @@ public class Search extends Module { .build() ); - private final Setting> blockConfigs = sgGeneral.add(new BlockDataSetting.Builder() + private final Setting> blockConfigs = sgGeneral.add(new BlockDataSetting.Builder() .name("block-configs") .description("Config for each block.") .defaultData(defaultBlockConfig) @@ -77,13 +77,13 @@ public class Search extends Module { private final BlockPos.Mutable blockPos = new BlockPos.Mutable(); - private final Long2ObjectMap chunks = new Long2ObjectOpenHashMap<>(); - private final List groups = new UnorderedArrayList<>(); + private final Long2ObjectMap chunks = new Long2ObjectOpenHashMap<>(); + private final List groups = new UnorderedArrayList<>(); private Dimension lastDimension; - public Search() { - super(Categories.Render, "search", "Searches for specified blocks.", "base", "cave", "finder"); + public BlockESP() { + super(Categories.Render, "block-esp", "Renders specified blocks through walls.", "search", "base", "cave", "finder"); RainbowColors.register(this::onTickRainbow); } @@ -114,38 +114,38 @@ private void onTickRainbow() { if (!isActive()) return; defaultBlockConfig.get().tickRainbow(); - for (SBlockData blockData : blockConfigs.get().values()) blockData.tickRainbow(); + for (ESPBlockData blockData : blockConfigs.get().values()) blockData.tickRainbow(); } - SBlockData getBlockData(Block block) { - SBlockData blockData = blockConfigs.get().get(block); + ESPBlockData getBlockData(Block block) { + ESPBlockData blockData = blockConfigs.get().get(block); return blockData == null ? defaultBlockConfig.get() : blockData; } private void updateChunk(int x, int z) { - SChunk chunk = chunks.get(ChunkPos.toLong(x, z)); + ESPChunk chunk = chunks.get(ChunkPos.toLong(x, z)); if (chunk != null) chunk.update(); } private void updateBlock(int x, int y, int z) { - SChunk chunk = chunks.get(ChunkPos.toLong(x >> 4, z >> 4)); + ESPChunk chunk = chunks.get(ChunkPos.toLong(x >> 4, z >> 4)); if (chunk != null) chunk.update(x, y, z); } - public SBlock getBlock(int x, int y, int z) { - SChunk chunk = chunks.get(ChunkPos.toLong(x >> 4, z >> 4)); + public ESPBlock getBlock(int x, int y, int z) { + ESPChunk chunk = chunks.get(ChunkPos.toLong(x >> 4, z >> 4)); return chunk == null ? null : chunk.get(x, y, z); } - public SGroup newGroup(Block block) { + public ESPGroup newGroup(Block block) { synchronized (chunks) { - SGroup group = new SGroup(block); + ESPGroup group = new ESPGroup(block); groups.add(group); return group; } } - public void removeGroup(SGroup group) { + public void removeGroup(ESPGroup group) { synchronized (chunks) { groups.remove(group); } @@ -159,7 +159,7 @@ private void onChunkData(ChunkDataEvent event) { private void searchChunk(Chunk chunk, ChunkDataEvent event) { MeteorExecutor.execute(() -> { if (!isActive()) return; - SChunk schunk = SChunk.searchChunk(chunk, blocks.get()); + ESPChunk schunk = ESPChunk.searchChunk(chunk, blocks.get()); if (schunk.size() > 0) { synchronized (chunks) { @@ -195,10 +195,10 @@ private void onBlockUpdate(BlockUpdateEvent event) { if (added || removed) { MeteorExecutor.execute(() -> { synchronized (chunks) { - SChunk chunk = chunks.get(key); + ESPChunk chunk = chunks.get(key); if (chunk == null) { - chunk = new SChunk(chunkX, chunkZ); + chunk = new ESPChunk(chunkX, chunkZ); if (chunk.shouldBeDeleted()) return; chunks.put(key, chunk); @@ -236,12 +236,12 @@ private void onPostTick(TickEvent.Post event) { @EventHandler private void onRender(Render3DEvent event) { synchronized (chunks) { - for (Iterator it = chunks.values().iterator(); it.hasNext();) { - SChunk chunk = it.next(); + for (Iterator it = chunks.values().iterator(); it.hasNext();) { + ESPChunk chunk = it.next(); if (chunk.shouldBeDeleted()) { MeteorExecutor.execute(() -> { - for (SBlock block : chunk.blocks.values()) { + for (ESPBlock block : chunk.blocks.values()) { block.group.remove(block, false); block.loaded = false; } @@ -253,8 +253,8 @@ private void onRender(Render3DEvent event) { } if (tracers.get()) { - for (Iterator it = groups.iterator(); it.hasNext();) { - SGroup group = it.next(); + for (Iterator it = groups.iterator(); it.hasNext();) { + ESPGroup group = it.next(); if (group.blocks.isEmpty()) it.remove(); else group.render(event); diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/search/SBlock.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/blockesp/ESPBlock.java similarity index 92% rename from src/main/java/meteordevelopment/meteorclient/systems/modules/render/search/SBlock.java rename to src/main/java/meteordevelopment/meteorclient/systems/modules/render/blockesp/ESPBlock.java index e0725d8235..47e4f160a9 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/search/SBlock.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/blockesp/ESPBlock.java @@ -3,7 +3,7 @@ * Copyright (c) Meteor Development. */ -package meteordevelopment.meteorclient.systems.modules.render.search; +package meteordevelopment.meteorclient.systems.modules.render.blockesp; import meteordevelopment.meteorclient.events.render.Render3DEvent; import meteordevelopment.meteorclient.renderer.ShapeMode; @@ -17,10 +17,10 @@ import static meteordevelopment.meteorclient.MeteorClient.mc; -public class SBlock { +public class ESPBlock { private static final BlockPos.Mutable blockPos = new BlockPos.Mutable(); - private static final Search search = Modules.get().get(Search.class); + private static final BlockESP blockEsp = Modules.get().get(BlockESP.class); public static final int FO = 1 << 1; public static final int FO_RI = 1 << 2; @@ -48,36 +48,36 @@ public class SBlock { private BlockState state; public int neighbours; - public SGroup group; + public ESPGroup group; public boolean loaded = true; - public SBlock(int x, int y, int z) { + public ESPBlock(int x, int y, int z) { this.x = x; this.y = y; this.z = z; } - public SBlock getSideBlock(int side) { + public ESPBlock getSideBlock(int side) { switch (side) { - case FO: return search.getBlock(x, y, z + 1); - case BA: return search.getBlock(x, y, z - 1); - case LE: return search.getBlock(x - 1, y, z); - case RI: return search.getBlock(x + 1, y, z); - case TO: return search.getBlock(x, y + 1, z); - case BO: return search.getBlock(x, y - 1, z); + case FO: return blockEsp.getBlock(x, y, z + 1); + case BA: return blockEsp.getBlock(x, y, z - 1); + case LE: return blockEsp.getBlock(x - 1, y, z); + case RI: return blockEsp.getBlock(x + 1, y, z); + case TO: return blockEsp.getBlock(x, y + 1, z); + case BO: return blockEsp.getBlock(x, y - 1, z); } return null; } private void assignGroup() { - SGroup firstGroup = null; + ESPGroup firstGroup = null; for (int side : SIDES) { if ((neighbours & side) != side) continue; - SBlock neighbour = getSideBlock(side); + ESPBlock neighbour = getSideBlock(side); if (neighbour == null || neighbour.group == null) continue; if (firstGroup == null) { @@ -89,7 +89,7 @@ private void assignGroup() { } if (firstGroup == null) { - firstGroup = search.newGroup(state.getBlock()); + firstGroup = blockEsp.newGroup(state.getBlock()); } firstGroup.add(this); @@ -188,7 +188,7 @@ public void render(Render3DEvent event) { z2 = z + shape.getMax(Direction.Axis.Z); } - SBlockData blockData = search.getBlockData(state.getBlock()); + ESPBlockData blockData = blockEsp.getBlockData(state.getBlock()); ShapeMode shapeMode = blockData.shapeMode; Color lineColor = blockData.lineColor; diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/search/SBlockData.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/blockesp/ESPBlockData.java similarity index 77% rename from src/main/java/meteordevelopment/meteorclient/systems/modules/render/search/SBlockData.java rename to src/main/java/meteordevelopment/meteorclient/systems/modules/render/blockesp/ESPBlockData.java index fcc1817685..3905455cf0 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/search/SBlockData.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/blockesp/ESPBlockData.java @@ -3,7 +3,7 @@ * Copyright (c) Meteor Development. */ -package meteordevelopment.meteorclient.systems.modules.render.search; +package meteordevelopment.meteorclient.systems.modules.render.blockesp; import meteordevelopment.meteorclient.gui.GuiTheme; import meteordevelopment.meteorclient.gui.WidgetScreen; @@ -18,7 +18,7 @@ import net.minecraft.block.Block; import net.minecraft.nbt.NbtCompound; -public class SBlockData implements ICopyable, ISerializable, IChangeable, IBlockData, IScreenFactory { +public class ESPBlockData implements ICopyable, ISerializable, IChangeable, IBlockData, IScreenFactory { public ShapeMode shapeMode; public SettingColor lineColor; public SettingColor sideColor; @@ -28,7 +28,7 @@ public class SBlockData implements ICopyable, ISerializable setting) { - return new SBlockDataScreen(theme, this, block, setting); + public WidgetScreen createScreen(GuiTheme theme, Block block, BlockDataSetting setting) { + return new ESPBlockDataScreen(theme, this, block, setting); } @Override public WidgetScreen createScreen(GuiTheme theme) { - return new SBlockDataScreen(theme, this, null, null); + return new ESPBlockDataScreen(theme, this, null, null); } @Override @@ -63,7 +63,7 @@ public void tickRainbow() { } @Override - public SBlockData set(SBlockData value) { + public ESPBlockData set(ESPBlockData value) { shapeMode = value.shapeMode; lineColor.set(value.lineColor); sideColor.set(value.sideColor); @@ -77,8 +77,8 @@ public SBlockData set(SBlockData value) { } @Override - public SBlockData copy() { - return new SBlockData(shapeMode, new SettingColor(lineColor), new SettingColor(sideColor), tracer, new SettingColor(tracerColor)); + public ESPBlockData copy() { + return new ESPBlockData(shapeMode, new SettingColor(lineColor), new SettingColor(sideColor), tracer, new SettingColor(tracerColor)); } @Override @@ -98,7 +98,7 @@ public NbtCompound toTag() { } @Override - public SBlockData fromTag(NbtCompound tag) { + public ESPBlockData fromTag(NbtCompound tag) { shapeMode = ShapeMode.valueOf(tag.getString("shapeMode")); lineColor.fromTag(tag.getCompound("lineColor")); sideColor.fromTag(tag.getCompound("sideColor")); diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/search/SBlockDataScreen.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/blockesp/ESPBlockDataScreen.java similarity index 88% rename from src/main/java/meteordevelopment/meteorclient/systems/modules/render/search/SBlockDataScreen.java rename to src/main/java/meteordevelopment/meteorclient/systems/modules/render/blockesp/ESPBlockDataScreen.java index dd4a9e85c3..2686b88b6d 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/search/SBlockDataScreen.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/blockesp/ESPBlockDataScreen.java @@ -3,7 +3,7 @@ * Copyright (c) Meteor Development. */ -package meteordevelopment.meteorclient.systems.modules.render.search; +package meteordevelopment.meteorclient.systems.modules.render.blockesp; import meteordevelopment.meteorclient.gui.GuiTheme; import meteordevelopment.meteorclient.gui.WindowScreen; @@ -12,12 +12,12 @@ import meteordevelopment.meteorclient.utils.render.color.SettingColor; import net.minecraft.block.Block; -public class SBlockDataScreen extends WindowScreen { - private final SBlockData blockData; +public class ESPBlockDataScreen extends WindowScreen { + private final ESPBlockData blockData; private final Block block; - private final BlockDataSetting setting; + private final BlockDataSetting setting; - public SBlockDataScreen(GuiTheme theme, SBlockData blockData, Block block, BlockDataSetting setting) { + public ESPBlockDataScreen(GuiTheme theme, ESPBlockData blockData, Block block, BlockDataSetting setting) { super(theme, "Configure Block"); this.blockData = blockData; @@ -95,7 +95,7 @@ public void initWidgets() { add(theme.settings(settings)).expandX(); } - private void changed(SBlockData blockData, Block block, BlockDataSetting setting) { + private void changed(ESPBlockData blockData, Block block, BlockDataSetting setting) { if (!blockData.isChanged() && block != null && setting != null) { setting.get().put(block, blockData); setting.onChanged(); diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/search/SChunk.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/blockesp/ESPChunk.java similarity index 76% rename from src/main/java/meteordevelopment/meteorclient/systems/modules/render/search/SChunk.java rename to src/main/java/meteordevelopment/meteorclient/systems/modules/render/blockesp/ESPChunk.java index ffbc1a20f5..cc39ce2a30 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/search/SChunk.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/blockesp/ESPChunk.java @@ -3,7 +3,7 @@ * Copyright (c) Meteor Development. */ -package meteordevelopment.meteorclient.systems.modules.render.search; +package meteordevelopment.meteorclient.systems.modules.render.blockesp; import it.unimi.dsi.fastutil.longs.Long2ObjectMap; import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; @@ -20,26 +20,26 @@ import static meteordevelopment.meteorclient.MeteorClient.mc; import static meteordevelopment.meteorclient.utils.Utils.getRenderDistance; -public class SChunk { +public class ESPChunk { private static final BlockPos.Mutable blockPos = new BlockPos.Mutable(); private final int x, z; - public Long2ObjectMap blocks; + public Long2ObjectMap blocks; - public SChunk(int x, int z) { + public ESPChunk(int x, int z) { this.x = x; this.z = z; } - public SBlock get(int x, int y, int z) { - return blocks == null ? null : blocks.get(SBlock.getKey(x, y, z)); + public ESPBlock get(int x, int y, int z) { + return blocks == null ? null : blocks.get(ESPBlock.getKey(x, y, z)); } public void add(BlockPos blockPos, boolean update) { - SBlock block = new SBlock(blockPos.getX(), blockPos.getY(), blockPos.getZ()); + ESPBlock block = new ESPBlock(blockPos.getX(), blockPos.getY(), blockPos.getZ()); if (blocks == null) blocks = new Long2ObjectOpenHashMap<>(64); - blocks.put(SBlock.getKey(blockPos), block); + blocks.put(ESPBlock.getKey(blockPos), block); if (update) block.update(); } @@ -50,20 +50,20 @@ public void add(BlockPos blockPos) { public void remove(BlockPos blockPos) { if (blocks != null) { - SBlock block = blocks.remove(SBlock.getKey(blockPos)); + ESPBlock block = blocks.remove(ESPBlock.getKey(blockPos)); if (block != null) block.group.remove(block); } } public void update() { if (blocks != null) { - for (SBlock block : blocks.values()) block.update(); + for (ESPBlock block : blocks.values()) block.update(); } } public void update(int x, int y, int z) { if (blocks != null) { - SBlock block = blocks.get(SBlock.getKey(x, y, z)); + ESPBlock block = blocks.get(ESPBlock.getKey(x, y, z)); if (block != null) block.update(); } } @@ -82,13 +82,13 @@ public boolean shouldBeDeleted() { public void render(Render3DEvent event) { if (blocks != null) { - for (SBlock block : blocks.values()) block.render(event); + for (ESPBlock block : blocks.values()) block.render(event); } } - public static SChunk searchChunk(Chunk chunk, List blocks) { - SChunk schunk = new SChunk(chunk.getPos().x, chunk.getPos().z); + public static ESPChunk searchChunk(Chunk chunk, List blocks) { + ESPChunk schunk = new ESPChunk(chunk.getPos().x, chunk.getPos().z); if (schunk.shouldBeDeleted()) return schunk; for (int x = chunk.getPos().getStartX(); x <= chunk.getPos().getEndX(); x++) { diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/search/SGroup.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/blockesp/ESPGroup.java similarity index 61% rename from src/main/java/meteordevelopment/meteorclient/systems/modules/render/search/SGroup.java rename to src/main/java/meteordevelopment/meteorclient/systems/modules/render/blockesp/ESPGroup.java index 8950812c14..6f4c109f2f 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/search/SGroup.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/blockesp/ESPGroup.java @@ -3,7 +3,7 @@ * Copyright (c) Meteor Development. */ -package meteordevelopment.meteorclient.systems.modules.render.search; +package meteordevelopment.meteorclient.systems.modules.render.blockesp; import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; import meteordevelopment.meteorclient.events.render.Render3DEvent; @@ -16,20 +16,20 @@ import java.util.Queue; import java.util.Set; -public class SGroup { - private static final Search search = Modules.get().get(Search.class); +public class ESPGroup { + private static final BlockESP blockEsp = Modules.get().get(BlockESP.class); private final Block block; - public final UnorderedArrayList blocks = new UnorderedArrayList<>(); + public final UnorderedArrayList blocks = new UnorderedArrayList<>(); private double sumX, sumY, sumZ; - public SGroup(Block block) { + public ESPGroup(Block block) { this.block = block; } - public void add(SBlock block, boolean removeFromOld, boolean splitGroup) { + public void add(ESPBlock block, boolean removeFromOld, boolean splitGroup) { blocks.add(block); sumX += block.x; sumY += block.y; @@ -39,39 +39,39 @@ public void add(SBlock block, boolean removeFromOld, boolean splitGroup) { block.group = this; } - public void add(SBlock block) { + public void add(ESPBlock block) { add(block, true, true); } - public void remove(SBlock block, boolean splitGroup) { + public void remove(ESPBlock block, boolean splitGroup) { blocks.remove(block); sumX -= block.x; sumY -= block.y; sumZ -= block.z; - if (blocks.isEmpty()) search.removeGroup(block.group); + if (blocks.isEmpty()) blockEsp.removeGroup(block.group); else if (splitGroup) { trySplit(block); } } - public void remove(SBlock block) { + public void remove(ESPBlock block) { remove(block, true); } - private void trySplit(SBlock block) { - Set neighbours = new ObjectOpenHashSet<>(6); + private void trySplit(ESPBlock block) { + Set neighbours = new ObjectOpenHashSet<>(6); - for (int side : SBlock.SIDES) { + for (int side : ESPBlock.SIDES) { if ((block.neighbours & side) == side) { - SBlock neighbour = block.getSideBlock(side); + ESPBlock neighbour = block.getSideBlock(side); if (neighbour != null) neighbours.add(neighbour); } } if (neighbours.size() <= 1) return; - Set remainingBlocks = new ObjectOpenHashSet<>(blocks); - Queue blocksToCheck = new ArrayDeque<>(); + Set remainingBlocks = new ObjectOpenHashSet<>(blocks); + Queue blocksToCheck = new ArrayDeque<>(); blocksToCheck.offer(blocks.get(0)); remainingBlocks.remove(blocks.get(0)); @@ -79,11 +79,11 @@ private void trySplit(SBlock block) { loop: { while (!blocksToCheck.isEmpty()) { - SBlock b = blocksToCheck.poll(); + ESPBlock b = blocksToCheck.poll(); - for (int side : SBlock.SIDES) { + for (int side : ESPBlock.SIDES) { if ((b.neighbours & side) != side) continue; - SBlock neighbour = b.getSideBlock(side); + ESPBlock neighbour = b.getSideBlock(side); if (neighbour != null && remainingBlocks.contains(neighbour)) { blocksToCheck.offer(neighbour); @@ -97,12 +97,12 @@ private void trySplit(SBlock block) { } if (neighbours.size() > 0) { - SGroup group = search.newGroup(this.block); + ESPGroup group = blockEsp.newGroup(this.block); group.blocks.ensureCapacity(remainingBlocks.size()); blocks.removeIf(remainingBlocks::contains); - for (SBlock b : remainingBlocks) { + for (ESPBlock b : remainingBlocks) { group.add(b, false, false); sumX -= b.x; @@ -113,18 +113,18 @@ private void trySplit(SBlock block) { if (neighbours.size() > 1) { block.neighbours = 0; - for (SBlock b : neighbours) { + for (ESPBlock b : neighbours) { int x = b.x - block.x; - if (x == 1) block.neighbours |= SBlock.RI; - else if (x == -1) block.neighbours |= SBlock.LE; + if (x == 1) block.neighbours |= ESPBlock.RI; + else if (x == -1) block.neighbours |= ESPBlock.LE; int y = b.y - block.y; - if (y == 1) block.neighbours |= SBlock.TO; - else if (y == -1) block.neighbours |= SBlock.BO; + if (y == 1) block.neighbours |= ESPBlock.TO; + else if (y == -1) block.neighbours |= ESPBlock.BO; int z = b.z - block.z; - if (z == 1) block.neighbours |= SBlock.FO; - else if (z == -1) block.neighbours |= SBlock.BA; + if (z == 1) block.neighbours |= ESPBlock.FO; + else if (z == -1) block.neighbours |= ESPBlock.BA; } group.trySplit(block); @@ -132,14 +132,14 @@ private void trySplit(SBlock block) { } } - public void merge(SGroup group) { + public void merge(ESPGroup group) { blocks.ensureCapacity(blocks.size() + group.blocks.size()); - for (SBlock block : group.blocks) add(block, false, false); - search.removeGroup(group); + for (ESPBlock block : group.blocks) add(block, false, false); + blockEsp.removeGroup(group); } public void render(Render3DEvent event) { - SBlockData blockData = search.getBlockData(block); + ESPBlockData blockData = blockEsp.getBlockData(block); if (blockData.tracer) { event.renderer.line(RenderUtils.center.x, RenderUtils.center.y, RenderUtils.center.z, sumX / blocks.size() + 0.5, sumY / blocks.size() + 0.5, sumZ / blocks.size() + 0.5, blockData.tracerColor); diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/world/AntiCactus.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/world/AntiCactus.java deleted file mode 100644 index 499c06ea22..0000000000 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/world/AntiCactus.java +++ /dev/null @@ -1,15 +0,0 @@ -/* - * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). - * Copyright (c) Meteor Development. - */ - -package meteordevelopment.meteorclient.systems.modules.world; - -import meteordevelopment.meteorclient.systems.modules.Categories; -import meteordevelopment.meteorclient.systems.modules.Module; - -public class AntiCactus extends Module { - public AntiCactus() { - super(Categories.World, "anti-cactus", "Prevents you from taking damage from cacti."); - } -} diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/world/AutoShearer.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/world/AutoShearer.java index eca4c48b3a..c18b473d95 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/world/AutoShearer.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/world/AutoShearer.java @@ -20,7 +20,6 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.passive.SheepEntity; import net.minecraft.item.Items; -import net.minecraft.item.ShearsItem; import net.minecraft.util.Hand; public class AutoShearer extends Module { @@ -49,7 +48,7 @@ public class AutoShearer extends Module { ); private Entity entity; - private boolean offHand; + private Hand hand; public AutoShearer() { super(Categories.World, "auto-shearer", "Automatically shears sheep."); @@ -67,38 +66,21 @@ private void onTick(TickEvent.Pre event) { for (Entity entity : mc.world.getEntities()) { if (!(entity instanceof SheepEntity) || ((SheepEntity) entity).isSheared() || ((SheepEntity) entity).isBaby() || !PlayerUtils.isWithin(entity, distance.get())) continue; - boolean findNewShears = false; - if (mc.player.getInventory().getMainHandStack().getItem() instanceof ShearsItem) { - if (antiBreak.get() && mc.player.getInventory().getMainHandStack().getDamage() >= mc.player.getInventory().getMainHandStack().getMaxDamage() - 1) findNewShears = true; - } - else if (mc.player.getInventory().offHand.get(0).getItem() instanceof ShearsItem) { - if (antiBreak.get() && mc.player.getInventory().offHand.get(0).getDamage() >= mc.player.getInventory().offHand.get(0).getMaxDamage() - 1) findNewShears = true; - else offHand = true; - } - else { - findNewShears = true; - } - - boolean foundShears = !findNewShears; - if (findNewShears) { - FindItemResult shears = InvUtils.findInHotbar(itemStack -> (!antiBreak.get() || (antiBreak.get() && itemStack.getDamage() < itemStack.getMaxDamage() - 1)) && itemStack.getItem() == Items.SHEARS); - - if (InvUtils.swap(shears.slot(), true)) foundShears = true; - } - - if (foundShears) { - this.entity = entity; - - if (rotate.get()) Rotations.rotate(Rotations.getYaw(entity), Rotations.getPitch(entity), -100, this::interact); - else interact(); - - return; - } + FindItemResult findShear = InvUtils.findInHotbar(itemStack -> itemStack.getItem() == Items.SHEARS && (!antiBreak.get() || itemStack.getDamage() < itemStack.getMaxDamage() - 1)); + if (!InvUtils.swap(findShear.slot(), true)) return; + + this.hand = findShear.getHand(); + this.entity = entity; + + if (rotate.get()) Rotations.rotate(Rotations.getYaw(entity), Rotations.getPitch(entity), -100, this::interact); + else interact(); + + return; } } private void interact() { - mc.interactionManager.interactEntity(mc.player, entity, offHand ? Hand.OFF_HAND : Hand.MAIN_HAND); + mc.interactionManager.interactEntity(mc.player, entity, hand); InvUtils.swapBack(); } } diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/world/Collisions.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/world/Collisions.java new file mode 100644 index 0000000000..0c441ba7c5 --- /dev/null +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/world/Collisions.java @@ -0,0 +1,118 @@ +/* + * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). + * Copyright (c) Meteor Development. + */ + +package meteordevelopment.meteorclient.systems.modules.world; + +import meteordevelopment.meteorclient.events.entity.player.PlayerMoveEvent; +import meteordevelopment.meteorclient.events.packets.PacketEvent; +import meteordevelopment.meteorclient.events.world.CollisionShapeEvent; +import meteordevelopment.meteorclient.mixininterface.IVec3d; +import meteordevelopment.meteorclient.settings.BlockListSetting; +import meteordevelopment.meteorclient.settings.BoolSetting; +import meteordevelopment.meteorclient.settings.Setting; +import meteordevelopment.meteorclient.settings.SettingGroup; +import meteordevelopment.meteorclient.systems.modules.Categories; +import meteordevelopment.meteorclient.systems.modules.Module; +import meteordevelopment.orbit.EventHandler; +import net.minecraft.block.*; +import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket; +import net.minecraft.network.packet.c2s.play.VehicleMoveC2SPacket; +import net.minecraft.util.shape.VoxelShapes; + +import java.util.List; + +public class Collisions extends Module { + private final SettingGroup sgGeneral = settings.getDefaultGroup(); + + public final Setting> blocks = sgGeneral.add(new BlockListSetting.Builder() + .name("blocks") + .description("What blocks should be added collision box.") + .filter(this::blockFilter) + .build() + ); + + private final Setting magma = sgGeneral.add(new BoolSetting.Builder() + .name("magma") + .description("Prevents you from walking over magma blocks.") + .defaultValue(false) + .build() + ); + + private final Setting unloadedChunks = sgGeneral.add(new BoolSetting.Builder() + .name("unloaded-chunks") + .description("Stops you from going into unloaded chunks.") + .defaultValue(false) + .build() + ); + + private final Setting ignoreBorder = sgGeneral.add(new BoolSetting.Builder() + .name("ignore-border") + .description("Removes world border collision.") + .defaultValue(false) + .build() + ); + + public Collisions() { + super(Categories.World, "collisions", "Adds collision boxes to certain blocks/areas."); + } + + @EventHandler + private void onCollisionShape(CollisionShapeEvent event) { + if (mc.world == null || mc.player == null) return; + if (!event.state.getFluidState().isEmpty()) return; + if (blocks.get().contains(event.state.getBlock())) { + event.shape = VoxelShapes.fullCube(); + } else if (magma.get() && !mc.player.isSneaking() + && event.state.isAir() + && mc.world.getBlockState(event.pos.down()).getBlock() == Blocks.MAGMA_BLOCK) { + event.shape = VoxelShapes.fullCube(); + } + } + + @EventHandler + private void onPlayerMove(PlayerMoveEvent event) { + int x = (int) (mc.player.getX() + event.movement.x) >> 4; + int z = (int) (mc.player.getZ() + event.movement.z) >> 4; + if (unloadedChunks.get() && !mc.world.getChunkManager().isChunkLoaded(x, z)) { + ((IVec3d) event.movement).set(0, event.movement.y, 0); + } + } + + @EventHandler + private void onPacketSend(PacketEvent.Send event) { + if (!unloadedChunks.get()) return; + if (event.packet instanceof VehicleMoveC2SPacket packet) { + if (!mc.world.getChunkManager().isChunkLoaded((int) packet.getX() >> 4, (int) packet.getZ() >> 4)) { + mc.player.getVehicle().updatePosition(mc.player.getVehicle().prevX, mc.player.getVehicle().prevY, mc.player.getVehicle().prevZ); + event.cancel(); + } + } else if (event.packet instanceof PlayerMoveC2SPacket packet) { + if (!mc.world.getChunkManager().isChunkLoaded((int) packet.getX(mc.player.getX()) >> 4, (int) packet.getZ(mc.player.getZ()) >> 4)) { + event.cancel(); + } + } + } + + private boolean blockFilter(Block block) { + return (block instanceof AbstractFireBlock + || block instanceof AbstractPressurePlateBlock + || block instanceof TripwireBlock + || block instanceof TripwireHookBlock + || block instanceof CobwebBlock + || block instanceof CampfireBlock + || block instanceof SweetBerryBushBlock + || block instanceof CactusBlock + || block instanceof AbstractRailBlock + || block instanceof TrapdoorBlock + || block instanceof PowderSnowBlock + || block instanceof AbstractCauldronBlock + || block instanceof HoneyBlock + ); + } + + public boolean ignoreBorder() { + return isActive() && ignoreBorder.get(); + } +} diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/world/Flamethrower.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/world/Flamethrower.java index 52a636653d..4fc268ce4b 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/world/Flamethrower.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/world/Flamethrower.java @@ -10,6 +10,7 @@ import meteordevelopment.meteorclient.settings.*; import meteordevelopment.meteorclient.systems.modules.Categories; import meteordevelopment.meteorclient.systems.modules.Module; +import meteordevelopment.meteorclient.utils.player.FindItemResult; import meteordevelopment.meteorclient.utils.player.InvUtils; import meteordevelopment.meteorclient.utils.player.PlayerUtils; import meteordevelopment.meteorclient.utils.player.Rotations; @@ -85,6 +86,7 @@ public class Flamethrower extends Module { private Entity entity; private int ticks = 0; + private Hand hand; public Flamethrower() { super(Categories.World, "flamethrower", "Ignites every alive piece of food."); @@ -105,16 +107,16 @@ private void onTick(TickEvent.Pre event) { if (entity == mc.player) continue; if (!targetBabies.get() && entity instanceof LivingEntity && ((LivingEntity)entity).isBaby()) continue; - boolean success = selectSlot(); + FindItemResult findFlintAndSteel = InvUtils.findInHotbar(itemStack -> itemStack.getItem() == Items.FLINT_AND_STEEL && (!antiBreak.get() || itemStack.getDamage() < itemStack.getMaxDamage() - 1)); + if (!InvUtils.swap(findFlintAndSteel.slot(), true)) return; - if (success) { - this.entity = entity; + this.hand = findFlintAndSteel.getHand(); + this.entity = entity; - if (rotate.get()) Rotations.rotate(Rotations.getYaw(entity.getBlockPos()), Rotations.getPitch(entity.getBlockPos()), -100, this::interact); - else interact(); + if (rotate.get()) Rotations.rotate(Rotations.getYaw(entity.getBlockPos()), Rotations.getPitch(entity.getBlockPos()), -100, this::interact); + else interact(); - return; - } + return; } } @@ -132,7 +134,7 @@ private void interact() { mc.interactionManager.attackBlock(entity.getBlockPos().south(), Direction.DOWN); } else { if (ticks >= tickInterval.get() && !entity.isOnFire()) { - mc.interactionManager.interactBlock(mc.player, Hand.MAIN_HAND, new BlockHitResult( + mc.interactionManager.interactBlock(mc.player, hand, new BlockHitResult( entity.getPos().subtract(new Vec3d(0, 1, 0)), Direction.UP, entity.getBlockPos().down(), false)); ticks = 0; } @@ -140,23 +142,4 @@ private void interact() { InvUtils.swapBack(); } - - private boolean selectSlot() { - boolean findNewFlintAndSteel = false; - if (mc.player.getInventory().getMainHandStack().getItem() == Items.FLINT_AND_STEEL) { - if (antiBreak.get() && mc.player.getInventory().getMainHandStack().getDamage() >= mc.player.getInventory().getMainHandStack().getMaxDamage() - 1) - findNewFlintAndSteel = true; - } else if (mc.player.getInventory().offHand.get(0).getItem() == Items.FLINT_AND_STEEL) { - if (antiBreak.get() && mc.player.getInventory().offHand.get(0).getDamage() >= mc.player.getInventory().offHand.get(0).getMaxDamage() - 1) - findNewFlintAndSteel = true; - } else { - findNewFlintAndSteel = true; - } - - boolean foundFlintAndSteel = !findNewFlintAndSteel; - if (findNewFlintAndSteel) { - foundFlintAndSteel = InvUtils.swap(InvUtils.findInHotbar(itemStack -> (!antiBreak.get() || (antiBreak.get() && itemStack.getDamage() < itemStack.getMaxDamage() - 1)) && itemStack.getItem() == Items.FLINT_AND_STEEL).slot(), true); - } - return foundFlintAndSteel; - } } diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/world/Nuker.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/world/Nuker.java index b4e6059e9f..ca691ea6cd 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/world/Nuker.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/world/Nuker.java @@ -5,6 +5,7 @@ package meteordevelopment.meteorclient.systems.modules.world; +import meteordevelopment.meteorclient.events.entity.player.BlockBreakingCooldownEvent; import meteordevelopment.meteorclient.events.render.Render3DEvent; import meteordevelopment.meteorclient.events.world.TickEvent; import meteordevelopment.meteorclient.renderer.ShapeMode; @@ -18,6 +19,7 @@ import meteordevelopment.meteorclient.utils.world.BlockIterator; import meteordevelopment.meteorclient.utils.world.BlockUtils; import meteordevelopment.orbit.EventHandler; +import meteordevelopment.orbit.EventPriority; import net.minecraft.block.Block; import net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket; import net.minecraft.util.Hand; @@ -419,6 +421,11 @@ else if (sortMode.get() != SortMode.None) blocks.clear(); }); } + + @EventHandler(priority = EventPriority.HIGHEST) + private void onBlockBreakingCooldown(BlockBreakingCooldownEvent event) { + event.cooldown = 0; + } public enum ListMode { Whitelist, diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/world/PacketMine.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/world/PacketMine.java index 9d9489dbe1..73f2f8d3f8 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/world/PacketMine.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/world/PacketMine.java @@ -202,51 +202,6 @@ private void onRender(Render3DEvent event) { } } - private double getBreakDelta(int slot, BlockState state) { - float hardness = state.getHardness(null, null); - if (hardness == -1) return 0; - else { - return getBlockBreakingSpeed(slot, state) / hardness / (!state.isToolRequired() || mc.player.getInventory().main.get(slot).isSuitableFor(state) ? 30 : 100); - } - } - - private double getBlockBreakingSpeed(int slot, BlockState block) { - double speed = mc.player.getInventory().main.get(slot).getMiningSpeedMultiplier(block); - - if (speed > 1) { - ItemStack tool = mc.player.getInventory().getStack(slot); - - int efficiency = EnchantmentHelper.getLevel(Enchantments.EFFICIENCY, tool); - - if (efficiency > 0 && !tool.isEmpty()) speed += efficiency * efficiency + 1; - } - - if (StatusEffectUtil.hasHaste(mc.player)) { - speed *= 1 + (StatusEffectUtil.getHasteAmplifier(mc.player) + 1) * 0.2F; - } - - if (mc.player.hasStatusEffect(StatusEffects.MINING_FATIGUE)) { - float k = switch (mc.player.getStatusEffect(StatusEffects.MINING_FATIGUE).getAmplifier()) { - case 0 -> 0.3F; - case 1 -> 0.09F; - case 2 -> 0.0027F; - default -> 8.1E-4F; - }; - - speed *= k; - } - - if (mc.player.isSubmergedIn(FluidTags.WATER) && !EnchantmentHelper.hasAquaAffinity(mc.player)) { - speed /= 5.0F; - } - - if (!mc.player.isOnGround()) { - speed /= 5.0F; - } - - return speed; - } - public class MyBlock { public BlockPos blockPos; public BlockState blockState; @@ -301,7 +256,7 @@ public void mine() { } } - progress += getBreakDelta(bestSlot != -1 ? bestSlot : mc.player.getInventory().selectedSlot, blockState); + progress += BlockUtils.getBreakDelta(bestSlot != -1 ? bestSlot : mc.player.getInventory().selectedSlot, blockState); } private void sendMinePackets() { diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/world/StashFinder.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/world/StashFinder.java index 373c5111b9..5c8ae85e55 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/world/StashFinder.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/world/StashFinder.java @@ -270,6 +270,11 @@ private File getCsvFile() { return new File(new File(new File(MeteorClient.FOLDER, "stashes"), Utils.getFileWorldName()), "stashes.csv"); } + @Override + public String getInfoString() { + return String.valueOf(chunks.size()); + } + public enum Mode { Chat, Toast, diff --git a/src/main/java/meteordevelopment/meteorclient/utils/ReflectInit.java b/src/main/java/meteordevelopment/meteorclient/utils/ReflectInit.java index 47ca5ca2b3..1baf3b15ad 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/ReflectInit.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/ReflectInit.java @@ -18,27 +18,31 @@ import java.util.stream.Collectors; public class ReflectInit { - private static final List packages = new ArrayList<>(); + private static final List reflections = new ArrayList<>(); public static void registerPackages() { - packages.add(MeteorClient.ADDON.getPackage()); + add(MeteorClient.ADDON); + for (MeteorAddon addon : AddonManager.ADDONS) { try { - String pkg = addon.getPackage(); - if (pkg != null && !pkg.isBlank()) { - packages.add(pkg); - } + add(addon); } catch (AbstractMethodError e) { throw new RuntimeException("Addon \"%s\" is too old and cannot be ran.".formatted(addon.name), e); } } } + private static void add(MeteorAddon addon) { + String pkg = addon.getPackage(); + if (pkg == null || pkg.isBlank()) return; + reflections.add(new Reflections(pkg, Scanners.MethodsAnnotated)); + } + public static void init(Class annotation) { - for (String pkg : packages) { - Reflections reflections = new Reflections(pkg, Scanners.MethodsAnnotated); - Set initTasks = reflections.getMethodsAnnotatedWith(annotation); + for (Reflections reflection : reflections) { + Set initTasks = reflection.getMethodsAnnotatedWith(annotation); if (initTasks == null) return; + Map, List> byClass = initTasks.stream().collect(Collectors.groupingBy(Method::getDeclaringClass)); Set left = new HashSet<>(initTasks); diff --git a/src/main/java/meteordevelopment/meteorclient/utils/Utils.java b/src/main/java/meteordevelopment/meteorclient/utils/Utils.java index 66f4a7487c..8c33c08a80 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/Utils.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/Utils.java @@ -87,17 +87,25 @@ private static void onTick(TickEvent.Post event) { } } - public static double getPlayerSpeed() { - if (mc.player == null) return 0; + public static Vec3d getPlayerSpeed() { + if (mc.player == null) return Vec3d.ZERO; - double tX = Math.abs(mc.player.getX() - mc.player.prevX); - double tZ = Math.abs(mc.player.getZ() - mc.player.prevZ); - double length = Math.sqrt(tX * tX + tZ * tZ); + double tX = mc.player.getX() - mc.player.prevX; + double tY = mc.player.getY() - mc.player.prevY; + double tZ = mc.player.getZ() - mc.player.prevZ; Timer timer = Modules.get().get(Timer.class); - if (timer.isActive()) length *= Modules.get().get(Timer.class).getMultiplier(); + if (timer.isActive()) { + tX *= timer.getMultiplier(); + tY *= timer.getMultiplier(); + tZ *= timer.getMultiplier(); + } + + tX *= 20; + tY *= 20; + tZ *= 20; - return length * 20; + return new Vec3d(tX, tY, tZ); } public static String getWorldTime() { diff --git a/src/main/java/meteordevelopment/meteorclient/utils/entity/EntityUtils.java b/src/main/java/meteordevelopment/meteorclient/utils/entity/EntityUtils.java index de1f48ab54..42e8d0df08 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/entity/EntityUtils.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/entity/EntityUtils.java @@ -14,6 +14,8 @@ import meteordevelopment.meteorclient.mixin.WorldAccessor; import meteordevelopment.meteorclient.utils.player.PlayerUtils; import meteordevelopment.meteorclient.utils.render.color.Color; +import net.minecraft.block.AirBlock; +import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.block.entity.BlockEntity; @@ -25,6 +27,7 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.fluid.Fluid; import net.minecraft.fluid.Fluids; +import net.minecraft.registry.entry.RegistryEntry; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Box; import net.minecraft.util.math.ChunkSectionPos; @@ -35,15 +38,16 @@ import net.minecraft.world.entity.SectionedEntityCache; import net.minecraft.world.entity.SimpleEntityLookup; -import java.util.ArrayList; -import java.util.Comparator; -import java.util.List; +import javax.annotation.Nullable; +import java.util.*; import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.Predicate; import static meteordevelopment.meteorclient.MeteorClient.mc; public class EntityUtils { + private static BlockPos.Mutable testPos = new BlockPos.Mutable(); + public static boolean isAttackable(EntityType type) { return type != EntityType.AREA_EFFECT_CLOUD && type != EntityType.ARROW && type != EntityType.FALLING_BLOCK && type != EntityType.FIREWORK_ROCKET && type != EntityType.ITEM && type != EntityType.LLAMA_SPIT && type != EntityType.SPECTRAL_ARROW && type != EntityType.ENDER_PEARL && type != EntityType.EXPERIENCE_BOTTLE && type != EntityType.POTION && type != EntityType.TRIDENT && type != EntityType.LIGHTNING_BOLT && type != EntityType.FISHING_BOBBER && type != EntityType.EXPERIENCE_ORB && type != EntityType.EGG; } @@ -109,28 +113,28 @@ public static boolean isInRenderDistance(double posX, double posZ) { return x < d && z < d; } - public static List getSurroundBlocks(PlayerEntity player) { + public static BlockPos getCityBlock(PlayerEntity player) { if (player == null) return null; - List positions = new ArrayList<>(); + double bestDistance = 6; + Direction bestDirection = null; - for (Direction direction : Direction.values()) { - if (direction == Direction.UP || direction == Direction.DOWN) continue; + for (Direction direction : Direction.HORIZONTAL) { + testPos.set(player.getBlockPos().offset(direction)); - BlockPos pos = player.getBlockPos().offset(direction); + Block block = mc.world.getBlockState(testPos).getBlock(); + if (block != Blocks.OBSIDIAN && block != Blocks.NETHERITE_BLOCK && block != Blocks.CRYING_OBSIDIAN + && block != Blocks.RESPAWN_ANCHOR && block != Blocks.ANCIENT_DEBRIS) continue; - if (mc.world.getBlockState(pos).getBlock() == Blocks.OBSIDIAN) { - positions.add(pos); + double testDistance = PlayerUtils.distanceTo(testPos); + if (testDistance < bestDistance) { + bestDistance = testDistance; + bestDirection = direction; } } - return positions; - } - - public static BlockPos getCityBlock(PlayerEntity player) { - List posList = getSurroundBlocks(player); - posList.sort(Comparator.comparingDouble(PlayerUtils::squaredDistanceTo)); - return posList.isEmpty() ? null : posList.get(0); + if (bestDirection == null) return null; + return player.getBlockPos().offset(bestDirection); } public static String getName(Entity entity) { diff --git a/src/main/java/meteordevelopment/meteorclient/utils/entity/TargetUtils.java b/src/main/java/meteordevelopment/meteorclient/utils/entity/TargetUtils.java index cb174d4274..b1721767ce 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/entity/TargetUtils.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/entity/TargetUtils.java @@ -101,6 +101,6 @@ private static int sortAngle(Entity e1, Entity e2) { double e1pitch = Math.abs(Rotations.getPitch(e1) - mc.player.getPitch()); double e2pitch = Math.abs(Rotations.getPitch(e2) - mc.player.getPitch()); - return Double.compare(Math.sqrt(e1yaw * e1yaw + e1pitch * e1pitch), Math.sqrt(e2yaw * e2yaw + e2pitch * e2pitch)); + return Double.compare(e1yaw * e1yaw + e1pitch * e1pitch, e2yaw * e2yaw + e2pitch * e2pitch); } } diff --git a/src/main/java/meteordevelopment/meteorclient/utils/entity/fakeplayer/FakePlayerEntity.java b/src/main/java/meteordevelopment/meteorclient/utils/entity/fakeplayer/FakePlayerEntity.java index a0ee18223b..4ddc217c9e 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/entity/fakeplayer/FakePlayerEntity.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/entity/fakeplayer/FakePlayerEntity.java @@ -5,18 +5,21 @@ package meteordevelopment.meteorclient.utils.entity.fakeplayer; +import com.mojang.authlib.GameProfile; import net.minecraft.client.network.OtherClientPlayerEntity; import net.minecraft.client.network.PlayerListEntry; import net.minecraft.entity.player.PlayerEntity; import org.jetbrains.annotations.Nullable; +import java.util.UUID; + import static meteordevelopment.meteorclient.MeteorClient.mc; public class FakePlayerEntity extends OtherClientPlayerEntity { public boolean doNotPush, hideWhenInsideCamera; public FakePlayerEntity(PlayerEntity player, String name, float health, boolean copyInv) { - super(mc.world, player.getGameProfile()); + super(mc.world, new GameProfile(UUID.randomUUID(), name)); copyPositionAndRotation(player); diff --git a/src/main/java/meteordevelopment/meteorclient/utils/entity/fakeplayer/FakePlayerManager.java b/src/main/java/meteordevelopment/meteorclient/utils/entity/fakeplayer/FakePlayerManager.java index ff071968a4..b6fe58d550 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/entity/fakeplayer/FakePlayerManager.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/entity/fakeplayer/FakePlayerManager.java @@ -17,6 +17,10 @@ public class FakePlayerManager { private static final List ENTITIES = new ArrayList<>(); + public static List getFakePlayers() { + return ENTITIES; + } + public static FakePlayerEntity get(String name) { for (FakePlayerEntity fp : ENTITIES) { if (fp.getEntityName().equals(name)) return fp; diff --git a/src/main/java/meteordevelopment/meteorclient/utils/misc/MeteorStarscript.java b/src/main/java/meteordevelopment/meteorclient/utils/misc/MeteorStarscript.java index 5adce7ed9b..7ad7106a47 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/misc/MeteorStarscript.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/misc/MeteorStarscript.java @@ -74,7 +74,6 @@ public static void init() { StandardLib.init(ss); // General - ss.set("version", MeteorClient.VERSION != null ? MeteorClient.VERSION.toString() : ""); ss.set("mc_version", SharedConstants.getGameVersion().getName()); ss.set("fps", () -> Value.number(MinecraftClientAccessor.getFps())); ss.set("ping", MeteorStarscript::ping); @@ -82,10 +81,13 @@ public static void init() { // Meteor ss.set("meteor", new ValueMap() + .set("name", MeteorClient.NAME) + .set("version", MeteorClient.VERSION != null ? MeteorClient.VERSION.toString() : "") .set("modules", () -> Value.number(Modules.get().getAll().size())) .set("active_modules", () -> Value.number(Modules.get().getActive().size())) .set("is_module_active", MeteorStarscript::isModuleActive) .set("get_module_info", MeteorStarscript::getModuleInfo) + .set("prefix", MeteorStarscript::getMeteorPrefix) ); // Baritone @@ -121,7 +123,14 @@ public static void init() { .set("_toString", () -> Value.string(mc.getSession().getUsername())) .set("health", () -> Value.number(mc.player != null ? mc.player.getHealth() : 0)) .set("hunger", () -> Value.number(mc.player != null ? mc.player.getHungerManager().getFoodLevel() : 0)) - .set("speed", () -> Value.number(Utils.getPlayerSpeed())) + + .set("speed", () -> Value.number(Utils.getPlayerSpeed().horizontalLength())) + .set("speed_all", new ValueMap() + .set("_toString", () -> Value.string(mc.player != null ? Utils.getPlayerSpeed().toString() : "")) + .set("x", () -> Value.number(mc.player != null ? Utils.getPlayerSpeed().x : 0)) + .set("y", () -> Value.number(mc.player != null ? Utils.getPlayerSpeed().y : 0)) + .set("z", () -> Value.number(mc.player != null ? Utils.getPlayerSpeed().z : 0)) + ) .set("breaking_progress", () -> Value.number(mc.interactionManager != null ? ((ClientPlayerInteractionManagerAccessor) mc.interactionManager).getBreakingProgress() : 0)) .set("biome", MeteorStarscript::biome) @@ -220,12 +229,12 @@ public static void printChatError(int i, Error error) { String caller = getCallerName(); if (caller != null) { - if (i != -1) ChatUtils.error("Starscript", "%d, %d '%c': %s (from %s)", i, error.character, error.ch, error.message, caller); - else ChatUtils.error("Starscript", "%d '%c': %s (from %s)", error.character, error.ch, error.message, caller); + if (i != -1) ChatUtils.errorPrefix("Starscript", "%d, %d '%c': %s (from %s)", i, error.character, error.ch, error.message, caller); + else ChatUtils.errorPrefix("Starscript", "%d '%c': %s (from %s)", error.character, error.ch, error.message, caller); } else { - if (i != -1) ChatUtils.error("Starscript", "%d, %d '%c': %s", i, error.character, error.ch, error.message); - else ChatUtils.error("Starscript", "%d '%c': %s", error.character, error.ch, error.message); + if (i != -1) ChatUtils.errorPrefix("Starscript", "%d, %d '%c': %s", i, error.character, error.ch, error.message); + else ChatUtils.errorPrefix("Starscript", "%d '%c': %s", error.character, error.ch, error.message); } } @@ -236,8 +245,8 @@ public static void printChatError(Error error) { public static void printChatError(StarscriptError e) { String caller = getCallerName(); - if (caller != null) ChatUtils.error("Starscript", "%s (from %s)", e.getMessage(), caller); - else ChatUtils.error("Starscript", "%s", e.getMessage()); + if (caller != null) ChatUtils.errorPrefix("Starscript", "%s (from %s)", e.getMessage(), caller); + else ChatUtils.errorPrefix("Starscript", "%s", e.getMessage()); } private static String getCallerName() { @@ -365,6 +374,11 @@ private static Value countItems(Starscript ss, int argCount) { return Value.number(count); } + private static Value getMeteorPrefix() { + if (Config.get() == null) return Value.null_(); + return Value.string(Config.get().prefix.get()); + } + // Other private static Value baritoneProcess() { diff --git a/src/main/java/meteordevelopment/meteorclient/utils/misc/input/KeyBinds.java b/src/main/java/meteordevelopment/meteorclient/utils/misc/input/KeyBinds.java index 362b66f77b..067f6cb7ae 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/misc/input/KeyBinds.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/misc/input/KeyBinds.java @@ -21,4 +21,7 @@ public class KeyBinds { public static int getKey(KeyBinding bind) { return ((KeyBindingAccessor) bind).getKey().getCode(); } + + public static void ensureInitialized() { + } } diff --git a/src/main/java/meteordevelopment/meteorclient/utils/misc/text/TextUtils.java b/src/main/java/meteordevelopment/meteorclient/utils/misc/text/TextUtils.java index d31e31f62b..a89ab36e81 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/misc/text/TextUtils.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/misc/text/TextUtils.java @@ -5,6 +5,8 @@ package meteordevelopment.meteorclient.utils.misc.text; +import it.unimi.dsi.fastutil.objects.Object2IntMap; +import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; import meteordevelopment.meteorclient.utils.render.color.Color; import net.minecraft.text.MutableText; import net.minecraft.text.OrderedText; @@ -21,7 +23,7 @@ public static List toColoredTextList(Text text) { Stack stack = new Stack<>(); List coloredTexts = new ArrayList<>(); preOrderTraverse(text, stack, coloredTexts); - coloredTexts.removeIf(e -> e.getText().equals("")); + coloredTexts.removeIf(e -> e.getText().isEmpty()); return coloredTexts; } @@ -44,15 +46,15 @@ public static MutableText parseOrderedText(OrderedText orderedText) { * Returns the {@link Color} that is most prevalent through the given {@link Text} * * @param text the {@link Text} to scan through - * @return You know what it returns. Read the docs! Also, returns white if the internal {@link Optional} is empty + * @return You know what it returns. Read the docs! Also, returns white if the internal {@link Object2IntMap.Entry} is null */ public static Color getMostPopularColor(Text text) { - Comparator integerComparator = Comparator.naturalOrder(); - Optional> optionalColor = getColoredCharacterCount(toColoredTextList(text)) - .entrySet().stream() - .max((a, b) -> integerComparator.compare(a.getValue(), b.getValue())); - - return optionalColor.map(Map.Entry::getKey).orElse(new Color(255, 255, 255)); + Object2IntMap.Entry biggestEntry = null; + for (var entry : getColoredCharacterCount(toColoredTextList(text)).object2IntEntrySet()) { + if (biggestEntry == null) biggestEntry = entry; + else if (entry.getIntValue() > biggestEntry.getIntValue()) biggestEntry = entry; + } + return biggestEntry == null ? new Color(255, 255, 255) : biggestEntry.getKey(); } /** @@ -64,13 +66,13 @@ public static Color getMostPopularColor(Text text) { * if the argument for this function is fed from the return from {@link #toColoredTextList(Text)}), and the corresponding values being {@link Integer}s * representing the number of occurrences of text that bear that color. The order of the keys are in no particular order */ - public static Map getColoredCharacterCount(List coloredTexts) { - Map colorCount = new HashMap<>(); + public static Object2IntMap getColoredCharacterCount(List coloredTexts) { + Object2IntMap colorCount = new Object2IntOpenHashMap<>(); for (ColoredText coloredText : coloredTexts) { if (colorCount.containsKey(coloredText.getColor())) { // Since color was already catalogued, simply update the record by adding the length of the new text segment to the old one - colorCount.put(coloredText.getColor(), colorCount.get(coloredText.getColor()) + coloredText.getText().length()); + colorCount.put(coloredText.getColor(), colorCount.getInt(coloredText.getColor()) + coloredText.getText().length()); } else { // Add new entry to the hashmap colorCount.put(coloredText.getColor(), coloredText.getText().length()); diff --git a/src/main/java/meteordevelopment/meteorclient/utils/network/PacketUtils.java b/src/main/java/meteordevelopment/meteorclient/utils/network/PacketUtils.java index 35ecc1fdef..a84f836088 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/network/PacketUtils.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/network/PacketUtils.java @@ -9,7 +9,7 @@ import com.mojang.datafixers.util.Pair; import com.mojang.serialization.Lifecycle; import meteordevelopment.meteorclient.utils.misc.MeteorIdentifier; -import net.minecraft.network.Packet; +import net.minecraft.network.packet.Packet; import net.minecraft.registry.Registry; import net.minecraft.registry.RegistryKey; import net.minecraft.registry.SimpleRegistry; @@ -19,7 +19,6 @@ import net.minecraft.util.Identifier; import net.minecraft.util.math.random.Random; import org.jetbrains.annotations.NotNull; - import java.util.*; import java.util.stream.Stream; @@ -89,14 +88,16 @@ public class PacketUtils { C2S_PACKETS_R.put("PlayerMoveC2SPacket", net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket.class); C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.PickFromInventoryC2SPacket.class, "PickFromInventoryC2SPacket"); C2S_PACKETS_R.put("PickFromInventoryC2SPacket", net.minecraft.network.packet.c2s.play.PickFromInventoryC2SPacket.class); + C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.PlayerSessionC2SPacket.class, "PlayerSessionC2SPacket"); + C2S_PACKETS_R.put("PlayerSessionC2SPacket", net.minecraft.network.packet.c2s.play.PlayerSessionC2SPacket.class); C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.CloseHandledScreenC2SPacket.class, "CloseHandledScreenC2SPacket"); C2S_PACKETS_R.put("CloseHandledScreenC2SPacket", net.minecraft.network.packet.c2s.play.CloseHandledScreenC2SPacket.class); C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.BoatPaddleStateC2SPacket.class, "BoatPaddleStateC2SPacket"); C2S_PACKETS_R.put("BoatPaddleStateC2SPacket", net.minecraft.network.packet.c2s.play.BoatPaddleStateC2SPacket.class); - C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.ChatMessageC2SPacket.class, "ChatMessageC2SPacket"); - C2S_PACKETS_R.put("ChatMessageC2SPacket", net.minecraft.network.packet.c2s.play.ChatMessageC2SPacket.class); C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.ButtonClickC2SPacket.class, "ButtonClickC2SPacket"); C2S_PACKETS_R.put("ButtonClickC2SPacket", net.minecraft.network.packet.c2s.play.ButtonClickC2SPacket.class); + C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.ChatMessageC2SPacket.class, "ChatMessageC2SPacket"); + C2S_PACKETS_R.put("ChatMessageC2SPacket", net.minecraft.network.packet.c2s.play.ChatMessageC2SPacket.class); C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.UpdateBeaconC2SPacket.class, "UpdateBeaconC2SPacket"); C2S_PACKETS_R.put("UpdateBeaconC2SPacket", net.minecraft.network.packet.c2s.play.UpdateBeaconC2SPacket.class); C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.UpdateSignC2SPacket.class, "UpdateSignC2SPacket"); @@ -117,18 +118,18 @@ public class PacketUtils { C2S_PACKETS_R.put("UpdateJigsawC2SPacket", net.minecraft.network.packet.c2s.play.UpdateJigsawC2SPacket.class); C2S_PACKETS.put(net.minecraft.network.packet.c2s.query.QueryPingC2SPacket.class, "QueryPingC2SPacket"); C2S_PACKETS_R.put("QueryPingC2SPacket", net.minecraft.network.packet.c2s.query.QueryPingC2SPacket.class); - C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.ResourcePackStatusC2SPacket.class, "ResourcePackStatusC2SPacket"); - C2S_PACKETS_R.put("ResourcePackStatusC2SPacket", net.minecraft.network.packet.c2s.play.ResourcePackStatusC2SPacket.class); C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.PlayPongC2SPacket.class, "PlayPongC2SPacket"); C2S_PACKETS_R.put("PlayPongC2SPacket", net.minecraft.network.packet.c2s.play.PlayPongC2SPacket.class); + C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.ResourcePackStatusC2SPacket.class, "ResourcePackStatusC2SPacket"); + C2S_PACKETS_R.put("ResourcePackStatusC2SPacket", net.minecraft.network.packet.c2s.play.ResourcePackStatusC2SPacket.class); + C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.MessageAcknowledgmentC2SPacket.class, "MessageAcknowledgmentC2SPacket"); + C2S_PACKETS_R.put("MessageAcknowledgmentC2SPacket", net.minecraft.network.packet.c2s.play.MessageAcknowledgmentC2SPacket.class); C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.CreativeInventoryActionC2SPacket.class, "CreativeInventoryActionC2SPacket"); C2S_PACKETS_R.put("CreativeInventoryActionC2SPacket", net.minecraft.network.packet.c2s.play.CreativeInventoryActionC2SPacket.class); C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.VehicleMoveC2SPacket.class, "VehicleMoveC2SPacket"); C2S_PACKETS_R.put("VehicleMoveC2SPacket", net.minecraft.network.packet.c2s.play.VehicleMoveC2SPacket.class); C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.BookUpdateC2SPacket.class, "BookUpdateC2SPacket"); C2S_PACKETS_R.put("BookUpdateC2SPacket", net.minecraft.network.packet.c2s.play.BookUpdateC2SPacket.class); - //C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.RequestChatPreviewC2SPacket.class, "RequestChatPreviewC2SPacket"); - //C2S_PACKETS_R.put("RequestChatPreviewC2SPacket", net.minecraft.network.packet.c2s.play.RequestChatPreviewC2SPacket.class); C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.RecipeBookDataC2SPacket.class, "RecipeBookDataC2SPacket"); C2S_PACKETS_R.put("RecipeBookDataC2SPacket", net.minecraft.network.packet.c2s.play.RecipeBookDataC2SPacket.class); C2S_PACKETS.put(net.minecraft.network.packet.c2s.login.LoginQueryResponseC2SPacket.class, "LoginQueryResponseC2SPacket"); @@ -152,6 +153,8 @@ public class PacketUtils { S2C_PACKETS_R.put("WorldBorderSizeChangedS2CPacket", net.minecraft.network.packet.s2c.play.WorldBorderSizeChangedS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.AdvancementUpdateS2CPacket.class, "AdvancementUpdateS2CPacket"); S2C_PACKETS_R.put("AdvancementUpdateS2CPacket", net.minecraft.network.packet.s2c.play.AdvancementUpdateS2CPacket.class); + S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.FeaturesS2CPacket.class, "FeaturesS2CPacket"); + S2C_PACKETS_R.put("FeaturesS2CPacket", net.minecraft.network.packet.s2c.play.FeaturesS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.CustomPayloadS2CPacket.class, "CustomPayloadS2CPacket"); S2C_PACKETS_R.put("CustomPayloadS2CPacket", net.minecraft.network.packet.s2c.play.CustomPayloadS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.WorldBorderInterpolateSizeS2CPacket.class, "WorldBorderInterpolateSizeS2CPacket"); @@ -166,6 +169,8 @@ public class PacketUtils { S2C_PACKETS_R.put("PlayerListHeaderS2CPacket", net.minecraft.network.packet.s2c.play.PlayerListHeaderS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.EntitySpawnS2CPacket.class, "EntitySpawnS2CPacket"); S2C_PACKETS_R.put("EntitySpawnS2CPacket", net.minecraft.network.packet.s2c.play.EntitySpawnS2CPacket.class); + S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.RemoveMessageS2CPacket.class, "RemoveMessageS2CPacket"); + S2C_PACKETS_R.put("RemoveMessageS2CPacket", net.minecraft.network.packet.s2c.play.RemoveMessageS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.SetCameraEntityS2CPacket.class, "SetCameraEntityS2CPacket"); S2C_PACKETS_R.put("SetCameraEntityS2CPacket", net.minecraft.network.packet.s2c.play.SetCameraEntityS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.CraftFailedResponseS2CPacket.class, "CraftFailedResponseS2CPacket"); @@ -216,16 +221,18 @@ public class PacketUtils { S2C_PACKETS_R.put("CooldownUpdateS2CPacket", net.minecraft.network.packet.s2c.play.CooldownUpdateS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.OpenScreenS2CPacket.class, "OpenScreenS2CPacket"); S2C_PACKETS_R.put("OpenScreenS2CPacket", net.minecraft.network.packet.s2c.play.OpenScreenS2CPacket.class); - S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.ExperienceOrbSpawnS2CPacket.class, "ExperienceOrbSpawnS2CPacket"); - S2C_PACKETS_R.put("ExperienceOrbSpawnS2CPacket", net.minecraft.network.packet.s2c.play.ExperienceOrbSpawnS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.EntityAnimationS2CPacket.class, "EntityAnimationS2CPacket"); S2C_PACKETS_R.put("EntityAnimationS2CPacket", net.minecraft.network.packet.s2c.play.EntityAnimationS2CPacket.class); + S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.ExperienceOrbSpawnS2CPacket.class, "ExperienceOrbSpawnS2CPacket"); + S2C_PACKETS_R.put("ExperienceOrbSpawnS2CPacket", net.minecraft.network.packet.s2c.play.ExperienceOrbSpawnS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.PlayerAbilitiesS2CPacket.class, "PlayerAbilitiesS2CPacket"); S2C_PACKETS_R.put("PlayerAbilitiesS2CPacket", net.minecraft.network.packet.s2c.play.PlayerAbilitiesS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.WorldBorderWarningBlocksChangedS2CPacket.class, "WorldBorderWarningBlocksChangedS2CPacket"); S2C_PACKETS_R.put("WorldBorderWarningBlocksChangedS2CPacket", net.minecraft.network.packet.s2c.play.WorldBorderWarningBlocksChangedS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.EntitiesDestroyS2CPacket.class, "EntitiesDestroyS2CPacket"); S2C_PACKETS_R.put("EntitiesDestroyS2CPacket", net.minecraft.network.packet.s2c.play.EntitiesDestroyS2CPacket.class); + S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.PlayerRemoveS2CPacket.class, "PlayerRemoveS2CPacket"); + S2C_PACKETS_R.put("PlayerRemoveS2CPacket", net.minecraft.network.packet.s2c.play.PlayerRemoveS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.UnlockRecipesS2CPacket.class, "UnlockRecipesS2CPacket"); S2C_PACKETS_R.put("UnlockRecipesS2CPacket", net.minecraft.network.packet.s2c.play.UnlockRecipesS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.LightUpdateS2CPacket.class, "LightUpdateS2CPacket"); @@ -250,10 +257,14 @@ public class PacketUtils { S2C_PACKETS_R.put("ScreenHandlerPropertyUpdateS2CPacket", net.minecraft.network.packet.s2c.play.ScreenHandlerPropertyUpdateS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.SimulationDistanceS2CPacket.class, "SimulationDistanceS2CPacket"); S2C_PACKETS_R.put("SimulationDistanceS2CPacket", net.minecraft.network.packet.s2c.play.SimulationDistanceS2CPacket.class); + S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.ChatSuggestionsS2CPacket.class, "ChatSuggestionsS2CPacket"); + S2C_PACKETS_R.put("ChatSuggestionsS2CPacket", net.minecraft.network.packet.s2c.play.ChatSuggestionsS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.EnterCombatS2CPacket.class, "EnterCombatS2CPacket"); S2C_PACKETS_R.put("EnterCombatS2CPacket", net.minecraft.network.packet.s2c.play.EnterCombatS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.DeathMessageS2CPacket.class, "DeathMessageS2CPacket"); S2C_PACKETS_R.put("DeathMessageS2CPacket", net.minecraft.network.packet.s2c.play.DeathMessageS2CPacket.class); + S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.ProfilelessChatMessageS2CPacket.class, "ProfilelessChatMessageS2CPacket"); + S2C_PACKETS_R.put("ProfilelessChatMessageS2CPacket", net.minecraft.network.packet.s2c.play.ProfilelessChatMessageS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.MapUpdateS2CPacket.class, "MapUpdateS2CPacket"); S2C_PACKETS_R.put("MapUpdateS2CPacket", net.minecraft.network.packet.s2c.play.MapUpdateS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.ScreenHandlerSlotUpdateS2CPacket.class, "ScreenHandlerSlotUpdateS2CPacket"); @@ -287,6 +298,7 @@ public class PacketUtils { S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.ScoreboardPlayerUpdateS2CPacket.class, "ScoreboardPlayerUpdateS2CPacket"); S2C_PACKETS_R.put("ScoreboardPlayerUpdateS2CPacket", net.minecraft.network.packet.s2c.play.ScoreboardPlayerUpdateS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.query.QueryPongS2CPacket.class, "QueryPongS2CPacket"); + S2C_PACKETS_R.put("QueryPongS2CPacket", net.minecraft.network.packet.s2c.query.QueryPongS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.ChatMessageS2CPacket.class, "ChatMessageS2CPacket"); S2C_PACKETS_R.put("ChatMessageS2CPacket", net.minecraft.network.packet.s2c.play.ChatMessageS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.OpenWrittenBookS2CPacket.class, "OpenWrittenBookS2CPacket"); @@ -322,6 +334,8 @@ public class PacketUtils { S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.CloseScreenS2CPacket.class, "CloseScreenS2CPacket"); S2C_PACKETS_R.put("CloseScreenS2CPacket", net.minecraft.network.packet.s2c.play.CloseScreenS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.ScoreboardDisplayS2CPacket.class, "ScoreboardDisplayS2CPacket"); + S2C_PACKETS_R.put("ScoreboardDisplayS2CPacket", net.minecraft.network.packet.s2c.play.ScoreboardDisplayS2CPacket.class); + S2C_PACKETS.put(net.minecraft.network.packet.s2c.login.LoginSuccessS2CPacket.class, "LoginSuccessS2CPacket"); S2C_PACKETS_R.put("LoginSuccessS2CPacket", net.minecraft.network.packet.s2c.login.LoginSuccessS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.GameMessageS2CPacket.class, "GameMessageS2CPacket"); S2C_PACKETS_R.put("GameMessageS2CPacket", net.minecraft.network.packet.s2c.play.GameMessageS2CPacket.class); diff --git a/src/main/java/meteordevelopment/meteorclient/utils/network/PacketUtilsUtil.java b/src/main/java/meteordevelopment/meteorclient/utils/network/PacketUtilsUtil.java index d92f229b7f..3e01148d1b 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/network/PacketUtilsUtil.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/network/PacketUtilsUtil.java @@ -5,7 +5,7 @@ package meteordevelopment.meteorclient.utils.network; -import net.minecraft.network.Packet; +import net.minecraft.network.packet.Packet; import org.reflections.Reflections; import org.reflections.scanners.Scanners; @@ -156,10 +156,18 @@ public Set>>> getKeys() { } """; -// @PostInit + public static void main(String[] args) { + try { + init(); + } + catch (IOException e) { + throw new RuntimeException(e); + } + } + public static void init() throws IOException { // Generate PacketUtils.java - File file = new File(System.getProperty("user.dir") + "/PacketUtils.java"); + File file = new File("src/main/java/" + PacketUtilsUtil.class.getPackageName().replace('.', '/') + "/PacketUtils.java"); if (!file.exists()) { file.getParentFile().mkdirs(); file.createNewFile(); @@ -179,7 +187,7 @@ public static void init() throws IOException { writer.write("import com.mojang.datafixers.util.Pair;\n"); writer.write("import com.mojang.serialization.Lifecycle;\n"); writer.write("import meteordevelopment.meteorclient.utils.misc.MeteorIdentifier;\n"); - writer.write("import net.minecraft.network.Packet;\n"); + writer.write("import net.minecraft.network.packet.Packet;\n"); writer.write("import net.minecraft.registry.Registry;\n"); writer.write("import net.minecraft.registry.RegistryKey;\n"); writer.write("import net.minecraft.registry.SimpleRegistry;\n"); diff --git a/src/main/java/meteordevelopment/meteorclient/utils/notebot/NotebotUtils.java b/src/main/java/meteordevelopment/meteorclient/utils/notebot/NotebotUtils.java index 5d8113fe5b..e0383f20c0 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/notebot/NotebotUtils.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/notebot/NotebotUtils.java @@ -5,10 +5,12 @@ package meteordevelopment.meteorclient.utils.notebot; +import meteordevelopment.meteorclient.utils.notebot.instrumentdetect.InstrumentDetectFunction; import meteordevelopment.meteorclient.utils.notebot.song.Note; import net.minecraft.block.BlockState; import net.minecraft.block.NoteBlock; import net.minecraft.block.enums.Instrument; +import net.minecraft.util.math.BlockPos; import org.jetbrains.annotations.Nullable; import java.util.HashMap; @@ -16,11 +18,11 @@ public class NotebotUtils { - public static Note getNoteFromNoteBlock(BlockState noteBlock, NotebotMode mode) { + public static Note getNoteFromNoteBlock(BlockState noteBlock, BlockPos blockPos, NotebotMode mode, InstrumentDetectFunction instrumentDetectFunction) { Instrument instrument = null; int level = noteBlock.get(NoteBlock.NOTE); if (mode == NotebotMode.ExactInstruments) { - instrument = noteBlock.get(NoteBlock.INSTRUMENT); + instrument = instrumentDetectFunction.detectInstrument(noteBlock, blockPos); } return new Note(instrument, level); diff --git a/src/main/java/meteordevelopment/meteorclient/utils/notebot/decoder/NBSSongDecoder.java b/src/main/java/meteordevelopment/meteorclient/utils/notebot/decoder/NBSSongDecoder.java index ec282271ab..222cd5991e 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/notebot/decoder/NBSSongDecoder.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/notebot/decoder/NBSSongDecoder.java @@ -7,10 +7,10 @@ import com.google.common.collect.Multimap; import com.google.common.collect.MultimapBuilder; -import meteordevelopment.meteorclient.MeteorClient; import meteordevelopment.meteorclient.utils.notebot.song.Note; import meteordevelopment.meteorclient.utils.notebot.song.Song; import net.minecraft.block.enums.Instrument; +import org.jetbrains.annotations.NotNull; import java.io.*; @@ -31,109 +31,89 @@ public class NBSSongDecoder extends SongDecoder { * @return Song object representing a Note Block Studio project */ @Override - public Song parse(File songFile) { - try { - return parse(new FileInputStream(songFile), songFile); - } catch (FileNotFoundException e) { - e.printStackTrace(); - } - return null; - } - - /** - * Parses a Song from an InputStream - * @see Song - * @param inputStream of a Note Block Studio project file (.nbs) - * @return Song object from the InputStream - */ - public Song parse(InputStream inputStream) { - return parse(inputStream, null); // Source is unknown -> no file + @NotNull + public Song parse(File songFile) throws Exception { + return parse(new FileInputStream(songFile)); } /** * Parses a Song from an InputStream and a Note Block Studio project file (.nbs) * @see Song * @param inputStream of a .nbs file - * @param songFile representing a .nbs file * @return Song object representing the given .nbs file */ - private Song parse(InputStream inputStream, File songFile) { + @NotNull + private Song parse(InputStream inputStream) throws Exception { Multimap notesMap = MultimapBuilder.linkedHashKeys().arrayListValues().build(); - try { - DataInputStream dataInputStream = new DataInputStream(inputStream); - short length = readShort(dataInputStream); - int nbsversion = 0; - if (length == 0) { - nbsversion = dataInputStream.readByte(); - dataInputStream.readByte(); // first custom instrument - if (nbsversion >= 3) { - length = readShort(dataInputStream); - } - } - readShort(dataInputStream); // Song Height - String title = readString(dataInputStream); - String author = readString(dataInputStream); - readString(dataInputStream); // original author - readString(dataInputStream); // description - float speed = readShort(dataInputStream) / 100f; - dataInputStream.readBoolean(); // auto-save - dataInputStream.readByte(); // auto-save duration - dataInputStream.readByte(); // x/4ths, time signature - readInt(dataInputStream); // minutes spent on project - readInt(dataInputStream); // left clicks (why?) - readInt(dataInputStream); // right clicks (why?) - readInt(dataInputStream); // blocks added - readInt(dataInputStream); // blocks removed - readString(dataInputStream); // .mid/.schematic file name - if (nbsversion >= 4) { - dataInputStream.readByte(); // loop on/off - dataInputStream.readByte(); // max loop count - readShort(dataInputStream); // loop start tick + DataInputStream dataInputStream = new DataInputStream(inputStream); + short length = readShort(dataInputStream); + int nbsversion = 0; + if (length == 0) { + nbsversion = dataInputStream.readByte(); + dataInputStream.readByte(); // first custom instrument + if (nbsversion >= 3) { + length = readShort(dataInputStream); } + } + readShort(dataInputStream); // Song Height + String title = readString(dataInputStream); + String author = readString(dataInputStream); + readString(dataInputStream); // original author + readString(dataInputStream); // description + float speed = readShort(dataInputStream) / 100f; + dataInputStream.readBoolean(); // auto-save + dataInputStream.readByte(); // auto-save duration + dataInputStream.readByte(); // x/4ths, time signature + readInt(dataInputStream); // minutes spent on project + readInt(dataInputStream); // left clicks (why?) + readInt(dataInputStream); // right clicks (why?) + readInt(dataInputStream); // blocks added + readInt(dataInputStream); // blocks removed + readString(dataInputStream); // .mid/.schematic file name + if (nbsversion >= 4) { + dataInputStream.readByte(); // loop on/off + dataInputStream.readByte(); // max loop count + readShort(dataInputStream); // loop start tick + } - double tick = -1; + double tick = -1; + while (true) { + short jumpTicks = readShort(dataInputStream); // jumps till next tick + //System.out.println("Jumps to next tick: " + jumpTicks); + if (jumpTicks == 0) { + break; + } + tick += jumpTicks * (20f / speed); + //System.out.println("Tick: " + tick); + short layer = -1; while (true) { - short jumpTicks = readShort(dataInputStream); // jumps till next tick - //System.out.println("Jumps to next tick: " + jumpTicks); - if (jumpTicks == 0) { + short jumpLayers = readShort(dataInputStream); // jumps till next layer + if (jumpLayers == 0) { break; } - tick += jumpTicks * (20f / speed); - //System.out.println("Tick: " + tick); - short layer = -1; - while (true) { - short jumpLayers = readShort(dataInputStream); // jumps till next layer - if (jumpLayers == 0) { - break; - } - layer += jumpLayers; - //System.out.println("Layer: " + layer); - byte instrument = dataInputStream.readByte(); - - byte key = dataInputStream.readByte(); - if (nbsversion >= 4) { - dataInputStream.readByte(); // note block velocity - dataInputStream.readUnsignedByte(); // note panning, 0 is right in nbs format - readShort(dataInputStream); // note block pitch - } - - Note note = new Note(fromNBSInstrument(instrument) /* instrument */, key - NOTE_OFFSET /* note */); - setNote((int) Math.round(tick), note, notesMap); + layer += jumpLayers; + //System.out.println("Layer: " + layer); + byte instrument = dataInputStream.readByte(); + + byte key = dataInputStream.readByte(); + if (nbsversion >= 4) { + dataInputStream.readUnsignedByte(); // note block velocity + dataInputStream.readUnsignedByte(); // note panning, 0 is right in nbs format + readShort(dataInputStream); // note block pitch } - } - return new Song(notesMap, title, author); - } catch (EOFException e) { - String file = ""; - if (songFile != null) { - file = songFile.getName(); + Instrument inst = fromNBSInstrument(instrument); + + // Probably a custom instrument. Ignore this note + if (inst == null) continue; + + Note note = new Note(inst /* instrument */, key - NOTE_OFFSET /* note */); + setNote((int) Math.round(tick), note, notesMap); } - MeteorClient.LOG.error("Song is corrupted: " + file, e); - } catch (IOException e) { - e.printStackTrace(); } - return null; + + return new Song(notesMap, title, author); } /** @@ -162,6 +142,13 @@ private static int readInt(DataInputStream dataInputStream) throws IOException { private static String readString(DataInputStream dataInputStream) throws IOException { int length = readInt(dataInputStream); + if (length < 0) { + throw new EOFException("Length can't be negative! Length: " + length); + } + if (length > dataInputStream.available()) { + throw new EOFException("Can't read string that is larger than a buffer! Length: " + length + " Readable Bytes Length: " + dataInputStream.available()); + } + StringBuilder builder = new StringBuilder(length); for (; length > 0; --length) { char c = (char) dataInputStream.readByte(); diff --git a/src/main/java/meteordevelopment/meteorclient/utils/notebot/decoder/SongDecoder.java b/src/main/java/meteordevelopment/meteorclient/utils/notebot/decoder/SongDecoder.java index 455266e7b6..24a447fa61 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/notebot/decoder/SongDecoder.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/notebot/decoder/SongDecoder.java @@ -14,5 +14,11 @@ public abstract class SongDecoder { protected Notebot notebot = Modules.get().get(Notebot.class); - public abstract Song parse(File file); + /** + * Parse file to a {@link Song} object + * + * @param file Song file + * @return A {@link Song} object + */ + public abstract Song parse(File file) throws Exception; } diff --git a/src/main/java/meteordevelopment/meteorclient/utils/notebot/decoder/SongDecoders.java b/src/main/java/meteordevelopment/meteorclient/utils/notebot/decoder/SongDecoders.java index 48d485ae31..2233b3bc6c 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/notebot/decoder/SongDecoders.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/notebot/decoder/SongDecoders.java @@ -12,6 +12,7 @@ import meteordevelopment.meteorclient.utils.notebot.song.Song; import net.minecraft.block.enums.Instrument; import org.apache.commons.io.FilenameUtils; +import org.jetbrains.annotations.NotNull; import java.io.File; import java.nio.file.Path; @@ -43,8 +44,15 @@ public static boolean hasDecoder(Path path) { return hasDecoder(path.toFile()); } - public static Song parse(File file) { - if (!hasDecoder(file)) return null; + /** + * Parse file to one of {@link SongDecoder} + * + * @param file A song file + * @return A {@link Song} object + */ + @NotNull + public static Song parse(File file) throws Exception { + if (!hasDecoder(file)) throw new IllegalStateException("Decoder for this file does not exists!"); SongDecoder decoder = getDecoder(file); Song song = decoder.parse(file); @@ -55,6 +63,11 @@ public static Song parse(File file) { return song; } + /** + * This method adapts {@link Song} to settings in Notebot module + * + * @param song A song + */ private static void fixSong(Song song) { Notebot notebot = Modules.get().get(Notebot.class); diff --git a/src/main/java/meteordevelopment/meteorclient/utils/notebot/decoder/TextSongDecoder.java b/src/main/java/meteordevelopment/meteorclient/utils/notebot/decoder/TextSongDecoder.java index b8d3c4dbd9..cfe0be8233 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/notebot/decoder/TextSongDecoder.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/notebot/decoder/TextSongDecoder.java @@ -13,21 +13,14 @@ import org.apache.commons.io.FilenameUtils; import java.io.File; -import java.io.IOException; import java.nio.file.Files; import java.util.List; public class TextSongDecoder extends SongDecoder { @Override - public Song parse(File file) { - List data; - try { - data = Files.readAllLines(file.toPath()); - } catch (IOException e) { - notebot.error("Error while reading \"%s\"", file.getName()); - return null; - } + public Song parse(File file) throws Exception { + List data = Files.readAllLines(file.toPath()); Multimap notesMap = MultimapBuilder.linkedHashKeys().arrayListValues().build(); String title = FilenameUtils.getBaseName(file.getName()); diff --git a/src/main/java/meteordevelopment/meteorclient/utils/notebot/instrumentdetect/InstrumentDetectFunction.java b/src/main/java/meteordevelopment/meteorclient/utils/notebot/instrumentdetect/InstrumentDetectFunction.java new file mode 100644 index 0000000000..96a6fbfe15 --- /dev/null +++ b/src/main/java/meteordevelopment/meteorclient/utils/notebot/instrumentdetect/InstrumentDetectFunction.java @@ -0,0 +1,21 @@ +/* + * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). + * Copyright (c) Meteor Development. + */ + +package meteordevelopment.meteorclient.utils.notebot.instrumentdetect; + +import net.minecraft.block.BlockState; +import net.minecraft.block.enums.Instrument; +import net.minecraft.util.math.BlockPos; + +public interface InstrumentDetectFunction { + /** + * Detects an instrument for noteblock + * + * @param noteBlock Noteblock state + * @param blockPos Noteblock position + * @return Detected instrument + */ + Instrument detectInstrument(BlockState noteBlock, BlockPos blockPos); +} diff --git a/src/main/java/meteordevelopment/meteorclient/utils/notebot/instrumentdetect/InstrumentDetectMode.java b/src/main/java/meteordevelopment/meteorclient/utils/notebot/instrumentdetect/InstrumentDetectMode.java new file mode 100644 index 0000000000..37d0da24ba --- /dev/null +++ b/src/main/java/meteordevelopment/meteorclient/utils/notebot/instrumentdetect/InstrumentDetectMode.java @@ -0,0 +1,26 @@ +/* + * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). + * Copyright (c) Meteor Development. + */ + +package meteordevelopment.meteorclient.utils.notebot.instrumentdetect; + +import net.minecraft.block.NoteBlock; +import net.minecraft.block.enums.Instrument; +import net.minecraft.client.MinecraftClient; + +public enum InstrumentDetectMode { + BlockState(((noteBlock, blockPos) -> noteBlock.get(NoteBlock.INSTRUMENT))), + BelowBlock(((noteBlock, blockPos) -> Instrument.fromBelowState(MinecraftClient.getInstance().world.getBlockState(blockPos.down())))) + ; + + private final InstrumentDetectFunction instrumentDetectFunction; + + InstrumentDetectMode(InstrumentDetectFunction instrumentDetectFunction) { + this.instrumentDetectFunction = instrumentDetectFunction; + } + + public InstrumentDetectFunction getInstrumentDetectFunction() { + return instrumentDetectFunction; + } +} diff --git a/src/main/java/meteordevelopment/meteorclient/utils/player/ChatUtils.java b/src/main/java/meteordevelopment/meteorclient/utils/player/ChatUtils.java index e160a67132..ad1fef9c71 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/player/ChatUtils.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/player/ChatUtils.java @@ -33,10 +33,14 @@ public static void init() { PREFIX = Text.literal("") .setStyle(Style.EMPTY.withFormatting(Formatting.GRAY)) .append("[") - .append(Text.literal("Meteor").setStyle(Style.EMPTY.withColor(new TextColor(MeteorClient.ADDON.color.getPacked())))) + .append(Text.literal("Meteor").setStyle(Style.EMPTY.withColor(TextColor.fromRgb(MeteorClient.ADDON.color.getPacked())))) .append("] "); } + public static Text getMeteorPrefix() { + return PREFIX; + } + /** Registers a custom prefix to be used when calling from a class in the specified package. When null is returned from the supplier the default Meteor prefix is used. */ public static void registerCustomPrefix(String packageName, Supplier supplier) { for (Pair> pair : customPrefixes) { @@ -64,7 +68,7 @@ public static void forceNextPrefixClass(Class klass) { public static void sendPlayerMsg(String message) { mc.inGameHud.getChatHud().addToMessageHistory(message); - if (message.startsWith("/")) mc.player.networkHandler.sendCommand(message.substring(1)); + if (message.startsWith("/")) mc.player.networkHandler.sendChatCommand(message.substring(1)); else mc.player.networkHandler.sendChatMessage(message); } @@ -74,7 +78,7 @@ public static void info(String message, Object... args) { sendMsg(Formatting.GRAY, message, args); } - public static void info(String prefix, String message, Object... args) { + public static void infoPrefix(String prefix, String message, Object... args) { sendMsg(0, prefix, Formatting.LIGHT_PURPLE, Formatting.GRAY, message, args); } @@ -84,7 +88,7 @@ public static void warning(String message, Object... args) { sendMsg(Formatting.YELLOW, message, args); } - public static void warning(String prefix, String message, Object... args) { + public static void warningPrefix(String prefix, String message, Object... args) { sendMsg(0, prefix, Formatting.LIGHT_PURPLE, Formatting.YELLOW, message, args); } @@ -94,7 +98,7 @@ public static void error(String message, Object... args) { sendMsg(Formatting.RED, message, args); } - public static void error(String prefix, String message, Object... args) { + public static void errorPrefix(String prefix, String message, Object... args) { sendMsg(0, prefix, Formatting.LIGHT_PURPLE, Formatting.RED, message, args); } diff --git a/src/main/java/meteordevelopment/meteorclient/utils/player/DamageUtils.java b/src/main/java/meteordevelopment/meteorclient/utils/player/DamageUtils.java index 25104fee25..2da57562df 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/player/DamageUtils.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/player/DamageUtils.java @@ -164,9 +164,9 @@ public static double bedDamage(LivingEntity player, Vec3d bed) { // Anchor damage public static double anchorDamage(LivingEntity player, Vec3d anchor) { - mc.world.removeBlock(new BlockPos(anchor), false); + mc.world.removeBlock(BlockPos.ofFloored(anchor), false); double damage = bedDamage(player, anchor); - mc.world.setBlockState(new BlockPos(anchor), Blocks.RESPAWN_ANCHOR.getDefaultState()); + mc.world.setBlockState(BlockPos.ofFloored(anchor), Blocks.RESPAWN_ANCHOR.getDefaultState()); return damage; } @@ -182,7 +182,7 @@ private static double getDamageForDifficulty(double damage) { } private static double normalProtReduction(Entity player, double damage) { - int protLevel = EnchantmentHelper.getProtectionAmount(player.getArmorItems(), DamageSource.GENERIC); + int protLevel = EnchantmentHelper.getProtectionAmount(player.getArmorItems(), mc.world.getDamageSources().generic()); if (protLevel > 20) protLevel = 20; damage *= 1 - (protLevel / 25.0); @@ -190,7 +190,7 @@ private static double normalProtReduction(Entity player, double damage) { } private static double blastProtReduction(Entity player, double damage, Explosion explosion) { - int protLevel = EnchantmentHelper.getProtectionAmount(player.getArmorItems(), DamageSource.explosion(explosion)); + int protLevel = EnchantmentHelper.getProtectionAmount(player.getArmorItems(), mc.world.getDamageSources().explosion(explosion)); if (protLevel > 20) protLevel = 20; damage *= (1 - (protLevel / 25.0)); @@ -269,7 +269,7 @@ private static BlockHitResult raycast(RaycastContext context, BlockPos obsidianP return d <= e ? blockHitResult : blockHitResult2; }, (raycastContext) -> { Vec3d vec3d = raycastContext.getStart().subtract(raycastContext.getEnd()); - return BlockHitResult.createMissed(raycastContext.getEnd(), Direction.getFacing(vec3d.x, vec3d.y, vec3d.z), new BlockPos(raycastContext.getEnd())); + return BlockHitResult.createMissed(raycastContext.getEnd(), Direction.getFacing(vec3d.x, vec3d.y, vec3d.z), BlockPos.ofFloored(raycastContext.getEnd())); }); } } diff --git a/src/main/java/meteordevelopment/meteorclient/utils/player/InvUtils.java b/src/main/java/meteordevelopment/meteorclient/utils/player/InvUtils.java index 44976c083f..11e5602a81 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/player/InvUtils.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/player/InvUtils.java @@ -44,9 +44,16 @@ public static boolean testInOffHand(Item... items) { }); } + public static boolean testInHands(Predicate predicate) { + return testInMainHand(predicate) || testInOffHand(predicate); + } + + public static boolean testInHands(Item... items) { + return testInMainHand(items) || testInOffHand(items); + } + public static boolean testInHotbar(Predicate predicate) { - if (testInMainHand(predicate)) return true; - if (testInOffHand(predicate)) return true; + if (testInHands(predicate)) return true; for (int i = SlotUtils.HOTBAR_START; i < SlotUtils.HOTBAR_END; i++) { ItemStack stack = mc.player.getInventory().getStack(i); @@ -79,11 +86,11 @@ public static FindItemResult findInHotbar(Item... items) { } public static FindItemResult findInHotbar(Predicate isGood) { - if (isGood.test(mc.player.getOffHandStack())) { + if (testInOffHand(isGood)) { return new FindItemResult(SlotUtils.OFFHAND, mc.player.getOffHandStack().getCount()); } - if (isGood.test(mc.player.getMainHandStack())) { + if (testInMainHand(isGood)) { return new FindItemResult(mc.player.getInventory().selectedSlot, mc.player.getMainHandStack().getCount()); } @@ -122,11 +129,14 @@ public static FindItemResult find(Predicate isGood, int start, int en } public static FindItemResult findFastestTool(BlockState state) { - float bestScore = -1; + float bestScore = 1; int slot = -1; for (int i = 0; i < 9; i++) { - float score = mc.player.getInventory().getStack(i).getMiningSpeedMultiplier(state); + ItemStack stack = mc.player.getInventory().getStack(i); + if (!stack.isSuitableFor(state)) continue; + + float score = stack.getMiningSpeedMultiplier(state); if (score > bestScore) { bestScore = score; slot = i; @@ -139,6 +149,7 @@ public static FindItemResult findFastestTool(BlockState state) { // Interactions public static boolean swap(int slot, boolean swapBack) { + if (slot == SlotUtils.OFFHAND) return true; if (slot < 0 || slot > 8) return false; if (swapBack && previousSlot == -1) previousSlot = mc.player.getInventory().selectedSlot; else if (!swapBack) previousSlot = -1; diff --git a/src/main/java/meteordevelopment/meteorclient/utils/player/PlayerUtils.java b/src/main/java/meteordevelopment/meteorclient/utils/player/PlayerUtils.java index 2f0ff7a725..13b7604ef1 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/player/PlayerUtils.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/player/PlayerUtils.java @@ -50,8 +50,8 @@ public static Color getPlayerColor(PlayerEntity entity, Color defaultColor) { return color.set(Config.get().friendColor.get()).a(defaultColor.a); } - if (!color.set(TextUtils.getMostPopularColor(entity.getDisplayName())).equals(WHITE) && Config.get().useTeamColor.get()) { - return color.set(color).a(defaultColor.a); + if (Config.get().useTeamColor.get() && !color.set(TextUtils.getMostPopularColor(entity.getDisplayName())).equals(WHITE)) { + return color.a(defaultColor.a); } return defaultColor; @@ -256,10 +256,14 @@ public static double squaredDistanceTo(BlockPos blockPos) { } public static double squaredDistanceTo(double x, double y, double z) { - float f = (float) (mc.player.getX() - x); - float g = (float) (mc.player.getY() - y); - float h = (float) (mc.player.getZ() - z); - return f * f + g * g + h * h; + return squaredDistance(mc.player.getX(), mc.player.getY(), mc.player.getZ(), x, y, z); + } + + public static double squaredDistance(double x1, double y1, double z1, double x2, double y2, double z2) { + float f = (float) (x1 - x2); + float g = (float) (y1 - y2); + float h = (float) (z1 - z2); + return org.joml.Math.fma(f, f, org.joml.Math.fma(g, g, h * h)); } public static boolean isWithin(Entity entity, double r) { @@ -287,7 +291,8 @@ public static double distanceToCamera(Entity entity) { } public static double squaredDistanceToCamera(double x, double y, double z) { - return mc.gameRenderer.getCamera().getPos().squaredDistanceTo(x, y, z); + Vec3d cameraPos = mc.gameRenderer.getCamera().getPos(); + return squaredDistance(cameraPos.x, cameraPos.y, cameraPos.z, x, y, z); } public static double squaredDistanceToCamera(Entity entity) { @@ -323,10 +328,7 @@ public static boolean isWithinReach(BlockPos blockPos) { } public static boolean isWithinReach(double x, double y, double z) { - float f = (float) (mc.player.getX() - x); - float g = (float) (mc.player.getEyeY() - y); - float h = (float) (mc.player.getZ() - z); - return (f * f + g * g + h * h) <= mc.interactionManager.getReachDistance() * mc.interactionManager.getReachDistance(); + return squaredDistance(mc.player.getX(), mc.player.getEyeY(), mc.player.getZ(), x, y, z) <= mc.interactionManager.getReachDistance() * mc.interactionManager.getReachDistance(); } public static Dimension getDimension() { diff --git a/src/main/java/meteordevelopment/meteorclient/utils/render/ContainerButtonWidget.java b/src/main/java/meteordevelopment/meteorclient/utils/render/ContainerButtonWidget.java deleted file mode 100644 index 08455a0196..0000000000 --- a/src/main/java/meteordevelopment/meteorclient/utils/render/ContainerButtonWidget.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). - * Copyright (c) Meteor Development. - */ - -package meteordevelopment.meteorclient.utils.render; - -import com.mojang.blaze3d.systems.RenderSystem; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.font.TextRenderer; -import net.minecraft.client.gui.widget.ButtonWidget; -import net.minecraft.client.render.GameRenderer; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.text.Text; -import net.minecraft.util.math.MathHelper; - -public class ContainerButtonWidget extends ButtonWidget { - public ContainerButtonWidget(int x, int y, int width, int height, Text message, PressAction onPress, NarrationSupplier narrationSupplier) { - super(x, y, width, height, message, onPress, narrationSupplier); - } - - @Override - public void renderButton(MatrixStack matrices, int mouseX, int mouseY, float delta) { - MinecraftClient minecraftClient = MinecraftClient.getInstance(); - TextRenderer textRenderer = minecraftClient.textRenderer; - RenderSystem.setShader(GameRenderer::getPositionTexProgram); - RenderSystem.setShaderTexture(0, WIDGETS_TEXTURE); - RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, alpha); - RenderSystem.enableBlend(); - RenderSystem.defaultBlendFunc(); - RenderSystem.enableDepthTest(); - - int halfWidth = width / 2; - int halfHeight = height / 2; - int texY = getYImage(isHovered()) * 20; - - drawTexture(matrices, getX(), getY(), 0, 46 + texY, halfWidth, halfHeight); - drawTexture(matrices, getX(), getY() + halfHeight, 0, 46 + texY + 14, halfWidth, halfHeight); - - drawTexture(matrices, getX() + halfWidth, getY(), 200 - halfWidth, 46 + texY, halfWidth, halfHeight); - drawTexture(matrices, getX() + halfWidth, getY() + halfHeight, 200 - halfWidth, 46 + texY + 14, halfWidth, halfHeight); - - drawCenteredText(matrices, textRenderer, getMessage(), getX() + width / 2, (getY() + height / 2) - 4, active ? 16777215 : 10526880 | MathHelper.ceil(alpha * 255.0F) << 24); - } -} diff --git a/src/main/java/meteordevelopment/meteorclient/utils/render/MeshVertexConsumerProvider.java b/src/main/java/meteordevelopment/meteorclient/utils/render/MeshVertexConsumerProvider.java index d550c084f4..fec0384191 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/render/MeshVertexConsumerProvider.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/render/MeshVertexConsumerProvider.java @@ -31,7 +31,7 @@ public void setOffset(double offsetX, double offsetY, double offsetZ) { vertexConsumer.setOffset(offsetX, offsetY, offsetZ); } - private static class MeshVertexConsumer implements VertexConsumer { + public static class MeshVertexConsumer implements VertexConsumer { private final Mesh mesh; private double offsetX, offsetY, offsetZ; diff --git a/src/main/java/meteordevelopment/meteorclient/utils/render/MeteorToast.java b/src/main/java/meteordevelopment/meteorclient/utils/render/MeteorToast.java index 509c88ae7f..e44391f0de 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/render/MeteorToast.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/render/MeteorToast.java @@ -35,15 +35,15 @@ public class MeteorToast implements Toast { public MeteorToast(@Nullable Item item, @NotNull String title, @Nullable String text, long duration) { this.icon = item != null ? item.getDefaultStack() : null; - this.title = Text.literal(title).setStyle(Style.EMPTY.withColor(new TextColor(TITLE_COLOR))); - this.text = text != null ? Text.literal(text).setStyle(Style.EMPTY.withColor(new TextColor(TEXT_COLOR))) : null; + this.title = Text.literal(title).setStyle(Style.EMPTY.withColor(TextColor.fromRgb(TITLE_COLOR))); + this.text = text != null ? Text.literal(text).setStyle(Style.EMPTY.withColor(TextColor.fromRgb(TEXT_COLOR))) : null; this.duration = duration; } public MeteorToast(@Nullable Item item, @NotNull String title, @Nullable String text) { this.icon = item != null ? item.getDefaultStack() : null; - this.title = Text.literal(title).setStyle(Style.EMPTY.withColor(new TextColor(TITLE_COLOR))); - this.text = text != null ? Text.literal(text).setStyle(Style.EMPTY.withColor(new TextColor(TEXT_COLOR))) : null; + this.title = Text.literal(title).setStyle(Style.EMPTY.withColor(TextColor.fromRgb(TITLE_COLOR))); + this.text = text != null ? Text.literal(text).setStyle(Style.EMPTY.withColor(TextColor.fromRgb(TEXT_COLOR))) : null; this.duration = 6000; } @@ -69,7 +69,7 @@ public Visibility draw(MatrixStack matrices, ToastManager toastManager, long cur mc.textRenderer.draw(matrices, title, x, titleY, TITLE_COLOR); - if (icon != null) mc.getItemRenderer().renderInGui(icon, 8, 8); + if (icon != null) mc.getItemRenderer().renderInGui(matrices, icon, 8, 8); if (!playedSound) { mc.getSoundManager().play(getSound()); @@ -85,12 +85,12 @@ public void setIcon(@Nullable Item item) { } public void setTitle(@NotNull String title) { - this.title = Text.literal(title).setStyle(Style.EMPTY.withColor(new TextColor(TITLE_COLOR))); + this.title = Text.literal(title).setStyle(Style.EMPTY.withColor(TextColor.fromRgb(TITLE_COLOR))); justUpdated = true; } public void setText(@Nullable String text) { - this.text = text != null ? Text.literal(text).setStyle(Style.EMPTY.withColor(new TextColor(TEXT_COLOR))) : null; + this.text = text != null ? Text.literal(text).setStyle(Style.EMPTY.withColor(TextColor.fromRgb(TEXT_COLOR))) : null; justUpdated = true; } diff --git a/src/main/java/meteordevelopment/meteorclient/utils/render/PeekScreen.java b/src/main/java/meteordevelopment/meteorclient/utils/render/PeekScreen.java index 1227b2e97d..71d7f72070 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/render/PeekScreen.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/render/PeekScreen.java @@ -34,9 +34,9 @@ public PeekScreen(ItemStack storageBlock, ItemStack[] contents) { @Override public boolean mouseClicked(double mouseX, double mouseY, int button) { - BetterTooltips toolips = Modules.get().get(BetterTooltips.class); + BetterTooltips tooltips = Modules.get().get(BetterTooltips.class); - if (button == GLFW.GLFW_MOUSE_BUTTON_MIDDLE && focusedSlot != null && !focusedSlot.getStack().isEmpty() && mc.player.currentScreenHandler.getCursorStack().isEmpty() && toolips.middleClickOpen()) { + if (button == GLFW.GLFW_MOUSE_BUTTON_MIDDLE && focusedSlot != null && !focusedSlot.getStack().isEmpty() && mc.player.currentScreenHandler.getCursorStack().isEmpty() && tooltips.middleClickOpen()) { return Utils.openContainer(focusedSlot.getStack(), contents, false); } return false; diff --git a/src/main/java/meteordevelopment/meteorclient/utils/render/RenderUtils.java b/src/main/java/meteordevelopment/meteorclient/utils/render/RenderUtils.java index e774ea39d6..f643a9eb98 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/render/RenderUtils.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/render/RenderUtils.java @@ -32,6 +32,8 @@ import static meteordevelopment.meteorclient.MeteorClient.mc; public class RenderUtils { + private static final MatrixStack MATRICES = new MatrixStack(); + public static Vec3d center; private static final Pool renderBlockPool = new Pool<>(RenderBlock::new); @@ -46,15 +48,13 @@ public static void init() { public static void drawItem(ItemStack itemStack, int x, int y, double scale, boolean overlay) { //RenderSystem.disableDepthTest(); - MatrixStack matrices = RenderSystem.getModelViewStack(); - - matrices.push(); - matrices.scale((float) scale, (float) scale, 1); + MATRICES.push(); + MATRICES.scale((float) scale, (float) scale, 1); - mc.getItemRenderer().renderGuiItemIcon(itemStack, (int) (x / scale), (int) (y / scale)); - if (overlay) mc.getItemRenderer().renderGuiItemOverlay(mc.textRenderer, itemStack, (int) (x / scale), (int) (y / scale), null); + mc.getItemRenderer().renderGuiItemIcon(MATRICES, itemStack, (int) (x / scale), (int) (y / scale)); + if (overlay) mc.getItemRenderer().renderGuiItemOverlay(MATRICES, mc.textRenderer, itemStack, (int) (x / scale), (int) (y / scale), null); - matrices.pop(); + MATRICES.pop(); //RenderSystem.enableDepthTest(); } @@ -89,13 +89,23 @@ private static void bobView(MatrixStack matrices) { float h = -(playerEntity.horizontalSpeed + g * f); float i = MathHelper.lerp(f, playerEntity.prevStrideDistance, playerEntity.strideDistance); - matrices.translate(-(MathHelper.sin(h * 3.1415927f) * i * 0.5), -(-Math.abs(MathHelper.cos(h * 3.1415927f) * i)), 0); + matrices.translate(-(MathHelper.sin(h * 3.1415927f) * i * 0.5), Math.abs(MathHelper.cos(h * 3.1415927f) * i), 0); matrices.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(MathHelper.sin(h * 3.1415927f) * i * 3)); matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(Math.abs(MathHelper.cos(h * 3.1415927f - 0.2f) * i) * 5)); } } public static void renderTickingBlock(BlockPos blockPos, Color sideColor, Color lineColor, ShapeMode shapeMode, int excludeDir, int duration, boolean fade, boolean shrink) { + // Ensure there aren't multiple fading blocks in one pos + Iterator iterator = renderBlocks.iterator(); + while (iterator.hasNext()) { + RenderBlock next = iterator.next(); + if (next.pos.equals(blockPos)) { + iterator.remove(); + renderBlockPool.free(next); + } + } + renderBlocks.add(renderBlockPool.get().set(blockPos, sideColor, lineColor, shapeMode, excludeDir, duration, fade, shrink)); } diff --git a/src/main/java/meteordevelopment/meteorclient/utils/render/WireframeEntityRenderer.java b/src/main/java/meteordevelopment/meteorclient/utils/render/WireframeEntityRenderer.java index bbf9541862..f808114a21 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/render/WireframeEntityRenderer.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/render/WireframeEntityRenderer.java @@ -110,8 +110,8 @@ public static void render(Render3DEvent event, Entity entity, double scale, Colo float limbAngle = 0; if (!livingEntity.hasVehicle() && livingEntity.isAlive()) { - limbDistance = MathHelper.lerp(event.tickDelta, livingEntity.lastLimbDistance, livingEntity.limbDistance); - limbAngle = livingEntity.limbAngle - livingEntity.limbDistance * (1 - event.tickDelta); + limbDistance = livingEntity.limbAnimator.getSpeed(event.tickDelta); + limbAngle = livingEntity.limbAnimator.getPos(event.tickDelta); if (livingEntity.isBaby()) limbAngle *= 3; if (limbDistance > 1) limbDistance = 1; diff --git a/src/main/java/meteordevelopment/meteorclient/utils/render/color/Color.java b/src/main/java/meteordevelopment/meteorclient/utils/render/color/Color.java index e4eec5b823..d0f89d390a 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/render/color/Color.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/render/color/Color.java @@ -277,7 +277,7 @@ public SettingColor toSetting() { } public TextColor toTextColor() { - return new TextColor(getPacked()); + return TextColor.fromRgb(getPacked()); } public Style toStyle() { diff --git a/src/main/java/meteordevelopment/meteorclient/utils/tooltip/BannerTooltipComponent.java b/src/main/java/meteordevelopment/meteorclient/utils/tooltip/BannerTooltipComponent.java index 730be9648e..a77c4a48d9 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/tooltip/BannerTooltipComponent.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/tooltip/BannerTooltipComponent.java @@ -47,10 +47,10 @@ public int getWidth(TextRenderer textRenderer) { } @Override - public void drawItems(TextRenderer textRenderer, int x, int y, MatrixStack matrices, ItemRenderer itemRenderer, int z) { + public void drawItems(TextRenderer textRenderer, int x, int y, MatrixStack matrices, ItemRenderer itemRenderer) { DiffuseLighting.disableGuiDepthLighting(); matrices.push(); - matrices.translate(x + 8, y + 8, z); + matrices.translate(x + 8, y + 8, 0); matrices.push(); matrices.translate(0.5, 16, 0); diff --git a/src/main/java/meteordevelopment/meteorclient/utils/tooltip/BookTooltipComponent.java b/src/main/java/meteordevelopment/meteorclient/utils/tooltip/BookTooltipComponent.java index aef1541d75..11d66d6ca4 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/tooltip/BookTooltipComponent.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/tooltip/BookTooltipComponent.java @@ -41,15 +41,15 @@ public int getWidth(TextRenderer textRenderer) { } @Override - public void drawItems(TextRenderer textRenderer, int x, int y, MatrixStack matrices, ItemRenderer itemRenderer, int z) { + public void drawItems(TextRenderer textRenderer, int x, int y, MatrixStack matrices, ItemRenderer itemRenderer) { // Background RenderSystem.setShader(GameRenderer::getPositionTexProgram); RenderSystem.setShaderTexture(0, TEXTURE_BOOK_BACKGROUND); - DrawableHelper.drawTexture(matrices, x, y, z, 12, 0, 112, 134, 179, 179); + DrawableHelper.drawTexture(matrices, x, y, 0, 12, 0, 112, 134, 179, 179); // Content matrices.push(); - matrices.translate(x + 16, y + 12, z + 1); + matrices.translate(x + 16, y + 12, 1); matrices.scale(0.7f, 0.7f, 1f); int offset = 0; for (OrderedText line : textRenderer.wrapLines(page, 112)) { diff --git a/src/main/java/meteordevelopment/meteorclient/utils/tooltip/ContainerTooltipComponent.java b/src/main/java/meteordevelopment/meteorclient/utils/tooltip/ContainerTooltipComponent.java index 6244c1734a..c30e4bfffb 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/tooltip/ContainerTooltipComponent.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/tooltip/ContainerTooltipComponent.java @@ -46,13 +46,13 @@ public int getWidth(TextRenderer textRenderer) { } @Override - public void drawItems(TextRenderer textRenderer, int x, int y, MatrixStack matrices, ItemRenderer itemRenderer, int z) { + public void drawItems(TextRenderer textRenderer, int x, int y, MatrixStack matrices, ItemRenderer itemRenderer) { // Background RenderSystem.setShader(GameRenderer::getPositionTexProgram); RenderSystem.setShaderColor(color.r / 255f, color.g / 255f, color.b / 255f, color.a / 255f); RenderSystem.setShaderTexture(0, TEXTURE_CONTAINER_BACKGROUND); - DrawableHelper.drawTexture(matrices, x, y, z, 0, 0, 176, 67, 176, 67); + DrawableHelper.drawTexture(matrices, x, y, 0, 0, 0, 176, 67, 176, 67); //Contents int row = 0; diff --git a/src/main/java/meteordevelopment/meteorclient/utils/tooltip/EntityTooltipComponent.java b/src/main/java/meteordevelopment/meteorclient/utils/tooltip/EntityTooltipComponent.java index 15b7070a56..5dc7eb0b29 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/tooltip/EntityTooltipComponent.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/tooltip/EntityTooltipComponent.java @@ -46,9 +46,9 @@ public int getWidth(TextRenderer textRenderer) { } @Override - public void drawItems(TextRenderer textRenderer, int x, int y, MatrixStack matrices, ItemRenderer itemRenderer, int z) { + public void drawItems(TextRenderer textRenderer, int x, int y, MatrixStack matrices, ItemRenderer itemRenderer) { matrices.push(); - matrices.translate(15, 2, z); + matrices.translate(15, 2, 0); this.entity.setVelocity(1.f, 1.f, 1.f); this.renderEntity(matrices, x, y); matrices.pop(); diff --git a/src/main/java/meteordevelopment/meteorclient/utils/tooltip/MapTooltipComponent.java b/src/main/java/meteordevelopment/meteorclient/utils/tooltip/MapTooltipComponent.java index f3625966df..bc3173791f 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/tooltip/MapTooltipComponent.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/tooltip/MapTooltipComponent.java @@ -47,12 +47,12 @@ public TooltipComponent getComponent() { } @Override - public void drawItems(TextRenderer textRenderer, int x, int y, MatrixStack matrices, ItemRenderer itemRenderer, int z) { + public void drawItems(TextRenderer textRenderer, int x, int y, MatrixStack matrices, ItemRenderer itemRenderer) { double scale = Modules.get().get(BetterTooltips.class).mapsScale.get(); // Background matrices.push(); - matrices.translate(x, y, z); + matrices.translate(x, y, 0); matrices.scale((float) (scale) * 2, (float) (scale) * 2, 0); matrices.scale((64 + 8) / 64f, (64 + 8) / 64f, 0); RenderSystem.setShader(GameRenderer::getPositionTexProgram); @@ -65,7 +65,7 @@ public void drawItems(TextRenderer textRenderer, int x, int y, MatrixStack matri MapState mapState = FilledMapItem.getMapState(this.mapId, mc.world); if (mapState == null) return; matrices.push(); - matrices.translate(x, y, z); + matrices.translate(x, y, 0); matrices.scale((float) scale, (float) scale, 0); matrices.translate(8, 8, 0); mc.gameRenderer.getMapRenderer().draw(matrices, consumer, this.mapId, mapState, false, 0xF000F0); diff --git a/src/main/java/meteordevelopment/meteorclient/utils/world/BlockUtils.java b/src/main/java/meteordevelopment/meteorclient/utils/world/BlockUtils.java index 10b9c0d812..c151027bef 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/world/BlockUtils.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/world/BlockUtils.java @@ -7,7 +7,6 @@ import meteordevelopment.meteorclient.MeteorClient; import meteordevelopment.meteorclient.events.world.TickEvent; -import meteordevelopment.meteorclient.mixininterface.IVec3d; import meteordevelopment.meteorclient.utils.PreInit; import meteordevelopment.meteorclient.utils.player.FindItemResult; import meteordevelopment.meteorclient.utils.player.InvUtils; @@ -17,7 +16,13 @@ import net.minecraft.block.*; import net.minecraft.block.enums.BlockHalf; import net.minecraft.block.enums.SlabType; +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.enchantment.Enchantments; +import net.minecraft.entity.effect.StatusEffectUtil; +import net.minecraft.entity.effect.StatusEffects; +import net.minecraft.item.ItemStack; import net.minecraft.network.packet.c2s.play.HandSwingC2SPacket; +import net.minecraft.registry.tag.FluidTags; import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; import net.minecraft.util.hit.BlockHitResult; @@ -31,8 +36,6 @@ import static meteordevelopment.meteorclient.MeteorClient.mc; public class BlockUtils { - private static final Vec3d hitPos = new Vec3d(0, 0, 0); - public static boolean breaking; private static boolean breakingThisTick; @@ -76,7 +79,7 @@ public static boolean place(BlockPos blockPos, Hand hand, int slot, boolean rota if (slot < 0 || slot > 8) return false; if (!canPlace(blockPos, checkEntities)) return false; - ((IVec3d) hitPos).set(blockPos.getX() + 0.5, blockPos.getY() + 0.5, blockPos.getZ() + 0.5); + Vec3d hitPos = Vec3d.ofCenter(blockPos); BlockPos neighbour; Direction side = getPlaceSide(blockPos); @@ -89,20 +92,20 @@ public static boolean place(BlockPos blockPos, Hand hand, int slot, boolean rota hitPos.add(side.getOffsetX() * 0.5, side.getOffsetY() * 0.5, side.getOffsetZ() * 0.5); } - Direction s = side; + BlockHitResult bhr = new BlockHitResult(hitPos, side, neighbour, false); if (rotate) { Rotations.rotate(Rotations.getYaw(hitPos), Rotations.getPitch(hitPos), rotationPriority, () -> { InvUtils.swap(slot, swapBack); - place(new BlockHitResult(hitPos, s, neighbour, false), hand, swingHand); + interact(bhr, hand, swingHand); if (swapBack) InvUtils.swapBack(); }); } else { InvUtils.swap(slot, swapBack); - place(new BlockHitResult(hitPos, s, neighbour, false), hand, swingHand); + interact(bhr, hand, swingHand); if (swapBack) InvUtils.swapBack(); } @@ -111,7 +114,7 @@ public static boolean place(BlockPos blockPos, Hand hand, int slot, boolean rota return true; } - private static void place(BlockHitResult blockHitResult, Hand hand, boolean swing) { + public static void interact(BlockHitResult blockHitResult, Hand hand, boolean swing) { boolean wasSneaking = mc.player.input.sneaking; mc.player.input.sneaking = false; @@ -135,7 +138,7 @@ public static boolean canPlace(BlockPos blockPos, boolean checkEntities) { if (!mc.world.getBlockState(blockPos).getMaterial().isReplaceable()) return false; // Check if intersects entities - return !checkEntities || mc.world.canPlace(mc.world.getBlockState(blockPos), blockPos, ShapeContext.absent()); + return !checkEntities || mc.world.canPlace(Blocks.OBSIDIAN.getDefaultState(), blockPos, ShapeContext.absent()); } public static boolean canPlace(BlockPos blockPos) { @@ -176,14 +179,17 @@ private static void onTickPost(TickEvent.Post event) { } } - /** Needs to be used in {@link TickEvent.Pre} */ + /** + * Needs to be used in {@link TickEvent.Pre} + */ public static boolean breakBlock(BlockPos blockPos, boolean swing) { if (!canBreak(blockPos, mc.world.getBlockState(blockPos))) return false; // Creating new instance of block pos because minecraft assigns the parameter to a field and we don't want it to change when it has been stored in a field somewhere BlockPos pos = blockPos instanceof BlockPos.Mutable ? new BlockPos(blockPos) : blockPos; - if (mc.interactionManager.isBreakingBlock()) mc.interactionManager.updateBlockBreakingProgress(pos, Direction.UP); + if (mc.interactionManager.isBreakingBlock()) + mc.interactionManager.updateBlockBreakingProgress(pos, Direction.UP); else mc.interactionManager.attackBlock(pos, Direction.UP); if (swing) mc.player.swingHand(Hand.MAIN_HAND); @@ -199,15 +205,29 @@ public static boolean canBreak(BlockPos blockPos, BlockState state) { if (!mc.player.isCreative() && state.getHardness(mc.world, blockPos) < 0) return false; return state.getOutlineShape(mc.world, blockPos) != VoxelShapes.empty(); } + public static boolean canBreak(BlockPos blockPos) { return canBreak(blockPos, mc.world.getBlockState(blockPos)); } - public static boolean canInstaBreak(BlockPos blockPos, BlockState state) { - return mc.player.isCreative() || state.calcBlockBreakingDelta(mc.player, mc.world, blockPos) >= 1; + public static boolean canInstaBreak(BlockPos blockPos, float breakSpeed) { + return mc.player.isCreative() || calcBlockBreakingDelta2(blockPos, breakSpeed) >= 1; } + public static boolean canInstaBreak(BlockPos blockPos) { - return canInstaBreak(blockPos, mc.world.getBlockState(blockPos)); + BlockState state = mc.world.getBlockState(blockPos); + return canInstaBreak(blockPos, mc.player.getBlockBreakingSpeed(state)); + } + + public static float calcBlockBreakingDelta2(BlockPos blockPos, float breakSpeed) { + BlockState state = mc.world.getBlockState(blockPos); + float f = state.getHardness(mc.world, blockPos); + if (f == -1.0F) { + return 0.0F; + } else { + int i = mc.player.canHarvest(state) ? 30 : 100; + return breakSpeed / f / (float) i; + } } // Other @@ -231,8 +251,9 @@ public static MobSpawn isValidMobSpawn(BlockPos blockPos, boolean newMobSpawnLig mc.world.getBlockState(blockPos.down()).getBlock() == Blocks.BEDROCK) return MobSpawn.Never; if (!topSurface(mc.world.getBlockState(blockPos.down()))) { - if (mc.world.getBlockState(blockPos.down()).getCollisionShape(mc.world, blockPos.down()) != VoxelShapes.fullCube()) return MobSpawn.Never; - if (mc.world.getBlockState(blockPos.down()).isTranslucent(mc.world, blockPos.down())) return MobSpawn.Never; + if (mc.world.getBlockState(blockPos.down()).getCollisionShape(mc.world, blockPos.down()) != VoxelShapes.fullCube()) + return MobSpawn.Never; + if (mc.world.getBlockState(blockPos.down()).isTransparent(mc.world, blockPos.down())) return MobSpawn.Never; } if (mc.world.getLightLevel(blockPos, 0) <= spawnLightLimit) return MobSpawn.Potential; @@ -261,4 +282,49 @@ public static boolean isExposed(BlockPos blockPos) { return false; } + + public static double getBreakDelta(int slot, BlockState state) { + float hardness = state.getHardness(null, null); + if (hardness == -1) return 0; + else { + return getBlockBreakingSpeed(slot, state) / hardness / (!state.isToolRequired() || mc.player.getInventory().main.get(slot).isSuitableFor(state) ? 30 : 100); + } + } + + private static double getBlockBreakingSpeed(int slot, BlockState block) { + double speed = mc.player.getInventory().main.get(slot).getMiningSpeedMultiplier(block); + + if (speed > 1) { + ItemStack tool = mc.player.getInventory().getStack(slot); + + int efficiency = EnchantmentHelper.getLevel(Enchantments.EFFICIENCY, tool); + + if (efficiency > 0 && !tool.isEmpty()) speed += efficiency * efficiency + 1; + } + + if (StatusEffectUtil.hasHaste(mc.player)) { + speed *= 1 + (StatusEffectUtil.getHasteAmplifier(mc.player) + 1) * 0.2F; + } + + if (mc.player.hasStatusEffect(StatusEffects.MINING_FATIGUE)) { + float k = switch (mc.player.getStatusEffect(StatusEffects.MINING_FATIGUE).getAmplifier()) { + case 0 -> 0.3F; + case 1 -> 0.09F; + case 2 -> 0.0027F; + default -> 8.1E-4F; + }; + + speed *= k; + } + + if (mc.player.isSubmergedIn(FluidTags.WATER) && !EnchantmentHelper.hasAquaAffinity(mc.player)) { + speed /= 5.0F; + } + + if (!mc.player.isOnGround()) { + speed /= 5.0F; + } + + return speed; + } } diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 2f285616d3..adf375184f 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -26,7 +26,8 @@ "meteor-client-baritone.mixins.json", "meteor-client-indigo.mixins.json", "meteor-client-sodium.mixins.json", - "meteor-client-canvas.mixins.json" + "meteor-client-canvas.mixins.json", + "meteor-client-lithium.mixins.json" ], "accessWidener": "meteor-client.accesswidener", "custom": { @@ -34,8 +35,8 @@ }, "depends": { "java": ">=17", - "minecraft": ">=1.19.3", - "fabricloader": ">=0.14.11" + "minecraft": ">=1.19.4", + "fabricloader": ">=0.14.17" }, "breaks": { "optifabric": "*", diff --git a/src/main/resources/meteor-client-indigo.mixins.json b/src/main/resources/meteor-client-indigo.mixins.json index 3b51d68352..8a7f2a6389 100644 --- a/src/main/resources/meteor-client-indigo.mixins.json +++ b/src/main/resources/meteor-client-indigo.mixins.json @@ -4,8 +4,7 @@ "compatibilityLevel": "JAVA_17", "plugin": "meteordevelopment.meteorclient.MixinPlugin", "client": [ - "AbstractQuadRendererMixin", - "TerrainRenderContextMixin" + "AbstractQuadRendererMixin" ], "injectors": { "defaultRequire": 1 diff --git a/src/main/resources/meteor-client-lithium.mixins.json b/src/main/resources/meteor-client-lithium.mixins.json new file mode 100644 index 0000000000..53450f38f3 --- /dev/null +++ b/src/main/resources/meteor-client-lithium.mixins.json @@ -0,0 +1,12 @@ +{ + "required": false, + "package": "meteordevelopment.meteorclient.mixin.lithium", + "compatibilityLevel": "JAVA_17", + "plugin": "meteordevelopment.meteorclient.MixinPlugin", + "client": [ + "ChunkAwareBlockCollisionSweeperMixin" + ], + "injectors": { + "defaultRequire": 1 + } +} diff --git a/src/main/resources/meteor-client-sodium.mixins.json b/src/main/resources/meteor-client-sodium.mixins.json index 4dc4c81c99..3c4cb95adf 100644 --- a/src/main/resources/meteor-client-sodium.mixins.json +++ b/src/main/resources/meteor-client-sodium.mixins.json @@ -8,7 +8,8 @@ "LightDataAccessMixin", "SodiumBlockOcculsionCacheMixin", "SodiumBlockRendererMixin", - "SodiumFluidRendererMixin" + "SodiumFluidRendererMixin", + "MeshVertexConsumerMixin" ], "injectors": { "defaultRequire": 1 diff --git a/src/main/resources/meteor-client.accesswidener b/src/main/resources/meteor-client.accesswidener index 8e2bb3ad5f..39f93577bd 100644 --- a/src/main/resources/meteor-client.accesswidener +++ b/src/main/resources/meteor-client.accesswidener @@ -7,8 +7,6 @@ accessible class net/minecraft/network/packet/c2s/play/PlayerInteractEntityC accessible class net/minecraft/network/packet/c2s/play/PlayerInteractEntityC2SPacket$InteractTypeHandler accessible class net/minecraft/client/world/ClientChunkManager$ClientChunkMap -accessible method net/minecraft/text/TextColor (I)V - accessible field net/minecraft/client/network/AbstractClientPlayerEntity playerListEntry Lnet/minecraft/client/network/PlayerListEntry; accessible field net/minecraft/client/model/ModelPart cuboids Ljava/util/List; @@ -70,5 +68,6 @@ accessible class net/minecraft/client/gui/screen/ingame/BeaconScreen$EffectB accessible class net/minecraft/client/resource/ResourceReloadLogger$ReloadState accessible field net/minecraft/block/AbstractBlock collidable Z +accessible field net/minecraft/util/math/Direction HORIZONTAL [Lnet/minecraft/util/math/Direction; accessible field net/minecraft/item/ItemGroups INVENTORY Lnet/minecraft/item/ItemGroup; diff --git a/src/main/resources/meteor-client.mixins.json b/src/main/resources/meteor-client.mixins.json index 5dfe8eb8b9..f3565229bf 100644 --- a/src/main/resources/meteor-client.mixins.json +++ b/src/main/resources/meteor-client.mixins.json @@ -14,8 +14,10 @@ "ArmorFeatureRendererMixin", "BackgroundRendererMixin", "BannerBlockEntityRendererMixin", + "BeaconBlockEntityRendererMixin", "BeaconScreenMixin", "BiomeColorsMixin", + "BlockCollisionSpliteratorMixin", "BlockEntityRenderDispatcherMixin", "BlockEntityTypeAccessor", "BlockHitResultAccessor", @@ -32,7 +34,6 @@ "BrewingStandScreenMixin", "BufferBuilderAccessor", "BufferRendererAccessor", - "CactusBlockMixin", "CameraMixin", "CapabilityTrackerMixin", "ChatHudAccessor", @@ -62,6 +63,7 @@ "CreativeSlotMixin", "CrossbowItemAccessor", "CustomPayloadC2SPacketAccessor", + "CustomPayloadS2CPacketMixin", "DefaultSkinHelperMixin", "DisconnectedScreenMixin", "EnchantingTableBlockEntityRendererMixin", @@ -78,12 +80,10 @@ "FireworkRocketEntityMixin", "FireworksSparkParticleMixin", "FireworksSparkParticleSubMixin", - "FluidBlockMixin", "FluidRendererMixin", "FoliageColorsMixin", "GameOptionsMixin", "GameRendererMixin", - "GenericContainerScreenMixin", "HandledScreenAccessor", "HandledScreenMixin", "HeldItemRendererMixin", @@ -95,6 +95,7 @@ "ItemEntityMixin", "ItemEntityRendererMixin", "ItemMixin", + "ItemRendererMixin", "ItemStackAccessor", "ItemStackMixin", "KeyBindingAccessor", @@ -113,15 +114,19 @@ "MobSpawnerBlockEntityRendererMixin", "MouseMixin", "MultiplayerScreenMixin", + "PacketByteBufMixin", + "PacketInflaterMixin", "ParticleManagerMixin", "PlayerArmorSlotMixin", "PlayerEntityMixin", "PlayerEntityRendererMixin", "PlayerInteractEntityC2SPacketMixin", + "PlayerListEntryMixin", "PlayerListHudMixin", "PlayerMoveC2SPacketAccessor", "PlayerMoveC2SPacketMixin", "PlayerPositionLookS2CPacketAccessor", + "PlayerSkinProviderAccessor", "PowderSnowBlockMixin", "ProjectileEntityAccessor", "ProjectileInGroundAccessor", @@ -134,7 +139,6 @@ "SectionedEntityCacheAccessor", "ShapeIndexBufferAccessor", "ShulkerBoxBlockMixin", - "ShulkerBoxScreenMixin", "SignBlockEntityRendererMixin", "SimpleEntityLookupAccessor", "SimpleOptionMixin", @@ -144,15 +148,20 @@ "SoundSystemMixin", "StatusEffectInstanceAccessor", "StatusEffectInstanceMixin", + "StringHelperMixin", + "SweetBerryBushBlockMixin", "TextHandlerAccessor", + "TextRendererMixin", "TextVisitFactoryMixin", "TridentItemMixin", "Vec3dMixin", "VertexBufferMixin", "WorldAccessor", + "WorldBorderMixin", "WorldChunkMixin", "WorldRendererAccessor", - "WorldRendererMixin" + "WorldRendererMixin", + "YggdrasilMinecraftSessionServiceAccessor" ], "injectors": { "defaultRequire": 1