From 80f6b8143999ed4c60a4f80c18cdc4fbb0d5931d Mon Sep 17 00:00:00 2001 From: RickyTheRacc <80427814+RickyTheRacc@users.noreply.github.com> Date: Fri, 19 Jul 2024 23:10:57 -0500 Subject: [PATCH] Merge pull request #27 from RickyTheRacc/code-cleanup * Remove Enums Class * Change Javadocs to Comments * Remove General Comments * Move Variables * Use PlayerUtils in Center Command * Use .noSlider() * Optimize ToggleCommandMixin * Organize AxisViewer * Cleanup HIGUtils * Separate Modules into Categories * Make AFKLogout Settings Clearer * Standardize Event Function Names --- .../redcarlos/higtools/commands/Center.java | 8 +- .../higtools/mixins/ToggleCommandMixin.java | 33 +++---- .../modules/highwayborers/AxisBorer.java | 2 +- .../modules/highwayborers/BorerModule.java | 34 ++++--- .../modules/highwayborers/NegNegBorer.java | 2 +- .../modules/highwayborers/NegPosBorer.java | 2 +- .../modules/highwayborers/PosNegBorer.java | 2 +- .../modules/highwayborers/PosPosBorer.java | 2 +- .../higtools/modules/main/AfkLogout.java | 10 +- .../higtools/modules/main/AutoCenter.java | 4 +- .../higtools/modules/main/AxisViewer.java | 92 +++++++++---------- .../higtools/modules/main/DiscordRPC.java | 10 +- .../modules/main/HighwayBuilderPlus.java | 75 +++++++-------- .../higtools/modules/main/HotbarManager.java | 2 +- .../modules/main/LiquidFillerHig.java | 20 ++-- .../higtools/modules/main/OffhandManager.java | 21 ++--- .../higtools/modules/main/RotationLock.java | 12 +-- .../higtools/modules/main/ScaffoldPlus.java | 15 ++- .../me/redcarlos/higtools/utils/Enums.java | 8 -- .../me/redcarlos/higtools/utils/HIGUtils.java | 70 ++------------ .../me/redcarlos/higtools/utils/ListMode.java | 6 ++ 21 files changed, 178 insertions(+), 252 deletions(-) delete mode 100644 src/main/java/me/redcarlos/higtools/utils/Enums.java create mode 100644 src/main/java/me/redcarlos/higtools/utils/ListMode.java diff --git a/src/main/java/me/redcarlos/higtools/commands/Center.java b/src/main/java/me/redcarlos/higtools/commands/Center.java index 1a77387..746b010 100644 --- a/src/main/java/me/redcarlos/higtools/commands/Center.java +++ b/src/main/java/me/redcarlos/higtools/commands/Center.java @@ -2,6 +2,8 @@ import com.mojang.brigadier.builder.LiteralArgumentBuilder; import meteordevelopment.meteorclient.commands.Command; +import meteordevelopment.meteorclient.utils.Utils; +import meteordevelopment.meteorclient.utils.player.PlayerUtils; import net.minecraft.command.CommandSource; import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket; import net.minecraft.util.math.MathHelper; @@ -14,11 +16,7 @@ public Center() { @Override public void build(LiteralArgumentBuilder builder) { builder.executes(context -> { - double x = MathHelper.floor(mc.player.getX()) + 0.5; - double z = MathHelper.floor(mc.player.getZ()) + 0.5; - mc.player.setPosition(x, mc.player.getY(), z); - mc.player.networkHandler.sendPacket(new PlayerMoveC2SPacket.PositionAndOnGround(mc.player.getX(), mc.player.getY(), mc.player.getZ(), mc.player.isOnGround())); - + PlayerUtils.centerPlayer(); return SINGLE_SUCCESS; }); } diff --git a/src/main/java/me/redcarlos/higtools/mixins/ToggleCommandMixin.java b/src/main/java/me/redcarlos/higtools/mixins/ToggleCommandMixin.java index 09a880b..f7245ed 100644 --- a/src/main/java/me/redcarlos/higtools/mixins/ToggleCommandMixin.java +++ b/src/main/java/me/redcarlos/higtools/mixins/ToggleCommandMixin.java @@ -17,32 +17,27 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import java.util.List; +import java.util.Arrays; +@SuppressWarnings("unchecked") @Mixin(value = ToggleCommand.class, remap = false) public abstract class ToggleCommandMixin extends Command { public ToggleCommandMixin(String name, String description, String... aliases) { super(name, description, aliases); } - /** - * Borers & HighwayBuilder - */ @Unique - private final List> borerClasses = List.of( - HighwayBuilderPlus.class, + private final Class[] borerModules = new Class[]{ AxisBorer.class, NegNegBorer.class, NegPosBorer.class, PosNegBorer.class, PosPosBorer.class - ); + }; - /** - * HighwayTools Modules - */ @Unique - private final List> higToolsClasses = List.of( + private final Class[] otherModules = new Class[]{ + HighwayTools.class, AutoCenter.class, AutoLog.class, AutoWalkHig.class, @@ -52,18 +47,24 @@ public ToggleCommandMixin(String name, String description, String... aliases) { LiquidFillerHig.class, RotationLock.class, SafeWalk.class, - ScaffoldPlus.class - ); + ScaffoldPlus.class, + HighwayBuilderPlus.class + }; @Inject(method = "build", at = @At("HEAD")) private void inject(LiteralArgumentBuilder builder, CallbackInfo ci) { builder.then(literal("higtools").then(literal("off").executes(context -> { Modules modules = Modules.get(); - if (modules.get(HighwayTools.class).isActive()) modules.get(HighwayTools.class).toggle(); + Arrays.stream(borerModules).forEach(module -> { + if (!modules.get(module).isActive()) return; + modules.get(module).toggle(); + }); - borerClasses.stream().filter(borer -> modules.get(borer).isActive()).forEach(borer -> modules.get(borer).toggle()); - higToolsClasses.stream().filter(higTool -> modules.get(higTool).isActive()).forEach(higTool -> modules.get(higTool).toggle()); + Arrays.stream(otherModules).forEach(module -> { + if (!modules.get(module).isActive()) return; + modules.get(module).toggle(); + }); return SINGLE_SUCCESS; }))); diff --git a/src/main/java/me/redcarlos/higtools/modules/highwayborers/AxisBorer.java b/src/main/java/me/redcarlos/higtools/modules/highwayborers/AxisBorer.java index 5b1b44f..9cb5427 100644 --- a/src/main/java/me/redcarlos/higtools/modules/highwayborers/AxisBorer.java +++ b/src/main/java/me/redcarlos/higtools/modules/highwayborers/AxisBorer.java @@ -25,7 +25,7 @@ public void onDeactivate() { @Override @EventHandler - public void tick(TickEvent.Pre event) { + public void onTick(TickEvent.Pre event) { if (mc.player == null || mc.world == null) return; // Previous floored block position of player BlockPos prevBlockPos = playerPos; diff --git a/src/main/java/me/redcarlos/higtools/modules/highwayborers/BorerModule.java b/src/main/java/me/redcarlos/higtools/modules/highwayborers/BorerModule.java index 7ed7a92..6ff26b0 100644 --- a/src/main/java/me/redcarlos/higtools/modules/highwayborers/BorerModule.java +++ b/src/main/java/me/redcarlos/higtools/modules/highwayborers/BorerModule.java @@ -17,30 +17,20 @@ import static me.redcarlos.higtools.utils.HIGUtils.*; public abstract class BorerModule extends Module { - /** - * Preserve 2 block tall tunnel for speed bypass - */ - protected final ArrayList blackList = new ArrayList<>(); - /** - * Last time packets were sent - */ - protected long lastUpdateTime = 0; - /** - * Floored block position of player - */ - protected BlockPos playerPos = BlockPos.ORIGIN; - protected int packets = 0; private final SettingGroup sgGeneral = settings.getDefaultGroup(); + protected final Setting mode = sgGeneral.add(new EnumSetting.Builder() .name("shape") .description("Which shape to dig.") .defaultValue(Shape.HIGHWAY) .build() ); + protected final Setting extForward; protected final Setting extBackward; protected final Setting xOffset; protected final Setting zOffset; + protected final Setting keepY = sgGeneral.add(new IntSetting.Builder() .name("keepY") .description("Keeps a specific Y level when digging.") @@ -49,6 +39,7 @@ public abstract class BorerModule extends Module { .sliderRange(-1, 255) .build() ); + protected final Setting jumping = sgGeneral.add(new BoolSetting.Builder() .name("jumping") .description("Send more or less packs.") @@ -56,6 +47,21 @@ public abstract class BorerModule extends Module { .build() ); + /** + * Preserve 2 block tall tunnel for speed bypass + */ + protected final ArrayList blackList = new ArrayList<>(); + /** + * Last time packets were sent + */ + protected long lastUpdateTime = 0; + /** + * Floored block position of player + */ + protected BlockPos playerPos = BlockPos.ORIGIN; + + protected int packets = 0; + protected BorerModule(String name, String description, int extForwards, int extBackwards, int xOffset, int zOffset) { super(HIGTools.BORERS, name, description); @@ -95,7 +101,7 @@ protected BorerModule(String name, String description, int extForwards, int extB } @EventHandler - public abstract void tick(TickEvent.Pre event); + public abstract void onTick(TickEvent.Pre event); protected void getBlacklistedBlockPoses() { if (mc.player == null) return; diff --git a/src/main/java/me/redcarlos/higtools/modules/highwayborers/NegNegBorer.java b/src/main/java/me/redcarlos/higtools/modules/highwayborers/NegNegBorer.java index c25065f..758b84c 100644 --- a/src/main/java/me/redcarlos/higtools/modules/highwayborers/NegNegBorer.java +++ b/src/main/java/me/redcarlos/higtools/modules/highwayborers/NegNegBorer.java @@ -25,7 +25,7 @@ public void onDeactivate() { @Override @EventHandler - public void tick(TickEvent.Pre event) { + public void onTick(TickEvent.Pre event) { if (mc.player == null || mc.world == null) return; // Previous floored block position of player BlockPos prevBlockPos = playerPos; diff --git a/src/main/java/me/redcarlos/higtools/modules/highwayborers/NegPosBorer.java b/src/main/java/me/redcarlos/higtools/modules/highwayborers/NegPosBorer.java index ab27bce..125619c 100644 --- a/src/main/java/me/redcarlos/higtools/modules/highwayborers/NegPosBorer.java +++ b/src/main/java/me/redcarlos/higtools/modules/highwayborers/NegPosBorer.java @@ -25,7 +25,7 @@ public void onDeactivate() { @Override @EventHandler - public void tick(TickEvent.Pre event) { + public void onTick(TickEvent.Pre event) { if (mc.player == null || mc.world == null) return; // Previous floored block position of player BlockPos prevBlockPos = playerPos; diff --git a/src/main/java/me/redcarlos/higtools/modules/highwayborers/PosNegBorer.java b/src/main/java/me/redcarlos/higtools/modules/highwayborers/PosNegBorer.java index d7f2198..68a33bb 100644 --- a/src/main/java/me/redcarlos/higtools/modules/highwayborers/PosNegBorer.java +++ b/src/main/java/me/redcarlos/higtools/modules/highwayborers/PosNegBorer.java @@ -25,7 +25,7 @@ public void onDeactivate() { @Override @EventHandler - public void tick(TickEvent.Pre event) { + public void onTick(TickEvent.Pre event) { if (mc.player == null || mc.world == null) return; // Previous floored block position of player BlockPos prevBlockPos = playerPos; diff --git a/src/main/java/me/redcarlos/higtools/modules/highwayborers/PosPosBorer.java b/src/main/java/me/redcarlos/higtools/modules/highwayborers/PosPosBorer.java index 061be2c..3c49efb 100644 --- a/src/main/java/me/redcarlos/higtools/modules/highwayborers/PosPosBorer.java +++ b/src/main/java/me/redcarlos/higtools/modules/highwayborers/PosPosBorer.java @@ -25,7 +25,7 @@ public void onDeactivate() { @Override @EventHandler - public void tick(TickEvent.Pre event) { + public void onTick(TickEvent.Pre event) { if (mc.player == null || mc.world == null) return; // Previous floored block position of player BlockPos prevBlockPos = playerPos; diff --git a/src/main/java/me/redcarlos/higtools/modules/main/AfkLogout.java b/src/main/java/me/redcarlos/higtools/modules/main/AfkLogout.java index 58cac59..d921967 100644 --- a/src/main/java/me/redcarlos/higtools/modules/main/AfkLogout.java +++ b/src/main/java/me/redcarlos/higtools/modules/main/AfkLogout.java @@ -24,25 +24,25 @@ public class AfkLogout extends Module { private final Setting xCoords = sgGeneral.add(new IntSetting.Builder() .name("x-coord") - .description("The X coordinate at which to log out.") + .description("The X coordinate at which to log out (world border is at +/- 29999983).") .defaultValue(1000) .range(-29999983, 29999983) - .sliderRange(-29999983, 29999983) + .noSlider() .build() ); private final Setting zCoords = sgGeneral.add(new IntSetting.Builder() .name("z-coord") - .description("The Z coordinate at which to log out.") + .description("The Z coordinate at which to log out (world border is at +/- 29999983).") .defaultValue(1000) .range(-29999983, 29999983) - .sliderRange(-29999983, 29999983) + .noSlider() .build() ); private final Setting radius = sgGeneral.add(new IntSetting.Builder() .name("radius") - .description("The radius from the exact coordinates it will log you out.") + .description("Log out when you are this far away from the coordinates.") .defaultValue(64) .min(0) .sliderRange(0, 100) diff --git a/src/main/java/me/redcarlos/higtools/modules/main/AutoCenter.java b/src/main/java/me/redcarlos/higtools/modules/main/AutoCenter.java index 356bf8d..eff88d1 100644 --- a/src/main/java/me/redcarlos/higtools/modules/main/AutoCenter.java +++ b/src/main/java/me/redcarlos/higtools/modules/main/AutoCenter.java @@ -46,12 +46,12 @@ public void onActivate() { } @EventHandler - public void motions(TickEvent.Pre event) { + public void onPreTick(TickEvent.Pre event) { check(); } @EventHandler - public void motions(TickEvent.Post event) { + public void onPostTick(TickEvent.Post event) { check(); } diff --git a/src/main/java/me/redcarlos/higtools/modules/main/AxisViewer.java b/src/main/java/me/redcarlos/higtools/modules/main/AxisViewer.java index 9700bf5..edb45bf 100644 --- a/src/main/java/me/redcarlos/higtools/modules/main/AxisViewer.java +++ b/src/main/java/me/redcarlos/higtools/modules/main/AxisViewer.java @@ -5,6 +5,7 @@ import meteordevelopment.meteorclient.settings.*; import meteordevelopment.meteorclient.systems.modules.Module; import meteordevelopment.meteorclient.utils.player.PlayerUtils; +import meteordevelopment.meteorclient.utils.render.color.Color; import meteordevelopment.meteorclient.utils.render.color.SettingColor; import meteordevelopment.orbit.EventHandler; @@ -13,9 +14,8 @@ public class AxisViewer extends Module { private final SettingGroup sgNether = settings.createGroup("Nether"); private final SettingGroup sgEnd = settings.createGroup("End"); - /** - * Overworld - */ + // Overworld + private final Setting overworldAxisTypes = sgOverworld.add(new EnumSetting.Builder() .name("render") .description("Which axis to display.") @@ -41,9 +41,8 @@ public class AxisViewer extends Module { .build() ); - /** - * Nether - */ + // Nether + private final Setting netherAxisTypes = sgNether.add(new EnumSetting.Builder() .name("render") .description("Which axis to display.") @@ -69,9 +68,8 @@ public class AxisViewer extends Module { .build() ); - /** - * End - */ + // End + private final Setting endAxisTypes = sgEnd.add(new EnumSetting.Builder() .name("render") .description("Which axis to display.") @@ -102,60 +100,62 @@ public AxisViewer() { } @EventHandler - private void onRender(Render3DEvent event) { + private void onRender3D(Render3DEvent event) { if (mc.options.hudHidden) return; + + AxisType axisType; + int y; + Color lineColor; + switch (PlayerUtils.getDimension()) { case Overworld -> { - if (overworldAxisTypes.get() == AxisType.Both) { - drawLines(event, true, true, overworldY.get(), overworldColor.get()); - } else if (overworldAxisTypes.get() == AxisType.Axis) { - drawLines(event, true, false, overworldY.get(), overworldColor.get()); - } else if (overworldAxisTypes.get() == AxisType.Diagonals) { - drawLines(event, false, true, overworldY.get(), overworldColor.get()); - } + axisType = overworldAxisTypes.get(); + y = overworldY.get(); + lineColor = overworldColor.get(); } case Nether -> { - if (netherAxisTypes.get() == AxisType.Both) { - drawLines(event, true, true, netherY.get(), netherColor.get()); - } else if (netherAxisTypes.get() == AxisType.Axis) { - drawLines(event, true, false, netherY.get(), netherColor.get()); - } else if (netherAxisTypes.get() == AxisType.Diagonals) { - drawLines(event, false, true, netherY.get(), netherColor.get()); - } + axisType = netherAxisTypes.get(); + y = netherY.get(); + lineColor = netherColor.get(); } case End -> { - if (endAxisTypes.get() == AxisType.Both) { - drawLines(event, true, true, endY.get(), endColor.get()); - } else if (endAxisTypes.get() == AxisType.Axis) { - drawLines(event, true, false, endY.get(), endColor.get()); - } else if (endAxisTypes.get() == AxisType.Diagonals) { - drawLines(event, false, true, endY.get(), endColor.get()); - } + axisType = endAxisTypes.get(); + y = endY.get(); + lineColor = endColor.get(); } + default -> throw new IllegalStateException("Unexpected value: " + PlayerUtils.getDimension()); } - } - // Todo : Render lines block per block to prevent render culling breaking rendering - private void drawLines(Render3DEvent event, boolean axis, boolean diags, int y, SettingColor color) { - if (axis) { - event.renderer.line(0, y, 0, 0, y, 30_000_000, color); // Z+ - event.renderer.line(0, y, 0, 30_000_000, y, 0, color); // X+ - event.renderer.line(0, y, 0, 0, y, -30_000_000, color); // -Z - event.renderer.line(0, y, 0, -30_000_000, y, 0, color); // -X + // TODO: Fix to be unaffected by render culling + + if (axisType.cardinals()) { + event.renderer.line(0, y, 0, 0, y, 30_000_000, lineColor); // Z+ + event.renderer.line(0, y, 0, 30_000_000, y, 0, lineColor); // X+ + event.renderer.line(0, y, 0, 0, y, -30_000_000, lineColor); // -Z + event.renderer.line(0, y, 0, -30_000_000, y, 0, lineColor); // -X } - if (diags) { - event.renderer.line(0, y, 0, 30_000_000, y, 30_000_000, color); // ++ - event.renderer.line(0, y, 0, 30_000_000, y, -30_000_000, color); // +- - event.renderer.line(0, y, 0, -30_000_000, y, 30_000_000, color); // -+ - event.renderer.line(0, y, 0, -30_000_000, y, -30_000_000, color); // -- + if (axisType.diagonals()) { + event.renderer.line(0, y, 0, 30_000_000, y, 30_000_000, lineColor); // ++ + event.renderer.line(0, y, 0, 30_000_000, y, -30_000_000, lineColor); // +- + event.renderer.line(0, y, 0, -30_000_000, y, 30_000_000, lineColor); // -+ + event.renderer.line(0, y, 0, -30_000_000, y, -30_000_000, lineColor); // -- } + } public enum AxisType { Both, - Axis, + Cardinals, Diagonals, - None + None; + + boolean cardinals() { + return this == Both || this == Cardinals; + } + + boolean diagonals() { + return this == Both || this == Diagonals; + } } } diff --git a/src/main/java/me/redcarlos/higtools/modules/main/DiscordRPC.java b/src/main/java/me/redcarlos/higtools/modules/main/DiscordRPC.java index edf1909..c370382 100644 --- a/src/main/java/me/redcarlos/higtools/modules/main/DiscordRPC.java +++ b/src/main/java/me/redcarlos/higtools/modules/main/DiscordRPC.java @@ -38,9 +38,8 @@ public class DiscordRPC extends Module { private final SettingGroup sgLine1 = settings.createGroup("Line 1"); private final SettingGroup sgLine2 = settings.createGroup("Line 2"); - /** - * Line 1 - */ + // Line 1 + private final Setting> line1Strings = sgLine1.add(new StringListSetting.Builder() .name("1st-line-messages") .description("Messages used for the first line.") @@ -66,9 +65,8 @@ public class DiscordRPC extends Module { .build() ); - /** - * Line 2 - */ + // Line 2 + private final Setting> line2Strings = sgLine2.add(new StringListSetting.Builder() .name("2nd-line-messages") .description("Messages used for the second line.") diff --git a/src/main/java/me/redcarlos/higtools/modules/main/HighwayBuilderPlus.java b/src/main/java/me/redcarlos/higtools/modules/main/HighwayBuilderPlus.java index 2330e7e..31d131c 100644 --- a/src/main/java/me/redcarlos/higtools/modules/main/HighwayBuilderPlus.java +++ b/src/main/java/me/redcarlos/higtools/modules/main/HighwayBuilderPlus.java @@ -62,30 +62,6 @@ public class HighwayBuilderPlus extends Module { private final SettingGroup sgRenderPaving = settings.createGroup("Render Paving"); private final SettingGroup sgStatistics = settings.createGroup("Statistics"); - public enum Floor { - Replace, - PlaceMissing - } - - private static final BlockPos ZERO = new BlockPos(0, 0, 0); - - public enum Rotation { - None(false, false), - Mine(true, false), - Place(false, true), - Both(true, true); - - public final boolean mine, place; - - Rotation(boolean mine, boolean place) { - this.mine = mine; - this.place = place; - } - } - - /** - * General - */ private final Setting width = sgGeneral.add(new IntSetting.Builder() .name("width") .description("Width of the highway.") @@ -157,9 +133,8 @@ public enum Rotation { .build() ); - /** - * Digging - */ + // Digging + private final Setting ignoreSigns = sgDigging.add(new BoolSetting.Builder() .name("ignore-signs") .description("Ignore breaking signs = preserving history (based).") @@ -201,14 +176,13 @@ public enum Rotation { .build() ); - /** - * Paving - */ + // Paving + private final Setting> blocksToPlace = sgPaving.add(new BlockListSetting.Builder() .name("blocks-to-place") .description("Blocks it is allowed to place.") .defaultValue(Blocks.OBSIDIAN) - .filter(block -> Block.isShapeFullCube(block.getDefaultState().getCollisionShape(EmptyBlockView.INSTANCE, ZERO))) + .filter(block -> Block.isShapeFullCube(block.getDefaultState().getCollisionShape(EmptyBlockView.INSTANCE, BlockPos.ORIGIN))) .build() ); @@ -228,9 +202,8 @@ public enum Rotation { .build() ); - /** - * Inventory - */ + // Inventory + private final Setting> trashItems = sgInventory.add(new ItemListSetting.Builder() .name("trash-items") .description("Items that are considered trash and can be thrown out.") @@ -276,9 +249,8 @@ public enum Rotation { .build() ); - /** - * Render digging - */ + // Render Digging + private final Setting renderMine = sgRenderDigging.add(new BoolSetting.Builder() .name("render-blocks-to-mine") .description("Render blocks to be mined.") @@ -307,9 +279,8 @@ public enum Rotation { .build() ); - /** - * Render paving - */ + // Render Paving + private final Setting renderPlace = sgRenderPaving.add(new BoolSetting.Builder() .name("render-blocks-to-place") .description("Render blocks to be placed.") @@ -338,9 +309,8 @@ public enum Rotation { .build() ); - /** - * Statistics - */ + // Statistics + private final Setting printStatistics = sgStatistics.add(new BoolSetting.Builder() .name("print-statistics") .description("Prints statistics in chat when disabling Highway Builder+.") @@ -1800,4 +1770,23 @@ public void restore() { }; } } + + public enum Rotation { + None(false, false), + Mine(true, false), + Place(false, true), + Both(true, true); + + public final boolean mine, place; + + Rotation(boolean mine, boolean place) { + this.mine = mine; + this.place = place; + } + } + + public enum Floor { + Replace, + PlaceMissing + } } diff --git a/src/main/java/me/redcarlos/higtools/modules/main/HotbarManager.java b/src/main/java/me/redcarlos/higtools/modules/main/HotbarManager.java index bbe8b12..75867a5 100644 --- a/src/main/java/me/redcarlos/higtools/modules/main/HotbarManager.java +++ b/src/main/java/me/redcarlos/higtools/modules/main/HotbarManager.java @@ -122,7 +122,7 @@ private void fillTable(GuiTheme theme, WTable table) { } @EventHandler - public void onRender(Render3DEvent event) { + public void onRender3D(Render3DEvent event) { if (mc.player == null || mc.world == null || mc.interactionManager == null) return; if (mc.player.age % delay.get() != 0) return; diff --git a/src/main/java/me/redcarlos/higtools/modules/main/LiquidFillerHig.java b/src/main/java/me/redcarlos/higtools/modules/main/LiquidFillerHig.java index 3199b22..01ebbe9 100644 --- a/src/main/java/me/redcarlos/higtools/modules/main/LiquidFillerHig.java +++ b/src/main/java/me/redcarlos/higtools/modules/main/LiquidFillerHig.java @@ -6,8 +6,8 @@ package me.redcarlos.higtools.modules.main; -import me.redcarlos.higtools.utils.Enums; import me.redcarlos.higtools.HIGTools; +import me.redcarlos.higtools.utils.ListMode; import meteordevelopment.meteorclient.events.world.TickEvent; import meteordevelopment.meteorclient.settings.*; import meteordevelopment.meteorclient.systems.modules.Module; @@ -32,9 +32,6 @@ public class LiquidFillerHig extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); private final SettingGroup sgBlocks = settings.createGroup("Blocks"); - /** - * General - */ private final Setting placeInLiquids = sgGeneral.add(new EnumSetting.Builder() .name("place-in") .description("What type of liquids to place in.") @@ -88,13 +85,12 @@ public class LiquidFillerHig extends Module { .build() ); - /** - * Blocks - */ - private final Setting listMode = sgBlocks.add(new EnumSetting.Builder() + // Blocks + + private final Setting listMode = sgBlocks.add(new EnumSetting.Builder() .name("block-list-mode") .description("Block list selection mode.") - .defaultValue(Enums.ListMode.Whitelist) + .defaultValue(ListMode.Whitelist) .build() ); @@ -104,14 +100,14 @@ public class LiquidFillerHig extends Module { .defaultValue( Blocks.NETHERRACK ) - .visible(() -> listMode.get() == Enums.ListMode.Whitelist) + .visible(() -> listMode.get() == ListMode.Whitelist) .build() ); private final Setting> blacklist = sgBlocks.add(new BlockListSetting.Builder() .name("blacklist") .description("Blocks denied to fill up liquids.") - .visible(() -> listMode.get() == Enums.ListMode.Blacklist) + .visible(() -> listMode.get() == ListMode.Blacklist) .build() ); @@ -151,7 +147,7 @@ private void onTick(TickEvent.Pre event) { // Find slot with a block FindItemResult item; - if (listMode.get() == Enums.ListMode.Whitelist) { + if (listMode.get() == ListMode.Whitelist) { item = InvUtils.findInHotbar(itemStack -> itemStack.getItem() instanceof BlockItem && whitelist.get().contains(Block.getBlockFromItem(itemStack.getItem()))); } else { item = InvUtils.findInHotbar(itemStack -> itemStack.getItem() instanceof BlockItem && !blacklist.get().contains(Block.getBlockFromItem(itemStack.getItem()))); diff --git a/src/main/java/me/redcarlos/higtools/modules/main/OffhandManager.java b/src/main/java/me/redcarlos/higtools/modules/main/OffhandManager.java index 69c4a71..270113a 100644 --- a/src/main/java/me/redcarlos/higtools/modules/main/OffhandManager.java +++ b/src/main/java/me/redcarlos/higtools/modules/main/OffhandManager.java @@ -29,9 +29,6 @@ public class OffhandManager extends Module { private final SettingGroup sgAutoGap = settings.createGroup("Auto Gap"); private final SettingGroup sgAutoTotem = settings.createGroup("Auto Totem"); - /** - * General - */ private final Setting hotbar = sgGeneral.add(new BoolSetting.Builder() .name("hotbar") .description("Whether to use items from your hotbar.") @@ -46,9 +43,8 @@ public class OffhandManager extends Module { .build() ); - /** - * Auto Gap - */ + // Auto Gap + private final Setting hungerThreshold = sgAutoGap.add(new IntSetting.Builder() .name("hunger") .description("Hunger to gap at.") @@ -65,9 +61,8 @@ public class OffhandManager extends Module { .build() ); - /** - * Auto Totem - */ + // Auto Totem + private final Setting healthThreshold = sgAutoTotem.add(new IntSetting.Builder() .name("min-health") .description("The minimum health to hold a totem at.") @@ -109,7 +104,7 @@ public void onDeactivate() { } @EventHandler - public void onRender(Render3DEvent event) { + public void onRender3D(Render3DEvent event) { if (mc.player == null || mc.world == null) return; if (!Utils.canUpdate()) return; @@ -144,7 +139,7 @@ else if (!autoTotem.isLocked() && !item.isOffhand()) { } @EventHandler - private void onTick(TickEvent.Pre event) { + private void onPreTick(TickEvent.Pre event) { if (mc.player == null) return; if (eating) { @@ -168,7 +163,7 @@ private void onTick(TickEvent.Pre event) { } @EventHandler - private void onTick(TickEvent.Post event) { + private void onPostTick(TickEvent.Post event) { if (mc.player == null || mc.world == null) return; if (mc.player.getHealth() <= healthThreshold.get() || fallDamage.get() && !EntityUtils.isAboveWater(mc.player) && mc.player.fallDistance > 3) currentItem = Item.Totem; @@ -178,7 +173,7 @@ private void onTick(TickEvent.Post event) { } @EventHandler - public void sendPacket(PacketEvent.Receive event) { + public void onReceivePacket(PacketEvent.Receive event) { if (event.packet instanceof PlayerInteractBlockC2SPacket) stopEating(); } diff --git a/src/main/java/me/redcarlos/higtools/modules/main/RotationLock.java b/src/main/java/me/redcarlos/higtools/modules/main/RotationLock.java index ec5cc80..fa26178 100644 --- a/src/main/java/me/redcarlos/higtools/modules/main/RotationLock.java +++ b/src/main/java/me/redcarlos/higtools/modules/main/RotationLock.java @@ -22,9 +22,8 @@ public class RotationLock extends Module { private final SettingGroup sgYaw = settings.createGroup("Yaw"); private final SettingGroup sgPitch = settings.createGroup("Pitch"); - /** - * Yaw - */ + // Yaw + private final Setting yawLockMode = sgYaw.add(new EnumSetting.Builder() .name("yaw-lock-mode") .description("The way in which your yaw is locked.") @@ -42,9 +41,8 @@ public class RotationLock extends Module { .build() ); - /** - * Pitch - */ + // Pitch + private final Setting pitchLockMode = sgPitch.add(new EnumSetting.Builder() .name("pitch-lock-mode") .description("The way in which your pitch is locked.") @@ -77,7 +75,7 @@ private void onGameLeft(GameLeftEvent event) { } @EventHandler - private void onRender(Render3DEvent event) { + private void onRender3D(Render3DEvent event) { if (mc.player == null || mc.world == null) return; switch (yawLockMode.get()) { diff --git a/src/main/java/me/redcarlos/higtools/modules/main/ScaffoldPlus.java b/src/main/java/me/redcarlos/higtools/modules/main/ScaffoldPlus.java index 88feb0c..dd844cf 100644 --- a/src/main/java/me/redcarlos/higtools/modules/main/ScaffoldPlus.java +++ b/src/main/java/me/redcarlos/higtools/modules/main/ScaffoldPlus.java @@ -1,7 +1,7 @@ package me.redcarlos.higtools.modules.main; import me.redcarlos.higtools.HIGTools; -import me.redcarlos.higtools.utils.Enums; +import me.redcarlos.higtools.utils.ListMode; import meteordevelopment.meteorclient.events.world.TickEvent; import meteordevelopment.meteorclient.mixininterface.IVec3d; import meteordevelopment.meteorclient.settings.*; @@ -13,7 +13,6 @@ import net.minecraft.block.Blocks; import net.minecraft.item.BlockItem; import net.minecraft.network.packet.c2s.play.PlayerInteractBlockC2SPacket; -import net.minecraft.network.packet.c2s.play.UpdateSelectedSlotC2SPacket; import net.minecraft.util.Hand; import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.math.BlockPos; @@ -26,10 +25,10 @@ public class ScaffoldPlus extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); - private final Setting listMode = sgGeneral.add(new EnumSetting.Builder() + private final Setting listMode = sgGeneral.add(new EnumSetting.Builder() .name("block-list-mode") .description("Block list selection mode.") - .defaultValue(Enums.ListMode.Whitelist) + .defaultValue(ListMode.Whitelist) .build() ); @@ -37,7 +36,7 @@ public class ScaffoldPlus extends Module { .name("whitelist") .description("Blocks allowed to fill up liquids.") .defaultValue(Blocks.NETHERRACK) - .visible(() -> listMode.get() == Enums.ListMode.Whitelist) + .visible(() -> listMode.get() == ListMode.Whitelist) .build() ); @@ -45,7 +44,7 @@ public class ScaffoldPlus extends Module { .name("blacklist") .description("Blocks denied to fill up liquids.") .defaultValue(Blocks.OBSIDIAN) - .visible(() -> listMode.get() == Enums.ListMode.Blacklist) + .visible(() -> listMode.get() == ListMode.Blacklist) .build() ); @@ -97,7 +96,7 @@ public ScaffoldPlus() { } @EventHandler - public void tick(TickEvent.Pre event) { + public void onTick(TickEvent.Pre event) { if (mc.player == null || mc.world == null) return; float f = MathHelper.sin(mc.player.getYaw() * 0.017453292f); @@ -118,7 +117,7 @@ public void tick(TickEvent.Pre event) { // Find slot with a block FindItemResult item; - if (listMode.get() == Enums.ListMode.Whitelist) { + if (listMode.get() == ListMode.Whitelist) { item = InvUtils.findInHotbar(itemStack -> itemStack.getItem() instanceof BlockItem && whitelist.get().contains(Block.getBlockFromItem(itemStack.getItem()))); } else { item = InvUtils.findInHotbar(itemStack -> itemStack.getItem() instanceof BlockItem && !blacklist.get().contains(Block.getBlockFromItem(itemStack.getItem()))); diff --git a/src/main/java/me/redcarlos/higtools/utils/Enums.java b/src/main/java/me/redcarlos/higtools/utils/Enums.java deleted file mode 100644 index cbbfa4c..0000000 --- a/src/main/java/me/redcarlos/higtools/utils/Enums.java +++ /dev/null @@ -1,8 +0,0 @@ -package me.redcarlos.higtools.utils; - -public class Enums { - public enum ListMode { - Whitelist, - Blacklist - } -} diff --git a/src/main/java/me/redcarlos/higtools/utils/HIGUtils.java b/src/main/java/me/redcarlos/higtools/utils/HIGUtils.java index fa21433..8469c63 100644 --- a/src/main/java/me/redcarlos/higtools/utils/HIGUtils.java +++ b/src/main/java/me/redcarlos/higtools/utils/HIGUtils.java @@ -12,9 +12,8 @@ public class HIGUtils { private HIGUtils() {} - /** - * Packets - */ + // Packets + private static final Int2IntMap packetToClient = new Int2IntOpenHashMap(); private static final Int2IntMap clientToPacket = new Int2IntOpenHashMap(); @@ -29,10 +28,12 @@ private HIGUtils() {} clientToPacket.put(36, 8); packetToClient.put(45, 40); clientToPacket.put(40, 45); + IntStream.rangeClosed(9, 35).forEach(i -> { packetToClient.put(i, i); clientToPacket.put(i, i); }); + IntStream.rangeClosed(0, 8).forEach(i -> { packetToClient.put(i + 36, i); clientToPacket.put(i, i + 36); @@ -43,9 +44,8 @@ public static int csToPs(int clientSlot) { return clientToPacket.getOrDefault(clientSlot, -1); } - /** - * Block pos - */ + // Blockpos + public static boolean canPlaceHIG(BlockPos blockPos) { return canPlace(blockPos, false); } @@ -86,9 +86,8 @@ public static BlockPos right(BlockPos pos, int distance) { }; } - /** - * Highway Axis - */ + // Highway Axes + public static int getHighway() { double playerZ = mc.player.getZ(); double playerX = mc.player.getX(); @@ -107,58 +106,7 @@ public static int getHighway() { if (diag && xp) return 7; if (diag) return 8; return -1; - } - - /** - * Desktop notifications (soon:tm:) - */ - - /* - * This section of the file is part of Baritone - * Thanks to the Baritone team for the source code. - * Download Baritone here : https://github.com/cabaletta/baritonefile - */ - - - /** - * Send a message as a desktop notification - * @param message The message to display in the notification - * - private void logNotification(String message) { - logNotification(message, false); - } - */ - /** - * Send a message as a desktop notification - * @param message The message to display in the notification - * @param error Whether to log as an error - */ - /* - private void logNotification(String message, boolean error) { - if (-1) { - logNotificationDirect(message, error); - } - } - - /** - * Send a message as a desktop notification regardless of desktopNotifications - * (should only be used for critically important messages) - * @param message The message to display in the notification - */ - /* - private void logNotificationDirect(String message) { - logNotificationDirect(message, false); - } - /** - * Send a message as a desktop notification regardless of desktopNotifications - * (should only be used for critically important messages) - * @param message The message to display in the notification - * @param error Whether to log as an error - */ - /* - private void logNotificationDirect(String message, boolean error) { - MinecraftClient.getInstance().execute(() -> BaritoneAPI.getSettings().notifier.value.accept(message, error)); + // TODO: Add toast notifications system (reference Baritone?) } - */ } diff --git a/src/main/java/me/redcarlos/higtools/utils/ListMode.java b/src/main/java/me/redcarlos/higtools/utils/ListMode.java new file mode 100644 index 0000000..05b036f --- /dev/null +++ b/src/main/java/me/redcarlos/higtools/utils/ListMode.java @@ -0,0 +1,6 @@ +package me.redcarlos.higtools.utils; + +public enum ListMode { + Blacklist, + Whitelist +}