From ce4d26dafaef9acde16e5fba754213b2912c60f5 Mon Sep 17 00:00:00 2001 From: tanishisherewithhh <120117618+tanishisherewithhh@users.noreply.github.com> Date: Tue, 24 Sep 2024 12:48:40 +0530 Subject: [PATCH] PacketMine rewrite (works), Gradient setting crashing, Mixin priority compatibility, HoleUtils optimisation, NoSlow actually works now, More strict sprint checks, AutoTotem changes, and some better rendering, removed ModMenu dependency. --- build.gradle | 4 - gradle.properties | 1 - .../dev/heliosclient/ModMenuIntegration.java | 12 - .../hud/hudelements/ModuleList.java | 6 +- .../mixin/ClientPlayerEntityMixin.java | 19 +- .../heliosclient/mixin/MixinChatScreen.java | 2 +- .../heliosclient/mixin/MixinItemRenderer.java | 2 +- .../heliosclient/mixin/MixinSplashScreen.java | 2 +- .../java/dev/heliosclient/module/Module_.java | 34 +-- .../module/modules/combat/AutoTotem.java | 13 +- .../modules/misc/NotificationModule.java | 5 + .../module/modules/movement/GuiMove.java | 11 +- .../module/modules/movement/NoSlow.java | 19 +- .../module/modules/movement/Scaffold.java | 11 +- .../module/modules/movement/Speed.java | 8 +- .../module/modules/movement/Sprint.java | 21 +- .../module/modules/render/BreakIndicator.java | 69 +++-- .../module/modules/render/Fullbright.java | 3 +- .../module/modules/render/NoRender.java | 8 + .../module/modules/world/PacketMine.java | 269 ++++++++++++------ .../module/settings/BooleanSetting.java | 2 +- .../module/settings/ColorSetting.java | 2 +- .../module/settings/CycleSetting.java | 5 + .../module/settings/DoubleSetting.java | 3 +- .../module/settings/DropDownSetting.java | 2 +- .../module/settings/GradientSetting.java | 14 +- .../module/settings/Vector3dSetting.java | 13 +- .../ui/clickgui/ClickGUIScreen.java | 8 +- .../heliosclient/util/blocks/HoleUtils.java | 28 +- .../heliosclient/util/player/DamageUtils.java | 2 - .../util/player/RotationUtils.java | 50 ++-- .../util/render/GradientBlockRenderer.java | 6 +- .../heliosclient/util/render/Renderer2D.java | 31 +- src/main/resources/fabric.mod.json | 3 - 34 files changed, 433 insertions(+), 255 deletions(-) delete mode 100644 src/main/java/dev/heliosclient/ModMenuIntegration.java diff --git a/build.gradle b/build.gradle index a73c75a5..edab84ec 100644 --- a/build.gradle +++ b/build.gradle @@ -26,7 +26,6 @@ repositories { includeGroupByRegex 'dev\\.onyxstudios.*' } } - maven { url "https://maven.terraformersmc.com/releases/" } maven { name = "meteor-maven" url = "https://maven.meteordev.org/releases" @@ -76,9 +75,6 @@ dependencies { // LuaJ library modInclude("org.luaj:luaj-jse:3.0.1") - // ModMenu - modApi "com.terraformersmc:modmenu:${project.modmenu_version}" - // Discord GameSDK modInclude('com.github.JnCrMx:discord-game-sdk4j:v0.5.5') diff --git a/gradle.properties b/gradle.properties index 72aa603c..3192f7c8 100644 --- a/gradle.properties +++ b/gradle.properties @@ -15,5 +15,4 @@ archives_base_name = heliosclient # Dependencies fabric_version=0.91.1+1.20.4 -modmenu_version=9.0.0 baritone_version=1.20.4-SNAPSHOT \ No newline at end of file diff --git a/src/main/java/dev/heliosclient/ModMenuIntegration.java b/src/main/java/dev/heliosclient/ModMenuIntegration.java deleted file mode 100644 index 33fdd57f..00000000 --- a/src/main/java/dev/heliosclient/ModMenuIntegration.java +++ /dev/null @@ -1,12 +0,0 @@ -package dev.heliosclient; - -import com.terraformersmc.modmenu.api.ConfigScreenFactory; -import com.terraformersmc.modmenu.api.ModMenuApi; -import dev.heliosclient.ui.clickgui.ClickGUIScreen; - -public class ModMenuIntegration implements ModMenuApi { - @Override - public ConfigScreenFactory getModConfigScreenFactory() { - return parent -> ClickGUIScreen.INSTANCE; - } -} \ No newline at end of file diff --git a/src/main/java/dev/heliosclient/hud/hudelements/ModuleList.java b/src/main/java/dev/heliosclient/hud/hudelements/ModuleList.java index 7fa1c71b..89c265b8 100644 --- a/src/main/java/dev/heliosclient/hud/hudelements/ModuleList.java +++ b/src/main/java/dev/heliosclient/hud/hudelements/ModuleList.java @@ -211,8 +211,6 @@ public void renderElement(DrawContext drawContext, TextRenderer textRenderer) { int yOffset = this.y; // Start rendering from this.y for (Module_ m : enabledModules) { - if (!m.showInModulesList.value) continue; - String info = m.getInfoString(); float nameWidth = Renderer2D.getStringWidth(m.name) + getInfoStringWidth(info); @@ -239,11 +237,12 @@ public void renderElement(DrawContext drawContext, TextRenderer textRenderer) { } } - if (sideLines.value) + if (sideLines.value) { // Draw a vertical separator line Renderer2D.drawRectangle(drawContext.getMatrices().peek().getPositionMatrix(), x - 2.3f + width, yOffset, 2, Math.round(Renderer2D.getStringHeight()) + 3, colorToRenderIn.getRGB()); + } // Draw the module name Renderer2D.drawString(drawContext.getMatrices(), m.name, @@ -282,6 +281,7 @@ private float getInfoStringWidth(String infoString) { @SubscribeEvent public void update(TickEvent.CLIENT event) { enabledModules = ModuleManager.getEnabledModules(); + enabledModules.removeIf(module -> !module.showInModulesList.value); enabledModules.sort(getComparator()); diff --git a/src/main/java/dev/heliosclient/mixin/ClientPlayerEntityMixin.java b/src/main/java/dev/heliosclient/mixin/ClientPlayerEntityMixin.java index f1477dc1..2a25ee98 100644 --- a/src/main/java/dev/heliosclient/mixin/ClientPlayerEntityMixin.java +++ b/src/main/java/dev/heliosclient/mixin/ClientPlayerEntityMixin.java @@ -12,7 +12,6 @@ import dev.heliosclient.module.modules.render.Freecam; import dev.heliosclient.module.modules.world.BetterPortals; import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.hud.InGameHud; import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.entity.MovementType; @@ -26,7 +25,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -@Mixin(value = ClientPlayerEntity.class, priority = 600) +@Mixin(value = ClientPlayerEntity.class, priority = 620) public abstract class ClientPlayerEntityMixin { @Unique @@ -38,6 +37,8 @@ public abstract class ClientPlayerEntityMixin { @Shadow protected abstract void sendMovementPackets(); + @Shadow public abstract boolean isSneaking(); + @Inject(method = "move", at = @At(value = "HEAD"), cancellable = true) public void onMove(MovementType type, Vec3d movement, CallbackInfo ci) { PlayerMotionEvent event = new PlayerMotionEvent(type, movement); @@ -79,6 +80,20 @@ private float onHunger(float constant) { return constant; } + @Redirect(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isUsingItem()Z"), require = 0) + private boolean tickMovementHook(ClientPlayerEntity player) { + if (NoSlow.get().items.value && NoSlow.get().isActive()) + return false; + return player.isUsingItem(); + } + + @Inject(method = "shouldSlowDown", at = @At("HEAD"), cancellable = true) + public void shouldSlowDownHook(CallbackInfoReturnable cir) { + if(NoSlow.get().isActive() && (NoSlow.get().sneak.value || NoSlow.get().crawl.value)) { + cir.setReturnValue(false); + } + } + @Inject(method = "tick", at = @At(value = "HEAD"), cancellable = true) public void onTick(CallbackInfo ci) { if (HeliosClient.MC.player != null) { diff --git a/src/main/java/dev/heliosclient/mixin/MixinChatScreen.java b/src/main/java/dev/heliosclient/mixin/MixinChatScreen.java index bbb1b40c..5e97a11c 100644 --- a/src/main/java/dev/heliosclient/mixin/MixinChatScreen.java +++ b/src/main/java/dev/heliosclient/mixin/MixinChatScreen.java @@ -12,7 +12,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -@Mixin(value = ChatScreen.class, priority = 1001) +@Mixin(value = ChatScreen.class, priority = 100) public abstract class MixinChatScreen { @Shadow protected TextFieldWidget chatField; diff --git a/src/main/java/dev/heliosclient/mixin/MixinItemRenderer.java b/src/main/java/dev/heliosclient/mixin/MixinItemRenderer.java index dcf71b6e..18a78c2c 100644 --- a/src/main/java/dev/heliosclient/mixin/MixinItemRenderer.java +++ b/src/main/java/dev/heliosclient/mixin/MixinItemRenderer.java @@ -27,7 +27,7 @@ public abstract class MixinItemRenderer { ) ) private void modifyEnchant(Args args, ItemStack stack, ModelTransformationMode renderMode, boolean leftHanded, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay, BakedModel model) { - if (NoRender.get().isActive() && !NoRender.get().noEnchantGlint.value) return; + if (NoRender.enchantGlint()) 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/dev/heliosclient/mixin/MixinSplashScreen.java b/src/main/java/dev/heliosclient/mixin/MixinSplashScreen.java index e2281546..b7285e56 100644 --- a/src/main/java/dev/heliosclient/mixin/MixinSplashScreen.java +++ b/src/main/java/dev/heliosclient/mixin/MixinSplashScreen.java @@ -34,7 +34,7 @@ import static dev.heliosclient.util.render.textures.ClientTexture.CLIENT_LOGO_TEXTURE; -@Mixin(value = SplashOverlay.class, priority = 3000) +@Mixin(value = SplashOverlay.class, priority = 3001) public abstract class MixinSplashScreen { @Unique diff --git a/src/main/java/dev/heliosclient/module/Module_.java b/src/main/java/dev/heliosclient/module/Module_.java index f5f177d4..650f576c 100644 --- a/src/main/java/dev/heliosclient/module/Module_.java +++ b/src/main/java/dev/heliosclient/module/Module_.java @@ -3,8 +3,6 @@ import dev.heliosclient.HeliosClient; import dev.heliosclient.event.SubscribeEvent; import dev.heliosclient.event.events.TickEvent; -import dev.heliosclient.event.events.player.PlayerMotionEvent; -import dev.heliosclient.event.events.render.RenderEvent; import dev.heliosclient.event.listener.Listener; import dev.heliosclient.managers.EventManager; import dev.heliosclient.managers.ModuleManager; @@ -37,12 +35,12 @@ public abstract class Module_ implements Listener, ISettingChange, ISaveAndLoad public Set settingGroups; public Set> quickSettings; public boolean settingsOpen = false; - public SettingGroup sgbind = new SettingGroup("Bind"); + public SettingGroup sgBind = new SettingGroup("Bind"); /** * Setting indicating if chat feedback for this module should be shown. Don't remove, that will cause crash. */ - public BooleanSetting chatFeedback = sgbind.add(new BooleanSetting.Builder() + public BooleanSetting chatFeedback = sgBind.add(new BooleanSetting.Builder() .name("Enable chat feedback") .description("Toggles feedback in chat.") .onSettingChange(this) @@ -53,7 +51,7 @@ public abstract class Module_ implements Listener, ISettingChange, ISaveAndLoad /** * Setting that will tell module list if it should be shown. Don't remove, that will cause crash. */ - public BooleanSetting showInModulesList = sgbind.add(new BooleanSetting.Builder() + public BooleanSetting showInModulesList = sgBind.add(new BooleanSetting.Builder() .name("Show in Modules List") .description("If this module should show up in Module List.") .onSettingChange(this) @@ -64,7 +62,7 @@ public abstract class Module_ implements Listener, ISettingChange, ISaveAndLoad /** * Key-bind setting. Don't remove, that will cause crash. */ - public KeyBind keyBind = sgbind.add(new KeyBind.Builder() + public KeyBind keyBind = sgBind.add(new KeyBind.Builder() .name("Keybind") .description("Key to toggle this module.") .onSettingChange(this) @@ -75,7 +73,7 @@ public abstract class Module_ implements Listener, ISettingChange, ISaveAndLoad /** * Key-bind setting. Don't remove, that will cause crash. */ - public BooleanSetting toggleOnBindRelease = sgbind.add(new BooleanSetting.Builder() + public BooleanSetting toggleOnBindRelease = sgBind.add(new BooleanSetting.Builder() .name("Toggle On Bind Release") .description("Toggle on if key is being held and off if key is released") .onSettingChange(this) @@ -87,7 +85,7 @@ public abstract class Module_ implements Listener, ISettingChange, ISaveAndLoad /** * Value indicating if module is enabled. Don't remove, that will cause crash. */ - public BooleanSetting active = sgbind.add(new BooleanSetting.Builder() + public BooleanSetting active = sgBind.add(new BooleanSetting.Builder() .name("Active") .description("State of this module.") .onSettingChange(this) @@ -157,7 +155,6 @@ public void addQuickSettings(List> setting) { public void onEnable() { active.value = true; if (chatFeedback.value) { - assert mc.player != null; ChatUtils.sendHeliosMsg(this.name + " was enabled."); } EventManager.register(this); @@ -176,19 +173,11 @@ public boolean isActive() { public void onDisable() { active.value = false; if (chatFeedback.value) { - assert mc.player != null; ChatUtils.sendHeliosMsg(this.name + " was disabled."); } EventManager.unregister(this); } - /** - * Called on player motion. - */ - @SubscribeEvent - public void onMotion(PlayerMotionEvent event) { - } - /** * Called on tick. */ @@ -196,13 +185,6 @@ public void onMotion(PlayerMotionEvent event) { public void onTick(TickEvent.CLIENT event) { } - /** - * Called on render. - */ - @SubscribeEvent - public void render(RenderEvent event) { - } - /** * Toggles the module. */ @@ -220,7 +202,7 @@ public void toggle() { public void sendNotification(boolean enabled) { String description = enabled ? "was enabled!" : "was disabled!"; - if (ModuleManager.get(NotificationModule.class).moduleNotification.value && HeliosClient.shouldSendNotification()) { + if (ModuleManager.get(NotificationModule.class).displayModuleNotification()) { NotificationManager.addNotification(new InfoNotification(this.name, description, 2000, SoundUtils.TING_SOUNDEVENT, enabled ? 1f : 0.5f)); } } @@ -245,7 +227,7 @@ public void setKeybind(Integer keycode) { * Called on load. Override to remove default settings. */ public void onLoad() { - addSettingGroup(sgbind); + addSettingGroup(sgBind); } public String getNameWithInfo() { diff --git a/src/main/java/dev/heliosclient/module/modules/combat/AutoTotem.java b/src/main/java/dev/heliosclient/module/modules/combat/AutoTotem.java index b043d2e4..2ef48494 100644 --- a/src/main/java/dev/heliosclient/module/modules/combat/AutoTotem.java +++ b/src/main/java/dev/heliosclient/module/modules/combat/AutoTotem.java @@ -99,7 +99,7 @@ public void onDisable() { @SubscribeEvent public void onKey(KeyPressedEvent e){ - if(e.getKey() == totemSwitchKey.value){ + if(e.getKey() == totemSwitchKey.value && mc.currentScreen == null){ doAutoTotem(); timer.restartTimer(); } @@ -118,10 +118,10 @@ public void onTick(TickEvent.WORLD event) { return; } if(always.value || didTotemPop || isPlayerLow()) { - doAutoTotem(); + boolean status = doAutoTotem(); didTotemPop = false; - if(log.value){ + if(log.value && status){ ChatUtils.sendHeliosMsg("Restocked Totem, Totems left: " + InventoryUtils.getItemCountInInventory(Items.TOTEM_OF_UNDYING)); } } @@ -132,11 +132,11 @@ public void onTick(TickEvent.WORLD event) { } } - public void doAutoTotem(){ + public boolean doAutoTotem(){ boolean offhandHasItem = !mc.player.getOffHandStack().isEmpty(); int itemSlot = InventoryUtils.findItemInInventory(Items.TOTEM_OF_UNDYING); - if(itemSlot == -1 || itemSlot == InventoryUtils.OFFHAND){ - return; + if(itemSlot == -1 || itemSlot == InventoryUtils.OFFHAND || mc.player.getOffHandStack().getItem() == Items.TOTEM_OF_UNDYING){ + return false; } //if is hotbar then swap item with offhand super-fast. @@ -151,6 +151,7 @@ public void doAutoTotem(){ mc.interactionManager.clickSlot(mc.player.currentScreenHandler.syncId,itemSlot,0,SlotActionType.PICKUP,mc.player); } } + return true; } @SubscribeEvent diff --git a/src/main/java/dev/heliosclient/module/modules/misc/NotificationModule.java b/src/main/java/dev/heliosclient/module/modules/misc/NotificationModule.java index 7f636409..29747786 100644 --- a/src/main/java/dev/heliosclient/module/modules/misc/NotificationModule.java +++ b/src/main/java/dev/heliosclient/module/modules/misc/NotificationModule.java @@ -1,5 +1,6 @@ package dev.heliosclient.module.modules.misc; +import dev.heliosclient.HeliosClient; import dev.heliosclient.managers.NotificationManager; import dev.heliosclient.module.Categories; import dev.heliosclient.module.Module_; @@ -91,6 +92,10 @@ public void onDisable() { NotificationManager.INSTANCE.clear(); } + public boolean displayModuleNotification(){ + return HeliosClient.shouldSendNotification() && moduleNotification.value; + } + @Override public void onSettingChange(Setting setting) { super.onSettingChange(setting); diff --git a/src/main/java/dev/heliosclient/module/modules/movement/GuiMove.java b/src/main/java/dev/heliosclient/module/modules/movement/GuiMove.java index c69359e3..ac83b5d7 100644 --- a/src/main/java/dev/heliosclient/module/modules/movement/GuiMove.java +++ b/src/main/java/dev/heliosclient/module/modules/movement/GuiMove.java @@ -19,7 +19,16 @@ public GuiMove() { } public boolean dontMove() { - return mc.currentScreen == null || mc.currentScreen instanceof AbstractCommandBlockScreen || mc.currentScreen instanceof CreativeInventoryScreen || mc.currentScreen instanceof ChatScreen || mc.currentScreen instanceof AnvilScreen || mc.currentScreen instanceof StructureBlockScreen || mc.currentScreen instanceof SignEditScreen || ClickGUIScreen.INSTANCE.searchBar.isFocused() || mc.currentScreen instanceof AbstractSettingScreen || mc.currentScreen instanceof HudEditorScreen; + return mc.currentScreen == null || + mc.currentScreen instanceof AbstractCommandBlockScreen || + mc.currentScreen instanceof CreativeInventoryScreen || + mc.currentScreen instanceof ChatScreen || + mc.currentScreen instanceof AnvilScreen || + mc.currentScreen instanceof StructureBlockScreen || + mc.currentScreen instanceof SignEditScreen || + ClickGUIScreen.INSTANCE.searchBar.isFocused() || + mc.currentScreen instanceof AbstractSettingScreen || + mc.currentScreen instanceof HudEditorScreen; } @SubscribeEvent diff --git a/src/main/java/dev/heliosclient/module/modules/movement/NoSlow.java b/src/main/java/dev/heliosclient/module/modules/movement/NoSlow.java index 88aa25e9..739d5e08 100644 --- a/src/main/java/dev/heliosclient/module/modules/movement/NoSlow.java +++ b/src/main/java/dev/heliosclient/module/modules/movement/NoSlow.java @@ -11,7 +11,7 @@ public class NoSlow extends Module_ { public BooleanSetting items = sgGeneral.add(new BooleanSetting.Builder() .name("Items") - .description("Should item use slow you down?") + .description("Should item use slow you down? (any item like food, bow, crossbow, trident,shield, etc.)") .onSettingChange(this) .defaultValue(true) .build() @@ -48,7 +48,7 @@ public class NoSlow extends Module_ { .name("Fluid drag") .description("Should fluid push slow you down?") .onSettingChange(this) - .defaultValue(true) + .defaultValue(false) .build() ); public BooleanSetting hunger = sgGeneral.add(new BooleanSetting.Builder() @@ -58,13 +58,26 @@ public class NoSlow extends Module_ { .defaultValue(true) .build() ); + public BooleanSetting sneak = sgGeneral.add(new BooleanSetting.Builder() + .name("Sneak") + .description("Should sneaking slow you down?") + .onSettingChange(this) + .defaultValue(true) + .build() + ); + public BooleanSetting crawl = sgGeneral.add(new BooleanSetting.Builder() + .name("Crawl") + .description("Should crawling slow you down?") + .onSettingChange(this) + .defaultValue(true) + .build() + ); public NoSlow() { super("NoSlow", "Removes slowness due to some actions or blocks", Categories.MOVEMENT); addSettingGroup(sgGeneral); addQuickSettings(sgGeneral.getSettings()); - } public static NoSlow get() { diff --git a/src/main/java/dev/heliosclient/module/modules/movement/Scaffold.java b/src/main/java/dev/heliosclient/module/modules/movement/Scaffold.java index cab59394..6c459b0e 100644 --- a/src/main/java/dev/heliosclient/module/modules/movement/Scaffold.java +++ b/src/main/java/dev/heliosclient/module/modules/movement/Scaffold.java @@ -134,13 +134,6 @@ public class Scaffold extends Module_ { .defaultValue(false) .build() ); - BooleanSetting clientSide = sgPlace.add(new BooleanSetting.Builder() - .name("ClientSide rotation") - .onSettingChange(this) - .defaultValue(true) - .shouldRender(() -> rotate.value) - .build() - ); /* Switch */ BooleanSetting autoSwitch = sgSwitch.add(new BooleanSetting.Builder() .name("AutoSwitch") @@ -338,9 +331,9 @@ private boolean placeBlockPos(BlockPos pos, int itemSlot) { if (autoSwitch.value) { - placeResult = BlockUtils.place(pos, airPlace.value, rotate.value, clientSide.value, itemSlot, silentSwitch.value); + placeResult = BlockUtils.place(pos, airPlace.value, rotate.value, true, itemSlot, silentSwitch.value); } else { - placeResult = BlockUtils.place(pos, airPlace.value, rotate.value, clientSide.value); + placeResult = BlockUtils.place(pos, airPlace.value, rotate.value, true); } if (placeResult) { diff --git a/src/main/java/dev/heliosclient/module/modules/movement/Speed.java b/src/main/java/dev/heliosclient/module/modules/movement/Speed.java index fdbe87e3..c5c69bc0 100644 --- a/src/main/java/dev/heliosclient/module/modules/movement/Speed.java +++ b/src/main/java/dev/heliosclient/module/modules/movement/Speed.java @@ -32,7 +32,7 @@ public class Speed extends Module_ { .description("Strict movement and sprinting for strafing") .onSettingChange(this) .value(false) - .shouldRender(()->speedMode.isOption(Modes.StrictStrafe)) + .shouldRender(()-> speedMode.isOption(Modes.StrictStrafe)) .build() ); BooleanSetting whileSneaking = sgGeneral.add(new BooleanSetting.Builder() @@ -94,9 +94,9 @@ public void onMotion(PlayerMotionEvent e) { mc.player.networkHandler.sendPacket(new ClientCommandC2SPacket(mc.player, ClientCommandC2SPacket.Mode.START_SPRINTING)); } - double prevX = e.getMovement().x * (1.0 - speed.value/speed.max); - double prevZ = e.getMovement().z * (1.0 - speed.value/speed.max); - double useSpeed = mc.player.getVelocity().horizontalLength() * (speed.value/speed.max); + double prevX = e.getMovement().x * (1.0 - speed.value/10.1); + double prevZ = e.getMovement().z * (1.0 - speed.value/10.1); + double useSpeed = mc.player.getVelocity().horizontalLength() * (speed.value/10.0); double angle = Math.toRadians(mc.player.getYaw(mc.getTickDelta())); double x = (-Math.sin(angle) * useSpeed) + prevX; diff --git a/src/main/java/dev/heliosclient/module/modules/movement/Sprint.java b/src/main/java/dev/heliosclient/module/modules/movement/Sprint.java index 4c96af99..1dafd40b 100644 --- a/src/main/java/dev/heliosclient/module/modules/movement/Sprint.java +++ b/src/main/java/dev/heliosclient/module/modules/movement/Sprint.java @@ -2,6 +2,7 @@ import dev.heliosclient.event.SubscribeEvent; import dev.heliosclient.event.events.TickEvent; +import dev.heliosclient.managers.ModuleManager; import dev.heliosclient.module.Categories; import dev.heliosclient.module.Module_; import dev.heliosclient.module.settings.BooleanSetting; @@ -11,8 +12,8 @@ public class Sprint extends Module_ { SettingGroup sgGeneral = new SettingGroup("General"); - BooleanSetting strictMode = sgGeneral.add(new BooleanSetting("Strict Mode", "Only sprints when you are moving", this, false, () -> true, true)); - BooleanSetting keepSprint = sgGeneral.add(new BooleanSetting("Keep Sprint", "Keeps sprinting even after attacking", this, false, () -> true, false)); + BooleanSetting strictMode = sgGeneral.add(new BooleanSetting("Strict Mode", "Only sprints when you are moving", this, true)); + BooleanSetting keepSprint = sgGeneral.add(new BooleanSetting("Keep Sprint", "Keeps sprinting even after attacking", this, false)); public Sprint() { super("Sprint", "Automatically sprints for you", Categories.MOVEMENT); @@ -29,15 +30,23 @@ public void onDisable() { @SubscribeEvent public void onTick(TickEvent.PLAYER event) { - if (mc.player.getHungerManager().getFoodLevel() <= 6) + if (mc.player.getHungerManager().getFoodLevel() <= 6.0F) return; - if (strictMode.value && mc.player.forwardSpeed > 0.00f) { - mc.player.setSprinting(true); - } else if (!strictMode.value) { + if (strictModeCheck()) { mc.player.setSprinting(true); } } + public boolean strictModeCheck() { + if(!strictMode.value){ + return mc.currentScreen == null; + } + return mc.player.forwardSpeed > 0.00f && + !mc.player.horizontalCollision && + !mc.player.isTouchingWater() && + !mc.player.isSubmergedInWater() && + (mc.currentScreen == null || ModuleManager.get(GuiMove.class).isActive()); + } public boolean shouldStopSprinting() { return !isActive() || !keepSprint.value; diff --git a/src/main/java/dev/heliosclient/module/modules/render/BreakIndicator.java b/src/main/java/dev/heliosclient/module/modules/render/BreakIndicator.java index 8ec514b3..dc15427e 100644 --- a/src/main/java/dev/heliosclient/module/modules/render/BreakIndicator.java +++ b/src/main/java/dev/heliosclient/module/modules/render/BreakIndicator.java @@ -6,9 +6,7 @@ import dev.heliosclient.mixin.AccessorWorldRenderer; import dev.heliosclient.module.Categories; import dev.heliosclient.module.Module_; -import dev.heliosclient.module.settings.CycleSetting; -import dev.heliosclient.module.settings.RGBASetting; -import dev.heliosclient.module.settings.SettingGroup; +import dev.heliosclient.module.settings.*; import dev.heliosclient.util.ColorUtils; import dev.heliosclient.util.render.Renderer3D; import dev.heliosclient.util.render.color.QuadColor; @@ -36,6 +34,35 @@ public class BreakIndicator extends Module_ { .defaultListOption(Highlight) .build() ); + BooleanSetting gradientBool = sgGeneral.add(new BooleanSetting.Builder() + .name("Use a gradient") + .description("Whether to use gradient or not") + .defaultValue(false) + .value(false) + .onSettingChange(this) + .shouldRender(() -> type.getOption() == Highlight) + .build() + ); + GradientSetting gradient = sgGeneral.add(new GradientSetting.Builder() + .name("Gradient Value") + .description("The gradient to use") + .onSettingChange(this) + .defaultValue("Rainbow") + .shouldRender(() -> type.getOption() == Highlight && gradientBool.value) + .build() + ); + DoubleSetting alpha = sgGeneral.add(new DoubleSetting.Builder() + .name("Gradient Alpha/Opacity") + .description("Desired alpha (opacity) value of the gradients") + .onSettingChange(this) + .value(150) + .defaultValue(150) + .min(0) + .max(255) + .shouldRender(() -> type.getOption() == Highlight && gradientBool.value) + .roundingPlace(0) + .build() + ); RGBASetting highlightColor = sgGeneral.add(new RGBASetting.Builder() .name("Highlight color") .description("Color of the highlight") @@ -43,7 +70,7 @@ public class BreakIndicator extends Module_ { .value(Color.WHITE) .onSettingChange(this) .rainbow(true) - .shouldRender(() -> type.getOption() == Highlight) + .shouldRender(() -> type.getOption() == Highlight && !gradientBool.value) .build() ); @@ -70,8 +97,10 @@ public void onRender3d(Render3DEvent event) { BlockState state = mc.world.getBlockState(currentBreakingPos); VoxelShape shape = state.getOutlineShape(mc.world, currentBreakingPos); if (shape == null || shape.isEmpty()) return; + int start = gradientBool.value ? ColorUtils.changeAlpha(gradient.get().getStartGradient().getRGB(),alpha.getInt()).getRGB() : highlightColor.value.getRGB(); + int end = gradientBool.value ? ColorUtils.changeAlpha(gradient.get().getEndGradient().getRGB(),alpha.getInt()).getRGB() : highlightColor.value.getRGB(); - renderIndicator(shape.getBoundingBox().expand(0.005f).offset(currentBreakingPos), selfBreakingProgress); + renderIndicator(shape.getBoundingBox().expand(0.001f).offset(currentBreakingPos), selfBreakingProgress/10.0f, (IndicateType) type.getOption(),start,end); } breakingInfos.forEach((integer, info) -> { @@ -84,23 +113,25 @@ public void onRender3d(Render3DEvent event) { VoxelShape shape = state.getOutlineShape(mc.world, pos); if (shape == null || shape.isEmpty()) return; + int start = gradientBool.value ? ColorUtils.changeAlpha(gradient.get().getStartGradient().getRGB(),alpha.getInt()).getRGB() : highlightColor.value.getRGB(); + int end = gradientBool.value ? ColorUtils.changeAlpha(gradient.get().getEndGradient().getRGB(),alpha.getInt()).getRGB() : highlightColor.value.getRGB(); - renderIndicator(shape.getBoundingBox().expand(0.005f).offset(pos), breakProgress + 1); + renderIndicator(shape.getBoundingBox().expand(0.001f).offset(pos), (float) (breakProgress + 1) / 10, (IndicateType) type.getOption(),start,end); }); Renderer3D.stopRenderingThroughWalls(); } - public void renderIndicator(Box box, float breakingProg) { - if (IndicateType.values()[type.value] == Highlight) { - Renderer3D.drawBoxFill(box, QuadColor.single(highlightColor.value.getRGB())); - - } else if (IndicateType.values()[type.value] == Stretch) { - Box stretchedBox = shrinkBoxExtreme(box).stretch(0,0,breakingProg/10.0); - Renderer3D.drawBoxBoth(stretchedBox, QuadColor.single(getColor((int)breakingProg)), 1f); - - } else if (IndicateType.values()[type.value] == Contract) { - Box shrunkBox = box.expand(breakingProg / 20.0 - 1.0); - Renderer3D.drawBoxBoth(shrunkBox, QuadColor.single(getColor((int)breakingProg)), 1f); + public void renderIndicator(Box box, float breakingProg,IndicateType type, int start, int end) { + if (type == Highlight) { + QuadColor color = QuadColor.gradient(start,end, QuadColor.CardinalDirection.DIAGONAL_LEFT); + + Renderer3D.drawBoxFill(box, color); + } else if (type == Stretch) { + Box stretchedBox = shrinkBoxExtreme(box).stretch(0,0,breakingProg); + Renderer3D.drawBoxBoth(stretchedBox, QuadColor.single(getColor(breakingProg)), 1f); + } else if (type == Contract) { + Box shrunkBox = box.expand((breakingProg / 2) - 1.0); + Renderer3D.drawBoxBoth(shrunkBox, QuadColor.single(getColor(breakingProg)), 1f); } } @@ -109,8 +140,8 @@ public Box shrinkBoxExtreme(Box box){ return new Box(box.minX,box.minY,box.minZ,box.maxX,box.maxY,box.minZ); } - public int getColor(int breakingPos) { - return breakingPos > 5 ? (breakingPos > 8 ? get(Color.GREEN) : get(Color.YELLOW)) : breakingPos > 3 ? get(Color.ORANGE) : get(Color.RED); + public int getColor(float breakingPos) { + return breakingPos > 0.5 ? (breakingPos > 0.8 ? get(Color.GREEN) : get(Color.YELLOW)) : breakingPos > 0.3 ? get(Color.ORANGE) : get(Color.RED); } public int get(Color c) { diff --git a/src/main/java/dev/heliosclient/module/modules/render/Fullbright.java b/src/main/java/dev/heliosclient/module/modules/render/Fullbright.java index 22384b3e..cd56edf4 100644 --- a/src/main/java/dev/heliosclient/module/modules/render/Fullbright.java +++ b/src/main/java/dev/heliosclient/module/modules/render/Fullbright.java @@ -37,7 +37,8 @@ public class Fullbright extends Module_ { .max(7.0) .shouldRender(() -> mode.value == 0) .roundingPlace(0) - .build()); + .build() + ); public Fullbright() { super("Fullbright", "Allows you to see in the dark.", Categories.RENDER); diff --git a/src/main/java/dev/heliosclient/module/modules/render/NoRender.java b/src/main/java/dev/heliosclient/module/modules/render/NoRender.java index 89f95dbc..3a9ef9d3 100644 --- a/src/main/java/dev/heliosclient/module/modules/render/NoRender.java +++ b/src/main/java/dev/heliosclient/module/modules/render/NoRender.java @@ -47,6 +47,14 @@ public static NoRender get() { return ModuleManager.get(NoRender.class); } + public static boolean enchantGlint(){ + if(!get().isActive()){ + return true; + } + + return get().noEnchantGlint.value; + } + @SubscribeEvent public void onParticle(ParticleEvent event) { if (event.parameters.getType() == ParticleTypes.RAIN && noWeather.value) { diff --git a/src/main/java/dev/heliosclient/module/modules/world/PacketMine.java b/src/main/java/dev/heliosclient/module/modules/world/PacketMine.java index 321bfea8..cbc068a1 100644 --- a/src/main/java/dev/heliosclient/module/modules/world/PacketMine.java +++ b/src/main/java/dev/heliosclient/module/modules/world/PacketMine.java @@ -4,35 +4,37 @@ import dev.heliosclient.event.events.TickEvent; import dev.heliosclient.event.events.block.BeginBreakingBlockEvent; import dev.heliosclient.event.events.render.Render3DEvent; +import dev.heliosclient.managers.ModuleManager; import dev.heliosclient.module.Categories; import dev.heliosclient.module.Module_; -import dev.heliosclient.module.settings.BooleanSetting; -import dev.heliosclient.module.settings.DoubleSetting; -import dev.heliosclient.module.settings.RGBASetting; -import dev.heliosclient.module.settings.SettingGroup; -import dev.heliosclient.util.blocks.BlockUtils; +import dev.heliosclient.module.modules.render.BreakIndicator; +import dev.heliosclient.module.settings.*; import dev.heliosclient.util.ColorUtils; +import dev.heliosclient.util.blocks.BlockUtils; import dev.heliosclient.util.player.InventoryUtils; import dev.heliosclient.util.player.RotationUtils; import dev.heliosclient.util.render.Renderer3D; -import dev.heliosclient.util.render.color.QuadColor; +import net.minecraft.block.BlockState; +import net.minecraft.network.packet.c2s.play.HandSwingC2SPacket; import net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket; import net.minecraft.network.packet.c2s.play.UpdateSelectedSlotC2SPacket; +import net.minecraft.util.Hand; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; +import net.minecraft.util.shape.VoxelShape; import java.awt.*; -import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; import java.util.Map; -import java.util.Optional; + +import static dev.heliosclient.module.modules.render.BreakIndicator.IndicateType.Highlight; public class PacketMine extends Module_ { private final SettingGroup sgGeneral = new SettingGroup("General"); - private final SettingGroup sgRender = new SettingGroup("Render"); - private final Map blocks = new HashMap<>(); - private final Map progressMap = new HashMap<>(); - private final Map timerMap = new HashMap<>(); - private final Map miningMap = new HashMap<>(); + private final SettingGroup sgRender = new SettingGroup("Break Render"); + + private final MiningQueue miningQueue = new MiningQueue(); private final DoubleSetting delay = sgGeneral.add(new DoubleSetting.Builder() .name("Delay") @@ -47,7 +49,27 @@ public class PacketMine extends Module_ { .name("Rotate") .description("Rotates to look at the block before mining it") .defaultValue(false) + .value(false) + .onSettingChange(this) + .build() + ); + private final BooleanSetting reattempt = sgGeneral.add(new BooleanSetting.Builder() + .name("Re-attempt") + .description("If a block fails to get mined, then should we attempt to re break it again? This may break the block") + .defaultValue(false) + .onSettingChange(this) + .build() + ); + private final DoubleSetting maxReattempts = sgGeneral.add(new DoubleSetting.Builder() + .name("Max Re-attempts") + .description("The max number of attempts to mine a block before discarding it.") .onSettingChange(this) + .value(2) + .defaultValue(2) + .min(2) + .max(10) + .shouldRender(() -> reattempt.value) + .roundingPlace(0) .build() ); private final BooleanSetting autoSwitch = sgGeneral.add(new BooleanSetting.Builder() @@ -65,31 +87,55 @@ public class PacketMine extends Module_ { .shouldRender(() -> autoSwitch.value) .build() ); - BooleanSetting outline = sgRender.add(new BooleanSetting.Builder() - .name("Outline") - .description("Draw outline of blocks") - .value(true) - .defaultValue(true) + private final CycleSetting type = sgRender.add(new CycleSetting.Builder() + .name("Indicator Type") + .description("Type of break indication") .onSettingChange(this) + .value(List.of(BreakIndicator.IndicateType.values())) + .defaultListOption(Highlight) .build() ); - BooleanSetting fill = sgRender.add(new BooleanSetting.Builder() - .name("Fill") - .description("Draw side fill of blocks") - .value(false) + private final BooleanSetting gradientBool = sgRender.add(new BooleanSetting.Builder() + .name("Use a gradient") + .description("Whether to use gradient or not") .defaultValue(false) + .value(false) .onSettingChange(this) + .shouldRender(() -> type.getOption() == Highlight) .build() ); - RGBASetting color = sgRender.add(new RGBASetting.Builder() - .name("Color") - .value(ColorUtils.changeAlpha(Color.WHITE, 125)) - .defaultValue(ColorUtils.changeAlpha(Color.WHITE, 125)) + private final GradientSetting gradient = sgRender.add(new GradientSetting.Builder() + .name("Gradient Value") + .description("The gradient to use") .onSettingChange(this) + .defaultValue("Rainbow") + .shouldRender(() -> type.getOption() == Highlight && gradientBool.value) + .build() + ); + private final DoubleSetting alpha = sgRender.add(new DoubleSetting.Builder() + .name("Gradient Alpha/Opacity") + .description("Desired alpha (opacity) value of the gradients") + .onSettingChange(this) + .value(150) + .defaultValue(150) + .min(0) + .max(255) + .shouldRender(() -> type.getOption() == Highlight && gradientBool.value) + .roundingPlace(0) + .build() + ); + private final RGBASetting highlightColor = sgRender.add(new RGBASetting.Builder() + .name("Highlight color") + .description("Color of the highlight") + .defaultValue(Color.WHITE) + .value(Color.WHITE) + .onSettingChange(this) + .rainbow(true) + .shouldRender(() -> type.getOption() == Highlight && !gradientBool.value) .build() ); - private boolean swapped, shouldUpdateSlot; + private boolean swapped, shouldUpdateSlot; public PacketMine() { super("PacketMine", "Mines blocks via packets and allows you to mine several blocks in queue", Categories.WORLD); @@ -98,7 +144,6 @@ public PacketMine() { addQuickSettings(sgGeneral.getSettings()); addQuickSettings(sgRender.getSettings()); - } @Override @@ -109,103 +154,155 @@ public void onEnable() { @Override public void onDisable() { super.onDisable(); - blocks.clear(); - if (mc.interactionManager != null) mc.interactionManager.syncSelectedSlot(); + + miningQueue.clear(); } @SubscribeEvent public void onStartBreakingBlock(BeginBreakingBlockEvent event) { if (!BlockUtils.canBreak(event.getPos(), mc.world.getBlockState(event.getPos()))) return; - event.setCanceled(true); + event.cancel(); swapped = false; - if (!isMiningBlock(event.getPos())) { - blocks.put(event.getPos(), event.getDir()); - } + miningQueue.add(event.getPos(), event.getDir()); } @SubscribeEvent public void onTick(TickEvent.PLAYER event) { - blocks.entrySet().removeIf(blockPosDirectionEntry -> shouldRemove(blockPosDirectionEntry.getKey(), blockPosDirectionEntry.getValue())); - if (shouldUpdateSlot) { mc.interactionManager.syncSelectedSlot(); shouldUpdateSlot = false; } - if (!blocks.isEmpty()) { - Optional> firstBlockAndDirection = blocks.entrySet().stream().findFirst(); - Map.Entry entry = firstBlockAndDirection.get(); - mineBlock(entry.getKey(), entry.getValue()); - } + miningQueue.update(); if (!swapped && autoSwitch.value && (!mc.player.isUsingItem() || !notOnUse.value)) { - for (BlockPos blockPos : blocks.keySet()) { - if (isBlockReady(blockPos)) { - int slot = InventoryUtils.getFastestTool(mc.world.getBlockState(blockPos), false); - if (slot == -1 || mc.player.getInventory().selectedSlot == slot) continue; - mc.player.networkHandler.sendPacket(new UpdateSelectedSlotC2SPacket(slot)); - shouldUpdateSlot = true; - swapped = true; - break; - } - } + switchIfNeeded(miningQueue.getNextBlock()); } } - private boolean isBlockReady(BlockPos pos) { - return progressMap.getOrDefault(pos, 0.0) >= 1; - } + private boolean shouldRemove(BlockPos pos, Direction direction) { + boolean isGettingRemoved = mc.world.getBlockState(pos).isAir() || + mc.player.getEyePos() + .subtract(0.5, 0, 0.5f) + .distanceTo(pos.offset(direction).toCenterPos()) > mc.interactionManager.getReachDistance(); - private void mineBlock(BlockPos pos, Direction direction) { - if (rotate.value) { - RotationUtils.rotate((float) RotationUtils.getYaw(pos), (float) RotationUtils.getPitch(pos), false, () -> sendMinePackets(pos, direction)); - } else { - sendMinePackets(pos, direction); + if (isGettingRemoved) { + mc.getNetworkHandler().sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.ABORT_DESTROY_BLOCK, pos, direction)); + mc.getNetworkHandler().sendPacket(new HandSwingC2SPacket(Hand.MAIN_HAND)); } - int slot = InventoryUtils.getFastestTool(mc.world.getBlockState(pos), false); + return isGettingRemoved; + } - progressMap.put(pos, progressMap.getOrDefault(pos, 0.0) + BlockUtils.calcBlockBreakingDelta(mc.world.getBlockState(pos), mc.player.getInventory().getStack(slot != -1 ? slot : mc.player.getInventory().selectedSlot))); + private void switchIfNeeded(BlockPos pos) { + if (pos == null) return; + int bestSlot = InventoryUtils.getFastestTool(mc.world.getBlockState(pos),false); + if (bestSlot == -1 || mc.player.getInventory().selectedSlot == bestSlot) return; + mc.player.networkHandler.sendPacket(new UpdateSelectedSlotC2SPacket(bestSlot)); + swapped = true; + shouldUpdateSlot = true; } + @SubscribeEvent + public void render3d(Render3DEvent event) { + Renderer3D.renderThroughWalls(); + miningQueue.getBlocks().forEach((pos,info)->{ + BlockState state = mc.world.getBlockState(pos); + VoxelShape shape = state.getOutlineShape(mc.world, pos); + if (shape == null || shape.isEmpty()) return; + + int start = gradientBool.value ? ColorUtils.changeAlpha(gradient.get().getStartGradient().getRGB(),alpha.getInt()).getRGB() : highlightColor.value.getRGB(); + int end = gradientBool.value ? ColorUtils.changeAlpha(gradient.get().getEndGradient().getRGB(),alpha.getInt()).getRGB() : highlightColor.value.getRGB(); - public boolean isMiningBlock(BlockPos pos) { - return blocks.containsKey(pos); + ModuleManager.get(BreakIndicator.class).renderIndicator(shape.getBoundingBox().expand(0.001f).offset(pos), (float) info.progress, (BreakIndicator.IndicateType) type.getOption(),start,end); + }); + Renderer3D.stopRenderingThroughWalls(); } - private boolean shouldRemove(BlockPos pos, Direction direction) { - return mc.world.getBlockState(pos).isAir() || - mc.player.getEyePos().subtract(0.5, 0, 0.5f).distanceTo(pos.add(direction.getOffsetX(), direction.getOffsetY(), direction.getOffsetZ()).toCenterPos()) > mc.interactionManager.getReachDistance(); - } + private class MiningQueue { + private final LinkedHashMap queue = new LinkedHashMap<>(); - private void sendMinePackets(BlockPos pos, Direction direction) { - if (timerMap.getOrDefault(pos, (int) delay.value) <= 0) { - if (!miningMap.getOrDefault(pos, false)) { - mc.getNetworkHandler().sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.START_DESTROY_BLOCK, pos, direction)); - mc.getNetworkHandler().sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.STOP_DESTROY_BLOCK, pos, direction)); - miningMap.put(pos, true); + void add(BlockPos pos, Direction dir) { + queue.put(pos, new MiningInfo(dir)); + } + + void update() { + queue.entrySet().removeIf(entry -> shouldRemove(entry.getKey(),entry.getValue().direction)); + BlockPos nextBlock = getNextBlock(); + if(nextBlock == null) return; + + MiningInfo info = queue.get(nextBlock); + + //Sometimes the blocks dont get mined but the calculated progress is 1.. So we attempt to mine it again from scratch. + if(info.progress >= 1.0f && !mc.world.getBlockState(nextBlock).isAir() && reattempt.value){ + mc.getNetworkHandler().sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.ABORT_DESTROY_BLOCK, nextBlock, info.direction)); + mc.getNetworkHandler().sendPacket(new HandSwingC2SPacket(Hand.MAIN_HAND)); + if(info.attempts > maxReattempts.getInt()){ + queue.remove(nextBlock); + return; + } + + info.restart(); } - } else { - timerMap.put(pos, timerMap.getOrDefault(pos, (int) delay.value) - 1); + + mine(nextBlock, info); } - } - @SubscribeEvent - public void render3d(Render3DEvent event) { - for (BlockPos pos : blocks.keySet()) { - QuadColor color = QuadColor.single(this.color.value.getRGB()); - if (outline.value && fill.value) { - Renderer3D.drawBoxBoth(pos, color, 1.2f); - } else if (outline.value) { - Renderer3D.drawBoxOutline(pos, color, 1.2f); - } else if (fill.value) { - Renderer3D.drawBoxFill(pos, color); + void clear() { + queue.clear(); + } + + BlockPos getNextBlock() { + return queue.keySet().stream() + .findFirst() + .orElse(null); + } + + Map getBlocks() { + return queue; + } + + private void mine(BlockPos pos, MiningInfo info) { + if (rotate.get()) { + RotationUtils.rotate((float) RotationUtils.getYaw(pos), (float) RotationUtils.getPitch(pos), true, () -> sendMinePackets(pos,info)); + } else { + sendMinePackets(pos, info); + } + int slot = InventoryUtils.getFastestTool(mc.world.getBlockState(pos),false); + info.progress += BlockUtils.calcBlockBreakingDelta(mc.world.getBlockState(pos),mc.player.getInventory().getStack(slot != -1 ? slot : mc.player.getInventory().selectedSlot)); + } + + private void sendMinePackets(BlockPos pos, MiningInfo info) { + if (info.timer <= 0 && !info.started) { + mc.getNetworkHandler().sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.START_DESTROY_BLOCK, pos, info.direction)); + mc.getNetworkHandler().sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.STOP_DESTROY_BLOCK, pos, info.direction)); + info.started = true; + } else { + info.timer--; } } } + private class MiningInfo { + Direction direction; + double progress; + int timer; + boolean started; + int attempts; + MiningInfo(Direction dir) { + this.direction = dir; + restart(); + } + + void restart() { + this.progress = 0.0; + this.timer = delay.getInt(); + this.started = false; + this.attempts++; + } + } } diff --git a/src/main/java/dev/heliosclient/module/settings/BooleanSetting.java b/src/main/java/dev/heliosclient/module/settings/BooleanSetting.java index 2ac1b0b4..1bcd027c 100644 --- a/src/main/java/dev/heliosclient/module/settings/BooleanSetting.java +++ b/src/main/java/dev/heliosclient/module/settings/BooleanSetting.java @@ -101,7 +101,7 @@ public Boolean get() { @Override public void setValue(Boolean value) { - super.setValue(value); + this.value = value; } @Override diff --git a/src/main/java/dev/heliosclient/module/settings/ColorSetting.java b/src/main/java/dev/heliosclient/module/settings/ColorSetting.java index e9ab634a..4e527237 100644 --- a/src/main/java/dev/heliosclient/module/settings/ColorSetting.java +++ b/src/main/java/dev/heliosclient/module/settings/ColorSetting.java @@ -108,7 +108,7 @@ public Integer get() { @Override public void setValue(Integer value) { - super.setValue(value); + this.value = value; } @Override diff --git a/src/main/java/dev/heliosclient/module/settings/CycleSetting.java b/src/main/java/dev/heliosclient/module/settings/CycleSetting.java index 3d28990c..7ce3f707 100644 --- a/src/main/java/dev/heliosclient/module/settings/CycleSetting.java +++ b/src/main/java/dev/heliosclient/module/settings/CycleSetting.java @@ -136,6 +136,11 @@ public void mouseClicked(double mouseX, double mouseY, int button) { } } + @Override + public void setValue(Integer value) { + this.value = value; + } + @Override public Object saveToFile(List objectList) { if (options.isEmpty() || options.size() - 1 < value) { diff --git a/src/main/java/dev/heliosclient/module/settings/DoubleSetting.java b/src/main/java/dev/heliosclient/module/settings/DoubleSetting.java index 7620cd3c..46af30a5 100644 --- a/src/main/java/dev/heliosclient/module/settings/DoubleSetting.java +++ b/src/main/java/dev/heliosclient/module/settings/DoubleSetting.java @@ -216,7 +216,8 @@ public int getInt() { return (int) value; } - public void setValue(double value) { + @Override + public void setValue(Double value) { this.value = value; } diff --git a/src/main/java/dev/heliosclient/module/settings/DropDownSetting.java b/src/main/java/dev/heliosclient/module/settings/DropDownSetting.java index 8d3f406d..887d60af 100644 --- a/src/main/java/dev/heliosclient/module/settings/DropDownSetting.java +++ b/src/main/java/dev/heliosclient/module/settings/DropDownSetting.java @@ -46,7 +46,7 @@ public DropDownSetting(String name, String description, ISettingChange iSett this(name, description, iSettingChange, Arrays.asList(options), value, shouldRender, defaultValue, optionsTooltips); } - public void setOptions(List options) { + public void setOptions(List options) { this.options = options; for (Object option : options) { maxOptionWidth = Math.max(maxOptionWidth, Math.round(Renderer2D.getFxStringWidth(option.toString()))); diff --git a/src/main/java/dev/heliosclient/module/settings/GradientSetting.java b/src/main/java/dev/heliosclient/module/settings/GradientSetting.java index 2004c215..bb50dc6a 100644 --- a/src/main/java/dev/heliosclient/module/settings/GradientSetting.java +++ b/src/main/java/dev/heliosclient/module/settings/GradientSetting.java @@ -37,11 +37,18 @@ public GradientSetting(String name, String description, BooleanSupplier shouldRe this.iSettingChange = iSettingChange; gradientList = GradientManager.getAllGradientsNames(); + checkGradientAvailability(); + } + private void checkGradientAvailability(){ if(defaultValue == null){ Optional optional = gradientList.stream().findFirst(); - optional.ifPresent(s -> this.value = GradientManager.getGradient(s)); + optional.ifPresent(s ->{ + this.value = GradientManager.getGradient(s); + this.defaultValue = value; + }); } } + public void createTable(double width){ gradientTable = new Table(); @@ -53,6 +60,7 @@ public void createTable(double width){ @Override public void render(DrawContext drawContext, int x, int y, int mouseX, int mouseY, TextRenderer textRenderer) { super.render(drawContext, x, y, mouseX, mouseY, textRenderer); + checkGradientAvailability(); Renderer2D.drawFixedString(drawContext.getMatrices(), name, x + 2, y + 4, ColorManager.INSTANCE.defaultTextColor); @@ -129,6 +137,8 @@ public void renderAllGradients(DrawContext context, int mouseX, int mouseY){ @Override public void renderCompact(DrawContext drawContext, int x, int y, int mouseX, int mouseY, TextRenderer textRenderer) { super.renderCompact(drawContext, x, y, mouseX, mouseY, textRenderer); + checkGradientAvailability(); + Renderer2D.drawFixedString(drawContext.getMatrices(), FontRenderers.fxfontRenderer.trimToWidth(name, moduleWidth), x + 2, y + 4, ColorManager.INSTANCE.defaultTextColor); // Draw a '🖋' button next to the text @@ -158,7 +168,6 @@ protected boolean hoveredOverEdit(double mouseX, double mouseY) { @Override public void mouseClicked(double mouseX, double mouseY, int button) { - super.mouseClicked(mouseX, mouseY, button); if (hoveredSetting((int) mouseX, (int) mouseY) && hoveredOverReset(mouseX, mouseY)) { if(defaultValue != null) { this.value = defaultValue; @@ -196,7 +205,6 @@ public void loadFromFile(MapReader map) { this.value = GradientManager.getGradient(mapVal.toString()); } - @Override public void setValue(GradientManager.Gradient value) { this.value = value; diff --git a/src/main/java/dev/heliosclient/module/settings/Vector3dSetting.java b/src/main/java/dev/heliosclient/module/settings/Vector3dSetting.java index 4ad55832..0f8c72fe 100644 --- a/src/main/java/dev/heliosclient/module/settings/Vector3dSetting.java +++ b/src/main/java/dev/heliosclient/module/settings/Vector3dSetting.java @@ -1,8 +1,10 @@ package dev.heliosclient.module.settings; +import dev.heliosclient.HeliosClient; import dev.heliosclient.managers.ColorManager; import dev.heliosclient.system.mixininterface.IVec3d; import dev.heliosclient.util.interfaces.ISettingChange; +import dev.heliosclient.util.misc.MapReader; import dev.heliosclient.util.render.Renderer2D; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.DrawContext; @@ -10,11 +12,9 @@ import java.awt.*; import java.util.List; -import java.util.Map; import java.util.function.BooleanSupplier; import static dev.heliosclient.util.fontutils.FontRenderers.Small_fxfontRenderer; -import dev.heliosclient.util.misc.MapReader; public class Vector3dSetting extends Setting implements ISettingChange { private final DoubleSetting xSet; @@ -137,6 +137,7 @@ public void loadFromFile(MapReader map) { this.ySet.setValue(defaultValue.y); this.zSet.setValue(defaultValue.z); value = defaultValue; + HeliosClient.LOGGER.error("{} has no Vec3d values... defaulting", this.name); } else { List vec3 = (List) map.getAs(getSaveName(),List.class); this.xSet.setValue(vec3.get(0)); @@ -148,9 +149,9 @@ public void loadFromFile(MapReader map) { @Override public Object saveToFile(List objectList) { - objectList.add(xSet.value); - objectList.add(ySet.value); - objectList.add(zSet.value); + objectList.add(xSet.get()); + objectList.add(ySet.get()); + objectList.add(zSet.get()); return objectList; } @@ -188,7 +189,7 @@ public Vec3d get() { @Override public void setValue(Vec3d value) { - super.setValue(value); + this.value = value; } public static class Builder extends SettingBuilder { diff --git a/src/main/java/dev/heliosclient/ui/clickgui/ClickGUIScreen.java b/src/main/java/dev/heliosclient/ui/clickgui/ClickGUIScreen.java index b2c7683c..68793e27 100644 --- a/src/main/java/dev/heliosclient/ui/clickgui/ClickGUIScreen.java +++ b/src/main/java/dev/heliosclient/ui/clickgui/ClickGUIScreen.java @@ -98,6 +98,7 @@ private void updateScale(float speed, boolean close) { this.scale -= speed * Easing.ease(EasingType.BOUNCE_OUT, MathHelper.clamp((currentTime - timeOnOpen) / 2000f, 0, 1)); if (this.scale <= 0.0) { super.close(); + searchBar.setText(""); shouldClose = false; } } else { @@ -214,7 +215,12 @@ public boolean charTyped(char chr, int modifiers) { @Override public void close() { - shouldClose = true; + if(ModuleManager.get(GUI.class).bounceAnimation.value) { + shouldClose = true; + }else{ + searchBar.setText(""); + super.close(); + } } @Override diff --git a/src/main/java/dev/heliosclient/util/blocks/HoleUtils.java b/src/main/java/dev/heliosclient/util/blocks/HoleUtils.java index ef4924f4..91720654 100644 --- a/src/main/java/dev/heliosclient/util/blocks/HoleUtils.java +++ b/src/main/java/dev/heliosclient/util/blocks/HoleUtils.java @@ -197,24 +197,14 @@ private static boolean isBlastProof(Block block){ } private static HoleInfo getHoleType(World world, BlockPos pos, Set checkedPositions, boolean quadChecker) { - if (!world.getBlockState(pos).isAir() || !world.getBlockState(pos.up()).isAir() || checkedPositions.contains(pos)) { + if (!world.getBlockState(pos).isAir() || !world.getBlockState(pos.up()).isAir() || !world.getBlockState(pos.up(2)).isAir() || checkedPositions.contains(pos)) { return null; } - - if (quadChecker && isQuad(pos, world,checkedPositions)) { - //System.out.println("QUAD: " + pos); - - //Return a box containing all the four poses. - BlockPos start = pos.offset(airOffset[0][0]).offset(airOffset[0][1]); - checkedPositions.add(pos); - - return new HoleInfo(HoleType.UNSAFE, pos, new Box(pos).union(new Box(start)).contract(0.005f, 0f, 0.005f).offset(0, 0.005f, 0)); - } - checkedPositions.add(pos); HoleType hT = null; + boolean quadChecked = false; int obsidian = 0, bedrock = 0, air = 0; BlockPos doubleStart = null; @@ -232,7 +222,19 @@ private static HoleInfo getHoleType(World world, BlockPos pos, Set che obsidian++; } else if (block == Blocks.BEDROCK) { bedrock++; - } else if (block == Blocks.AIR) { + } else if (block == Blocks.AIR && world.isAir(newPos.offset(Direction.UP))) { + if (quadChecker && (obsidian + bedrock == 2) && !quadChecked) { + if (isQuad(pos, world, checkedPositions)) { + //Return a box containing all the four poses. + BlockPos start = pos.offset(airOffset[0][0]).offset(airOffset[0][1]); + checkedPositions.add(pos); + + //Any quad hole should be unsafe no matter how protected it is. + return new HoleInfo(HoleType.UNSAFE, pos, new Box(pos).union(new Box(start)).contract(0.005f, 0f, 0.005f).offset(0, 0.005f, 0)); + } + quadChecked = true; + } + int coveringBlocks = 0; for (Direction dir1 : Direction.values()) { if (dir1 == Direction.UP || dir.getOpposite() == dir1) continue; diff --git a/src/main/java/dev/heliosclient/util/player/DamageUtils.java b/src/main/java/dev/heliosclient/util/player/DamageUtils.java index 7963e2ba..54f0005e 100644 --- a/src/main/java/dev/heliosclient/util/player/DamageUtils.java +++ b/src/main/java/dev/heliosclient/util/player/DamageUtils.java @@ -191,8 +191,6 @@ public static float calculateDamageByEnv(){ totalDamage = Math.max(calcFallDamage(HeliosClient.MC.player),totalDamage); } - System.out.println(totalDamage); - return totalDamage; } diff --git a/src/main/java/dev/heliosclient/util/player/RotationUtils.java b/src/main/java/dev/heliosclient/util/player/RotationUtils.java index c6acaa66..a553c46c 100644 --- a/src/main/java/dev/heliosclient/util/player/RotationUtils.java +++ b/src/main/java/dev/heliosclient/util/player/RotationUtils.java @@ -54,57 +54,41 @@ public static void lookAt(HitResult result) { } public static double getYaw(double targetX, double targetZ) { - double dx = targetX - mc.player.getX(); - double dz = targetZ - mc.player.getZ(); + double dx = targetX - mc.player.getEyePos().getX(); + double dz = targetZ - mc.player.getEyePos().getZ(); + float yaw = (float) Math.toDegrees(Math.atan2(dz, dx)) - 90F; - return Math.toDegrees(Math.atan2(dz, dx)) - 90; + return MathHelper.wrapDegrees(yaw); } public static double getYaw(Vec3d target) { - double dx = target.getX() - mc.player.getX(); - double dz = target.getZ() - mc.player.getZ(); - - return Math.toDegrees(Math.atan2(dz, dx)) - 90; + return getYaw(target.getX(),target.getZ()); } public static double getYaw(BlockPos target) { - double dx = target.getX() - mc.player.getX(); - double dz = target.getZ() - mc.player.getZ(); - - return Math.toDegrees(Math.atan2(dz, dx)) - 90; + return getYaw(target.getX(),target.getZ()); } public static double getPitch(double targetX, double targetY, double targetZ) { - double dx = targetX - mc.player.getX(); - double dy = targetY - mc.player.getEyeY(); // account for the player's eye height - double dz = targetZ - mc.player.getZ(); + double dx = targetX - mc.player.getEyePos().getX(); + double dy = targetY - mc.player.getEyePos().getY(); + double dz = targetZ - mc.player.getEyePos().getZ(); double distanceXZ = Math.sqrt(dx * dx + dz * dz); + float pitch = (float) -Math.toDegrees(Math.atan2(dy, distanceXZ)); - return -Math.toDegrees(Math.atan2(dy, distanceXZ)); + + return MathHelper.wrapDegrees(pitch); } public static double getPitch(BlockPos target) { - double dx = target.getX() - mc.player.getX(); - double dy = target.getY() - mc.player.getEyeY(); // account for the player's eye height - double dz = target.getZ() - mc.player.getZ(); - - double distanceXZ = Math.sqrt(dx * dx + dz * dz); - - return -Math.toDegrees(Math.atan2(dy, distanceXZ)); + return getPitch(target.getX(),target.getY(),target.getZ()); } public static double getPitch(Vec3d target) { - double dx = target.getX() - mc.player.getX(); - double dy = target.getY() - mc.player.getEyeY(); // account for the player's eye height - double dz = target.getZ() - mc.player.getZ(); - - double distanceXZ = Math.sqrt(dx * dx + dz * dz); - - return -Math.toDegrees(Math.atan2(dy, distanceXZ)); + return getPitch(target.getX(),target.getY(),target.getZ()); } - public static void rotate(double yaw, double pitch, boolean clientSide, @Nullable Runnable task) { if(prevYaw != yaw && prevPitch != pitch && clientSide){ timerSinceLastRotation.restartTimer(); @@ -114,6 +98,12 @@ public static void rotate(double yaw, double pitch, boolean clientSide, @Nullabl mc.player.setPitch((float) pitch); mc.player.setYaw((float) yaw); + mc.player.setHeadYaw(mc.player.getYaw()); + mc.player.prevPitch = mc.player.getPitch(); + mc.player.prevYaw = mc.player.getYaw(); + mc.player.prevHeadYaw = mc.player.headYaw; + mc.player.bodyYaw = mc.player.headYaw; + mc.player.prevBodyYaw = mc.player.bodyYaw; if (clientSide) { mc.player.renderYaw = (float) yaw; diff --git a/src/main/java/dev/heliosclient/util/render/GradientBlockRenderer.java b/src/main/java/dev/heliosclient/util/render/GradientBlockRenderer.java index 3482bd8d..bbbd7d10 100644 --- a/src/main/java/dev/heliosclient/util/render/GradientBlockRenderer.java +++ b/src/main/java/dev/heliosclient/util/render/GradientBlockRenderer.java @@ -3,8 +3,10 @@ import dev.heliosclient.util.ColorUtils; import dev.heliosclient.util.render.color.QuadColor; import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.util.math.*; +import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Box; +import net.minecraft.util.math.Direction; +import net.minecraft.util.math.MathHelper; import org.jetbrains.annotations.ApiStatus; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @@ -52,7 +54,7 @@ public static void renderGradientBlock(Supplier gradientStart, Supplier> 16 & 255) / 255.0F; + float green = (float) (color >> 8 & 255) / 255.0F; + float blue = (float) (color & 255) / 255.0F; + float alpha = (float) (color >> 24 & 255) / 255.0F; + + if(TOP) drawRectangleBufferInternal(matrix4f,bufferBuilder, x - thickness, y, width + thickness*2, -thickness, red,green,blue,alpha); + if(BOTTOM) drawRectangleBufferInternal(matrix4f,bufferBuilder, x - thickness, y + height, width + thickness*2, thickness, red,green,blue,alpha); + if(LEFT) drawRectangleBufferInternal(matrix4f,bufferBuilder, x, y, -thickness, height, red,green,blue,alpha); + if(RIGHT) drawRectangleBufferInternal(matrix4f,bufferBuilder, x + width, y, thickness, height, red,green,blue,alpha); + + draw(); + + RenderSystem.disableBlend(); } /** @@ -1253,7 +1274,7 @@ public static BufferBuilder setupAndBegin(VertexFormat.DrawMode m, VertexFormat return bufferBuilder; } - static void draw() { + public static void draw() { draw(Tessellator.getInstance().getBuffer()); } diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 6b615028..23d8a026 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -20,9 +20,6 @@ "entrypoints": { "main": [ "dev.heliosclient.HeliosClient" - ], - "modmenu": [ - "dev.heliosclient.ModMenuIntegration" ] }, "accessWidener": "heliosclient.accesswidener",