From 403bf740547b324936483a0fd183307867c80d72 Mon Sep 17 00:00:00 2001 From: someRandomDude-a Date: Wed, 7 Jan 2026 19:04:55 +0530 Subject: [PATCH 01/17] implemented first revision of spear reach --- .../zergatul/cheatutils/common/Events.java | 1 + .../zergatul/cheatutils/configs/Config.java | 1 + .../cheatutils/configs/SpearRangeConfig.java | 13 +++++ .../common/MixinMultiPlayerGameMode.java | 4 ++ .../zergatul/cheatutils/modules/Modules.java | 1 + .../modules/automation/SpearRange.java | 49 +++++++++++++++++++ .../scripting/modules/SpearRangeApi.java | 13 +++++ .../zergatul/cheatutils/webui/ApiHandler.java | 12 +++++ .../web/components/automation/SpearRange.html | 10 ++++ .../web/components/automation/SpearRange.js | 5 ++ common/resources/web/modules.js | 7 +++ 11 files changed, 116 insertions(+) create mode 100644 common/java/com/zergatul/cheatutils/configs/SpearRangeConfig.java create mode 100644 common/java/com/zergatul/cheatutils/modules/automation/SpearRange.java create mode 100644 common/java/com/zergatul/cheatutils/scripting/modules/SpearRangeApi.java create mode 100644 common/resources/web/components/automation/SpearRange.html create mode 100644 common/resources/web/components/automation/SpearRange.js diff --git a/common/java/com/zergatul/cheatutils/common/Events.java b/common/java/com/zergatul/cheatutils/common/Events.java index 40279b96..0d4b1ad8 100644 --- a/common/java/com/zergatul/cheatutils/common/Events.java +++ b/common/java/com/zergatul/cheatutils/common/Events.java @@ -75,6 +75,7 @@ public class Events { public static final ParameterizedEventHandler AfterScreenRendered = new ParameterizedEventHandler<>(); public static final CancelableEventHandler SendChat = new CancelableEventHandler<>(); public static final CancelableEventHandler BeforeAttack = new CancelableEventHandler<>(); + public static final SimpleEventHandler AfterAttack = new SimpleEventHandler(); public static final ParameterizedEventHandler EntityInteract = new ParameterizedEventHandler<>(); public static final ParameterizedEventHandler BeforeInstaMine = new ParameterizedEventHandler<>(); public static final SimpleEventHandler WindowResize = new SimpleEventHandler(); diff --git a/common/java/com/zergatul/cheatutils/configs/Config.java b/common/java/com/zergatul/cheatutils/configs/Config.java index 57ee00bf..58a3d8d9 100644 --- a/common/java/com/zergatul/cheatutils/configs/Config.java +++ b/common/java/com/zergatul/cheatutils/configs/Config.java @@ -52,6 +52,7 @@ public class Config { public BobHurtConfig bobHurtConfig = new BobHurtConfig(); public AutoAttackConfig autoAttackConfig = new AutoAttackConfig(); public BreachSwapConfig breachSwapConfig = new BreachSwapConfig(); + public SpearRangeConfig spearRangeConfig = new SpearRangeConfig(); public NoWeatherConfig noWeatherConfig = new NoWeatherConfig(); public FakeWeatherConfig fakeWeatherConfig = new FakeWeatherConfig(); public ChatUtilitiesConfig chatUtilitiesConfig = new ChatUtilitiesConfig(); diff --git a/common/java/com/zergatul/cheatutils/configs/SpearRangeConfig.java b/common/java/com/zergatul/cheatutils/configs/SpearRangeConfig.java new file mode 100644 index 00000000..2d252d6b --- /dev/null +++ b/common/java/com/zergatul/cheatutils/configs/SpearRangeConfig.java @@ -0,0 +1,13 @@ +package com.zergatul.cheatutils.configs; + +public class SpearRangeConfig extends ModuleConfig implements ValidatableConfig { + + SpearRangeConfig() { + + } + + @Override + public void validate() { + return; + } +} \ No newline at end of file diff --git a/common/java/com/zergatul/cheatutils/mixins/common/MixinMultiPlayerGameMode.java b/common/java/com/zergatul/cheatutils/mixins/common/MixinMultiPlayerGameMode.java index d52bad98..687648de 100644 --- a/common/java/com/zergatul/cheatutils/mixins/common/MixinMultiPlayerGameMode.java +++ b/common/java/com/zergatul/cheatutils/mixins/common/MixinMultiPlayerGameMode.java @@ -76,5 +76,9 @@ private void onAttack(Player player, Entity entity, CallbackInfo ci) { ci.cancel(); } } + @Inject(at = @At("TAIL"), method = "attack", cancellable = false) + private void afterAttack(Player player, Entity entity, CallbackInfo ci){ + Events.AfterAttack.trigger(); + } } diff --git a/common/java/com/zergatul/cheatutils/modules/Modules.java b/common/java/com/zergatul/cheatutils/modules/Modules.java index 80766cbb..9b5fc3d4 100644 --- a/common/java/com/zergatul/cheatutils/modules/Modules.java +++ b/common/java/com/zergatul/cheatutils/modules/Modules.java @@ -63,6 +63,7 @@ public static void register() { register(Fog.instance); register(AutoAttack.instance); register(BreachSwap.instance); + register(SpearRange.instance); register(Exec.instance); register(VillagerRoller.instance); register(AutoHotbar.instance); diff --git a/common/java/com/zergatul/cheatutils/modules/automation/SpearRange.java b/common/java/com/zergatul/cheatutils/modules/automation/SpearRange.java new file mode 100644 index 00000000..fcd142d8 --- /dev/null +++ b/common/java/com/zergatul/cheatutils/modules/automation/SpearRange.java @@ -0,0 +1,49 @@ +package com.zergatul.cheatutils.modules.automation; + +import com.zergatul.cheatutils.common.Events; +import com.zergatul.cheatutils.common.events.BeforeAttackEvent; +import com.zergatul.cheatutils.configs.ConfigStore; +import com.zergatul.cheatutils.modules.Module; +import net.minecraft.client.Minecraft; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.item.ItemStack; + +import static net.minecraft.core.component.DataComponents.ATTACK_RANGE; + +public class SpearRange implements Module { + public static final SpearRange instance = new SpearRange(); + private final Minecraft mc = Minecraft.getInstance(); + private Inventory inventory; + int prevSelectedSlot = -1; + + private SpearRange() { + Events.BeforeAttack.add(this::onBeforeAttack); + Events.AfterAttack.add(this::onAfterAttack); + } + + public void onBeforeAttack(BeforeAttackEvent event) { + if (!ConfigStore.instance.getConfig().spearRangeConfig.enabled) return; + if (mc.player == null) return; + if (mc.player.isSpectator()) return; + inventory = mc.player.getInventory(); + + prevSelectedSlot = inventory.getSelectedSlot(); + int spear = -1; + for (int i = 0; i < 9; i++) { + ItemStack item = inventory.getItem(i); + if (item.getComponents().stream().anyMatch(component -> component.type() == ATTACK_RANGE)) { + spear = i; + break; + } + } + if (spear == -1) return; + if (spear == prevSelectedSlot) return; + + + inventory.setSelectedSlot(spear); + } + + private void onAfterAttack() { + inventory.setSelectedSlot(prevSelectedSlot); + } +} diff --git a/common/java/com/zergatul/cheatutils/scripting/modules/SpearRangeApi.java b/common/java/com/zergatul/cheatutils/scripting/modules/SpearRangeApi.java new file mode 100644 index 00000000..f6aa19be --- /dev/null +++ b/common/java/com/zergatul/cheatutils/scripting/modules/SpearRangeApi.java @@ -0,0 +1,13 @@ +package com.zergatul.cheatutils.scripting.modules; + +import com.zergatul.cheatutils.configs.SpearRangeConfig; +import com.zergatul.cheatutils.configs.ConfigStore; + +public class SpearRangeApi extends ModuleApi { + + + @Override + protected SpearRangeConfig getConfig() { + return ConfigStore.instance.getConfig().spearRangeConfig; + } +} \ No newline at end of file diff --git a/common/java/com/zergatul/cheatutils/webui/ApiHandler.java b/common/java/com/zergatul/cheatutils/webui/ApiHandler.java index 451aacdc..0bd32eb1 100644 --- a/common/java/com/zergatul/cheatutils/webui/ApiHandler.java +++ b/common/java/com/zergatul/cheatutils/webui/ApiHandler.java @@ -712,6 +712,18 @@ protected void setConfig(NoWeatherConfig config) { } }); + apis.add(new SimpleConfigApi<>("spear-range", SpearRangeConfig.class) { + @Override + protected SpearRangeConfig getConfig() { + return ConfigStore.instance.getConfig().spearRangeConfig; + } + + @Override + protected void setConfig(SpearRangeConfig config) { + ConfigStore.instance.getConfig().spearRangeConfig = config; + } + }); + apis.add(new SimpleConfigApi<>("fake-weather", FakeWeatherConfig.class) { @Override protected FakeWeatherConfig getConfig() { diff --git a/common/resources/web/components/automation/SpearRange.html b/common/resources/web/components/automation/SpearRange.html new file mode 100644 index 00000000..9d25644d --- /dev/null +++ b/common/resources/web/components/automation/SpearRange.html @@ -0,0 +1,10 @@ +
+
+ Uses the spear to extend your reach with weapons. +
+
+
+ Enabled +
+
+
\ No newline at end of file diff --git a/common/resources/web/components/automation/SpearRange.js b/common/resources/web/components/automation/SpearRange.js new file mode 100644 index 00000000..f11b4955 --- /dev/null +++ b/common/resources/web/components/automation/SpearRange.js @@ -0,0 +1,5 @@ +import { createSimpleComponent } from '/components/SimpleModule.js'; + +export function createComponent(template) { + return createSimpleComponent('/api/spear-range', template); +} \ No newline at end of file diff --git a/common/resources/web/modules.js b/common/resources/web/modules.js index 2320cd63..6eabce28 100644 --- a/common/resources/web/modules.js +++ b/common/resources/web/modules.js @@ -18,6 +18,13 @@ const module = (params) => { modules[params.group][params.component] = params; }; +module({ + group: 'automation', + name: 'Spear Range', + component: 'SpearRange', + path: 'spear-range', + tags: ['spear', 'reach', 'range'] +}); module({ group: 'automation', name: 'Auto Disconnect', From f7bcf06c753649466bf88411a639f530fdf780ad Mon Sep 17 00:00:00 2001 From: someRandomDude-a Date: Wed, 7 Jan 2026 19:52:09 +0530 Subject: [PATCH 02/17] updated auto criticals conditions --- .../modules/automation/BreachSwap.java | 1 - .../modules/hacks/AutoCriticals.java | 30 ++++++------------- 2 files changed, 9 insertions(+), 22 deletions(-) diff --git a/common/java/com/zergatul/cheatutils/modules/automation/BreachSwap.java b/common/java/com/zergatul/cheatutils/modules/automation/BreachSwap.java index 7877c13e..3b48d956 100644 --- a/common/java/com/zergatul/cheatutils/modules/automation/BreachSwap.java +++ b/common/java/com/zergatul/cheatutils/modules/automation/BreachSwap.java @@ -122,7 +122,6 @@ else if (item.getEnchantments().keySet().stream().anyMatch(enchantment -> if (isUsingShield && axe != -1) { - AutoCriticals.instance.skipAttack(); inventory.setSelectedSlot(axe); mc.gameMode.attack(mc.player, entity); mc.player.swing(InteractionHand.MAIN_HAND); diff --git a/common/java/com/zergatul/cheatutils/modules/hacks/AutoCriticals.java b/common/java/com/zergatul/cheatutils/modules/hacks/AutoCriticals.java index f5d03acc..ff331fac 100644 --- a/common/java/com/zergatul/cheatutils/modules/hacks/AutoCriticals.java +++ b/common/java/com/zergatul/cheatutils/modules/hacks/AutoCriticals.java @@ -15,27 +15,14 @@ public class AutoCriticals { public static final AutoCriticals instance = new AutoCriticals(); private final Minecraft mc = Minecraft.getInstance(); - private boolean skip; - - public void skipAttack() { - skip = true; - } - private AutoCriticals() { - skip = false; Events.BeforeAttack.add(this::onBeforeAttack); } private void onBeforeAttack(BeforeAttackEvent event) { AutoCriticalsConfig config = ConfigStore.instance.getConfig().autoCriticalsConfig; - //This needs to come before enable check, else it will queue this for future situation incorrectly - if (skip) { - skip = false; - return; - } - if (config.enabled) { if (mc.level == null) { return; @@ -47,14 +34,15 @@ private void onBeforeAttack(BeforeAttackEvent event) { if (config.onlyOnGround && !mc.player.onGround()) { return; } - - if (mc.player.isSprinting()) {// This will not critical anyways, so don't interfere - return; - } - - if (mc.player.fallDistance != 0 || mc.player.isFallFlying()) {//If player already falling - return; - } + // Hard Conditions not met, cannot do anything about it + if (!((mc.player.getAttackStrengthScale(0.5F) > 0.9F) && + (!mc.player.onClimbable() + && !mc.player.isInWater() && !mc.player.isMobilityRestricted() && !mc.player.isPassenger() + && mc.player.getLivingEntity().isAlive() && !mc.player.isSprinting())) + ) return; + + // Soft Conditions we can cheat to validate, do nothing if its already valid case + if (!(mc.player.fallDistance > 0 && !mc.player.onGround())) return; Vec3 PrevPos = mc.player.position(); From 9a94174478a1d7c3d4aaa33b028335f0eb067ef1 Mon Sep 17 00:00:00 2001 From: someRandomDude-a Date: Sun, 11 Jan 2026 10:31:13 +0530 Subject: [PATCH 03/17] Merge branch '1.21.11' into spear-reach --- .idea/vcs.xml | 8 + .idea/workspace.xml | 97 +++++++++++ LICENSE | 2 +- common/build/build.gradle.kts | 2 + common/gradle.properties | 2 +- .../zergatul/cheatutils/common/Events.java | 3 - .../compatibility/SodiumMixinPlugin.java | 9 - .../cheatutils/configs/AutoAttackConfig.java | 16 +- .../controllers/LockInputsController.java | 4 + .../extensions/BlockRendererExtension.java | 5 - .../ChunkRenderContextExtension.java | 8 - .../extensions/LevelSliceExtension.java | 5 - .../RenderSectionRegionExtension.java | 6 +- ...SubmitNodeStorageModelSubmitExtension.java | 8 - .../common/MixinChunkBorderRenderer.java | 24 +++ .../schematics/MixinRenderSectionRegion.java | 56 ++---- .../common/sodium/MixinBlockRenderer.java | 40 ----- .../sodium/MixinChunkBuilderMeshingTask.java | 46 ----- .../sodium/MixinChunkRenderContext.java | 22 --- .../mixins/common/sodium/MixinLevelSlice.java | 159 ------------------ .../modules/automation/AutoAttack.java | 17 +- .../cheatutils/modules/esp/EntityTitle.java | 1 + .../ShadedVertexConsumerWrapper.java | 4 + .../WrapperRenderSectionRegion.java | 95 +++++++++++ .../zergatul/cheatutils/scripting/Root.java | 1 + .../scripting/modules/AutoAttackApi.java | 12 ++ .../monaco/MonacoSuggestionFactory.java | 3 +- .../client/render/chunk/RenderSection.java | 16 -- .../chunk/compile/BuilderTaskOutput.java | 11 -- .../chunk/compile/ChunkBuildContext.java | 7 - .../chunk/compile/ChunkBuildOutput.java | 3 - .../render/chunk/compile/ChunkSortOutput.java | 3 - .../compile/pipeline/BlockRenderCache.java | 7 - .../chunk/compile/pipeline/BlockRenderer.java | 21 --- .../tasks/ChunkBuilderMeshingTask.java | 38 ----- .../chunk/compile/tasks/ChunkBuilderTask.java | 17 -- .../render/model/MutableQuadViewImpl.java | 7 - .../client/services/PlatformModelEmitter.java | 27 --- .../client/util/task/CancellationToken.java | 3 - .../mods/sodium/client/world/LevelSlice.java | 47 ------ .../world/cloned/ChunkRenderContext.java | 16 -- .../world/cloned/ClonedChunkSectionCache.java | 3 - .../resources/cheatutils.common.mixins.json | 1 + .../resources/cheatutils.sodium.mixins.json | 17 -- .../web/components/HoldKeyConfig.html | 35 ---- .../resources/web/components/HoldKeyConfig.js | 7 - .../web/components/automation/AutoAttack.html | 46 ++++- .../web/components/automation/Schematica.html | 2 +- fabric/build.gradle | 5 +- fabric/gradle.properties | 2 +- .../schematica/MixinSectionCompiler.java | 97 +++++++++-- fabric/src/main/resources/fabric.mod.json | 1 - .../schematica/MixinSectionCompiler.java | 109 ++++++++++-- .../schematics/MixinSectionCompiler.java | 94 +++++++++-- 54 files changed, 613 insertions(+), 684 deletions(-) create mode 100644 .idea/vcs.xml create mode 100644 .idea/workspace.xml delete mode 100644 common/java/com/zergatul/cheatutils/compatibility/SodiumMixinPlugin.java delete mode 100644 common/java/com/zergatul/cheatutils/extensions/BlockRendererExtension.java delete mode 100644 common/java/com/zergatul/cheatutils/extensions/ChunkRenderContextExtension.java delete mode 100644 common/java/com/zergatul/cheatutils/extensions/LevelSliceExtension.java delete mode 100644 common/java/com/zergatul/cheatutils/extensions/SubmitNodeStorageModelSubmitExtension.java create mode 100644 common/java/com/zergatul/cheatutils/mixins/common/MixinChunkBorderRenderer.java delete mode 100644 common/java/com/zergatul/cheatutils/mixins/common/sodium/MixinBlockRenderer.java delete mode 100644 common/java/com/zergatul/cheatutils/mixins/common/sodium/MixinChunkBuilderMeshingTask.java delete mode 100644 common/java/com/zergatul/cheatutils/mixins/common/sodium/MixinChunkRenderContext.java delete mode 100644 common/java/com/zergatul/cheatutils/mixins/common/sodium/MixinLevelSlice.java create mode 100644 common/java/com/zergatul/cheatutils/schematics/WrapperRenderSectionRegion.java create mode 100644 common/java/com/zergatul/cheatutils/scripting/modules/AutoAttackApi.java delete mode 100644 common/java/net/caffeinemc/mods/sodium/client/render/chunk/RenderSection.java delete mode 100644 common/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/BuilderTaskOutput.java delete mode 100644 common/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/ChunkBuildContext.java delete mode 100644 common/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/ChunkBuildOutput.java delete mode 100644 common/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/ChunkSortOutput.java delete mode 100644 common/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/pipeline/BlockRenderCache.java delete mode 100644 common/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/pipeline/BlockRenderer.java delete mode 100644 common/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/tasks/ChunkBuilderMeshingTask.java delete mode 100644 common/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/tasks/ChunkBuilderTask.java delete mode 100644 common/java/net/caffeinemc/mods/sodium/client/render/model/MutableQuadViewImpl.java delete mode 100644 common/java/net/caffeinemc/mods/sodium/client/services/PlatformModelEmitter.java delete mode 100644 common/java/net/caffeinemc/mods/sodium/client/util/task/CancellationToken.java delete mode 100644 common/java/net/caffeinemc/mods/sodium/client/world/LevelSlice.java delete mode 100644 common/java/net/caffeinemc/mods/sodium/client/world/cloned/ChunkRenderContext.java delete mode 100644 common/java/net/caffeinemc/mods/sodium/client/world/cloned/ClonedChunkSectionCache.java delete mode 100644 common/resources/cheatutils.sodium.mixins.json delete mode 100644 common/resources/web/components/HoldKeyConfig.html delete mode 100644 common/resources/web/components/HoldKeyConfig.js diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 00000000..3a66cda6 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 00000000..321a293f --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1767777418266 + + + + \ No newline at end of file diff --git a/LICENSE b/LICENSE index f2b88cea..989148ae 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2023 Igor Budzhak +Copyright (c) 2022-present Zergatul Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/common/build/build.gradle.kts b/common/build/build.gradle.kts index 2605aa0a..a327eea0 100644 --- a/common/build/build.gradle.kts +++ b/common/build/build.gradle.kts @@ -4,6 +4,8 @@ plugins { repositories { mavenCentral() } +java.toolchain.languageVersion = JavaLanguageVersion.of(21) + gradlePlugin { plugins { create("cheatutils") { diff --git a/common/gradle.properties b/common/gradle.properties index d579d491..b9e01cbb 100644 --- a/common/gradle.properties +++ b/common/gradle.properties @@ -1 +1 @@ -mod_version=3.14.11 \ No newline at end of file +mod_version=3.14.13 \ No newline at end of file diff --git a/common/java/com/zergatul/cheatutils/common/Events.java b/common/java/com/zergatul/cheatutils/common/Events.java index 0d4b1ad8..d91af174 100644 --- a/common/java/com/zergatul/cheatutils/common/Events.java +++ b/common/java/com/zergatul/cheatutils/common/Events.java @@ -86,7 +86,4 @@ public class Events { public static final CancelableEventHandler PlayerReleaseUsingItem = new CancelableEventHandler<>(); public static final CancelableEventHandler PlayerTurnByMouse = new CancelableEventHandler<>(); public static final ParameterizedEventHandler PlayerInfoUpdated = new ParameterizedEventHandler<>(); - - - } \ No newline at end of file diff --git a/common/java/com/zergatul/cheatutils/compatibility/SodiumMixinPlugin.java b/common/java/com/zergatul/cheatutils/compatibility/SodiumMixinPlugin.java deleted file mode 100644 index b8d084d8..00000000 --- a/common/java/com/zergatul/cheatutils/compatibility/SodiumMixinPlugin.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.zergatul.cheatutils.compatibility; - -public class SodiumMixinPlugin extends OptionalMixinPlugin { - - @Override - protected String getModName() { - return "Sodium"; - } -} \ No newline at end of file diff --git a/common/java/com/zergatul/cheatutils/configs/AutoAttackConfig.java b/common/java/com/zergatul/cheatutils/configs/AutoAttackConfig.java index 4fca6f97..2dd88611 100644 --- a/common/java/com/zergatul/cheatutils/configs/AutoAttackConfig.java +++ b/common/java/com/zergatul/cheatutils/configs/AutoAttackConfig.java @@ -3,10 +3,22 @@ import com.zergatul.cheatutils.utils.MathUtils; public class AutoAttackConfig extends ModuleConfig implements ValidatableConfig { - public double extraTicks; + + public boolean limitRange; + public double maxRange; + public int extraTicksMin; + public int extraTicksMax; + + public AutoAttackConfig() { + maxRange = 2.5; + extraTicksMin = 0; + extraTicksMax = 0; + } @Override public void validate() { - extraTicks = MathUtils.clamp( extraTicks, -10, 10); + maxRange = MathUtils.clamp(maxRange, 0, 10); + extraTicksMin = MathUtils.clamp(extraTicksMin, -10, 10); + extraTicksMax = MathUtils.clamp(extraTicksMax, extraTicksMin, 10); } } \ No newline at end of file diff --git a/common/java/com/zergatul/cheatutils/controllers/LockInputsController.java b/common/java/com/zergatul/cheatutils/controllers/LockInputsController.java index b64433eb..9b53ee23 100644 --- a/common/java/com/zergatul/cheatutils/controllers/LockInputsController.java +++ b/common/java/com/zergatul/cheatutils/controllers/LockInputsController.java @@ -19,6 +19,10 @@ private LockInputsController() { } private void onClientTickStart() { + if (mc.player == null) { + return; + } + LockInputsConfig config = ConfigStore.instance.getConfig().lockInputsConfig; if (config.holdForward) { diff --git a/common/java/com/zergatul/cheatutils/extensions/BlockRendererExtension.java b/common/java/com/zergatul/cheatutils/extensions/BlockRendererExtension.java deleted file mode 100644 index 731017d2..00000000 --- a/common/java/com/zergatul/cheatutils/extensions/BlockRendererExtension.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.zergatul.cheatutils.extensions; - -public interface BlockRendererExtension { -// void setSchematicaShadeMode_CU(boolean value); -} \ No newline at end of file diff --git a/common/java/com/zergatul/cheatutils/extensions/ChunkRenderContextExtension.java b/common/java/com/zergatul/cheatutils/extensions/ChunkRenderContextExtension.java deleted file mode 100644 index d0f5d920..00000000 --- a/common/java/com/zergatul/cheatutils/extensions/ChunkRenderContextExtension.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.zergatul.cheatutils.extensions; - -import com.zergatul.cheatutils.schematics.SchematicaSectionCopy; - -public interface ChunkRenderContextExtension { - SchematicaSectionCopy[] getSchematicaSections_CU(); - void setSchematicaSections_CU(SchematicaSectionCopy[] sections); -} \ No newline at end of file diff --git a/common/java/com/zergatul/cheatutils/extensions/LevelSliceExtension.java b/common/java/com/zergatul/cheatutils/extensions/LevelSliceExtension.java deleted file mode 100644 index 00b68d59..00000000 --- a/common/java/com/zergatul/cheatutils/extensions/LevelSliceExtension.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.zergatul.cheatutils.extensions; - -public interface LevelSliceExtension { - boolean hasSchematicaBlockAt_CU(int x, int y, int z); -} \ No newline at end of file diff --git a/common/java/com/zergatul/cheatutils/extensions/RenderSectionRegionExtension.java b/common/java/com/zergatul/cheatutils/extensions/RenderSectionRegionExtension.java index db538fa3..3f1fd0a8 100644 --- a/common/java/com/zergatul/cheatutils/extensions/RenderSectionRegionExtension.java +++ b/common/java/com/zergatul/cheatutils/extensions/RenderSectionRegionExtension.java @@ -1,9 +1,11 @@ package com.zergatul.cheatutils.extensions; import com.zergatul.cheatutils.schematics.SchematicaSectionCopy; -import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockAndTintGetter; public interface RenderSectionRegionExtension { void setSchematicaSections_CU(SchematicaSectionCopy[] copies, boolean shade); - boolean hasSchematicaBlockAt_CU(BlockPos pos); + boolean hasSchematicaBlocks_CU(); + boolean shadeSchematicaBlocks_CU(); + BlockAndTintGetter asWrapped_CU(); } \ No newline at end of file diff --git a/common/java/com/zergatul/cheatutils/extensions/SubmitNodeStorageModelSubmitExtension.java b/common/java/com/zergatul/cheatutils/extensions/SubmitNodeStorageModelSubmitExtension.java deleted file mode 100644 index a7f6096d..00000000 --- a/common/java/com/zergatul/cheatutils/extensions/SubmitNodeStorageModelSubmitExtension.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.zergatul.cheatutils.extensions; - -import com.zergatul.cheatutils.modules.esp.EntityEsp; - -public interface SubmitNodeStorageModelSubmitExtension { - EntityEsp.EntityRenderParameters getParameters_CU(); - void setParameters_CU(EntityEsp.EntityRenderParameters parameters); -} \ No newline at end of file diff --git a/common/java/com/zergatul/cheatutils/mixins/common/MixinChunkBorderRenderer.java b/common/java/com/zergatul/cheatutils/mixins/common/MixinChunkBorderRenderer.java new file mode 100644 index 00000000..7236bd09 --- /dev/null +++ b/common/java/com/zergatul/cheatutils/mixins/common/MixinChunkBorderRenderer.java @@ -0,0 +1,24 @@ +package com.zergatul.cheatutils.mixins.common; + +import com.llamalad7.mixinextras.injector.ModifyExpressionValue; +import com.zergatul.cheatutils.modules.esp.FreeCam; +import net.minecraft.client.renderer.debug.ChunkBorderRenderer; +import net.minecraft.core.SectionPos; +import net.minecraft.world.phys.Vec3; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; + +@Mixin(ChunkBorderRenderer.class) +public abstract class MixinChunkBorderRenderer { + + @ModifyExpressionValue( + method = "emitGizmos", + at = @At(value = "INVOKE", target = "Lnet/minecraft/core/SectionPos;of(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/core/SectionPos;")) + private SectionPos func(SectionPos original) { + if (FreeCam.instance.isActive()) { + return SectionPos.of(new Vec3(FreeCam.instance.getX(), FreeCam.instance.getY(), FreeCam.instance.getZ())); + } else { + return original; + } + } +} \ No newline at end of file diff --git a/common/java/com/zergatul/cheatutils/mixins/common/schematics/MixinRenderSectionRegion.java b/common/java/com/zergatul/cheatutils/mixins/common/schematics/MixinRenderSectionRegion.java index db1f6f2d..f188170f 100644 --- a/common/java/com/zergatul/cheatutils/mixins/common/schematics/MixinRenderSectionRegion.java +++ b/common/java/com/zergatul/cheatutils/mixins/common/schematics/MixinRenderSectionRegion.java @@ -2,21 +2,17 @@ import com.zergatul.cheatutils.extensions.RenderSectionRegionExtension; import com.zergatul.cheatutils.schematics.SchematicaSectionCopy; +import com.zergatul.cheatutils.schematics.WrapperRenderSectionRegion; import net.minecraft.client.renderer.chunk.RenderSectionRegion; -import net.minecraft.client.renderer.chunk.SectionCopy; -import net.minecraft.core.BlockPos; -import net.minecraft.core.SectionPos; -import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.BlockAndTintGetter; +import net.minecraft.world.level.Level; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(RenderSectionRegion.class) -public abstract class MixinRenderSectionRegion implements RenderSectionRegionExtension { +public abstract class MixinRenderSectionRegion implements RenderSectionRegionExtension, BlockAndTintGetter { @Shadow @Final @@ -31,7 +27,8 @@ public abstract class MixinRenderSectionRegion implements RenderSectionRegionExt private int minSectionZ; @Shadow - protected abstract SectionCopy getSection(int p_406718_, int p_406216_, int p_406392_); + @Final + private Level level; @Unique private SchematicaSectionCopy[] schematicaSections_CU; @@ -46,40 +43,17 @@ public void setSchematicaSections_CU(SchematicaSectionCopy[] schematicaSections, } @Override - public boolean hasSchematicaBlockAt_CU(BlockPos pos) { - if (schematicaSections_CU == null || !schematicaShadeBlocks_CU) { - return false; - } - - int x = pos.getX(); - int y = pos.getY(); - int z = pos.getZ(); - int xs = SectionPos.blockToSectionCoord(x); - int ys = SectionPos.blockToSectionCoord(y); - int zs = SectionPos.blockToSectionCoord(z); - - BlockState original = this.getSection(xs, ys, zs).getBlockState(pos); - return original.isAir(); + public boolean hasSchematicaBlocks_CU() { + return schematicaSections_CU != null; } - @Inject(at = @At("RETURN"), method = "getBlockState", cancellable = true) - private void onGetBlockState(BlockPos pos, CallbackInfoReturnable info) { - if (schematicaSections_CU == null) { - return; - } - - if (!info.getReturnValue().isAir()) { - return; - } - - int x = pos.getX(); - int y = pos.getY(); - int z = pos.getZ(); - int xs = SectionPos.blockToSectionCoord(x); - int ys = SectionPos.blockToSectionCoord(y); - int zs = SectionPos.blockToSectionCoord(z); + @Override + public boolean shadeSchematicaBlocks_CU() { + return schematicaShadeBlocks_CU; + } - int i = RenderSectionRegion.index(minSectionX, minSectionY, minSectionZ, xs, ys, zs); - info.setReturnValue(schematicaSections_CU[i].getBlockState(x, y, z)); + @Override + public BlockAndTintGetter asWrapped_CU() { + return new WrapperRenderSectionRegion(level, this, schematicaSections_CU, minSectionX, minSectionY, minSectionZ); } } \ No newline at end of file diff --git a/common/java/com/zergatul/cheatutils/mixins/common/sodium/MixinBlockRenderer.java b/common/java/com/zergatul/cheatutils/mixins/common/sodium/MixinBlockRenderer.java deleted file mode 100644 index cc4753a6..00000000 --- a/common/java/com/zergatul/cheatutils/mixins/common/sodium/MixinBlockRenderer.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.zergatul.cheatutils.mixins.common.sodium; - -import com.zergatul.cheatutils.extensions.BlockRendererExtension; -import com.zergatul.mixin.ModifyArgument; -import net.caffeinemc.mods.sodium.client.render.chunk.compile.pipeline.BlockRenderer; -import net.caffeinemc.mods.sodium.client.render.model.MutableQuadViewImpl; -import net.caffeinemc.mods.sodium.client.services.PlatformModelEmitter; -import net.minecraft.client.renderer.block.model.BlockModelPart; -import net.minecraft.core.Direction; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; - -import java.util.function.Consumer; -import java.util.function.Predicate; - -@Mixin(value = BlockRenderer.class, remap = false) -public abstract class MixinBlockRenderer implements BlockRendererExtension { - -// @Unique -// private boolean schematicaShadeMode_CU; -// -// public void setSchematicaShadeMode_CU(boolean value) { -// schematicaShadeMode_CU = value; -// } -// -// @ModifyArgument( -// method = "renderModel", -// at = @At(value = "INVOKE", target = "Lnet/caffeinemc/mods/sodium/client/services/PlatformModelEmitter;emitModel(Lnet/minecraft/client/renderer/block/model/BlockStateModel;Ljava/util/function/Predicate;Lnet/caffeinemc/mods/sodium/client/render/model/MutableQuadViewImpl;Lnet/minecraft/util/RandomSource;Lnet/minecraft/world/level/BlockAndTintGetter;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;Lnet/caffeinemc/mods/sodium/client/services/PlatformModelEmitter$Bufferer;)V")) -// private MutableQuadViewImpl onModifyBuffer(MutableQuadViewImpl quad) { -// if (schematicaShadeMode_CU) { -// quad.setColor(0, 0x80808080); -// quad.setColor(1, 0x80808080); -// quad.setColor(2, 0x80808080); -// quad.setColor(3, 0x80808080); -// } -// -// return quad; -// } -} \ No newline at end of file diff --git a/common/java/com/zergatul/cheatutils/mixins/common/sodium/MixinChunkBuilderMeshingTask.java b/common/java/com/zergatul/cheatutils/mixins/common/sodium/MixinChunkBuilderMeshingTask.java deleted file mode 100644 index 386cd424..00000000 --- a/common/java/com/zergatul/cheatutils/mixins/common/sodium/MixinChunkBuilderMeshingTask.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.zergatul.cheatutils.mixins.common.sodium; - -import com.zergatul.cheatutils.extensions.BlockRendererExtension; -import com.zergatul.cheatutils.extensions.LevelSliceExtension; -import com.zergatul.mixin.LiteInject; -import com.zergatul.mixin.LocalVariable; -import net.caffeinemc.mods.sodium.client.render.chunk.compile.ChunkBuildOutput; -import net.caffeinemc.mods.sodium.client.render.chunk.compile.pipeline.BlockRenderer; -import net.caffeinemc.mods.sodium.client.render.chunk.compile.tasks.ChunkBuilderMeshingTask; -import net.caffeinemc.mods.sodium.client.render.chunk.compile.tasks.ChunkBuilderTask; -import net.caffeinemc.mods.sodium.client.world.LevelSlice; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; - -@Mixin(value = ChunkBuilderMeshingTask.class, remap = false) -public abstract class MixinChunkBuilderMeshingTask { - -// @LiteInject( -// method = "execute(Lnet/caffeinemc/mods/sodium/client/render/chunk/compile/ChunkBuildContext;Lnet/caffeinemc/mods/sodium/client/util/task/CancellationToken;)Lnet/caffeinemc/mods/sodium/client/render/chunk/compile/ChunkBuildOutput;", -// at = @At( -// value = "INVOKE", -// target = "Lnet/caffeinemc/mods/sodium/client/render/chunk/compile/pipeline/BlockRenderer;renderModel(Lnet/minecraft/client/renderer/block/model/BlockStateModel;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/core/BlockPos;Lnet/minecraft/core/BlockPos;)V", -// shift = At.Shift.BEFORE)) -// private void onBeforeCallRenderModel( -// @LocalVariable(ordinal = 0) LevelSlice slice, -// @LocalVariable(ordinal = 0) BlockRenderer blockRenderer, -// @LocalVariable(ordinal = 8) int x, -// @LocalVariable(ordinal = 6) int y, -// @LocalVariable(ordinal = 7) int z -// ) { -// if (((LevelSliceExtension) slice).hasSchematicaBlockAt_CU(x, y, z)) { -// ((BlockRendererExtension) blockRenderer).setSchematicaShadeMode_CU(true); -// } -// } -// -// @LiteInject( -// method = "execute(Lnet/caffeinemc/mods/sodium/client/render/chunk/compile/ChunkBuildContext;Lnet/caffeinemc/mods/sodium/client/util/task/CancellationToken;)Lnet/caffeinemc/mods/sodium/client/render/chunk/compile/ChunkBuildOutput;", -// at = @At( -// value = "INVOKE", -// target = "Lnet/caffeinemc/mods/sodium/client/render/chunk/compile/pipeline/BlockRenderer;renderModel(Lnet/minecraft/client/renderer/block/model/BlockStateModel;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/core/BlockPos;Lnet/minecraft/core/BlockPos;)V")) -// private void onAfterCallRenderModel( -// @LocalVariable(ordinal = 0) BlockRenderer blockRenderer -// ) { -// ((BlockRendererExtension) blockRenderer).setSchematicaShadeMode_CU(false); -// } -} \ No newline at end of file diff --git a/common/java/com/zergatul/cheatutils/mixins/common/sodium/MixinChunkRenderContext.java b/common/java/com/zergatul/cheatutils/mixins/common/sodium/MixinChunkRenderContext.java deleted file mode 100644 index d46c7286..00000000 --- a/common/java/com/zergatul/cheatutils/mixins/common/sodium/MixinChunkRenderContext.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.zergatul.cheatutils.mixins.common.sodium; - -import com.zergatul.cheatutils.extensions.ChunkRenderContextExtension; -import com.zergatul.cheatutils.schematics.SchematicaSectionCopy; -import net.caffeinemc.mods.sodium.client.world.cloned.ChunkRenderContext; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Unique; - -@Mixin(value = ChunkRenderContext.class, remap = false) -public abstract class MixinChunkRenderContext implements ChunkRenderContextExtension { - - @Unique - private SchematicaSectionCopy[] schematicaSections_CU; - - public SchematicaSectionCopy[] getSchematicaSections_CU() { - return schematicaSections_CU; - } - - public void setSchematicaSections_CU(SchematicaSectionCopy[] sections) { - schematicaSections_CU = sections; - } -} \ No newline at end of file diff --git a/common/java/com/zergatul/cheatutils/mixins/common/sodium/MixinLevelSlice.java b/common/java/com/zergatul/cheatutils/mixins/common/sodium/MixinLevelSlice.java deleted file mode 100644 index 0a86eb0a..00000000 --- a/common/java/com/zergatul/cheatutils/mixins/common/sodium/MixinLevelSlice.java +++ /dev/null @@ -1,159 +0,0 @@ -package com.zergatul.cheatutils.mixins.common.sodium; - -import com.zergatul.cheatutils.extensions.ChunkRenderContextExtension; -import com.zergatul.cheatutils.extensions.LevelSliceExtension; -import com.zergatul.cheatutils.modules.automation.Schematica; -import com.zergatul.cheatutils.schematics.SchematicaSectionCopy; -import com.zergatul.mixin.LocalVariable; -import com.zergatul.mixin.ModifyMethodReturnValue; -import net.caffeinemc.mods.sodium.client.world.LevelSlice; -import net.caffeinemc.mods.sodium.client.world.cloned.ChunkRenderContext; -import net.caffeinemc.mods.sodium.client.world.cloned.ClonedChunkSectionCache; -import net.minecraft.client.renderer.chunk.RenderSectionRegion; -import net.minecraft.core.SectionPos; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.levelgen.structure.BoundingBox; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Mixin(value = LevelSlice.class, remap = false) -public abstract class MixinLevelSlice implements LevelSliceExtension { - - @Shadow - public static int getLocalSectionIndex(int sectionX, int sectionY, int sectionZ) { - throw new AssertionError(); - } - - @Shadow - public static int getLocalBlockIndex(int blockX, int blockY, int blockZ) { - throw new AssertionError(); - } - - @Shadow - private BoundingBox volume; - - @Shadow - private BlockState[][] blockArrays; - - @Shadow - private int originBlockX; - - @Shadow - private int originBlockY; - - @Shadow - private int originBlockZ; - - @Unique - private SchematicaSectionCopy[] schematicaSections_CU; - - public boolean hasSchematicaBlockAt_CU(int x, int y, int z) { - if (this.schematicaSections_CU == null) { - return false; - } - - if (!this.volume.isInside(x, y, z)) { - return false; - } - - int relBlockX = x - this.originBlockX; - int relBlockY = y - this.originBlockY; - int relBlockZ = z - this.originBlockZ; - - //SchematicaSectionCopy section = this.schematicaSections_CU[getLocalSectionIndex(relBlockX >> 4, relBlockY >> 4, relBlockZ >> 4)]; - BlockState blockState = this.blockArrays - [getLocalSectionIndex(relBlockX >> 4, relBlockY >> 4, relBlockZ >> 4)] - [getLocalBlockIndex(x & 15, y & 15, z & 15)]; - return blockState.isAir(); - } - - @ModifyMethodReturnValue(method = "prepare", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/chunk/LevelChunkSection;hasOnlyAir()Z")) - private static boolean onModifyHasOnlyAir(boolean hasOnlyAir, @LocalVariable(ordinal = 0) SectionPos pos) { - if (!hasOnlyAir) { - return false; - } - - return !Schematica.instance.hasBlocksAtSection(pos.getX(), pos.getY(), pos.getZ()); - } - - @Inject(at = @At("RETURN"), method = "prepare") - private static void onModifyChunkRenderContext(Level level, SectionPos pos, ClonedChunkSectionCache cache, CallbackInfoReturnable info) { - if (info.getReturnValue() == null) { - return; - } - - Schematica schematica = Schematica.instance; - if (!schematica.isBlockRenderingEnabled()) { - return; - } - - int xs = pos.getX(); - int ys = pos.getY(); - int zs = pos.getZ(); - - int xs1 = xs - RenderSectionRegion.RADIUS; - int xs2 = xs + RenderSectionRegion.RADIUS; - int ys1 = ys - RenderSectionRegion.RADIUS; - int ys2 = ys + RenderSectionRegion.RADIUS; - int zs1 = zs - RenderSectionRegion.RADIUS; - int zs2 = zs + RenderSectionRegion.RADIUS; - - boolean hasSchematicaBlocks = false; - for (int x = xs1; x <= xs2; x++) { - for (int y = ys1; y <= ys2; y++) { - for (int z = zs1; z <= zs2; z++) { - if (schematica.hasBlocksAtSection(x, y, z)) { - hasSchematicaBlocks = true; - } - } - } - } - - if (!hasSchematicaBlocks) { - return; - } - - SchematicaSectionCopy[] sections = new SchematicaSectionCopy[27]; - for (int x = 0; x < 3; x++) { - for (int y = 0; y < 3; y++) { - for (int z = 0; z < 3; z++) { - // TODO: cache copies like Sodium does - sections[getLocalSectionIndex(x, y, z)] = schematica.createSectionCopy(SectionPos.asLong(xs1 + x, ys1 + y, zs1 + z)); - } - } - } - - ((ChunkRenderContextExtension) info.getReturnValue()).setSchematicaSections_CU(sections); - } - - @Inject(at = @At("TAIL"), method = "copyData") - private void onCopyData(ChunkRenderContext context, CallbackInfo info) { - this.schematicaSections_CU = ((ChunkRenderContextExtension) context).getSchematicaSections_CU(); - } - - @Inject( - at = @At("RETURN"), - method = "Lnet/caffeinemc/mods/sodium/client/world/LevelSlice;getBlockState(III)Lnet/minecraft/world/level/block/state/BlockState;", - cancellable = true) - private void onGetBlockState(int blockX, int blockY, int blockZ, CallbackInfoReturnable info) { - if (this.schematicaSections_CU == null) { - return; - } - - if (!info.getReturnValue().isAir()) { - return; - } - - int index = getLocalSectionIndex( - SectionPos.blockToSectionCoord(blockX - originBlockX), - SectionPos.blockToSectionCoord(blockY - originBlockY), - SectionPos.blockToSectionCoord(blockZ - originBlockZ)); - info.setReturnValue(this.schematicaSections_CU[index].getBlockState(blockX, blockY, blockZ)); - } -} \ No newline at end of file diff --git a/common/java/com/zergatul/cheatutils/modules/automation/AutoAttack.java b/common/java/com/zergatul/cheatutils/modules/automation/AutoAttack.java index 5e4e62a3..31355287 100644 --- a/common/java/com/zergatul/cheatutils/modules/automation/AutoAttack.java +++ b/common/java/com/zergatul/cheatutils/modules/automation/AutoAttack.java @@ -15,6 +15,7 @@ public class AutoAttack implements Module { public static final AutoAttack instance = new AutoAttack(); private final Minecraft mc = Minecraft.getInstance(); + private int nextExtraTicks = Integer.MIN_VALUE; private AutoAttack() { Events.ClientTickEnd.add(this::onClientTickEnd); @@ -42,12 +43,26 @@ private void onClientTickEnd() { return; } - if (mc.player.getAttackStrengthScale((float) -config.extraTicks) != 1) { + calculateNextExtraTicksIfRequired(config); + + if (mc.player.getAttackStrengthScale(-nextExtraTicks) != 1) { + return; + } + + if (config.limitRange && mc.hitResult.getLocation().distanceToSqr(mc.player.getEyePosition()) > config.maxRange * config.maxRange) { return; } + nextExtraTicks = Integer.MIN_VALUE; + Entity entity = ((EntityHitResult) mc.hitResult).getEntity(); mc.gameMode.attack(mc.player, entity); mc.player.swing(InteractionHand.MAIN_HAND); } + + private void calculateNextExtraTicksIfRequired(AutoAttackConfig config) { + if (nextExtraTicks == Integer.MIN_VALUE) { + nextExtraTicks = config.extraTicksMin + (int) Math.floor(Math.random() * (config.extraTicksMax - config.extraTicksMin + 1)); + } + } } \ No newline at end of file diff --git a/common/java/com/zergatul/cheatutils/modules/esp/EntityTitle.java b/common/java/com/zergatul/cheatutils/modules/esp/EntityTitle.java index d6335037..f29e1539 100644 --- a/common/java/com/zergatul/cheatutils/modules/esp/EntityTitle.java +++ b/common/java/com/zergatul/cheatutils/modules/esp/EntityTitle.java @@ -463,6 +463,7 @@ private static class EnchantmentEntry { Map.entry(Enchantments.DENSITY.identifier(), new EnchantmentDisplayEntry("Dn")), Map.entry(Enchantments.BREACH.identifier(), new EnchantmentDisplayEntry("Br")), Map.entry(Enchantments.WIND_BURST.identifier(), new EnchantmentDisplayEntry("Wi")), + Map.entry(Enchantments.LUNGE.identifier(), new EnchantmentDisplayEntry("Lu")), Map.entry(Enchantments.SILK_TOUCH.identifier(), new EnchantmentDisplayEntry("Si")), Map.entry(Enchantments.FORTUNE.identifier(), new EnchantmentDisplayEntry("Fo")), diff --git a/common/java/com/zergatul/cheatutils/schematics/ShadedVertexConsumerWrapper.java b/common/java/com/zergatul/cheatutils/schematics/ShadedVertexConsumerWrapper.java index cb06dfc9..a2d4715c 100644 --- a/common/java/com/zergatul/cheatutils/schematics/ShadedVertexConsumerWrapper.java +++ b/common/java/com/zergatul/cheatutils/schematics/ShadedVertexConsumerWrapper.java @@ -11,6 +11,10 @@ public class ShadedVertexConsumerWrapper implements VertexConsumer { private final float shadeB; private final float shadeA; + public ShadedVertexConsumerWrapper(VertexConsumer inner) { + this(inner, 0.5f, 0.8f, 1.0f, 0.6f); + } + public ShadedVertexConsumerWrapper(VertexConsumer inner, float r, float g, float b, float a) { this.inner = inner; this.shadeR = r; diff --git a/common/java/com/zergatul/cheatutils/schematics/WrapperRenderSectionRegion.java b/common/java/com/zergatul/cheatutils/schematics/WrapperRenderSectionRegion.java new file mode 100644 index 00000000..1e665c99 --- /dev/null +++ b/common/java/com/zergatul/cheatutils/schematics/WrapperRenderSectionRegion.java @@ -0,0 +1,95 @@ +package com.zergatul.cheatutils.schematics; + +import net.minecraft.client.renderer.chunk.RenderSectionRegion; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.core.SectionPos; +import net.minecraft.world.level.BlockAndTintGetter; +import net.minecraft.world.level.ColorResolver; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.lighting.LevelLightEngine; +import net.minecraft.world.level.material.FluidState; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; + +@NullMarked +public class WrapperRenderSectionRegion implements BlockAndTintGetter { + + private final Level level; + private final BlockAndTintGetter inner; + private final SchematicaSectionCopy[] schematicaSections; + private final int minSectionX; + private final int minSectionY; + private final int minSectionZ; + + public WrapperRenderSectionRegion( + Level level, + BlockAndTintGetter inner, + SchematicaSectionCopy[] schematicaSections, + int minSectionX, + int minSectionY, + int minSectionZ + ) { + this.level = level; + this.inner = inner; + this.schematicaSections = schematicaSections; + this.minSectionX = minSectionX; + this.minSectionY = minSectionY; + this.minSectionZ = minSectionZ; + } + + @Override + public float getShade(Direction direction, boolean p_45523_) { + return level.getShade(direction, p_45523_); + } + + @Override + public LevelLightEngine getLightEngine() { + return inner.getLightEngine(); + } + + @Override + public int getBlockTint(BlockPos pos, ColorResolver resolver) { + return level.getBlockTint(pos, resolver); + } + + @Override + public @Nullable BlockEntity getBlockEntity(BlockPos pos) { + return null; + } + + @Override + public BlockState getBlockState(BlockPos pos) { + BlockState state = inner.getBlockState(pos); + if (!state.isAir()) { + return state; + } + + int x = pos.getX(); + int y = pos.getY(); + int z = pos.getZ(); + int xs = SectionPos.blockToSectionCoord(x); + int ys = SectionPos.blockToSectionCoord(y); + int zs = SectionPos.blockToSectionCoord(z); + + int index = RenderSectionRegion.index(minSectionX, minSectionY, minSectionZ, xs, ys, zs); + return schematicaSections[index].getBlockState(x, y, z); + } + + @Override + public FluidState getFluidState(BlockPos pos) { + return getBlockState(pos).getFluidState(); + } + + @Override + public int getHeight() { + throw new IllegalStateException(); + } + + @Override + public int getMinY() { + throw new IllegalStateException(); + } +} \ No newline at end of file diff --git a/common/java/com/zergatul/cheatutils/scripting/Root.java b/common/java/com/zergatul/cheatutils/scripting/Root.java index bf8fc902..951269fe 100644 --- a/common/java/com/zergatul/cheatutils/scripting/Root.java +++ b/common/java/com/zergatul/cheatutils/scripting/Root.java @@ -15,6 +15,7 @@ public class Root { public static AutoBucketApi autoBucket = new AutoBucketApi(); public static AutoHotbarApi autoHotbar = new AutoHotbarApi(); public static AutoToolApi autoTool = new AutoToolApi(); + public static AutoAttackApi autoAttack = new AutoAttackApi(); // ESP public static BlocksApi blocks = new BlocksApi(); diff --git a/common/java/com/zergatul/cheatutils/scripting/modules/AutoAttackApi.java b/common/java/com/zergatul/cheatutils/scripting/modules/AutoAttackApi.java new file mode 100644 index 00000000..87a818bc --- /dev/null +++ b/common/java/com/zergatul/cheatutils/scripting/modules/AutoAttackApi.java @@ -0,0 +1,12 @@ +package com.zergatul.cheatutils.scripting.modules; + +import com.zergatul.cheatutils.configs.AutoAttackConfig; +import com.zergatul.cheatutils.configs.ConfigStore; + +public class AutoAttackApi extends ModuleApi { + + @Override + protected AutoAttackConfig getConfig() { + return ConfigStore.instance.getConfig().autoAttackConfig; + } +} diff --git a/common/java/com/zergatul/cheatutils/scripting/monaco/MonacoSuggestionFactory.java b/common/java/com/zergatul/cheatutils/scripting/monaco/MonacoSuggestionFactory.java index 3f3ae2bf..68a31d4a 100644 --- a/common/java/com/zergatul/cheatutils/scripting/monaco/MonacoSuggestionFactory.java +++ b/common/java/com/zergatul/cheatutils/scripting/monaco/MonacoSuggestionFactory.java @@ -18,6 +18,7 @@ public MonacoSuggestionFactory(DocumentationProvider provider) { @Override public Suggestion getKeywordSuggestion(TokenType type) { String text = switch (type) { + case META_CAST -> "#cast"; case META_TYPE -> "#type"; case META_TYPE_OF -> "#typeof"; default -> type.toString().toLowerCase(); @@ -62,7 +63,7 @@ public List getTypeSuggestion(SType type) { "int64", CompletionItemKind.CLASS)); } - if (type instanceof SPredefinedType) { + if (type.isPredefined()) { return List.of(new Suggestion( type.toString(), null, diff --git a/common/java/net/caffeinemc/mods/sodium/client/render/chunk/RenderSection.java b/common/java/net/caffeinemc/mods/sodium/client/render/chunk/RenderSection.java deleted file mode 100644 index 4239ae3d..00000000 --- a/common/java/net/caffeinemc/mods/sodium/client/render/chunk/RenderSection.java +++ /dev/null @@ -1,16 +0,0 @@ -package net.caffeinemc.mods.sodium.client.render.chunk; - -public class RenderSection { - - public int getChunkX() { - return 0; - } - - public int getChunkY() { - return 0; - } - - public int getChunkZ() { - return 0; - } -} \ No newline at end of file diff --git a/common/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/BuilderTaskOutput.java b/common/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/BuilderTaskOutput.java deleted file mode 100644 index ddea6274..00000000 --- a/common/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/BuilderTaskOutput.java +++ /dev/null @@ -1,11 +0,0 @@ -package net.caffeinemc.mods.sodium.client.render.chunk.compile; - -import net.caffeinemc.mods.sodium.client.render.chunk.RenderSection; - -public abstract class BuilderTaskOutput { - public final RenderSection render; - - public BuilderTaskOutput() { - this.render = new RenderSection(); - } -} \ No newline at end of file diff --git a/common/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/ChunkBuildContext.java b/common/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/ChunkBuildContext.java deleted file mode 100644 index 074a8d6c..00000000 --- a/common/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/ChunkBuildContext.java +++ /dev/null @@ -1,7 +0,0 @@ -package net.caffeinemc.mods.sodium.client.render.chunk.compile; - -import net.caffeinemc.mods.sodium.client.render.chunk.compile.pipeline.BlockRenderCache; - -public class ChunkBuildContext { - public BlockRenderCache cache; -} \ No newline at end of file diff --git a/common/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/ChunkBuildOutput.java b/common/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/ChunkBuildOutput.java deleted file mode 100644 index 4c90b53c..00000000 --- a/common/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/ChunkBuildOutput.java +++ /dev/null @@ -1,3 +0,0 @@ -package net.caffeinemc.mods.sodium.client.render.chunk.compile; - -public class ChunkBuildOutput extends ChunkSortOutput {} \ No newline at end of file diff --git a/common/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/ChunkSortOutput.java b/common/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/ChunkSortOutput.java deleted file mode 100644 index 0a7d7439..00000000 --- a/common/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/ChunkSortOutput.java +++ /dev/null @@ -1,3 +0,0 @@ -package net.caffeinemc.mods.sodium.client.render.chunk.compile; - -public class ChunkSortOutput extends BuilderTaskOutput {} \ No newline at end of file diff --git a/common/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/pipeline/BlockRenderCache.java b/common/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/pipeline/BlockRenderCache.java deleted file mode 100644 index c68d079d..00000000 --- a/common/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/pipeline/BlockRenderCache.java +++ /dev/null @@ -1,7 +0,0 @@ -package net.caffeinemc.mods.sodium.client.render.chunk.compile.pipeline; - -public class BlockRenderCache { - public BlockRenderer getBlockRenderer() { - throw new AssertionError(); - } -} \ No newline at end of file diff --git a/common/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/pipeline/BlockRenderer.java b/common/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/pipeline/BlockRenderer.java deleted file mode 100644 index 462a584b..00000000 --- a/common/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/pipeline/BlockRenderer.java +++ /dev/null @@ -1,21 +0,0 @@ -package net.caffeinemc.mods.sodium.client.render.chunk.compile.pipeline; - -import net.caffeinemc.mods.sodium.client.render.model.MutableQuadViewImpl; -import net.caffeinemc.mods.sodium.client.services.PlatformModelEmitter; -import net.minecraft.client.renderer.block.model.BlockModelPart; -import net.minecraft.client.renderer.block.model.BlockStateModel; -import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; -import net.minecraft.world.level.block.state.BlockState; - -import java.util.function.Consumer; -import java.util.function.Predicate; - -public class BlockRenderer { - - public void renderModel(BlockStateModel model, BlockState state, BlockPos pos, BlockPos origin) { - PlatformModelEmitter.getInstance().emitModel(model, null, null, null, null, pos, state, this::bufferDefaultModel); - } - - public void bufferDefaultModel(BlockModelPart part, Predicate cullTest, Consumer emitter) {} -} \ No newline at end of file diff --git a/common/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/tasks/ChunkBuilderMeshingTask.java b/common/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/tasks/ChunkBuilderMeshingTask.java deleted file mode 100644 index 9a500f23..00000000 --- a/common/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/tasks/ChunkBuilderMeshingTask.java +++ /dev/null @@ -1,38 +0,0 @@ -package net.caffeinemc.mods.sodium.client.render.chunk.compile.tasks; - -import net.caffeinemc.mods.sodium.client.render.chunk.compile.ChunkBuildContext; -import net.caffeinemc.mods.sodium.client.render.chunk.compile.ChunkBuildOutput; -import net.caffeinemc.mods.sodium.client.render.chunk.compile.pipeline.BlockRenderer; -import net.caffeinemc.mods.sodium.client.util.task.CancellationToken; -import net.caffeinemc.mods.sodium.client.world.LevelSlice; -import net.minecraft.world.level.block.state.BlockState; - -public class ChunkBuilderMeshingTask extends ChunkBuilderTask { - - @Override - public ChunkBuildOutput execute(ChunkBuildContext buildContext, CancellationToken cancellationToken) { - LevelSlice slice = new LevelSlice(); - - int minX = 0; - int minY = 0; - int minZ = 0; - - int maxX = minX + 16; - int maxY = minY + 16; - int maxZ = minZ + 16; - - BlockRenderer blockRenderer = buildContext.cache.getBlockRenderer(); - - for (int y = minY; y < maxY; y++) { - for (int z = minZ; z < maxZ; z++) { - for (int x = minX; x < maxX; x++) { - BlockState blockState = slice.getBlockState(x, y, z); - blockRenderer.renderModel(null, blockState, null, null); - throw new AssertionError(); - } - } - } - - throw new AssertionError(); - } -} \ No newline at end of file diff --git a/common/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/tasks/ChunkBuilderTask.java b/common/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/tasks/ChunkBuilderTask.java deleted file mode 100644 index 1994c3dc..00000000 --- a/common/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/tasks/ChunkBuilderTask.java +++ /dev/null @@ -1,17 +0,0 @@ -package net.caffeinemc.mods.sodium.client.render.chunk.compile.tasks; - -import net.caffeinemc.mods.sodium.client.render.chunk.RenderSection; -import net.caffeinemc.mods.sodium.client.render.chunk.compile.BuilderTaskOutput; -import net.caffeinemc.mods.sodium.client.render.chunk.compile.ChunkBuildContext; -import net.caffeinemc.mods.sodium.client.util.task.CancellationToken; - -public abstract class ChunkBuilderTask { - - protected final RenderSection render; - - protected ChunkBuilderTask() { - this.render = new RenderSection(); - } - - public abstract OUTPUT execute(ChunkBuildContext context, CancellationToken cancellationToken); -} \ No newline at end of file diff --git a/common/java/net/caffeinemc/mods/sodium/client/render/model/MutableQuadViewImpl.java b/common/java/net/caffeinemc/mods/sodium/client/render/model/MutableQuadViewImpl.java deleted file mode 100644 index 8e10f7f7..00000000 --- a/common/java/net/caffeinemc/mods/sodium/client/render/model/MutableQuadViewImpl.java +++ /dev/null @@ -1,7 +0,0 @@ -package net.caffeinemc.mods.sodium.client.render.model; - -public class MutableQuadViewImpl { - public MutableQuadViewImpl setColor(int vertexIndex, int color) { - return this; - } -} \ No newline at end of file diff --git a/common/java/net/caffeinemc/mods/sodium/client/services/PlatformModelEmitter.java b/common/java/net/caffeinemc/mods/sodium/client/services/PlatformModelEmitter.java deleted file mode 100644 index 6aebb9ae..00000000 --- a/common/java/net/caffeinemc/mods/sodium/client/services/PlatformModelEmitter.java +++ /dev/null @@ -1,27 +0,0 @@ -package net.caffeinemc.mods.sodium.client.services; - -import net.caffeinemc.mods.sodium.client.render.model.MutableQuadViewImpl; -import net.minecraft.client.renderer.block.model.BlockModelPart; -import net.minecraft.client.renderer.block.model.BlockStateModel; -import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; -import net.minecraft.util.RandomSource; -import net.minecraft.world.level.BlockAndTintGetter; -import net.minecraft.world.level.block.state.BlockState; - -import java.util.function.Consumer; -import java.util.function.Predicate; - -public interface PlatformModelEmitter { - - static PlatformModelEmitter getInstance() { - throw new AssertionError(); - } - - void emitModel(BlockStateModel model, Predicate cullTest, MutableQuadViewImpl quad, RandomSource random, BlockAndTintGetter blockView, BlockPos pos, BlockState state, Bufferer defaultBuffer); - - @FunctionalInterface - interface Bufferer { - void emit(BlockModelPart part, Predicate cullTest, Consumer emitter); - } -} \ No newline at end of file diff --git a/common/java/net/caffeinemc/mods/sodium/client/util/task/CancellationToken.java b/common/java/net/caffeinemc/mods/sodium/client/util/task/CancellationToken.java deleted file mode 100644 index 6afb43ac..00000000 --- a/common/java/net/caffeinemc/mods/sodium/client/util/task/CancellationToken.java +++ /dev/null @@ -1,3 +0,0 @@ -package net.caffeinemc.mods.sodium.client.util.task; - -public interface CancellationToken {} \ No newline at end of file diff --git a/common/java/net/caffeinemc/mods/sodium/client/world/LevelSlice.java b/common/java/net/caffeinemc/mods/sodium/client/world/LevelSlice.java deleted file mode 100644 index d0ad0dc0..00000000 --- a/common/java/net/caffeinemc/mods/sodium/client/world/LevelSlice.java +++ /dev/null @@ -1,47 +0,0 @@ -package net.caffeinemc.mods.sodium.client.world; - -import net.caffeinemc.mods.sodium.client.world.cloned.ChunkRenderContext; -import net.caffeinemc.mods.sodium.client.world.cloned.ClonedChunkSectionCache; -import net.minecraft.core.BlockPos; -import net.minecraft.core.SectionPos; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.chunk.LevelChunk; -import net.minecraft.world.level.chunk.LevelChunkSection; -import net.minecraft.world.level.levelgen.structure.BoundingBox; - -public class LevelSlice { - - private BoundingBox volume; - private BlockState[][] blockArrays; - private int originBlockX, originBlockY, originBlockZ; - - public static ChunkRenderContext prepare(Level level, SectionPos pos, ClonedChunkSectionCache cache) { - LevelChunk chunk = level.getChunk(pos.getX(), pos.getZ()); - LevelChunkSection section = chunk.getSections()[level.getSectionIndexFromSectionY(pos.getY())]; - if (section == null || section.hasOnlyAir()) { - return null; - } - throw new AssertionError(); - } - - public BlockState getBlockState(BlockPos pos) { - throw new AssertionError(); - } - - public BlockState getBlockState(int blockX, int blockY, int blockZ) { - throw new AssertionError(); - } - - public void copyData(ChunkRenderContext context) { - throw new AssertionError(); - } - - public static int getLocalSectionIndex(int sectionX, int sectionY, int sectionZ) { - throw new AssertionError(); - } - - public static int getLocalBlockIndex(int blockX, int blockY, int blockZ) { - throw new AssertionError(); - } -} \ No newline at end of file diff --git a/common/java/net/caffeinemc/mods/sodium/client/world/cloned/ChunkRenderContext.java b/common/java/net/caffeinemc/mods/sodium/client/world/cloned/ChunkRenderContext.java deleted file mode 100644 index 27ce02be..00000000 --- a/common/java/net/caffeinemc/mods/sodium/client/world/cloned/ChunkRenderContext.java +++ /dev/null @@ -1,16 +0,0 @@ -package net.caffeinemc.mods.sodium.client.world.cloned; - -import net.minecraft.core.SectionPos; - -public class ChunkRenderContext { - - private final SectionPos origin; - - public ChunkRenderContext() { - throw new AssertionError(); - } - - public SectionPos getOrigin() { - return this.origin; - } -} \ No newline at end of file diff --git a/common/java/net/caffeinemc/mods/sodium/client/world/cloned/ClonedChunkSectionCache.java b/common/java/net/caffeinemc/mods/sodium/client/world/cloned/ClonedChunkSectionCache.java deleted file mode 100644 index 4a5f2f3c..00000000 --- a/common/java/net/caffeinemc/mods/sodium/client/world/cloned/ClonedChunkSectionCache.java +++ /dev/null @@ -1,3 +0,0 @@ -package net.caffeinemc.mods.sodium.client.world.cloned; - -public class ClonedChunkSectionCache {} \ No newline at end of file diff --git a/common/resources/cheatutils.common.mixins.json b/common/resources/cheatutils.common.mixins.json index f432198d..b865c695 100644 --- a/common/resources/cheatutils.common.mixins.json +++ b/common/resources/cheatutils.common.mixins.json @@ -48,6 +48,7 @@ "common.MixinCamera", "common.MixinChatComponent", "common.MixinChatScreen", + "common.MixinChunkBorderRenderer", "common.MixinClientboundDisconnectPacket", "common.MixinClientboundPlayerInfoRemovePacket", "common.MixinClientboundPlayerInfoUpdatePacket", diff --git a/common/resources/cheatutils.sodium.mixins.json b/common/resources/cheatutils.sodium.mixins.json deleted file mode 100644 index ed67a87b..00000000 --- a/common/resources/cheatutils.sodium.mixins.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "required": false, - "minVersion": "0.8.2", - "package": "com.zergatul.cheatutils.mixins", - "compatibilityLevel": "JAVA_21", - "plugin": "com.zergatul.cheatutils.compatibility.SodiumMixinPlugin", - "injectors": { - "defaultRequire": 0 - }, - "mixinPriority": 500, - "client": [ - "common.sodium.MixinBlockRenderer", - "common.sodium.MixinChunkBuilderMeshingTask", - "common.sodium.MixinChunkRenderContext", - "common.sodium.MixinLevelSlice" - ] -} \ No newline at end of file diff --git a/common/resources/web/components/HoldKeyConfig.html b/common/resources/web/components/HoldKeyConfig.html deleted file mode 100644 index e321edc4..00000000 --- a/common/resources/web/components/HoldKeyConfig.html +++ /dev/null @@ -1,35 +0,0 @@ -
-
- -
-
- Hold Key -
- Emulate holding keys. -
-
- -
-
- -
-
- -
-
-
\ No newline at end of file diff --git a/common/resources/web/components/HoldKeyConfig.js b/common/resources/web/components/HoldKeyConfig.js deleted file mode 100644 index bd2fb715..00000000 --- a/common/resources/web/components/HoldKeyConfig.js +++ /dev/null @@ -1,7 +0,0 @@ -import { createSimpleComponent } from './SimpleModule.js'; - -function createComponent(template) { - return createSimpleComponent('/api/hold-key', template); -} - -export { createComponent } \ No newline at end of file diff --git a/common/resources/web/components/automation/AutoAttack.html b/common/resources/web/components/automation/AutoAttack.html index 57153b0b..f608816e 100644 --- a/common/resources/web/components/automation/AutoAttack.html +++ b/common/resources/web/components/automation/AutoAttack.html @@ -8,12 +8,46 @@
Enabled
-
- Extra Ticks: - -
- Wait additional ticks once cooldown passed. Can be negative, in this case module will attack before cooldown. + +
+ + Limit Range + +
+ Max Range: +
-
+
+ Don't auto attack if target is further than specified distance. May help with some anticheats. +
+ + +
+ + Extra Delay + + + + + + + + + + +
+ Extra Ticks Min: + + +
+ Extra Ticks Max: + + +
+
+ Wait additional random ticks amount in [min..max] range once cooldown passed. + Values can be negative, in this case module will attack before cooldown. +
+
\ No newline at end of file diff --git a/common/resources/web/components/automation/Schematica.html b/common/resources/web/components/automation/Schematica.html index c1a57e3b..0e1e443a 100644 --- a/common/resources/web/components/automation/Schematica.html +++ b/common/resources/web/components/automation/Schematica.html @@ -64,7 +64,7 @@
Render Blocks feature doesn't work with Sodium. All questions to Sodium devs. - They stopped caring about compatibility. + They made it extremely hard to render custom blocks.
diff --git a/fabric/build.gradle b/fabric/build.gradle index 12f35394..b156639f 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -40,7 +40,7 @@ dependencies { modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" // Fabric API. This is technically optional, but you probably want it anyway. - modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" + modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}" // Uncomment the following line to enable the deprecated Fabric API modules. // These are included in the Fabric API production distribution and allow you to update your mod to the latest modules at a later more convenient time. @@ -50,9 +50,6 @@ dependencies { annotationProcessor files('../mixin-plugin/annotation-processor/build/libs/annotation-processor.jar') compileOnly("org.jspecify:jspecify:1.0.0") - - // to run with Sodium - //modRuntimeOnly(files("C:/Users/Zergatul/source/repos/sodium/build/mods/sodium-fabric-0.7.3-snapshot+mc1.21.10-local.jar")) } sourceSets { diff --git a/fabric/gradle.properties b/fabric/gradle.properties index cd0ea7ec..8982c68e 100644 --- a/fabric/gradle.properties +++ b/fabric/gradle.properties @@ -13,4 +13,4 @@ maven_group = com.zergatul.cheatutils archives_base_name = cheatutils # Dependencies -fabric_version=0.139.4+1.21.11 \ No newline at end of file +fabric_api_version=0.140.2+1.21.11 \ No newline at end of file diff --git a/fabric/src/main/java/com/zergatul/cheatutils/mixins/fabric/schematica/MixinSectionCompiler.java b/fabric/src/main/java/com/zergatul/cheatutils/mixins/fabric/schematica/MixinSectionCompiler.java index a3773507..59b9af60 100644 --- a/fabric/src/main/java/com/zergatul/cheatutils/mixins/fabric/schematica/MixinSectionCompiler.java +++ b/fabric/src/main/java/com/zergatul/cheatutils/mixins/fabric/schematica/MixinSectionCompiler.java @@ -1,29 +1,106 @@ package com.zergatul.cheatutils.mixins.fabric.schematica; +import com.llamalad7.mixinextras.sugar.Local; +import com.mojang.blaze3d.vertex.BufferBuilder; +import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; +import com.mojang.blaze3d.vertex.VertexSorting; import com.zergatul.cheatutils.extensions.RenderSectionRegionExtension; import com.zergatul.cheatutils.schematics.ShadedVertexConsumerWrapper; -import com.zergatul.mixin.LocalVariable; -import com.zergatul.mixin.ModifyArgument; +import it.unimi.dsi.fastutil.objects.ObjectArrayList; +import net.minecraft.client.renderer.ItemBlockRenderTypes; +import net.minecraft.client.renderer.SectionBufferBuilderPack; +import net.minecraft.client.renderer.block.BlockRenderDispatcher; +import net.minecraft.client.renderer.block.model.BlockModelPart; +import net.minecraft.client.renderer.chunk.ChunkSectionLayer; import net.minecraft.client.renderer.chunk.RenderSectionRegion; import net.minecraft.client.renderer.chunk.SectionCompiler; import net.minecraft.core.BlockPos; +import net.minecraft.core.SectionPos; +import net.minecraft.util.RandomSource; +import net.minecraft.world.level.BlockAndTintGetter; +import net.minecraft.world.level.block.RenderShape; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.FluidState; +import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +import java.util.List; +import java.util.Map; @Mixin(SectionCompiler.class) public abstract class MixinSectionCompiler { - @ModifyArgument( + @Shadow + @Final + private BlockRenderDispatcher blockRenderer; + + @Shadow + protected abstract BufferBuilder getOrBeginLayer(Map map, SectionBufferBuilderPack pack, ChunkSectionLayer layer); + + @Inject( method = "compile", - at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/block/BlockRenderDispatcher;renderBatched(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/BlockAndTintGetter;Lcom/mojang/blaze3d/vertex/PoseStack;Lcom/mojang/blaze3d/vertex/VertexConsumer;ZLjava/util/List;)V")) - private VertexConsumer onModifyVertexConsumer( - VertexConsumer consumer, - @LocalVariable(ordinal = 0) RenderSectionRegion region, - @LocalVariable(ordinal = 2) BlockPos pos + at = @At(value = "INVOKE", target = "Ljava/util/Map;entrySet()Ljava/util/Set;")) + private void onBeforeSorting( + SectionPos sectionPos, + RenderSectionRegion region, + VertexSorting sorting, + SectionBufferBuilderPack pack, + CallbackInfoReturnable info, + @Local(ordinal = 0) Map map, + @Local(ordinal = 0) PoseStack poseStack ) { - if (((RenderSectionRegionExtension) region).hasSchematicaBlockAt_CU(pos)) { - return new ShadedVertexConsumerWrapper(consumer, 0.5f, 0.8f, 1.0f, 0.6f); + RenderSectionRegionExtension extension = (RenderSectionRegionExtension) region; + if (!extension.hasSchematicaBlocks_CU()) { + return; + } + + boolean shaded = extension.shadeSchematicaBlocks_CU(); + RandomSource random = RandomSource.create(); + List list = new ObjectArrayList<>(); + BlockAndTintGetter wrapped = extension.asWrapped_CU(); + + BlockPos corner1 = sectionPos.origin(); + BlockPos corner2 = corner1.offset(15, 15, 15); + for (BlockPos pos : BlockPos.betweenClosed(corner1, corner2)) { + if (!region.getBlockState(pos).isAir()) { + continue; + } + + BlockState state = wrapped.getBlockState(pos); + if (state.isAir()) { + continue; + } + + FluidState fluidState = state.getFluidState(); + if (!fluidState.isEmpty()) { + ChunkSectionLayer layer = ItemBlockRenderTypes.getRenderLayer(fluidState); + this.blockRenderer.renderLiquid(pos, wrapped, getOrBeginLayer_CU(map, pack, layer, shaded), state, fluidState); + } + + if (state.getRenderShape() == RenderShape.MODEL) { + ChunkSectionLayer layer = ItemBlockRenderTypes.getChunkRenderType(state); + random.setSeed(state.getSeed(pos)); + this.blockRenderer.getBlockModel(state).collectParts(random, list); + poseStack.pushPose(); + poseStack.translate(pos.getX() & 0xF, pos.getY() & 0xF, pos.getZ() & 0xF); + this.blockRenderer.renderBatched(state, pos, wrapped, poseStack, getOrBeginLayer_CU(map, pack, layer, shaded), true, list); + poseStack.popPose(); + list.clear(); + } + } + } + + @Unique + private VertexConsumer getOrBeginLayer_CU(Map map, SectionBufferBuilderPack pack, ChunkSectionLayer layer, boolean shaded) { + VertexConsumer consumer = this.getOrBeginLayer(map, pack, layer); + if (shaded) { + return new ShadedVertexConsumerWrapper(consumer); } else { return consumer; } diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index 9fa7ac23..ccdb4b49 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -26,7 +26,6 @@ "accessWidener": "cheatutils.classtweaker", "mixins": [ "cheatutils.common.mixins.json", - "cheatutils.sodium.mixins.json", "cheatutils.iris.mixins.json", "cheatutils.fnf.mixins.json", "cheatutils.fabric.mixins.json" diff --git a/forge/src/main/java/com/zergatul/cheatutils/mixins/forge/schematica/MixinSectionCompiler.java b/forge/src/main/java/com/zergatul/cheatutils/mixins/forge/schematica/MixinSectionCompiler.java index 3819946a..ec38e8e8 100644 --- a/forge/src/main/java/com/zergatul/cheatutils/mixins/forge/schematica/MixinSectionCompiler.java +++ b/forge/src/main/java/com/zergatul/cheatutils/mixins/forge/schematica/MixinSectionCompiler.java @@ -1,29 +1,116 @@ package com.zergatul.cheatutils.mixins.forge.schematica; +import com.llamalad7.mixinextras.sugar.Local; +import com.mojang.blaze3d.vertex.BufferBuilder; +import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; +import com.mojang.blaze3d.vertex.VertexSorting; import com.zergatul.cheatutils.extensions.RenderSectionRegionExtension; import com.zergatul.cheatutils.schematics.ShadedVertexConsumerWrapper; -import com.zergatul.mixin.LocalVariable; -import com.zergatul.mixin.ModifyArgument; +import it.unimi.dsi.fastutil.objects.ObjectArrayList; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.client.renderer.ItemBlockRenderTypes; +import net.minecraft.client.renderer.SectionBufferBuilderPack; +import net.minecraft.client.renderer.block.BlockRenderDispatcher; +import net.minecraft.client.renderer.block.model.BlockModelPart; +import net.minecraft.client.renderer.block.model.BlockStateModel; +import net.minecraft.client.renderer.chunk.ChunkSectionLayer; import net.minecraft.client.renderer.chunk.RenderSectionRegion; import net.minecraft.client.renderer.chunk.SectionCompiler; import net.minecraft.core.BlockPos; -import org.spongepowered.asm.mixin.Mixin; +import net.minecraft.core.SectionPos; +import net.minecraft.util.RandomSource; +import net.minecraft.world.level.BlockAndTintGetter; +import net.minecraft.world.level.block.RenderShape; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.FluidState; +import net.minecraftforge.client.model.data.ModelData; +import org.spongepowered.asm.mixin.*; import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +import java.util.List; +import java.util.Map; @Mixin(SectionCompiler.class) public abstract class MixinSectionCompiler { - @ModifyArgument( + @Shadow + @Final + private BlockRenderDispatcher blockRenderer; + + @Shadow + protected abstract BufferBuilder getOrBeginLayer(Map map, SectionBufferBuilderPack pack, ChunkSectionLayer layer); + + @Inject( method = "compile", - at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/block/BlockRenderDispatcher;renderBatched(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/BlockAndTintGetter;Lcom/mojang/blaze3d/vertex/PoseStack;Lcom/mojang/blaze3d/vertex/VertexConsumer;ZLjava/util/List;)V")) - private VertexConsumer onModifyVertexConsumer( - VertexConsumer consumer, - @LocalVariable(ordinal = 0) RenderSectionRegion region, - @LocalVariable(ordinal = 2) BlockPos pos + at = @At(value = "INVOKE", target = "Ljava/util/Map;entrySet()Ljava/util/Set;")) + private void onBeforeSorting( + SectionPos sectionPos, + RenderSectionRegion region, + VertexSorting sorting, + SectionBufferBuilderPack pack, + CallbackInfoReturnable info, + @Local(ordinal = 1) Map map, + @Local(ordinal = 0) PoseStack poseStack ) { - if (((RenderSectionRegionExtension) region).hasSchematicaBlockAt_CU(pos)) { - return new ShadedVertexConsumerWrapper(consumer, 0.5f, 0.8f, 1.0f, 0.6f); + RenderSectionRegionExtension extension = (RenderSectionRegionExtension) region; + if (!extension.hasSchematicaBlocks_CU()) { + return; + } + + ClientLevel level = net.minecraft.client.Minecraft.getInstance().level; + assert level != null; + Map modelDataMap = level.getModelDataManager().getAt(sectionPos); + + boolean shaded = extension.shadeSchematicaBlocks_CU(); + RandomSource random = RandomSource.create(); + List list = new ObjectArrayList<>(); + BlockAndTintGetter wrapped = extension.asWrapped_CU(); + + BlockPos corner1 = sectionPos.origin(); + BlockPos corner2 = corner1.offset(15, 15, 15); + for (BlockPos pos : BlockPos.betweenClosed(corner1, corner2)) { + if (!region.getBlockState(pos).isAir()) { + continue; + } + + BlockState state = wrapped.getBlockState(pos); + if (state.isAir()) { + continue; + } + + FluidState fluidState = state.getFluidState(); + if (!fluidState.isEmpty()) { + ChunkSectionLayer layer = ItemBlockRenderTypes.getRenderLayer(fluidState); + this.blockRenderer.renderLiquid(pos, wrapped, getOrBeginLayer_CU(map, pack, layer, shaded), state, fluidState); + } + + if (state.getRenderShape() == RenderShape.MODEL) { + BlockStateModel model = this.blockRenderer.getBlockModel(state); + ModelData data = modelDataMap.getOrDefault(pos, net.minecraftforge.client.model.data.ModelData.EMPTY); + data = model.getModelData(wrapped, pos, state, data); + random.setSeed(state.getSeed(pos)); + for (ChunkSectionLayer layer : model.getRenderTypes(state, random, data)) { + VertexConsumer consumer = this.getOrBeginLayer_CU(map, pack, layer, shaded); + random.setSeed(state.getSeed(pos)); + model.collectParts(random, list, data, layer); + poseStack.pushPose(); + poseStack.translate(pos.getX() & 0xF, pos.getY() & 0xF, pos.getZ() & 0xF); + this.blockRenderer.renderBatched(state, pos, wrapped, poseStack, consumer, true, list); + poseStack.popPose(); + list.clear(); + } + } + } + } + + @Unique + private VertexConsumer getOrBeginLayer_CU(Map map, SectionBufferBuilderPack pack, ChunkSectionLayer layer, boolean shaded) { + VertexConsumer consumer = this.getOrBeginLayer(map, pack, layer); + if (shaded) { + return new ShadedVertexConsumerWrapper(consumer); } else { return consumer; } diff --git a/neoforge/src/main/java/com/zergatul/cheatutils/mixins/neoforge/schematics/MixinSectionCompiler.java b/neoforge/src/main/java/com/zergatul/cheatutils/mixins/neoforge/schematics/MixinSectionCompiler.java index 36d396b0..ca8cce17 100644 --- a/neoforge/src/main/java/com/zergatul/cheatutils/mixins/neoforge/schematics/MixinSectionCompiler.java +++ b/neoforge/src/main/java/com/zergatul/cheatutils/mixins/neoforge/schematics/MixinSectionCompiler.java @@ -1,34 +1,106 @@ package com.zergatul.cheatutils.mixins.neoforge.schematics; +import com.llamalad7.mixinextras.sugar.Local; +import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; +import com.mojang.blaze3d.vertex.VertexSorting; import com.zergatul.cheatutils.extensions.RenderSectionRegionExtension; import com.zergatul.cheatutils.schematics.ShadedVertexConsumerWrapper; -import com.zergatul.mixin.LocalVariable; -import com.zergatul.mixin.ModifyArgument; +import it.unimi.dsi.fastutil.objects.ObjectArrayList; +import net.minecraft.client.renderer.ItemBlockRenderTypes; +import net.minecraft.client.renderer.SectionBufferBuilderPack; +import net.minecraft.client.renderer.block.BlockRenderDispatcher; +import net.minecraft.client.renderer.block.model.BlockModelPart; import net.minecraft.client.renderer.chunk.ChunkSectionLayer; import net.minecraft.client.renderer.chunk.RenderSectionRegion; import net.minecraft.client.renderer.chunk.SectionCompiler; import net.minecraft.core.BlockPos; +import net.minecraft.core.SectionPos; +import net.minecraft.util.RandomSource; +import net.minecraft.world.level.BlockAndTintGetter; +import net.minecraft.world.level.block.RenderShape; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.FluidState; +import net.neoforged.neoforge.client.event.AddSectionGeometryEvent; +import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import java.util.List; import java.util.function.Function; @Mixin(SectionCompiler.class) public abstract class MixinSectionCompiler { - @ModifyArgument( + @Shadow + @Final + private BlockRenderDispatcher blockRenderer; + + @Inject( method = "compile(Lnet/minecraft/core/SectionPos;Lnet/minecraft/client/renderer/chunk/RenderSectionRegion;Lcom/mojang/blaze3d/vertex/VertexSorting;Lnet/minecraft/client/renderer/SectionBufferBuilderPack;Ljava/util/List;)Lnet/minecraft/client/renderer/chunk/SectionCompiler$Results;", - at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/block/BlockRenderDispatcher;renderBatched(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/BlockAndTintGetter;Lcom/mojang/blaze3d/vertex/PoseStack;Ljava/util/function/Function;ZLjava/util/List;)V")) - private Function onModifyBufferLookup( - Function lookup, - @LocalVariable(ordinal = 0) RenderSectionRegion region, - @LocalVariable(ordinal = 2) BlockPos pos + at = @At(value = "INVOKE", target = "Ljava/util/Map;entrySet()Ljava/util/Set;")) + private void onBeforeSorting( + SectionPos sectionPos, + RenderSectionRegion region, + VertexSorting sorting, + SectionBufferBuilderPack pack, + List additionalRenderers, + CallbackInfoReturnable info, + @Local(ordinal = 0) Function bufferLookup, + @Local(ordinal = 0) PoseStack poseStack ) { - if (((RenderSectionRegionExtension) region).hasSchematicaBlockAt_CU(pos)) { - return layer -> new ShadedVertexConsumerWrapper(lookup.apply(layer), 0.5f, 0.8f, 1.0f, 0.6f); + RenderSectionRegionExtension extension = (RenderSectionRegionExtension) region; + if (!extension.hasSchematicaBlocks_CU()) { + return; + } + + boolean shaded = extension.shadeSchematicaBlocks_CU(); + RandomSource random = RandomSource.create(); + List list = new ObjectArrayList<>(); + BlockAndTintGetter wrapped = extension.asWrapped_CU(); + + bufferLookup = wrapBufferLookup_CU(bufferLookup, shaded); + + BlockPos corner1 = sectionPos.origin(); + BlockPos corner2 = corner1.offset(15, 15, 15); + for (BlockPos pos : BlockPos.betweenClosed(corner1, corner2)) { + if (!region.getBlockState(pos).isAir()) { + continue; + } + + BlockState state = wrapped.getBlockState(pos); + if (state.isAir()) { + continue; + } + + FluidState fluidState = state.getFluidState(); + if (!fluidState.isEmpty()) { + ChunkSectionLayer layer = ItemBlockRenderTypes.getRenderLayer(fluidState); + this.blockRenderer.renderLiquid(pos, wrapped, bufferLookup.apply(layer), state, fluidState); + } + + if (state.getRenderShape() == RenderShape.MODEL) { + random.setSeed(state.getSeed(pos)); + this.blockRenderer.getBlockModel(state).collectParts(region, pos, state, random, list); + poseStack.pushPose(); + poseStack.translate(pos.getX() & 0xF, pos.getY() & 0xF, pos.getZ() & 0xF); + this.blockRenderer.renderBatched(state, pos, wrapped, poseStack, bufferLookup, true, list); + poseStack.popPose(); + list.clear(); + } + } + } + + @Unique + private Function wrapBufferLookup_CU(Function bufferLookup, boolean shaded) { + if (shaded) { + return layer -> new ShadedVertexConsumerWrapper(bufferLookup.apply(layer)); } else { - return lookup; + return bufferLookup; } } } \ No newline at end of file From d3f1bdcd904848cccc0cb6c0c9059a41051463f6 Mon Sep 17 00:00:00 2001 From: someRandomDude-a Date: Sun, 11 Jan 2026 11:07:38 +0530 Subject: [PATCH 04/17] Revert "Merge branch '1.21.11' into spear-reach" This reverts commit 9a94174478a1d7c3d4aaa33b028335f0eb067ef1. --- .idea/vcs.xml | 8 - .idea/workspace.xml | 97 ----------- LICENSE | 2 +- common/build/build.gradle.kts | 2 - common/gradle.properties | 2 +- .../zergatul/cheatutils/common/Events.java | 3 + .../compatibility/SodiumMixinPlugin.java | 9 + .../cheatutils/configs/AutoAttackConfig.java | 16 +- .../controllers/LockInputsController.java | 4 - .../extensions/BlockRendererExtension.java | 5 + .../ChunkRenderContextExtension.java | 8 + .../extensions/LevelSliceExtension.java | 5 + .../RenderSectionRegionExtension.java | 6 +- ...SubmitNodeStorageModelSubmitExtension.java | 8 + .../common/MixinChunkBorderRenderer.java | 24 --- .../schematics/MixinRenderSectionRegion.java | 56 ++++-- .../common/sodium/MixinBlockRenderer.java | 40 +++++ .../sodium/MixinChunkBuilderMeshingTask.java | 46 +++++ .../sodium/MixinChunkRenderContext.java | 22 +++ .../mixins/common/sodium/MixinLevelSlice.java | 159 ++++++++++++++++++ .../modules/automation/AutoAttack.java | 17 +- .../cheatutils/modules/esp/EntityTitle.java | 1 - .../ShadedVertexConsumerWrapper.java | 4 - .../WrapperRenderSectionRegion.java | 95 ----------- .../zergatul/cheatutils/scripting/Root.java | 1 - .../scripting/modules/AutoAttackApi.java | 12 -- .../monaco/MonacoSuggestionFactory.java | 3 +- .../client/render/chunk/RenderSection.java | 16 ++ .../chunk/compile/BuilderTaskOutput.java | 11 ++ .../chunk/compile/ChunkBuildContext.java | 7 + .../chunk/compile/ChunkBuildOutput.java | 3 + .../render/chunk/compile/ChunkSortOutput.java | 3 + .../compile/pipeline/BlockRenderCache.java | 7 + .../chunk/compile/pipeline/BlockRenderer.java | 21 +++ .../tasks/ChunkBuilderMeshingTask.java | 38 +++++ .../chunk/compile/tasks/ChunkBuilderTask.java | 17 ++ .../render/model/MutableQuadViewImpl.java | 7 + .../client/services/PlatformModelEmitter.java | 27 +++ .../client/util/task/CancellationToken.java | 3 + .../mods/sodium/client/world/LevelSlice.java | 47 ++++++ .../world/cloned/ChunkRenderContext.java | 16 ++ .../world/cloned/ClonedChunkSectionCache.java | 3 + .../resources/cheatutils.common.mixins.json | 1 - .../resources/cheatutils.sodium.mixins.json | 17 ++ .../web/components/HoldKeyConfig.html | 35 ++++ .../resources/web/components/HoldKeyConfig.js | 7 + .../web/components/automation/AutoAttack.html | 46 +---- .../web/components/automation/Schematica.html | 2 +- fabric/build.gradle | 5 +- fabric/gradle.properties | 2 +- .../schematica/MixinSectionCompiler.java | 97 ++--------- fabric/src/main/resources/fabric.mod.json | 1 + .../schematica/MixinSectionCompiler.java | 109 ++---------- .../schematics/MixinSectionCompiler.java | 94 ++--------- 54 files changed, 684 insertions(+), 613 deletions(-) delete mode 100644 .idea/vcs.xml delete mode 100644 .idea/workspace.xml create mode 100644 common/java/com/zergatul/cheatutils/compatibility/SodiumMixinPlugin.java create mode 100644 common/java/com/zergatul/cheatutils/extensions/BlockRendererExtension.java create mode 100644 common/java/com/zergatul/cheatutils/extensions/ChunkRenderContextExtension.java create mode 100644 common/java/com/zergatul/cheatutils/extensions/LevelSliceExtension.java create mode 100644 common/java/com/zergatul/cheatutils/extensions/SubmitNodeStorageModelSubmitExtension.java delete mode 100644 common/java/com/zergatul/cheatutils/mixins/common/MixinChunkBorderRenderer.java create mode 100644 common/java/com/zergatul/cheatutils/mixins/common/sodium/MixinBlockRenderer.java create mode 100644 common/java/com/zergatul/cheatutils/mixins/common/sodium/MixinChunkBuilderMeshingTask.java create mode 100644 common/java/com/zergatul/cheatutils/mixins/common/sodium/MixinChunkRenderContext.java create mode 100644 common/java/com/zergatul/cheatutils/mixins/common/sodium/MixinLevelSlice.java delete mode 100644 common/java/com/zergatul/cheatutils/schematics/WrapperRenderSectionRegion.java delete mode 100644 common/java/com/zergatul/cheatutils/scripting/modules/AutoAttackApi.java create mode 100644 common/java/net/caffeinemc/mods/sodium/client/render/chunk/RenderSection.java create mode 100644 common/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/BuilderTaskOutput.java create mode 100644 common/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/ChunkBuildContext.java create mode 100644 common/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/ChunkBuildOutput.java create mode 100644 common/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/ChunkSortOutput.java create mode 100644 common/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/pipeline/BlockRenderCache.java create mode 100644 common/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/pipeline/BlockRenderer.java create mode 100644 common/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/tasks/ChunkBuilderMeshingTask.java create mode 100644 common/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/tasks/ChunkBuilderTask.java create mode 100644 common/java/net/caffeinemc/mods/sodium/client/render/model/MutableQuadViewImpl.java create mode 100644 common/java/net/caffeinemc/mods/sodium/client/services/PlatformModelEmitter.java create mode 100644 common/java/net/caffeinemc/mods/sodium/client/util/task/CancellationToken.java create mode 100644 common/java/net/caffeinemc/mods/sodium/client/world/LevelSlice.java create mode 100644 common/java/net/caffeinemc/mods/sodium/client/world/cloned/ChunkRenderContext.java create mode 100644 common/java/net/caffeinemc/mods/sodium/client/world/cloned/ClonedChunkSectionCache.java create mode 100644 common/resources/cheatutils.sodium.mixins.json create mode 100644 common/resources/web/components/HoldKeyConfig.html create mode 100644 common/resources/web/components/HoldKeyConfig.js diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 3a66cda6..00000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml deleted file mode 100644 index 321a293f..00000000 --- a/.idea/workspace.xml +++ /dev/null @@ -1,97 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1767777418266 - - - - \ No newline at end of file diff --git a/LICENSE b/LICENSE index 989148ae..f2b88cea 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2022-present Zergatul +Copyright (c) 2023 Igor Budzhak Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/common/build/build.gradle.kts b/common/build/build.gradle.kts index a327eea0..2605aa0a 100644 --- a/common/build/build.gradle.kts +++ b/common/build/build.gradle.kts @@ -4,8 +4,6 @@ plugins { repositories { mavenCentral() } -java.toolchain.languageVersion = JavaLanguageVersion.of(21) - gradlePlugin { plugins { create("cheatutils") { diff --git a/common/gradle.properties b/common/gradle.properties index b9e01cbb..d579d491 100644 --- a/common/gradle.properties +++ b/common/gradle.properties @@ -1 +1 @@ -mod_version=3.14.13 \ No newline at end of file +mod_version=3.14.11 \ No newline at end of file diff --git a/common/java/com/zergatul/cheatutils/common/Events.java b/common/java/com/zergatul/cheatutils/common/Events.java index d91af174..0d4b1ad8 100644 --- a/common/java/com/zergatul/cheatutils/common/Events.java +++ b/common/java/com/zergatul/cheatutils/common/Events.java @@ -86,4 +86,7 @@ public class Events { public static final CancelableEventHandler PlayerReleaseUsingItem = new CancelableEventHandler<>(); public static final CancelableEventHandler PlayerTurnByMouse = new CancelableEventHandler<>(); public static final ParameterizedEventHandler PlayerInfoUpdated = new ParameterizedEventHandler<>(); + + + } \ No newline at end of file diff --git a/common/java/com/zergatul/cheatutils/compatibility/SodiumMixinPlugin.java b/common/java/com/zergatul/cheatutils/compatibility/SodiumMixinPlugin.java new file mode 100644 index 00000000..b8d084d8 --- /dev/null +++ b/common/java/com/zergatul/cheatutils/compatibility/SodiumMixinPlugin.java @@ -0,0 +1,9 @@ +package com.zergatul.cheatutils.compatibility; + +public class SodiumMixinPlugin extends OptionalMixinPlugin { + + @Override + protected String getModName() { + return "Sodium"; + } +} \ No newline at end of file diff --git a/common/java/com/zergatul/cheatutils/configs/AutoAttackConfig.java b/common/java/com/zergatul/cheatutils/configs/AutoAttackConfig.java index 2dd88611..4fca6f97 100644 --- a/common/java/com/zergatul/cheatutils/configs/AutoAttackConfig.java +++ b/common/java/com/zergatul/cheatutils/configs/AutoAttackConfig.java @@ -3,22 +3,10 @@ import com.zergatul.cheatutils.utils.MathUtils; public class AutoAttackConfig extends ModuleConfig implements ValidatableConfig { - - public boolean limitRange; - public double maxRange; - public int extraTicksMin; - public int extraTicksMax; - - public AutoAttackConfig() { - maxRange = 2.5; - extraTicksMin = 0; - extraTicksMax = 0; - } + public double extraTicks; @Override public void validate() { - maxRange = MathUtils.clamp(maxRange, 0, 10); - extraTicksMin = MathUtils.clamp(extraTicksMin, -10, 10); - extraTicksMax = MathUtils.clamp(extraTicksMax, extraTicksMin, 10); + extraTicks = MathUtils.clamp( extraTicks, -10, 10); } } \ No newline at end of file diff --git a/common/java/com/zergatul/cheatutils/controllers/LockInputsController.java b/common/java/com/zergatul/cheatutils/controllers/LockInputsController.java index 9b53ee23..b64433eb 100644 --- a/common/java/com/zergatul/cheatutils/controllers/LockInputsController.java +++ b/common/java/com/zergatul/cheatutils/controllers/LockInputsController.java @@ -19,10 +19,6 @@ private LockInputsController() { } private void onClientTickStart() { - if (mc.player == null) { - return; - } - LockInputsConfig config = ConfigStore.instance.getConfig().lockInputsConfig; if (config.holdForward) { diff --git a/common/java/com/zergatul/cheatutils/extensions/BlockRendererExtension.java b/common/java/com/zergatul/cheatutils/extensions/BlockRendererExtension.java new file mode 100644 index 00000000..731017d2 --- /dev/null +++ b/common/java/com/zergatul/cheatutils/extensions/BlockRendererExtension.java @@ -0,0 +1,5 @@ +package com.zergatul.cheatutils.extensions; + +public interface BlockRendererExtension { +// void setSchematicaShadeMode_CU(boolean value); +} \ No newline at end of file diff --git a/common/java/com/zergatul/cheatutils/extensions/ChunkRenderContextExtension.java b/common/java/com/zergatul/cheatutils/extensions/ChunkRenderContextExtension.java new file mode 100644 index 00000000..d0f5d920 --- /dev/null +++ b/common/java/com/zergatul/cheatutils/extensions/ChunkRenderContextExtension.java @@ -0,0 +1,8 @@ +package com.zergatul.cheatutils.extensions; + +import com.zergatul.cheatutils.schematics.SchematicaSectionCopy; + +public interface ChunkRenderContextExtension { + SchematicaSectionCopy[] getSchematicaSections_CU(); + void setSchematicaSections_CU(SchematicaSectionCopy[] sections); +} \ No newline at end of file diff --git a/common/java/com/zergatul/cheatutils/extensions/LevelSliceExtension.java b/common/java/com/zergatul/cheatutils/extensions/LevelSliceExtension.java new file mode 100644 index 00000000..00b68d59 --- /dev/null +++ b/common/java/com/zergatul/cheatutils/extensions/LevelSliceExtension.java @@ -0,0 +1,5 @@ +package com.zergatul.cheatutils.extensions; + +public interface LevelSliceExtension { + boolean hasSchematicaBlockAt_CU(int x, int y, int z); +} \ No newline at end of file diff --git a/common/java/com/zergatul/cheatutils/extensions/RenderSectionRegionExtension.java b/common/java/com/zergatul/cheatutils/extensions/RenderSectionRegionExtension.java index 3f1fd0a8..db538fa3 100644 --- a/common/java/com/zergatul/cheatutils/extensions/RenderSectionRegionExtension.java +++ b/common/java/com/zergatul/cheatutils/extensions/RenderSectionRegionExtension.java @@ -1,11 +1,9 @@ package com.zergatul.cheatutils.extensions; import com.zergatul.cheatutils.schematics.SchematicaSectionCopy; -import net.minecraft.world.level.BlockAndTintGetter; +import net.minecraft.core.BlockPos; public interface RenderSectionRegionExtension { void setSchematicaSections_CU(SchematicaSectionCopy[] copies, boolean shade); - boolean hasSchematicaBlocks_CU(); - boolean shadeSchematicaBlocks_CU(); - BlockAndTintGetter asWrapped_CU(); + boolean hasSchematicaBlockAt_CU(BlockPos pos); } \ No newline at end of file diff --git a/common/java/com/zergatul/cheatutils/extensions/SubmitNodeStorageModelSubmitExtension.java b/common/java/com/zergatul/cheatutils/extensions/SubmitNodeStorageModelSubmitExtension.java new file mode 100644 index 00000000..a7f6096d --- /dev/null +++ b/common/java/com/zergatul/cheatutils/extensions/SubmitNodeStorageModelSubmitExtension.java @@ -0,0 +1,8 @@ +package com.zergatul.cheatutils.extensions; + +import com.zergatul.cheatutils.modules.esp.EntityEsp; + +public interface SubmitNodeStorageModelSubmitExtension { + EntityEsp.EntityRenderParameters getParameters_CU(); + void setParameters_CU(EntityEsp.EntityRenderParameters parameters); +} \ No newline at end of file diff --git a/common/java/com/zergatul/cheatutils/mixins/common/MixinChunkBorderRenderer.java b/common/java/com/zergatul/cheatutils/mixins/common/MixinChunkBorderRenderer.java deleted file mode 100644 index 7236bd09..00000000 --- a/common/java/com/zergatul/cheatutils/mixins/common/MixinChunkBorderRenderer.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.zergatul.cheatutils.mixins.common; - -import com.llamalad7.mixinextras.injector.ModifyExpressionValue; -import com.zergatul.cheatutils.modules.esp.FreeCam; -import net.minecraft.client.renderer.debug.ChunkBorderRenderer; -import net.minecraft.core.SectionPos; -import net.minecraft.world.phys.Vec3; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; - -@Mixin(ChunkBorderRenderer.class) -public abstract class MixinChunkBorderRenderer { - - @ModifyExpressionValue( - method = "emitGizmos", - at = @At(value = "INVOKE", target = "Lnet/minecraft/core/SectionPos;of(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/core/SectionPos;")) - private SectionPos func(SectionPos original) { - if (FreeCam.instance.isActive()) { - return SectionPos.of(new Vec3(FreeCam.instance.getX(), FreeCam.instance.getY(), FreeCam.instance.getZ())); - } else { - return original; - } - } -} \ No newline at end of file diff --git a/common/java/com/zergatul/cheatutils/mixins/common/schematics/MixinRenderSectionRegion.java b/common/java/com/zergatul/cheatutils/mixins/common/schematics/MixinRenderSectionRegion.java index f188170f..db1f6f2d 100644 --- a/common/java/com/zergatul/cheatutils/mixins/common/schematics/MixinRenderSectionRegion.java +++ b/common/java/com/zergatul/cheatutils/mixins/common/schematics/MixinRenderSectionRegion.java @@ -2,17 +2,21 @@ import com.zergatul.cheatutils.extensions.RenderSectionRegionExtension; import com.zergatul.cheatutils.schematics.SchematicaSectionCopy; -import com.zergatul.cheatutils.schematics.WrapperRenderSectionRegion; import net.minecraft.client.renderer.chunk.RenderSectionRegion; -import net.minecraft.world.level.BlockAndTintGetter; -import net.minecraft.world.level.Level; +import net.minecraft.client.renderer.chunk.SectionCopy; +import net.minecraft.core.BlockPos; +import net.minecraft.core.SectionPos; +import net.minecraft.world.level.block.state.BlockState; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(RenderSectionRegion.class) -public abstract class MixinRenderSectionRegion implements RenderSectionRegionExtension, BlockAndTintGetter { +public abstract class MixinRenderSectionRegion implements RenderSectionRegionExtension { @Shadow @Final @@ -27,8 +31,7 @@ public abstract class MixinRenderSectionRegion implements RenderSectionRegionExt private int minSectionZ; @Shadow - @Final - private Level level; + protected abstract SectionCopy getSection(int p_406718_, int p_406216_, int p_406392_); @Unique private SchematicaSectionCopy[] schematicaSections_CU; @@ -43,17 +46,40 @@ public void setSchematicaSections_CU(SchematicaSectionCopy[] schematicaSections, } @Override - public boolean hasSchematicaBlocks_CU() { - return schematicaSections_CU != null; - } + public boolean hasSchematicaBlockAt_CU(BlockPos pos) { + if (schematicaSections_CU == null || !schematicaShadeBlocks_CU) { + return false; + } - @Override - public boolean shadeSchematicaBlocks_CU() { - return schematicaShadeBlocks_CU; + int x = pos.getX(); + int y = pos.getY(); + int z = pos.getZ(); + int xs = SectionPos.blockToSectionCoord(x); + int ys = SectionPos.blockToSectionCoord(y); + int zs = SectionPos.blockToSectionCoord(z); + + BlockState original = this.getSection(xs, ys, zs).getBlockState(pos); + return original.isAir(); } - @Override - public BlockAndTintGetter asWrapped_CU() { - return new WrapperRenderSectionRegion(level, this, schematicaSections_CU, minSectionX, minSectionY, minSectionZ); + @Inject(at = @At("RETURN"), method = "getBlockState", cancellable = true) + private void onGetBlockState(BlockPos pos, CallbackInfoReturnable info) { + if (schematicaSections_CU == null) { + return; + } + + if (!info.getReturnValue().isAir()) { + return; + } + + int x = pos.getX(); + int y = pos.getY(); + int z = pos.getZ(); + int xs = SectionPos.blockToSectionCoord(x); + int ys = SectionPos.blockToSectionCoord(y); + int zs = SectionPos.blockToSectionCoord(z); + + int i = RenderSectionRegion.index(minSectionX, minSectionY, minSectionZ, xs, ys, zs); + info.setReturnValue(schematicaSections_CU[i].getBlockState(x, y, z)); } } \ No newline at end of file diff --git a/common/java/com/zergatul/cheatutils/mixins/common/sodium/MixinBlockRenderer.java b/common/java/com/zergatul/cheatutils/mixins/common/sodium/MixinBlockRenderer.java new file mode 100644 index 00000000..cc4753a6 --- /dev/null +++ b/common/java/com/zergatul/cheatutils/mixins/common/sodium/MixinBlockRenderer.java @@ -0,0 +1,40 @@ +package com.zergatul.cheatutils.mixins.common.sodium; + +import com.zergatul.cheatutils.extensions.BlockRendererExtension; +import com.zergatul.mixin.ModifyArgument; +import net.caffeinemc.mods.sodium.client.render.chunk.compile.pipeline.BlockRenderer; +import net.caffeinemc.mods.sodium.client.render.model.MutableQuadViewImpl; +import net.caffeinemc.mods.sodium.client.services.PlatformModelEmitter; +import net.minecraft.client.renderer.block.model.BlockModelPart; +import net.minecraft.core.Direction; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; + +import java.util.function.Consumer; +import java.util.function.Predicate; + +@Mixin(value = BlockRenderer.class, remap = false) +public abstract class MixinBlockRenderer implements BlockRendererExtension { + +// @Unique +// private boolean schematicaShadeMode_CU; +// +// public void setSchematicaShadeMode_CU(boolean value) { +// schematicaShadeMode_CU = value; +// } +// +// @ModifyArgument( +// method = "renderModel", +// at = @At(value = "INVOKE", target = "Lnet/caffeinemc/mods/sodium/client/services/PlatformModelEmitter;emitModel(Lnet/minecraft/client/renderer/block/model/BlockStateModel;Ljava/util/function/Predicate;Lnet/caffeinemc/mods/sodium/client/render/model/MutableQuadViewImpl;Lnet/minecraft/util/RandomSource;Lnet/minecraft/world/level/BlockAndTintGetter;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;Lnet/caffeinemc/mods/sodium/client/services/PlatformModelEmitter$Bufferer;)V")) +// private MutableQuadViewImpl onModifyBuffer(MutableQuadViewImpl quad) { +// if (schematicaShadeMode_CU) { +// quad.setColor(0, 0x80808080); +// quad.setColor(1, 0x80808080); +// quad.setColor(2, 0x80808080); +// quad.setColor(3, 0x80808080); +// } +// +// return quad; +// } +} \ No newline at end of file diff --git a/common/java/com/zergatul/cheatutils/mixins/common/sodium/MixinChunkBuilderMeshingTask.java b/common/java/com/zergatul/cheatutils/mixins/common/sodium/MixinChunkBuilderMeshingTask.java new file mode 100644 index 00000000..386cd424 --- /dev/null +++ b/common/java/com/zergatul/cheatutils/mixins/common/sodium/MixinChunkBuilderMeshingTask.java @@ -0,0 +1,46 @@ +package com.zergatul.cheatutils.mixins.common.sodium; + +import com.zergatul.cheatutils.extensions.BlockRendererExtension; +import com.zergatul.cheatutils.extensions.LevelSliceExtension; +import com.zergatul.mixin.LiteInject; +import com.zergatul.mixin.LocalVariable; +import net.caffeinemc.mods.sodium.client.render.chunk.compile.ChunkBuildOutput; +import net.caffeinemc.mods.sodium.client.render.chunk.compile.pipeline.BlockRenderer; +import net.caffeinemc.mods.sodium.client.render.chunk.compile.tasks.ChunkBuilderMeshingTask; +import net.caffeinemc.mods.sodium.client.render.chunk.compile.tasks.ChunkBuilderTask; +import net.caffeinemc.mods.sodium.client.world.LevelSlice; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; + +@Mixin(value = ChunkBuilderMeshingTask.class, remap = false) +public abstract class MixinChunkBuilderMeshingTask { + +// @LiteInject( +// method = "execute(Lnet/caffeinemc/mods/sodium/client/render/chunk/compile/ChunkBuildContext;Lnet/caffeinemc/mods/sodium/client/util/task/CancellationToken;)Lnet/caffeinemc/mods/sodium/client/render/chunk/compile/ChunkBuildOutput;", +// at = @At( +// value = "INVOKE", +// target = "Lnet/caffeinemc/mods/sodium/client/render/chunk/compile/pipeline/BlockRenderer;renderModel(Lnet/minecraft/client/renderer/block/model/BlockStateModel;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/core/BlockPos;Lnet/minecraft/core/BlockPos;)V", +// shift = At.Shift.BEFORE)) +// private void onBeforeCallRenderModel( +// @LocalVariable(ordinal = 0) LevelSlice slice, +// @LocalVariable(ordinal = 0) BlockRenderer blockRenderer, +// @LocalVariable(ordinal = 8) int x, +// @LocalVariable(ordinal = 6) int y, +// @LocalVariable(ordinal = 7) int z +// ) { +// if (((LevelSliceExtension) slice).hasSchematicaBlockAt_CU(x, y, z)) { +// ((BlockRendererExtension) blockRenderer).setSchematicaShadeMode_CU(true); +// } +// } +// +// @LiteInject( +// method = "execute(Lnet/caffeinemc/mods/sodium/client/render/chunk/compile/ChunkBuildContext;Lnet/caffeinemc/mods/sodium/client/util/task/CancellationToken;)Lnet/caffeinemc/mods/sodium/client/render/chunk/compile/ChunkBuildOutput;", +// at = @At( +// value = "INVOKE", +// target = "Lnet/caffeinemc/mods/sodium/client/render/chunk/compile/pipeline/BlockRenderer;renderModel(Lnet/minecraft/client/renderer/block/model/BlockStateModel;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/core/BlockPos;Lnet/minecraft/core/BlockPos;)V")) +// private void onAfterCallRenderModel( +// @LocalVariable(ordinal = 0) BlockRenderer blockRenderer +// ) { +// ((BlockRendererExtension) blockRenderer).setSchematicaShadeMode_CU(false); +// } +} \ No newline at end of file diff --git a/common/java/com/zergatul/cheatutils/mixins/common/sodium/MixinChunkRenderContext.java b/common/java/com/zergatul/cheatutils/mixins/common/sodium/MixinChunkRenderContext.java new file mode 100644 index 00000000..d46c7286 --- /dev/null +++ b/common/java/com/zergatul/cheatutils/mixins/common/sodium/MixinChunkRenderContext.java @@ -0,0 +1,22 @@ +package com.zergatul.cheatutils.mixins.common.sodium; + +import com.zergatul.cheatutils.extensions.ChunkRenderContextExtension; +import com.zergatul.cheatutils.schematics.SchematicaSectionCopy; +import net.caffeinemc.mods.sodium.client.world.cloned.ChunkRenderContext; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; + +@Mixin(value = ChunkRenderContext.class, remap = false) +public abstract class MixinChunkRenderContext implements ChunkRenderContextExtension { + + @Unique + private SchematicaSectionCopy[] schematicaSections_CU; + + public SchematicaSectionCopy[] getSchematicaSections_CU() { + return schematicaSections_CU; + } + + public void setSchematicaSections_CU(SchematicaSectionCopy[] sections) { + schematicaSections_CU = sections; + } +} \ No newline at end of file diff --git a/common/java/com/zergatul/cheatutils/mixins/common/sodium/MixinLevelSlice.java b/common/java/com/zergatul/cheatutils/mixins/common/sodium/MixinLevelSlice.java new file mode 100644 index 00000000..0a86eb0a --- /dev/null +++ b/common/java/com/zergatul/cheatutils/mixins/common/sodium/MixinLevelSlice.java @@ -0,0 +1,159 @@ +package com.zergatul.cheatutils.mixins.common.sodium; + +import com.zergatul.cheatutils.extensions.ChunkRenderContextExtension; +import com.zergatul.cheatutils.extensions.LevelSliceExtension; +import com.zergatul.cheatutils.modules.automation.Schematica; +import com.zergatul.cheatutils.schematics.SchematicaSectionCopy; +import com.zergatul.mixin.LocalVariable; +import com.zergatul.mixin.ModifyMethodReturnValue; +import net.caffeinemc.mods.sodium.client.world.LevelSlice; +import net.caffeinemc.mods.sodium.client.world.cloned.ChunkRenderContext; +import net.caffeinemc.mods.sodium.client.world.cloned.ClonedChunkSectionCache; +import net.minecraft.client.renderer.chunk.RenderSectionRegion; +import net.minecraft.core.SectionPos; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.levelgen.structure.BoundingBox; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(value = LevelSlice.class, remap = false) +public abstract class MixinLevelSlice implements LevelSliceExtension { + + @Shadow + public static int getLocalSectionIndex(int sectionX, int sectionY, int sectionZ) { + throw new AssertionError(); + } + + @Shadow + public static int getLocalBlockIndex(int blockX, int blockY, int blockZ) { + throw new AssertionError(); + } + + @Shadow + private BoundingBox volume; + + @Shadow + private BlockState[][] blockArrays; + + @Shadow + private int originBlockX; + + @Shadow + private int originBlockY; + + @Shadow + private int originBlockZ; + + @Unique + private SchematicaSectionCopy[] schematicaSections_CU; + + public boolean hasSchematicaBlockAt_CU(int x, int y, int z) { + if (this.schematicaSections_CU == null) { + return false; + } + + if (!this.volume.isInside(x, y, z)) { + return false; + } + + int relBlockX = x - this.originBlockX; + int relBlockY = y - this.originBlockY; + int relBlockZ = z - this.originBlockZ; + + //SchematicaSectionCopy section = this.schematicaSections_CU[getLocalSectionIndex(relBlockX >> 4, relBlockY >> 4, relBlockZ >> 4)]; + BlockState blockState = this.blockArrays + [getLocalSectionIndex(relBlockX >> 4, relBlockY >> 4, relBlockZ >> 4)] + [getLocalBlockIndex(x & 15, y & 15, z & 15)]; + return blockState.isAir(); + } + + @ModifyMethodReturnValue(method = "prepare", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/chunk/LevelChunkSection;hasOnlyAir()Z")) + private static boolean onModifyHasOnlyAir(boolean hasOnlyAir, @LocalVariable(ordinal = 0) SectionPos pos) { + if (!hasOnlyAir) { + return false; + } + + return !Schematica.instance.hasBlocksAtSection(pos.getX(), pos.getY(), pos.getZ()); + } + + @Inject(at = @At("RETURN"), method = "prepare") + private static void onModifyChunkRenderContext(Level level, SectionPos pos, ClonedChunkSectionCache cache, CallbackInfoReturnable info) { + if (info.getReturnValue() == null) { + return; + } + + Schematica schematica = Schematica.instance; + if (!schematica.isBlockRenderingEnabled()) { + return; + } + + int xs = pos.getX(); + int ys = pos.getY(); + int zs = pos.getZ(); + + int xs1 = xs - RenderSectionRegion.RADIUS; + int xs2 = xs + RenderSectionRegion.RADIUS; + int ys1 = ys - RenderSectionRegion.RADIUS; + int ys2 = ys + RenderSectionRegion.RADIUS; + int zs1 = zs - RenderSectionRegion.RADIUS; + int zs2 = zs + RenderSectionRegion.RADIUS; + + boolean hasSchematicaBlocks = false; + for (int x = xs1; x <= xs2; x++) { + for (int y = ys1; y <= ys2; y++) { + for (int z = zs1; z <= zs2; z++) { + if (schematica.hasBlocksAtSection(x, y, z)) { + hasSchematicaBlocks = true; + } + } + } + } + + if (!hasSchematicaBlocks) { + return; + } + + SchematicaSectionCopy[] sections = new SchematicaSectionCopy[27]; + for (int x = 0; x < 3; x++) { + for (int y = 0; y < 3; y++) { + for (int z = 0; z < 3; z++) { + // TODO: cache copies like Sodium does + sections[getLocalSectionIndex(x, y, z)] = schematica.createSectionCopy(SectionPos.asLong(xs1 + x, ys1 + y, zs1 + z)); + } + } + } + + ((ChunkRenderContextExtension) info.getReturnValue()).setSchematicaSections_CU(sections); + } + + @Inject(at = @At("TAIL"), method = "copyData") + private void onCopyData(ChunkRenderContext context, CallbackInfo info) { + this.schematicaSections_CU = ((ChunkRenderContextExtension) context).getSchematicaSections_CU(); + } + + @Inject( + at = @At("RETURN"), + method = "Lnet/caffeinemc/mods/sodium/client/world/LevelSlice;getBlockState(III)Lnet/minecraft/world/level/block/state/BlockState;", + cancellable = true) + private void onGetBlockState(int blockX, int blockY, int blockZ, CallbackInfoReturnable info) { + if (this.schematicaSections_CU == null) { + return; + } + + if (!info.getReturnValue().isAir()) { + return; + } + + int index = getLocalSectionIndex( + SectionPos.blockToSectionCoord(blockX - originBlockX), + SectionPos.blockToSectionCoord(blockY - originBlockY), + SectionPos.blockToSectionCoord(blockZ - originBlockZ)); + info.setReturnValue(this.schematicaSections_CU[index].getBlockState(blockX, blockY, blockZ)); + } +} \ No newline at end of file diff --git a/common/java/com/zergatul/cheatutils/modules/automation/AutoAttack.java b/common/java/com/zergatul/cheatutils/modules/automation/AutoAttack.java index 31355287..5e4e62a3 100644 --- a/common/java/com/zergatul/cheatutils/modules/automation/AutoAttack.java +++ b/common/java/com/zergatul/cheatutils/modules/automation/AutoAttack.java @@ -15,7 +15,6 @@ public class AutoAttack implements Module { public static final AutoAttack instance = new AutoAttack(); private final Minecraft mc = Minecraft.getInstance(); - private int nextExtraTicks = Integer.MIN_VALUE; private AutoAttack() { Events.ClientTickEnd.add(this::onClientTickEnd); @@ -43,26 +42,12 @@ private void onClientTickEnd() { return; } - calculateNextExtraTicksIfRequired(config); - - if (mc.player.getAttackStrengthScale(-nextExtraTicks) != 1) { - return; - } - - if (config.limitRange && mc.hitResult.getLocation().distanceToSqr(mc.player.getEyePosition()) > config.maxRange * config.maxRange) { + if (mc.player.getAttackStrengthScale((float) -config.extraTicks) != 1) { return; } - nextExtraTicks = Integer.MIN_VALUE; - Entity entity = ((EntityHitResult) mc.hitResult).getEntity(); mc.gameMode.attack(mc.player, entity); mc.player.swing(InteractionHand.MAIN_HAND); } - - private void calculateNextExtraTicksIfRequired(AutoAttackConfig config) { - if (nextExtraTicks == Integer.MIN_VALUE) { - nextExtraTicks = config.extraTicksMin + (int) Math.floor(Math.random() * (config.extraTicksMax - config.extraTicksMin + 1)); - } - } } \ No newline at end of file diff --git a/common/java/com/zergatul/cheatutils/modules/esp/EntityTitle.java b/common/java/com/zergatul/cheatutils/modules/esp/EntityTitle.java index f29e1539..d6335037 100644 --- a/common/java/com/zergatul/cheatutils/modules/esp/EntityTitle.java +++ b/common/java/com/zergatul/cheatutils/modules/esp/EntityTitle.java @@ -463,7 +463,6 @@ private static class EnchantmentEntry { Map.entry(Enchantments.DENSITY.identifier(), new EnchantmentDisplayEntry("Dn")), Map.entry(Enchantments.BREACH.identifier(), new EnchantmentDisplayEntry("Br")), Map.entry(Enchantments.WIND_BURST.identifier(), new EnchantmentDisplayEntry("Wi")), - Map.entry(Enchantments.LUNGE.identifier(), new EnchantmentDisplayEntry("Lu")), Map.entry(Enchantments.SILK_TOUCH.identifier(), new EnchantmentDisplayEntry("Si")), Map.entry(Enchantments.FORTUNE.identifier(), new EnchantmentDisplayEntry("Fo")), diff --git a/common/java/com/zergatul/cheatutils/schematics/ShadedVertexConsumerWrapper.java b/common/java/com/zergatul/cheatutils/schematics/ShadedVertexConsumerWrapper.java index a2d4715c..cb06dfc9 100644 --- a/common/java/com/zergatul/cheatutils/schematics/ShadedVertexConsumerWrapper.java +++ b/common/java/com/zergatul/cheatutils/schematics/ShadedVertexConsumerWrapper.java @@ -11,10 +11,6 @@ public class ShadedVertexConsumerWrapper implements VertexConsumer { private final float shadeB; private final float shadeA; - public ShadedVertexConsumerWrapper(VertexConsumer inner) { - this(inner, 0.5f, 0.8f, 1.0f, 0.6f); - } - public ShadedVertexConsumerWrapper(VertexConsumer inner, float r, float g, float b, float a) { this.inner = inner; this.shadeR = r; diff --git a/common/java/com/zergatul/cheatutils/schematics/WrapperRenderSectionRegion.java b/common/java/com/zergatul/cheatutils/schematics/WrapperRenderSectionRegion.java deleted file mode 100644 index 1e665c99..00000000 --- a/common/java/com/zergatul/cheatutils/schematics/WrapperRenderSectionRegion.java +++ /dev/null @@ -1,95 +0,0 @@ -package com.zergatul.cheatutils.schematics; - -import net.minecraft.client.renderer.chunk.RenderSectionRegion; -import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; -import net.minecraft.core.SectionPos; -import net.minecraft.world.level.BlockAndTintGetter; -import net.minecraft.world.level.ColorResolver; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.entity.BlockEntity; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.lighting.LevelLightEngine; -import net.minecraft.world.level.material.FluidState; -import org.jspecify.annotations.NullMarked; -import org.jspecify.annotations.Nullable; - -@NullMarked -public class WrapperRenderSectionRegion implements BlockAndTintGetter { - - private final Level level; - private final BlockAndTintGetter inner; - private final SchematicaSectionCopy[] schematicaSections; - private final int minSectionX; - private final int minSectionY; - private final int minSectionZ; - - public WrapperRenderSectionRegion( - Level level, - BlockAndTintGetter inner, - SchematicaSectionCopy[] schematicaSections, - int minSectionX, - int minSectionY, - int minSectionZ - ) { - this.level = level; - this.inner = inner; - this.schematicaSections = schematicaSections; - this.minSectionX = minSectionX; - this.minSectionY = minSectionY; - this.minSectionZ = minSectionZ; - } - - @Override - public float getShade(Direction direction, boolean p_45523_) { - return level.getShade(direction, p_45523_); - } - - @Override - public LevelLightEngine getLightEngine() { - return inner.getLightEngine(); - } - - @Override - public int getBlockTint(BlockPos pos, ColorResolver resolver) { - return level.getBlockTint(pos, resolver); - } - - @Override - public @Nullable BlockEntity getBlockEntity(BlockPos pos) { - return null; - } - - @Override - public BlockState getBlockState(BlockPos pos) { - BlockState state = inner.getBlockState(pos); - if (!state.isAir()) { - return state; - } - - int x = pos.getX(); - int y = pos.getY(); - int z = pos.getZ(); - int xs = SectionPos.blockToSectionCoord(x); - int ys = SectionPos.blockToSectionCoord(y); - int zs = SectionPos.blockToSectionCoord(z); - - int index = RenderSectionRegion.index(minSectionX, minSectionY, minSectionZ, xs, ys, zs); - return schematicaSections[index].getBlockState(x, y, z); - } - - @Override - public FluidState getFluidState(BlockPos pos) { - return getBlockState(pos).getFluidState(); - } - - @Override - public int getHeight() { - throw new IllegalStateException(); - } - - @Override - public int getMinY() { - throw new IllegalStateException(); - } -} \ No newline at end of file diff --git a/common/java/com/zergatul/cheatutils/scripting/Root.java b/common/java/com/zergatul/cheatutils/scripting/Root.java index 951269fe..bf8fc902 100644 --- a/common/java/com/zergatul/cheatutils/scripting/Root.java +++ b/common/java/com/zergatul/cheatutils/scripting/Root.java @@ -15,7 +15,6 @@ public class Root { public static AutoBucketApi autoBucket = new AutoBucketApi(); public static AutoHotbarApi autoHotbar = new AutoHotbarApi(); public static AutoToolApi autoTool = new AutoToolApi(); - public static AutoAttackApi autoAttack = new AutoAttackApi(); // ESP public static BlocksApi blocks = new BlocksApi(); diff --git a/common/java/com/zergatul/cheatutils/scripting/modules/AutoAttackApi.java b/common/java/com/zergatul/cheatutils/scripting/modules/AutoAttackApi.java deleted file mode 100644 index 87a818bc..00000000 --- a/common/java/com/zergatul/cheatutils/scripting/modules/AutoAttackApi.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.zergatul.cheatutils.scripting.modules; - -import com.zergatul.cheatutils.configs.AutoAttackConfig; -import com.zergatul.cheatutils.configs.ConfigStore; - -public class AutoAttackApi extends ModuleApi { - - @Override - protected AutoAttackConfig getConfig() { - return ConfigStore.instance.getConfig().autoAttackConfig; - } -} diff --git a/common/java/com/zergatul/cheatutils/scripting/monaco/MonacoSuggestionFactory.java b/common/java/com/zergatul/cheatutils/scripting/monaco/MonacoSuggestionFactory.java index 68a31d4a..3f3ae2bf 100644 --- a/common/java/com/zergatul/cheatutils/scripting/monaco/MonacoSuggestionFactory.java +++ b/common/java/com/zergatul/cheatutils/scripting/monaco/MonacoSuggestionFactory.java @@ -18,7 +18,6 @@ public MonacoSuggestionFactory(DocumentationProvider provider) { @Override public Suggestion getKeywordSuggestion(TokenType type) { String text = switch (type) { - case META_CAST -> "#cast"; case META_TYPE -> "#type"; case META_TYPE_OF -> "#typeof"; default -> type.toString().toLowerCase(); @@ -63,7 +62,7 @@ public List getTypeSuggestion(SType type) { "int64", CompletionItemKind.CLASS)); } - if (type.isPredefined()) { + if (type instanceof SPredefinedType) { return List.of(new Suggestion( type.toString(), null, diff --git a/common/java/net/caffeinemc/mods/sodium/client/render/chunk/RenderSection.java b/common/java/net/caffeinemc/mods/sodium/client/render/chunk/RenderSection.java new file mode 100644 index 00000000..4239ae3d --- /dev/null +++ b/common/java/net/caffeinemc/mods/sodium/client/render/chunk/RenderSection.java @@ -0,0 +1,16 @@ +package net.caffeinemc.mods.sodium.client.render.chunk; + +public class RenderSection { + + public int getChunkX() { + return 0; + } + + public int getChunkY() { + return 0; + } + + public int getChunkZ() { + return 0; + } +} \ No newline at end of file diff --git a/common/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/BuilderTaskOutput.java b/common/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/BuilderTaskOutput.java new file mode 100644 index 00000000..ddea6274 --- /dev/null +++ b/common/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/BuilderTaskOutput.java @@ -0,0 +1,11 @@ +package net.caffeinemc.mods.sodium.client.render.chunk.compile; + +import net.caffeinemc.mods.sodium.client.render.chunk.RenderSection; + +public abstract class BuilderTaskOutput { + public final RenderSection render; + + public BuilderTaskOutput() { + this.render = new RenderSection(); + } +} \ No newline at end of file diff --git a/common/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/ChunkBuildContext.java b/common/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/ChunkBuildContext.java new file mode 100644 index 00000000..074a8d6c --- /dev/null +++ b/common/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/ChunkBuildContext.java @@ -0,0 +1,7 @@ +package net.caffeinemc.mods.sodium.client.render.chunk.compile; + +import net.caffeinemc.mods.sodium.client.render.chunk.compile.pipeline.BlockRenderCache; + +public class ChunkBuildContext { + public BlockRenderCache cache; +} \ No newline at end of file diff --git a/common/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/ChunkBuildOutput.java b/common/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/ChunkBuildOutput.java new file mode 100644 index 00000000..4c90b53c --- /dev/null +++ b/common/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/ChunkBuildOutput.java @@ -0,0 +1,3 @@ +package net.caffeinemc.mods.sodium.client.render.chunk.compile; + +public class ChunkBuildOutput extends ChunkSortOutput {} \ No newline at end of file diff --git a/common/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/ChunkSortOutput.java b/common/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/ChunkSortOutput.java new file mode 100644 index 00000000..0a7d7439 --- /dev/null +++ b/common/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/ChunkSortOutput.java @@ -0,0 +1,3 @@ +package net.caffeinemc.mods.sodium.client.render.chunk.compile; + +public class ChunkSortOutput extends BuilderTaskOutput {} \ No newline at end of file diff --git a/common/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/pipeline/BlockRenderCache.java b/common/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/pipeline/BlockRenderCache.java new file mode 100644 index 00000000..c68d079d --- /dev/null +++ b/common/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/pipeline/BlockRenderCache.java @@ -0,0 +1,7 @@ +package net.caffeinemc.mods.sodium.client.render.chunk.compile.pipeline; + +public class BlockRenderCache { + public BlockRenderer getBlockRenderer() { + throw new AssertionError(); + } +} \ No newline at end of file diff --git a/common/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/pipeline/BlockRenderer.java b/common/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/pipeline/BlockRenderer.java new file mode 100644 index 00000000..462a584b --- /dev/null +++ b/common/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/pipeline/BlockRenderer.java @@ -0,0 +1,21 @@ +package net.caffeinemc.mods.sodium.client.render.chunk.compile.pipeline; + +import net.caffeinemc.mods.sodium.client.render.model.MutableQuadViewImpl; +import net.caffeinemc.mods.sodium.client.services.PlatformModelEmitter; +import net.minecraft.client.renderer.block.model.BlockModelPart; +import net.minecraft.client.renderer.block.model.BlockStateModel; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.state.BlockState; + +import java.util.function.Consumer; +import java.util.function.Predicate; + +public class BlockRenderer { + + public void renderModel(BlockStateModel model, BlockState state, BlockPos pos, BlockPos origin) { + PlatformModelEmitter.getInstance().emitModel(model, null, null, null, null, pos, state, this::bufferDefaultModel); + } + + public void bufferDefaultModel(BlockModelPart part, Predicate cullTest, Consumer emitter) {} +} \ No newline at end of file diff --git a/common/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/tasks/ChunkBuilderMeshingTask.java b/common/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/tasks/ChunkBuilderMeshingTask.java new file mode 100644 index 00000000..9a500f23 --- /dev/null +++ b/common/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/tasks/ChunkBuilderMeshingTask.java @@ -0,0 +1,38 @@ +package net.caffeinemc.mods.sodium.client.render.chunk.compile.tasks; + +import net.caffeinemc.mods.sodium.client.render.chunk.compile.ChunkBuildContext; +import net.caffeinemc.mods.sodium.client.render.chunk.compile.ChunkBuildOutput; +import net.caffeinemc.mods.sodium.client.render.chunk.compile.pipeline.BlockRenderer; +import net.caffeinemc.mods.sodium.client.util.task.CancellationToken; +import net.caffeinemc.mods.sodium.client.world.LevelSlice; +import net.minecraft.world.level.block.state.BlockState; + +public class ChunkBuilderMeshingTask extends ChunkBuilderTask { + + @Override + public ChunkBuildOutput execute(ChunkBuildContext buildContext, CancellationToken cancellationToken) { + LevelSlice slice = new LevelSlice(); + + int minX = 0; + int minY = 0; + int minZ = 0; + + int maxX = minX + 16; + int maxY = minY + 16; + int maxZ = minZ + 16; + + BlockRenderer blockRenderer = buildContext.cache.getBlockRenderer(); + + for (int y = minY; y < maxY; y++) { + for (int z = minZ; z < maxZ; z++) { + for (int x = minX; x < maxX; x++) { + BlockState blockState = slice.getBlockState(x, y, z); + blockRenderer.renderModel(null, blockState, null, null); + throw new AssertionError(); + } + } + } + + throw new AssertionError(); + } +} \ No newline at end of file diff --git a/common/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/tasks/ChunkBuilderTask.java b/common/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/tasks/ChunkBuilderTask.java new file mode 100644 index 00000000..1994c3dc --- /dev/null +++ b/common/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/tasks/ChunkBuilderTask.java @@ -0,0 +1,17 @@ +package net.caffeinemc.mods.sodium.client.render.chunk.compile.tasks; + +import net.caffeinemc.mods.sodium.client.render.chunk.RenderSection; +import net.caffeinemc.mods.sodium.client.render.chunk.compile.BuilderTaskOutput; +import net.caffeinemc.mods.sodium.client.render.chunk.compile.ChunkBuildContext; +import net.caffeinemc.mods.sodium.client.util.task.CancellationToken; + +public abstract class ChunkBuilderTask { + + protected final RenderSection render; + + protected ChunkBuilderTask() { + this.render = new RenderSection(); + } + + public abstract OUTPUT execute(ChunkBuildContext context, CancellationToken cancellationToken); +} \ No newline at end of file diff --git a/common/java/net/caffeinemc/mods/sodium/client/render/model/MutableQuadViewImpl.java b/common/java/net/caffeinemc/mods/sodium/client/render/model/MutableQuadViewImpl.java new file mode 100644 index 00000000..8e10f7f7 --- /dev/null +++ b/common/java/net/caffeinemc/mods/sodium/client/render/model/MutableQuadViewImpl.java @@ -0,0 +1,7 @@ +package net.caffeinemc.mods.sodium.client.render.model; + +public class MutableQuadViewImpl { + public MutableQuadViewImpl setColor(int vertexIndex, int color) { + return this; + } +} \ No newline at end of file diff --git a/common/java/net/caffeinemc/mods/sodium/client/services/PlatformModelEmitter.java b/common/java/net/caffeinemc/mods/sodium/client/services/PlatformModelEmitter.java new file mode 100644 index 00000000..6aebb9ae --- /dev/null +++ b/common/java/net/caffeinemc/mods/sodium/client/services/PlatformModelEmitter.java @@ -0,0 +1,27 @@ +package net.caffeinemc.mods.sodium.client.services; + +import net.caffeinemc.mods.sodium.client.render.model.MutableQuadViewImpl; +import net.minecraft.client.renderer.block.model.BlockModelPart; +import net.minecraft.client.renderer.block.model.BlockStateModel; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.util.RandomSource; +import net.minecraft.world.level.BlockAndTintGetter; +import net.minecraft.world.level.block.state.BlockState; + +import java.util.function.Consumer; +import java.util.function.Predicate; + +public interface PlatformModelEmitter { + + static PlatformModelEmitter getInstance() { + throw new AssertionError(); + } + + void emitModel(BlockStateModel model, Predicate cullTest, MutableQuadViewImpl quad, RandomSource random, BlockAndTintGetter blockView, BlockPos pos, BlockState state, Bufferer defaultBuffer); + + @FunctionalInterface + interface Bufferer { + void emit(BlockModelPart part, Predicate cullTest, Consumer emitter); + } +} \ No newline at end of file diff --git a/common/java/net/caffeinemc/mods/sodium/client/util/task/CancellationToken.java b/common/java/net/caffeinemc/mods/sodium/client/util/task/CancellationToken.java new file mode 100644 index 00000000..6afb43ac --- /dev/null +++ b/common/java/net/caffeinemc/mods/sodium/client/util/task/CancellationToken.java @@ -0,0 +1,3 @@ +package net.caffeinemc.mods.sodium.client.util.task; + +public interface CancellationToken {} \ No newline at end of file diff --git a/common/java/net/caffeinemc/mods/sodium/client/world/LevelSlice.java b/common/java/net/caffeinemc/mods/sodium/client/world/LevelSlice.java new file mode 100644 index 00000000..d0ad0dc0 --- /dev/null +++ b/common/java/net/caffeinemc/mods/sodium/client/world/LevelSlice.java @@ -0,0 +1,47 @@ +package net.caffeinemc.mods.sodium.client.world; + +import net.caffeinemc.mods.sodium.client.world.cloned.ChunkRenderContext; +import net.caffeinemc.mods.sodium.client.world.cloned.ClonedChunkSectionCache; +import net.minecraft.core.BlockPos; +import net.minecraft.core.SectionPos; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.chunk.LevelChunk; +import net.minecraft.world.level.chunk.LevelChunkSection; +import net.minecraft.world.level.levelgen.structure.BoundingBox; + +public class LevelSlice { + + private BoundingBox volume; + private BlockState[][] blockArrays; + private int originBlockX, originBlockY, originBlockZ; + + public static ChunkRenderContext prepare(Level level, SectionPos pos, ClonedChunkSectionCache cache) { + LevelChunk chunk = level.getChunk(pos.getX(), pos.getZ()); + LevelChunkSection section = chunk.getSections()[level.getSectionIndexFromSectionY(pos.getY())]; + if (section == null || section.hasOnlyAir()) { + return null; + } + throw new AssertionError(); + } + + public BlockState getBlockState(BlockPos pos) { + throw new AssertionError(); + } + + public BlockState getBlockState(int blockX, int blockY, int blockZ) { + throw new AssertionError(); + } + + public void copyData(ChunkRenderContext context) { + throw new AssertionError(); + } + + public static int getLocalSectionIndex(int sectionX, int sectionY, int sectionZ) { + throw new AssertionError(); + } + + public static int getLocalBlockIndex(int blockX, int blockY, int blockZ) { + throw new AssertionError(); + } +} \ No newline at end of file diff --git a/common/java/net/caffeinemc/mods/sodium/client/world/cloned/ChunkRenderContext.java b/common/java/net/caffeinemc/mods/sodium/client/world/cloned/ChunkRenderContext.java new file mode 100644 index 00000000..27ce02be --- /dev/null +++ b/common/java/net/caffeinemc/mods/sodium/client/world/cloned/ChunkRenderContext.java @@ -0,0 +1,16 @@ +package net.caffeinemc.mods.sodium.client.world.cloned; + +import net.minecraft.core.SectionPos; + +public class ChunkRenderContext { + + private final SectionPos origin; + + public ChunkRenderContext() { + throw new AssertionError(); + } + + public SectionPos getOrigin() { + return this.origin; + } +} \ No newline at end of file diff --git a/common/java/net/caffeinemc/mods/sodium/client/world/cloned/ClonedChunkSectionCache.java b/common/java/net/caffeinemc/mods/sodium/client/world/cloned/ClonedChunkSectionCache.java new file mode 100644 index 00000000..4a5f2f3c --- /dev/null +++ b/common/java/net/caffeinemc/mods/sodium/client/world/cloned/ClonedChunkSectionCache.java @@ -0,0 +1,3 @@ +package net.caffeinemc.mods.sodium.client.world.cloned; + +public class ClonedChunkSectionCache {} \ No newline at end of file diff --git a/common/resources/cheatutils.common.mixins.json b/common/resources/cheatutils.common.mixins.json index b865c695..f432198d 100644 --- a/common/resources/cheatutils.common.mixins.json +++ b/common/resources/cheatutils.common.mixins.json @@ -48,7 +48,6 @@ "common.MixinCamera", "common.MixinChatComponent", "common.MixinChatScreen", - "common.MixinChunkBorderRenderer", "common.MixinClientboundDisconnectPacket", "common.MixinClientboundPlayerInfoRemovePacket", "common.MixinClientboundPlayerInfoUpdatePacket", diff --git a/common/resources/cheatutils.sodium.mixins.json b/common/resources/cheatutils.sodium.mixins.json new file mode 100644 index 00000000..ed67a87b --- /dev/null +++ b/common/resources/cheatutils.sodium.mixins.json @@ -0,0 +1,17 @@ +{ + "required": false, + "minVersion": "0.8.2", + "package": "com.zergatul.cheatutils.mixins", + "compatibilityLevel": "JAVA_21", + "plugin": "com.zergatul.cheatutils.compatibility.SodiumMixinPlugin", + "injectors": { + "defaultRequire": 0 + }, + "mixinPriority": 500, + "client": [ + "common.sodium.MixinBlockRenderer", + "common.sodium.MixinChunkBuilderMeshingTask", + "common.sodium.MixinChunkRenderContext", + "common.sodium.MixinLevelSlice" + ] +} \ No newline at end of file diff --git a/common/resources/web/components/HoldKeyConfig.html b/common/resources/web/components/HoldKeyConfig.html new file mode 100644 index 00000000..e321edc4 --- /dev/null +++ b/common/resources/web/components/HoldKeyConfig.html @@ -0,0 +1,35 @@ +
+
+ +
+
+ Hold Key +
+ Emulate holding keys. +
+
+ +
+
+ +
+
+ +
+
+
\ No newline at end of file diff --git a/common/resources/web/components/HoldKeyConfig.js b/common/resources/web/components/HoldKeyConfig.js new file mode 100644 index 00000000..bd2fb715 --- /dev/null +++ b/common/resources/web/components/HoldKeyConfig.js @@ -0,0 +1,7 @@ +import { createSimpleComponent } from './SimpleModule.js'; + +function createComponent(template) { + return createSimpleComponent('/api/hold-key', template); +} + +export { createComponent } \ No newline at end of file diff --git a/common/resources/web/components/automation/AutoAttack.html b/common/resources/web/components/automation/AutoAttack.html index f608816e..57153b0b 100644 --- a/common/resources/web/components/automation/AutoAttack.html +++ b/common/resources/web/components/automation/AutoAttack.html @@ -8,46 +8,12 @@
Enabled
- -
- - Limit Range - -
- Max Range: - -
-
- Don't auto attack if target is further than specified distance. May help with some anticheats. +
+ Extra Ticks: + +
+ Wait additional ticks once cooldown passed. Can be negative, in this case module will attack before cooldown.
-
- -
- - Extra Delay - - - - - - - - - - -
- Extra Ticks Min: - - -
- Extra Ticks Max: - - -
-
- Wait additional random ticks amount in [min..max] range once cooldown passed. - Values can be negative, in this case module will attack before cooldown. -
-
+ \ No newline at end of file diff --git a/common/resources/web/components/automation/Schematica.html b/common/resources/web/components/automation/Schematica.html index 0e1e443a..c1a57e3b 100644 --- a/common/resources/web/components/automation/Schematica.html +++ b/common/resources/web/components/automation/Schematica.html @@ -64,7 +64,7 @@
Render Blocks feature doesn't work with Sodium. All questions to Sodium devs. - They made it extremely hard to render custom blocks. + They stopped caring about compatibility.
diff --git a/fabric/build.gradle b/fabric/build.gradle index b156639f..12f35394 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -40,7 +40,7 @@ dependencies { modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" // Fabric API. This is technically optional, but you probably want it anyway. - modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}" + modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" // Uncomment the following line to enable the deprecated Fabric API modules. // These are included in the Fabric API production distribution and allow you to update your mod to the latest modules at a later more convenient time. @@ -50,6 +50,9 @@ dependencies { annotationProcessor files('../mixin-plugin/annotation-processor/build/libs/annotation-processor.jar') compileOnly("org.jspecify:jspecify:1.0.0") + + // to run with Sodium + //modRuntimeOnly(files("C:/Users/Zergatul/source/repos/sodium/build/mods/sodium-fabric-0.7.3-snapshot+mc1.21.10-local.jar")) } sourceSets { diff --git a/fabric/gradle.properties b/fabric/gradle.properties index 8982c68e..cd0ea7ec 100644 --- a/fabric/gradle.properties +++ b/fabric/gradle.properties @@ -13,4 +13,4 @@ maven_group = com.zergatul.cheatutils archives_base_name = cheatutils # Dependencies -fabric_api_version=0.140.2+1.21.11 \ No newline at end of file +fabric_version=0.139.4+1.21.11 \ No newline at end of file diff --git a/fabric/src/main/java/com/zergatul/cheatutils/mixins/fabric/schematica/MixinSectionCompiler.java b/fabric/src/main/java/com/zergatul/cheatutils/mixins/fabric/schematica/MixinSectionCompiler.java index 59b9af60..a3773507 100644 --- a/fabric/src/main/java/com/zergatul/cheatutils/mixins/fabric/schematica/MixinSectionCompiler.java +++ b/fabric/src/main/java/com/zergatul/cheatutils/mixins/fabric/schematica/MixinSectionCompiler.java @@ -1,106 +1,29 @@ package com.zergatul.cheatutils.mixins.fabric.schematica; -import com.llamalad7.mixinextras.sugar.Local; -import com.mojang.blaze3d.vertex.BufferBuilder; -import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; -import com.mojang.blaze3d.vertex.VertexSorting; import com.zergatul.cheatutils.extensions.RenderSectionRegionExtension; import com.zergatul.cheatutils.schematics.ShadedVertexConsumerWrapper; -import it.unimi.dsi.fastutil.objects.ObjectArrayList; -import net.minecraft.client.renderer.ItemBlockRenderTypes; -import net.minecraft.client.renderer.SectionBufferBuilderPack; -import net.minecraft.client.renderer.block.BlockRenderDispatcher; -import net.minecraft.client.renderer.block.model.BlockModelPart; -import net.minecraft.client.renderer.chunk.ChunkSectionLayer; +import com.zergatul.mixin.LocalVariable; +import com.zergatul.mixin.ModifyArgument; import net.minecraft.client.renderer.chunk.RenderSectionRegion; import net.minecraft.client.renderer.chunk.SectionCompiler; import net.minecraft.core.BlockPos; -import net.minecraft.core.SectionPos; -import net.minecraft.util.RandomSource; -import net.minecraft.world.level.BlockAndTintGetter; -import net.minecraft.world.level.block.RenderShape; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.material.FluidState; -import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -import java.util.List; -import java.util.Map; @Mixin(SectionCompiler.class) public abstract class MixinSectionCompiler { - @Shadow - @Final - private BlockRenderDispatcher blockRenderer; - - @Shadow - protected abstract BufferBuilder getOrBeginLayer(Map map, SectionBufferBuilderPack pack, ChunkSectionLayer layer); - - @Inject( + @ModifyArgument( method = "compile", - at = @At(value = "INVOKE", target = "Ljava/util/Map;entrySet()Ljava/util/Set;")) - private void onBeforeSorting( - SectionPos sectionPos, - RenderSectionRegion region, - VertexSorting sorting, - SectionBufferBuilderPack pack, - CallbackInfoReturnable info, - @Local(ordinal = 0) Map map, - @Local(ordinal = 0) PoseStack poseStack + at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/block/BlockRenderDispatcher;renderBatched(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/BlockAndTintGetter;Lcom/mojang/blaze3d/vertex/PoseStack;Lcom/mojang/blaze3d/vertex/VertexConsumer;ZLjava/util/List;)V")) + private VertexConsumer onModifyVertexConsumer( + VertexConsumer consumer, + @LocalVariable(ordinal = 0) RenderSectionRegion region, + @LocalVariable(ordinal = 2) BlockPos pos ) { - RenderSectionRegionExtension extension = (RenderSectionRegionExtension) region; - if (!extension.hasSchematicaBlocks_CU()) { - return; - } - - boolean shaded = extension.shadeSchematicaBlocks_CU(); - RandomSource random = RandomSource.create(); - List list = new ObjectArrayList<>(); - BlockAndTintGetter wrapped = extension.asWrapped_CU(); - - BlockPos corner1 = sectionPos.origin(); - BlockPos corner2 = corner1.offset(15, 15, 15); - for (BlockPos pos : BlockPos.betweenClosed(corner1, corner2)) { - if (!region.getBlockState(pos).isAir()) { - continue; - } - - BlockState state = wrapped.getBlockState(pos); - if (state.isAir()) { - continue; - } - - FluidState fluidState = state.getFluidState(); - if (!fluidState.isEmpty()) { - ChunkSectionLayer layer = ItemBlockRenderTypes.getRenderLayer(fluidState); - this.blockRenderer.renderLiquid(pos, wrapped, getOrBeginLayer_CU(map, pack, layer, shaded), state, fluidState); - } - - if (state.getRenderShape() == RenderShape.MODEL) { - ChunkSectionLayer layer = ItemBlockRenderTypes.getChunkRenderType(state); - random.setSeed(state.getSeed(pos)); - this.blockRenderer.getBlockModel(state).collectParts(random, list); - poseStack.pushPose(); - poseStack.translate(pos.getX() & 0xF, pos.getY() & 0xF, pos.getZ() & 0xF); - this.blockRenderer.renderBatched(state, pos, wrapped, poseStack, getOrBeginLayer_CU(map, pack, layer, shaded), true, list); - poseStack.popPose(); - list.clear(); - } - } - } - - @Unique - private VertexConsumer getOrBeginLayer_CU(Map map, SectionBufferBuilderPack pack, ChunkSectionLayer layer, boolean shaded) { - VertexConsumer consumer = this.getOrBeginLayer(map, pack, layer); - if (shaded) { - return new ShadedVertexConsumerWrapper(consumer); + if (((RenderSectionRegionExtension) region).hasSchematicaBlockAt_CU(pos)) { + return new ShadedVertexConsumerWrapper(consumer, 0.5f, 0.8f, 1.0f, 0.6f); } else { return consumer; } diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index ccdb4b49..9fa7ac23 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -26,6 +26,7 @@ "accessWidener": "cheatutils.classtweaker", "mixins": [ "cheatutils.common.mixins.json", + "cheatutils.sodium.mixins.json", "cheatutils.iris.mixins.json", "cheatutils.fnf.mixins.json", "cheatutils.fabric.mixins.json" diff --git a/forge/src/main/java/com/zergatul/cheatutils/mixins/forge/schematica/MixinSectionCompiler.java b/forge/src/main/java/com/zergatul/cheatutils/mixins/forge/schematica/MixinSectionCompiler.java index ec38e8e8..3819946a 100644 --- a/forge/src/main/java/com/zergatul/cheatutils/mixins/forge/schematica/MixinSectionCompiler.java +++ b/forge/src/main/java/com/zergatul/cheatutils/mixins/forge/schematica/MixinSectionCompiler.java @@ -1,116 +1,29 @@ package com.zergatul.cheatutils.mixins.forge.schematica; -import com.llamalad7.mixinextras.sugar.Local; -import com.mojang.blaze3d.vertex.BufferBuilder; -import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; -import com.mojang.blaze3d.vertex.VertexSorting; import com.zergatul.cheatutils.extensions.RenderSectionRegionExtension; import com.zergatul.cheatutils.schematics.ShadedVertexConsumerWrapper; -import it.unimi.dsi.fastutil.objects.ObjectArrayList; -import net.minecraft.client.multiplayer.ClientLevel; -import net.minecraft.client.renderer.ItemBlockRenderTypes; -import net.minecraft.client.renderer.SectionBufferBuilderPack; -import net.minecraft.client.renderer.block.BlockRenderDispatcher; -import net.minecraft.client.renderer.block.model.BlockModelPart; -import net.minecraft.client.renderer.block.model.BlockStateModel; -import net.minecraft.client.renderer.chunk.ChunkSectionLayer; +import com.zergatul.mixin.LocalVariable; +import com.zergatul.mixin.ModifyArgument; import net.minecraft.client.renderer.chunk.RenderSectionRegion; import net.minecraft.client.renderer.chunk.SectionCompiler; import net.minecraft.core.BlockPos; -import net.minecraft.core.SectionPos; -import net.minecraft.util.RandomSource; -import net.minecraft.world.level.BlockAndTintGetter; -import net.minecraft.world.level.block.RenderShape; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.material.FluidState; -import net.minecraftforge.client.model.data.ModelData; -import org.spongepowered.asm.mixin.*; +import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -import java.util.List; -import java.util.Map; @Mixin(SectionCompiler.class) public abstract class MixinSectionCompiler { - @Shadow - @Final - private BlockRenderDispatcher blockRenderer; - - @Shadow - protected abstract BufferBuilder getOrBeginLayer(Map map, SectionBufferBuilderPack pack, ChunkSectionLayer layer); - - @Inject( + @ModifyArgument( method = "compile", - at = @At(value = "INVOKE", target = "Ljava/util/Map;entrySet()Ljava/util/Set;")) - private void onBeforeSorting( - SectionPos sectionPos, - RenderSectionRegion region, - VertexSorting sorting, - SectionBufferBuilderPack pack, - CallbackInfoReturnable info, - @Local(ordinal = 1) Map map, - @Local(ordinal = 0) PoseStack poseStack + at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/block/BlockRenderDispatcher;renderBatched(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/BlockAndTintGetter;Lcom/mojang/blaze3d/vertex/PoseStack;Lcom/mojang/blaze3d/vertex/VertexConsumer;ZLjava/util/List;)V")) + private VertexConsumer onModifyVertexConsumer( + VertexConsumer consumer, + @LocalVariable(ordinal = 0) RenderSectionRegion region, + @LocalVariable(ordinal = 2) BlockPos pos ) { - RenderSectionRegionExtension extension = (RenderSectionRegionExtension) region; - if (!extension.hasSchematicaBlocks_CU()) { - return; - } - - ClientLevel level = net.minecraft.client.Minecraft.getInstance().level; - assert level != null; - Map modelDataMap = level.getModelDataManager().getAt(sectionPos); - - boolean shaded = extension.shadeSchematicaBlocks_CU(); - RandomSource random = RandomSource.create(); - List list = new ObjectArrayList<>(); - BlockAndTintGetter wrapped = extension.asWrapped_CU(); - - BlockPos corner1 = sectionPos.origin(); - BlockPos corner2 = corner1.offset(15, 15, 15); - for (BlockPos pos : BlockPos.betweenClosed(corner1, corner2)) { - if (!region.getBlockState(pos).isAir()) { - continue; - } - - BlockState state = wrapped.getBlockState(pos); - if (state.isAir()) { - continue; - } - - FluidState fluidState = state.getFluidState(); - if (!fluidState.isEmpty()) { - ChunkSectionLayer layer = ItemBlockRenderTypes.getRenderLayer(fluidState); - this.blockRenderer.renderLiquid(pos, wrapped, getOrBeginLayer_CU(map, pack, layer, shaded), state, fluidState); - } - - if (state.getRenderShape() == RenderShape.MODEL) { - BlockStateModel model = this.blockRenderer.getBlockModel(state); - ModelData data = modelDataMap.getOrDefault(pos, net.minecraftforge.client.model.data.ModelData.EMPTY); - data = model.getModelData(wrapped, pos, state, data); - random.setSeed(state.getSeed(pos)); - for (ChunkSectionLayer layer : model.getRenderTypes(state, random, data)) { - VertexConsumer consumer = this.getOrBeginLayer_CU(map, pack, layer, shaded); - random.setSeed(state.getSeed(pos)); - model.collectParts(random, list, data, layer); - poseStack.pushPose(); - poseStack.translate(pos.getX() & 0xF, pos.getY() & 0xF, pos.getZ() & 0xF); - this.blockRenderer.renderBatched(state, pos, wrapped, poseStack, consumer, true, list); - poseStack.popPose(); - list.clear(); - } - } - } - } - - @Unique - private VertexConsumer getOrBeginLayer_CU(Map map, SectionBufferBuilderPack pack, ChunkSectionLayer layer, boolean shaded) { - VertexConsumer consumer = this.getOrBeginLayer(map, pack, layer); - if (shaded) { - return new ShadedVertexConsumerWrapper(consumer); + if (((RenderSectionRegionExtension) region).hasSchematicaBlockAt_CU(pos)) { + return new ShadedVertexConsumerWrapper(consumer, 0.5f, 0.8f, 1.0f, 0.6f); } else { return consumer; } diff --git a/neoforge/src/main/java/com/zergatul/cheatutils/mixins/neoforge/schematics/MixinSectionCompiler.java b/neoforge/src/main/java/com/zergatul/cheatutils/mixins/neoforge/schematics/MixinSectionCompiler.java index ca8cce17..36d396b0 100644 --- a/neoforge/src/main/java/com/zergatul/cheatutils/mixins/neoforge/schematics/MixinSectionCompiler.java +++ b/neoforge/src/main/java/com/zergatul/cheatutils/mixins/neoforge/schematics/MixinSectionCompiler.java @@ -1,106 +1,34 @@ package com.zergatul.cheatutils.mixins.neoforge.schematics; -import com.llamalad7.mixinextras.sugar.Local; -import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; -import com.mojang.blaze3d.vertex.VertexSorting; import com.zergatul.cheatutils.extensions.RenderSectionRegionExtension; import com.zergatul.cheatutils.schematics.ShadedVertexConsumerWrapper; -import it.unimi.dsi.fastutil.objects.ObjectArrayList; -import net.minecraft.client.renderer.ItemBlockRenderTypes; -import net.minecraft.client.renderer.SectionBufferBuilderPack; -import net.minecraft.client.renderer.block.BlockRenderDispatcher; -import net.minecraft.client.renderer.block.model.BlockModelPart; +import com.zergatul.mixin.LocalVariable; +import com.zergatul.mixin.ModifyArgument; import net.minecraft.client.renderer.chunk.ChunkSectionLayer; import net.minecraft.client.renderer.chunk.RenderSectionRegion; import net.minecraft.client.renderer.chunk.SectionCompiler; import net.minecraft.core.BlockPos; -import net.minecraft.core.SectionPos; -import net.minecraft.util.RandomSource; -import net.minecraft.world.level.BlockAndTintGetter; -import net.minecraft.world.level.block.RenderShape; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.material.FluidState; -import net.neoforged.neoforge.client.event.AddSectionGeometryEvent; -import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import java.util.List; import java.util.function.Function; @Mixin(SectionCompiler.class) public abstract class MixinSectionCompiler { - @Shadow - @Final - private BlockRenderDispatcher blockRenderer; - - @Inject( + @ModifyArgument( method = "compile(Lnet/minecraft/core/SectionPos;Lnet/minecraft/client/renderer/chunk/RenderSectionRegion;Lcom/mojang/blaze3d/vertex/VertexSorting;Lnet/minecraft/client/renderer/SectionBufferBuilderPack;Ljava/util/List;)Lnet/minecraft/client/renderer/chunk/SectionCompiler$Results;", - at = @At(value = "INVOKE", target = "Ljava/util/Map;entrySet()Ljava/util/Set;")) - private void onBeforeSorting( - SectionPos sectionPos, - RenderSectionRegion region, - VertexSorting sorting, - SectionBufferBuilderPack pack, - List additionalRenderers, - CallbackInfoReturnable info, - @Local(ordinal = 0) Function bufferLookup, - @Local(ordinal = 0) PoseStack poseStack + at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/block/BlockRenderDispatcher;renderBatched(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/BlockAndTintGetter;Lcom/mojang/blaze3d/vertex/PoseStack;Ljava/util/function/Function;ZLjava/util/List;)V")) + private Function onModifyBufferLookup( + Function lookup, + @LocalVariable(ordinal = 0) RenderSectionRegion region, + @LocalVariable(ordinal = 2) BlockPos pos ) { - RenderSectionRegionExtension extension = (RenderSectionRegionExtension) region; - if (!extension.hasSchematicaBlocks_CU()) { - return; - } - - boolean shaded = extension.shadeSchematicaBlocks_CU(); - RandomSource random = RandomSource.create(); - List list = new ObjectArrayList<>(); - BlockAndTintGetter wrapped = extension.asWrapped_CU(); - - bufferLookup = wrapBufferLookup_CU(bufferLookup, shaded); - - BlockPos corner1 = sectionPos.origin(); - BlockPos corner2 = corner1.offset(15, 15, 15); - for (BlockPos pos : BlockPos.betweenClosed(corner1, corner2)) { - if (!region.getBlockState(pos).isAir()) { - continue; - } - - BlockState state = wrapped.getBlockState(pos); - if (state.isAir()) { - continue; - } - - FluidState fluidState = state.getFluidState(); - if (!fluidState.isEmpty()) { - ChunkSectionLayer layer = ItemBlockRenderTypes.getRenderLayer(fluidState); - this.blockRenderer.renderLiquid(pos, wrapped, bufferLookup.apply(layer), state, fluidState); - } - - if (state.getRenderShape() == RenderShape.MODEL) { - random.setSeed(state.getSeed(pos)); - this.blockRenderer.getBlockModel(state).collectParts(region, pos, state, random, list); - poseStack.pushPose(); - poseStack.translate(pos.getX() & 0xF, pos.getY() & 0xF, pos.getZ() & 0xF); - this.blockRenderer.renderBatched(state, pos, wrapped, poseStack, bufferLookup, true, list); - poseStack.popPose(); - list.clear(); - } - } - } - - @Unique - private Function wrapBufferLookup_CU(Function bufferLookup, boolean shaded) { - if (shaded) { - return layer -> new ShadedVertexConsumerWrapper(bufferLookup.apply(layer)); + if (((RenderSectionRegionExtension) region).hasSchematicaBlockAt_CU(pos)) { + return layer -> new ShadedVertexConsumerWrapper(lookup.apply(layer), 0.5f, 0.8f, 1.0f, 0.6f); } else { - return bufferLookup; + return lookup; } } } \ No newline at end of file From 282da7aedd6a62847afb4a4a2c5f9eaf86b283ab Mon Sep 17 00:00:00 2001 From: someRandomDude-a Date: Sun, 11 Jan 2026 21:30:56 +0530 Subject: [PATCH 05/17] implemented shield breaker as "autoStunner" updated stuff to use beforeAttack events nicer seperated stunning to its own module --- README.md | 242 +++++++++++++++++- .../cheatutils/configs/AutoStunnerConfig.java | 4 + .../cheatutils/configs/BreachSwapConfig.java | 14 +- .../zergatul/cheatutils/configs/Config.java | 1 + .../cheatutils/configs/ConfigStore.java | 1 - .../cheatutils/configs/SpearRangeConfig.java | 11 +- .../zergatul/cheatutils/modules/Modules.java | 21 +- .../modules/automation/AutoStunner.java | 81 ++++++ .../modules/automation/BreachSwap.java | 118 ++------- .../modules/automation/SpearRange.java | 6 +- .../zergatul/cheatutils/scripting/Root.java | 4 +- .../scripting/modules/AutoStunnerApi.java | 12 + .../scripting/modules/BreachSwapApi.java | 4 - .../zergatul/cheatutils/webui/ApiHandler.java | 12 + common/resources/web/Web Examples.md | 25 ++ .../components/automation/AutoStunner.html | 12 + .../web/components/automation/AutoStunner.js | 5 + .../web/components/automation/BreachSwap.html | 33 +-- .../web/components/automation/BreachSwap.js | 4 +- common/resources/web/modules.js | 18 +- 20 files changed, 462 insertions(+), 166 deletions(-) create mode 100644 common/java/com/zergatul/cheatutils/configs/AutoStunnerConfig.java create mode 100644 common/java/com/zergatul/cheatutils/modules/automation/AutoStunner.java create mode 100644 common/java/com/zergatul/cheatutils/scripting/modules/AutoStunnerApi.java create mode 100644 common/resources/web/Web Examples.md create mode 100644 common/resources/web/components/automation/AutoStunner.html create mode 100644 common/resources/web/components/automation/AutoStunner.js diff --git a/README.md b/README.md index b250b14c..f2878964 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,248 @@ -### Warning +# Zergatul Cheat Utils + +## Warning + If you use download button on github, repository will not work since it is using git submodules. To download repository with submodules use below command: `git clone --recurse-submodules https://github.com/Zergatul/cheatutils.git` -### Build +## Build + To build mod by yourself go to Forge or Fabric directory and run `gradlew build`. -### Debugging/Customizing Web App +## Debugging/Customizing Web App + Download repo (or just `/common/resources/web` directory), and add JVM argument in Minecraft launcher like this: -``` + +```bat -Dcheatutils.web.dir=C:\full\path\to\web\directory ``` -Now local website uses static files from this directory instead of mod resources. \ No newline at end of file + +Now local website uses static files from this directory instead of mod resources. + +## Code Examples :- + +### Adding a module to the mod :- + +#### Step 1 + +Create your main class file. +This is where most of your modules code will be written. + +First, navigate to the modules folder located in `common/java/com/zergatul/cheatutils/modules`. +Select the folder that best fits your module type. +Create a new file : `"ClassName.java"`. +the class should be in this format: + +```java +import com.zergatul.cheatutils.modules.Module; + +public class ClassName implements Module { + public static final ClassName instance = new ClassName(); + ClassName(){ + + } +} +``` + +#### Step 2 + +For the purposes of this explaination, it is assumed your mod is named as "ClassName" +Register your module in the mod. +Navigate to `Modules.java` in the same directory. +Add your module to the following function + +```java +public static void register() { + register(ClassName.instance); +} +``` + +Make sure you place it in the right position, modules are initialized in the order listed here. This includes the order of their events added to EventsApi + +#### Step 3 + +Add your configuration class + +Navigate to `common/java/com/zergatul/cheatutils/configs` + +create a new file `ClassNameConfig.java` + +```java +package com.zergatul.cheatutils.configs; + +public class ClassNameConfig extends ModuleConfig implements ValidatableConfig { + + ClassNameConfig() { + + } + + @Override + public void validate() { + return; + } +} +``` + +add your config validation inside the `validate()` function, this is where you will add limits to your variables, for example clampign the range of a value. +If your API will be accessible from the scripting, it is highly recomended to include validation for any variables. + +##### Note:- + +* in case if your module does not require validation, you can skip `implements ValidatableConfig` and the overriden `public void validate()` function. When doing this, also skip adding validation to [`Root.java`](#adding-a-module-to-the-mod--) +* If your module does not require enable / disable, you can skip `extends ModuleConfig` as well. This also means you cannot use the `enabled` boolean or the `isEnabled()` inherited functions. Keep this in mind when creating the website / code for it. + +you can also add any more functions or values to change here. +for example: + +```java +public boolean bl1; +public double db1; +``` + +and so on. These must be public, you can also use functions internally, however functions will not work with the website API. +The API directly changes variables. + +an example of a minimal config which does not need validation or enable variable: + +```java + public class ClassNameConfig {} +``` + +Next, navigate to `Config.java`, located in the same directory. + +Add your config to the class + +```java + public ClassNameConfig classNameConfig = new ClassNameConfig(); +``` + +##### Now, navigate to `configStore.java`, located in the same directory and add this line + +```java + private void onConfigLoaded() { + config.classNameConfig.validate(); +``` + +#### Step 4 + +Adding the module API for the website to work with. +Navigate to `common/java/com/zergatul/cheatutils/scripting/modules/` +make a new file `ClassNameConfig.java` + +add these lines + +```java +package com.zergatul.cheatutils.scripting.modules; + +import com.zergatul.cheatutils.configs.ClassNameConfig; +import com.zergatul.cheatutils.configs.ConfigStore; + +public class ClassNameApi extends ModuleApi { + + + @Override + protected ClassNameConfig getConfig() { + return ConfigStore.instance.getConfig().classNameconfig; + } +} +``` + +#### Step 5 + +Allow the API to be accessed from scripting tools (this refers to user side scripting) + +Navigate to `common/java/com/zergatul/cheatutils/scripting/Root.java` + +Add the following lines inside the Root class. + +```java +public static ClassNameApi className = new ClassNameApi(); +``` + +This step is OPTIONAL and not required for module to function. +If you want your module configuration to be accessed from scripting +However, it is recomended to do this step + +#### Step 6 + +Adding your module to the website + +Navigate to `common/resources/web/modules.js` + +Add your module under line 21 with the following format: + +```javascript +module({ + group: 'automation', + name: 'Display Name', + component: 'ClassName', + path: 'class-name', + tags: ['search', 'terms', 'identifers'] +}); +``` + +Make sure you add your module to the correct section with the rest of its group +There are the following groups that can be used: + +```javascript +`automation` +`esp` +`hacks` +`visuals` +`scripting` +`utility` +``` + +In our example, we used `'automation'`, you can change this to match your module type + +now navigate to `common/resources/web/components` +next, navigate to the relevant folder for your module from the available folders. This is mapped to the groups used, so ensure you use the same folder. + +Create 2 new files: + +* ClassName.js +* ClassName.html + +inside the javascript file, add the following: + +```javascript +import { createSimpleComponent } from '/components/SimpleModule.js'; + +export function createComponent(template) { + return createSimpleComponent('/api/class-name', template); +} + +``` + +if you use any new components as listed in `common/resources/web/components.js` in your html, make sure to include them in your javascript file + +for example: + +```javascript +import { createSimpleComponent } from '/components/SimpleModule.js' + +export function createComponent(template) { + return createSimpleComponent('/api/class-name', template, { + components: ['CodeBlock', 'ColorBox'] + }); +} +``` + +##### How to make your html file + +This guide will focus on the working, for style and other formatting / component usage, look at the html of other modules already implemented + +your html file should look like this: + +```html +
+ +
+``` + +all components can be found at `common/resources/web/components/common` + +[Refer to this Document for more information and examples](./common/\/resources/web/Web%20Examples.md) diff --git a/common/java/com/zergatul/cheatutils/configs/AutoStunnerConfig.java b/common/java/com/zergatul/cheatutils/configs/AutoStunnerConfig.java new file mode 100644 index 00000000..b2256505 --- /dev/null +++ b/common/java/com/zergatul/cheatutils/configs/AutoStunnerConfig.java @@ -0,0 +1,4 @@ +package com.zergatul.cheatutils.configs; + +public class AutoStunnerConfig extends ModuleConfig { +} \ No newline at end of file diff --git a/common/java/com/zergatul/cheatutils/configs/BreachSwapConfig.java b/common/java/com/zergatul/cheatutils/configs/BreachSwapConfig.java index adfd2a69..ab1467d8 100644 --- a/common/java/com/zergatul/cheatutils/configs/BreachSwapConfig.java +++ b/common/java/com/zergatul/cheatutils/configs/BreachSwapConfig.java @@ -1,16 +1,4 @@ package com.zergatul.cheatutils.configs; -public class BreachSwapConfig extends ModuleConfig implements ValidatableConfig { - public boolean useAxe; - public boolean breakShield; - - BreachSwapConfig() { - useAxe = false; - breakShield = false; - } - - @Override - public void validate() { - return; - } +public class BreachSwapConfig extends ModuleConfig { } \ No newline at end of file diff --git a/common/java/com/zergatul/cheatutils/configs/Config.java b/common/java/com/zergatul/cheatutils/configs/Config.java index 58a3d8d9..780f2c83 100644 --- a/common/java/com/zergatul/cheatutils/configs/Config.java +++ b/common/java/com/zergatul/cheatutils/configs/Config.java @@ -53,6 +53,7 @@ public class Config { public AutoAttackConfig autoAttackConfig = new AutoAttackConfig(); public BreachSwapConfig breachSwapConfig = new BreachSwapConfig(); public SpearRangeConfig spearRangeConfig = new SpearRangeConfig(); + public AutoStunnerConfig autoStunnerConfig = new AutoStunnerConfig(); public NoWeatherConfig noWeatherConfig = new NoWeatherConfig(); public FakeWeatherConfig fakeWeatherConfig = new FakeWeatherConfig(); public ChatUtilitiesConfig chatUtilitiesConfig = new ChatUtilitiesConfig(); diff --git a/common/java/com/zergatul/cheatutils/configs/ConfigStore.java b/common/java/com/zergatul/cheatutils/configs/ConfigStore.java index 9b492351..92bf3efb 100644 --- a/common/java/com/zergatul/cheatutils/configs/ConfigStore.java +++ b/common/java/com/zergatul/cheatutils/configs/ConfigStore.java @@ -136,7 +136,6 @@ private void onConfigLoaded() { config.keyBindingsConfig.validate(); config.worldMarkersConfig.validate(); config.autoAttackConfig.validate(); - config.breachSwapConfig.validate(); config.projectilePathConfig.validate(); config.chatUtilitiesConfig.validate(); config.areaMineConfig.validate(); diff --git a/common/java/com/zergatul/cheatutils/configs/SpearRangeConfig.java b/common/java/com/zergatul/cheatutils/configs/SpearRangeConfig.java index 2d252d6b..9f8063b4 100644 --- a/common/java/com/zergatul/cheatutils/configs/SpearRangeConfig.java +++ b/common/java/com/zergatul/cheatutils/configs/SpearRangeConfig.java @@ -1,13 +1,4 @@ package com.zergatul.cheatutils.configs; -public class SpearRangeConfig extends ModuleConfig implements ValidatableConfig { - - SpearRangeConfig() { - - } - - @Override - public void validate() { - return; - } +public class SpearRangeConfig extends ModuleConfig { } \ No newline at end of file diff --git a/common/java/com/zergatul/cheatutils/modules/Modules.java b/common/java/com/zergatul/cheatutils/modules/Modules.java index 9b5fc3d4..3b312492 100644 --- a/common/java/com/zergatul/cheatutils/modules/Modules.java +++ b/common/java/com/zergatul/cheatutils/modules/Modules.java @@ -9,8 +9,12 @@ import com.zergatul.cheatutils.modules.automation.*; import com.zergatul.cheatutils.modules.esp.*; import com.zergatul.cheatutils.modules.hacks.*; -import com.zergatul.cheatutils.modules.scripting.*; -import com.zergatul.cheatutils.modules.utilities.*; +import com.zergatul.cheatutils.modules.scripting.BlockAutomation; +import com.zergatul.cheatutils.modules.scripting.Containers; +import com.zergatul.cheatutils.modules.scripting.Exec; +import com.zergatul.cheatutils.modules.scripting.StatusOverlay; +import com.zergatul.cheatutils.modules.utilities.LockInputs; +import com.zergatul.cheatutils.modules.utilities.RenderUtilities; import com.zergatul.cheatutils.modules.visuals.*; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -20,6 +24,14 @@ public class Modules { private static final Logger LOGGER = LogManager.getLogger(Modules.class); public static void register() { + + //Order dependent modules + //========================== + register(SpearRange.instance); + register(AutoStunner.instance); + register(BreachSwap.instance); + //=========================== + register(FakeRotation.instance); register(BlockEventsProcessor.instance); register(NetworkPacketsController.instance); @@ -62,8 +74,7 @@ public static void register() { register(ArmorOverlay.instance); register(Fog.instance); register(AutoAttack.instance); - register(BreachSwap.instance); - register(SpearRange.instance); + register(Exec.instance); register(VillagerRoller.instance); register(AutoHotbar.instance); @@ -86,12 +97,14 @@ public static void register() { register(TickEndExecutor.instance); // new order independent modules + //========================================== register(AfterPlayerAiStepExecutor.instance); register(AfterSendPlayerPosExecutor.instance); FontBackendHolders.add(StatusOverlay.instance); FontBackendHolders.add(EntityTitle.instance); FontBackendHolders.add(WorldMarkers.instance); + //=========================================== } public static void registerKeyBindings() { diff --git a/common/java/com/zergatul/cheatutils/modules/automation/AutoStunner.java b/common/java/com/zergatul/cheatutils/modules/automation/AutoStunner.java new file mode 100644 index 00000000..d2c0e7f0 --- /dev/null +++ b/common/java/com/zergatul/cheatutils/modules/automation/AutoStunner.java @@ -0,0 +1,81 @@ +package com.zergatul.cheatutils.modules.automation; + +import com.zergatul.cheatutils.common.Events; +import com.zergatul.cheatutils.common.events.BeforeAttackEvent; +import com.zergatul.cheatutils.configs.ConfigStore; +import com.zergatul.cheatutils.modules.Module; +import net.minecraft.client.Minecraft; +import net.minecraft.tags.ItemTags; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.phys.EntityHitResult; +import net.minecraft.world.phys.HitResult; +import net.minecraft.world.phys.Vec3; + +public class AutoStunner implements Module { + public static final AutoStunner instance = new AutoStunner(); + private final Minecraft mc = Minecraft.getInstance(); + private Inventory inventory; + private static int prevSelectedSlot = -1; + int axe = -1; + + AutoStunner() { + Events.BeforeAttack.add(this::onBeforeAttack); + Events.AfterAttack.add(this::onAfterAttack); + } + + private boolean isUsingShield(Entity entity) { + if (entity instanceof LivingEntity living) { + if (living.isBlocking()) { + // Calculate if target is looking at us + // Shields only block a 180 degree slice of a cylinder + Vec3 shield = living.calculateViewVector(0.0F, living.getYHeadRot()); + Vec3 player = mc.player.position().subtract(living.position()); + player = (new Vec3(player.x, 0D, player.z)).normalize(); + double dotProduct = player.dot(shield); + return dotProduct >= 0; + } + } + return false; + } + + private void onBeforeAttack(BeforeAttackEvent event) { + if (!ConfigStore.instance.getConfig().autoStunnerConfig.enabled) return; + prevSelectedSlot = -1; + + if (mc.hitResult.getType() != HitResult.Type.ENTITY) { + return; + } + Entity entity = ((EntityHitResult) mc.hitResult).getEntity(); + double reach = mc.player.entityInteractionRange(); + + if (reach * reach < mc.player.getEyePosition().distanceToSqr(mc.hitResult.getLocation())) { + return; + } + + if (!isUsingShield(entity)) { + return; + } + + inventory = mc.player.getInventory(); + prevSelectedSlot = inventory.getSelectedSlot(); + + for (int i = 0; i < 9; i++) { + ItemStack item = inventory.getItem(i); + if (item.getTags().anyMatch(tag -> tag == ItemTags.AXES)) { + axe = i; + break; + } + } + inventory.setSelectedSlot(axe); + } + + private void onAfterAttack() { + if (!ConfigStore.instance.getConfig().autoStunnerConfig.enabled) return; + if (prevSelectedSlot == -1) return; + inventory.setSelectedSlot(prevSelectedSlot); + } + +} diff --git a/common/java/com/zergatul/cheatutils/modules/automation/BreachSwap.java b/common/java/com/zergatul/cheatutils/modules/automation/BreachSwap.java index 3b48d956..4e625a1f 100644 --- a/common/java/com/zergatul/cheatutils/modules/automation/BreachSwap.java +++ b/common/java/com/zergatul/cheatutils/modules/automation/BreachSwap.java @@ -2,139 +2,77 @@ import com.zergatul.cheatutils.common.Events; import com.zergatul.cheatutils.common.events.BeforeAttackEvent; -import com.zergatul.cheatutils.configs.BreachSwapConfig; import com.zergatul.cheatutils.configs.ConfigStore; import com.zergatul.cheatutils.modules.Module; -import com.zergatul.cheatutils.modules.hacks.AutoCriticals; import net.minecraft.client.Minecraft; -import net.minecraft.tags.ItemTags; -import net.minecraft.world.InteractionHand; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.enchantment.EnchantmentEffectComponents; -import net.minecraft.world.phys.EntityHitResult; import net.minecraft.world.phys.HitResult; -import net.minecraft.world.phys.Vec3; public class BreachSwap implements Module { public static final BreachSwap instance = new BreachSwap(); private final Minecraft mc = Minecraft.getInstance(); + private Inventory inventory; + + private static int prevSelectedSlot = -1; private BreachSwap() { + Events.BeforeAttack.add(this::onBeforeAttack); - handling = false; + Events.AfterAttack.add(this::onAfterAttack); } + private void onBeforeAttack(BeforeAttackEvent event) { - private static boolean handling; - - public void onBeforeAttack(BeforeAttackEvent event) { - if (handling) { + if (!ConfigStore.instance.getConfig().breachSwapConfig.enabled) { return; } - BreachSwapConfig config = ConfigStore.instance.getConfig().breachSwapConfig; - if (config.enabled) { - if (instance.attack(config.useAxe, config.breakShield)) { - event.cancel(); - } - } - } - - public boolean attack(boolean useAxe, boolean breakShield) { - handling = true; - boolean returnVal = instance.run(useAxe, breakShield); - handling = false; - return returnVal; - } - - private boolean run(boolean useAxe, boolean breakShield) { + prevSelectedSlot = -1; if (mc.player == null) { - return false; + return; } if (mc.hitResult == null) { - return false; + return; } if (mc.hitResult.getType() != HitResult.Type.ENTITY) { - return false; + return; } - Entity entity = ((EntityHitResult) mc.hitResult).getEntity(); double reach = mc.player.entityInteractionRange(); + if (reach * reach < mc.player.getEyePosition().distanceToSqr(mc.hitResult.getLocation())) { - return false; + return; } - //Find position of axe, sword and mace - //Should only run when inventory is updated ideally - int axe = -1; - int sword = -1; + + int mace = -1; - int weapon; - Inventory inventory = mc.player.getInventory(); + inventory = mc.player.getInventory(); + for (int i = 0; i < 9; i++) { ItemStack item = inventory.getItem(i); - if (item.getTags().anyMatch(tag -> tag == ItemTags.SWORDS)) sword = i; - else if (item.getTags().anyMatch(tag -> tag == ItemTags.AXES)) axe = i; - else if (item.getEnchantments().keySet().stream().anyMatch(enchantment -> + + if (item.getEnchantments().keySet().stream().anyMatch(enchantment -> enchantment.value().effects().keySet().contains(EnchantmentEffectComponents.ARMOR_EFFECTIVENESS))) mace = i; } if (mace == -1) { - return false; - } - - if (axe == -1 && sword == -1) { - return false; - } - - if (useAxe) {//Prefer Axe to sword - if (axe != -1) { - weapon = axe; - } else { - weapon = sword; - } - } else {//Prefer sword to axe - if (sword != -1) { - weapon = sword; - } else { - weapon = axe; - } - } - - if (breakShield) { - boolean isUsingShield = false; - if (entity instanceof LivingEntity living) { - if (living.isBlocking()) { - // Calculate if target is looking at us - // Shields only block a 180 degree slice of a cylinder - Vec3 shield = living.calculateViewVector(0.0F, living.getYHeadRot()); - Vec3 player = mc.player.position().subtract(living.position()); - player = (new Vec3(player.x, 0D, player.z)).normalize(); - double dotProduct = player.dot(shield); - isUsingShield = dotProduct >= 0; - } - } - - - if (isUsingShield && axe != -1) { - inventory.setSelectedSlot(axe); - mc.gameMode.attack(mc.player, entity); - mc.player.swing(InteractionHand.MAIN_HAND); - - } + return; } - + prevSelectedSlot = inventory.getSelectedSlot(); inventory.setSelectedSlot(mace); - mc.gameMode.attack(mc.player, entity); - mc.player.swing(InteractionHand.MAIN_HAND); - inventory.setSelectedSlot(weapon); - return true; + } + private void onAfterAttack() { + if (!ConfigStore.instance.getConfig().breachSwapConfig.enabled) return; + if (prevSelectedSlot == -1) return; + inventory.setSelectedSlot(prevSelectedSlot); } + + } \ No newline at end of file diff --git a/common/java/com/zergatul/cheatutils/modules/automation/SpearRange.java b/common/java/com/zergatul/cheatutils/modules/automation/SpearRange.java index fcd142d8..7f45f2f0 100644 --- a/common/java/com/zergatul/cheatutils/modules/automation/SpearRange.java +++ b/common/java/com/zergatul/cheatutils/modules/automation/SpearRange.java @@ -23,11 +23,11 @@ private SpearRange() { public void onBeforeAttack(BeforeAttackEvent event) { if (!ConfigStore.instance.getConfig().spearRangeConfig.enabled) return; + prevSelectedSlot = -1; if (mc.player == null) return; if (mc.player.isSpectator()) return; inventory = mc.player.getInventory(); - prevSelectedSlot = inventory.getSelectedSlot(); int spear = -1; for (int i = 0; i < 9; i++) { ItemStack item = inventory.getItem(i); @@ -39,11 +39,13 @@ public void onBeforeAttack(BeforeAttackEvent event) { if (spear == -1) return; if (spear == prevSelectedSlot) return; - + prevSelectedSlot = inventory.getSelectedSlot(); inventory.setSelectedSlot(spear); } private void onAfterAttack() { + if (!ConfigStore.instance.getConfig().spearRangeConfig.enabled) return; + if (prevSelectedSlot == -1) return; inventory.setSelectedSlot(prevSelectedSlot); } } diff --git a/common/java/com/zergatul/cheatutils/scripting/Root.java b/common/java/com/zergatul/cheatutils/scripting/Root.java index 951269fe..f63936bc 100644 --- a/common/java/com/zergatul/cheatutils/scripting/Root.java +++ b/common/java/com/zergatul/cheatutils/scripting/Root.java @@ -16,6 +16,9 @@ public class Root { public static AutoHotbarApi autoHotbar = new AutoHotbarApi(); public static AutoToolApi autoTool = new AutoToolApi(); public static AutoAttackApi autoAttack = new AutoAttackApi(); + public static AutoStunnerApi autoStunner = new AutoStunnerApi(); + public static BreachSwapApi breachSwap = new BreachSwapApi(); + public static SpearRangeApi spearRange = new SpearRangeApi(); // ESP public static BlocksApi blocks = new BlocksApi(); @@ -43,7 +46,6 @@ public class Root { public static AreaMineApi areaMine = new AreaMineApi(); public static StepUpApi stepUp = new StepUpApi(); public static AimAssistApi aimAssist = new AimAssistApi(); - public static BreachSwapApi breachSwap = new BreachSwapApi(); public static AirPlaceApi airPlace = new AirPlaceApi(); // visuals diff --git a/common/java/com/zergatul/cheatutils/scripting/modules/AutoStunnerApi.java b/common/java/com/zergatul/cheatutils/scripting/modules/AutoStunnerApi.java new file mode 100644 index 00000000..6054eab5 --- /dev/null +++ b/common/java/com/zergatul/cheatutils/scripting/modules/AutoStunnerApi.java @@ -0,0 +1,12 @@ +package com.zergatul.cheatutils.scripting.modules; + +import com.zergatul.cheatutils.configs.AutoStunnerConfig; +import com.zergatul.cheatutils.configs.ConfigStore; + +public class AutoStunnerApi extends ModuleApi { + + @Override + protected AutoStunnerConfig getConfig() { + return ConfigStore.instance.getConfig().autoStunnerConfig; + } +} \ No newline at end of file diff --git a/common/java/com/zergatul/cheatutils/scripting/modules/BreachSwapApi.java b/common/java/com/zergatul/cheatutils/scripting/modules/BreachSwapApi.java index 64b2b0fa..2282e9c3 100644 --- a/common/java/com/zergatul/cheatutils/scripting/modules/BreachSwapApi.java +++ b/common/java/com/zergatul/cheatutils/scripting/modules/BreachSwapApi.java @@ -7,10 +7,6 @@ import com.zergatul.cheatutils.scripting.ApiVisibility; public class BreachSwapApi extends ModuleApi { - @ApiVisibility(ApiType.ACTION) - public void attack(boolean useAxe, boolean breakShield) { - BreachSwap.instance.attack(useAxe, breakShield); - } @Override protected BreachSwapConfig getConfig() { diff --git a/common/java/com/zergatul/cheatutils/webui/ApiHandler.java b/common/java/com/zergatul/cheatutils/webui/ApiHandler.java index 0bd32eb1..7832e984 100644 --- a/common/java/com/zergatul/cheatutils/webui/ApiHandler.java +++ b/common/java/com/zergatul/cheatutils/webui/ApiHandler.java @@ -700,6 +700,18 @@ protected void setConfig(BreachSwapConfig config) { ConfigStore.instance.getConfig().breachSwapConfig = config; } }); + apis.add(new SimpleConfigApi<>("auto-stunner", AutoStunnerConfig.class) { + @Override + protected AutoStunnerConfig getConfig() { + return ConfigStore.instance.getConfig().autoStunnerConfig; + } + + @Override + protected void setConfig(AutoStunnerConfig config) { + ConfigStore.instance.getConfig().autoStunnerConfig = config; + } + }); + apis.add(new SimpleConfigApi<>("no-weather", NoWeatherConfig.class) { @Override protected NoWeatherConfig getConfig() { diff --git a/common/resources/web/Web Examples.md b/common/resources/web/Web Examples.md new file mode 100644 index 00000000..5978398a --- /dev/null +++ b/common/resources/web/Web Examples.md @@ -0,0 +1,25 @@ +# Website components + +## Explanation:- + +### `v-model="config.VariableName"` This defines the variable to be modified. + +### `@change="update()"` This defines the function to be run on value change + +### [Website uses Vue components](https://vuejs.org/guide/introduction.html) + +## Component Examples:- + +### Switch + +```html +Enabled +``` +boolean output + +### Text Box + +```html + +``` +typecast output to the variable type \ No newline at end of file diff --git a/common/resources/web/components/automation/AutoStunner.html b/common/resources/web/components/automation/AutoStunner.html new file mode 100644 index 00000000..40e7ab55 --- /dev/null +++ b/common/resources/web/components/automation/AutoStunner.html @@ -0,0 +1,12 @@ +
+
+ Automatically disables shield if you have an axe available and the target is holding a shield that would block your attack + Module accounts for target look direction +
+ +
+
+ Enabled +
+
+
\ No newline at end of file diff --git a/common/resources/web/components/automation/AutoStunner.js b/common/resources/web/components/automation/AutoStunner.js new file mode 100644 index 00000000..5c3e8609 --- /dev/null +++ b/common/resources/web/components/automation/AutoStunner.js @@ -0,0 +1,5 @@ +import { createSimpleComponent } from '/components/SimpleModule.js'; + +export function createComponent(template) { + return createSimpleComponent('/api/auto-hotbar', template); +} \ No newline at end of file diff --git a/common/resources/web/components/automation/BreachSwap.html b/common/resources/web/components/automation/BreachSwap.html index 7d770e0a..83699165 100644 --- a/common/resources/web/components/automation/BreachSwap.html +++ b/common/resources/web/components/automation/BreachSwap.html @@ -1,39 +1,8 @@
- Breach Swap makes it so that attacking swaps sword and mace to perform a Breach Swap attack, - Penetrating armor with breach while using base damage and cooldown of a sword or axe. + Looks for a breach mace in your hotbar, if you have a breach mace, it will perform an attribute swap with your currently held item and the breach mace
Enabled -
-
- - Weapon Options - -
- Prefer Axe - Break shield automatically - -
-
-
- Use Axe option tells module to prefer using axe or sword. - Module always chooses valid weapon closest to the right of the taskbar.
- If the preferred weapon is not in hotbar, module uses the other weapon if available.
- Example: When "Prefer Axe" option is true but you do not have an axe in the hotbar, the module will - automatically use a sword instead.
- If no weapons are present or no mace (with breach) is present, module does nothing
- Break Shield option allows module to automatically break a shield if your attack would be blocked by its - shield. - This allows you to do damage while falling, even if target uses their shield. -
-
- Module can also be run from code. Here is a simple example to use with keybinds:
- -
-
-
\ No newline at end of file diff --git a/common/resources/web/components/automation/BreachSwap.js b/common/resources/web/components/automation/BreachSwap.js index fd119490..6e131a56 100644 --- a/common/resources/web/components/automation/BreachSwap.js +++ b/common/resources/web/components/automation/BreachSwap.js @@ -1,7 +1,5 @@ import { createSimpleComponent } from '/components/SimpleModule.js' export function createComponent(template) { - return createSimpleComponent('/api/breach-swap', template, { - components: ['CodeBlock'] - }); + return createSimpleComponent('/api/breach-swap', template); } \ No newline at end of file diff --git a/common/resources/web/modules.js b/common/resources/web/modules.js index 6eabce28..376215ad 100644 --- a/common/resources/web/modules.js +++ b/common/resources/web/modules.js @@ -17,7 +17,7 @@ const module = (params) => { params.componentRef = getComponent(`${params.group}/${params.component}`); modules[params.group][params.component] = params; }; - +//Automation Modules ================= module({ group: 'automation', name: 'Spear Range', @@ -25,6 +25,14 @@ module({ path: 'spear-range', tags: ['spear', 'reach', 'range'] }); + +module({ + group: 'automation', + name: 'Shield breaker', + component: 'AutoStunner', + path: 'auto-stunner', + tags: ['stun', 'shield', 'break', 'auto'] +}); module({ group: 'automation', name: 'Auto Disconnect', @@ -124,6 +132,8 @@ module({ tags: ['auto', 'tool'] }); +//ESP modules ====================== + module({ group: 'esp', name: 'Block ESP', @@ -188,6 +198,8 @@ module({ tags: ['entity', 'title', 'health'] }); +// Hacks Modules ========================== + module({ group: 'hacks', name: 'Kill Aura', @@ -357,6 +369,8 @@ module({ tags: ['air', 'place', 'airplace', 'scaffold'] }); +//Visuals Modules ============================ + module({ group: 'visuals', name: 'Full Bright', @@ -477,6 +491,8 @@ module({ tags: ['block', 'entity', 'chest', 'render'] }); +//Scripting Modules ====================== + module({ group: 'scripting', name: 'Key Bindings', From 5fe6d0880993a429dee6977cc235da96b2600a8c Mon Sep 17 00:00:00 2001 From: someRandomDude-a Date: Mon, 12 Jan 2026 21:51:34 +0530 Subject: [PATCH 06/17] implemented new attackClone_CU method and new attackEventHandler. Updated events to support priority numbering --- .../zergatul/cheatutils/common/Events.java | 24 ++++++++--- .../common/events/CancelableEventHandler.java | 39 ++++++++++++++++- .../events/ParameterizedEventHandler.java | 40 +++++++++++++++++- .../common/events/SimpleEventHandler.java | 14 ++++++- .../MultiPlayerGameModeExtension.java | 17 ++++++++ .../common/MixinMultiPlayerGameMode.java | 42 ++++++++++++++++++- .../modules/automation/AutoStunner.java | 19 +++++++-- .../components/automation/AutoStunner.html | 2 +- .../web/components/automation/AutoStunner.js | 2 +- 9 files changed, 181 insertions(+), 18 deletions(-) create mode 100644 common/java/com/zergatul/cheatutils/extensions/MultiPlayerGameModeExtension.java diff --git a/common/java/com/zergatul/cheatutils/common/Events.java b/common/java/com/zergatul/cheatutils/common/Events.java index d91af174..40ff850e 100644 --- a/common/java/com/zergatul/cheatutils/common/Events.java +++ b/common/java/com/zergatul/cheatutils/common/Events.java @@ -11,6 +11,8 @@ import net.minecraft.world.level.chunk.LevelChunk; import org.joml.Vector2ic; +import java.util.function.Consumer; + public class Events { // to better understand sequence of events they are ordered in trigger order @@ -45,10 +47,6 @@ public class Events { public static final SimpleEventHandler ClientTickEnd = new SimpleEventHandler(); - - - - public static final ParameterizedEventHandler ClientPlayerLoggingIn = new ParameterizedEventHandler<>(); public static final SimpleEventHandler ClientPlayerLoggingOut = new SimpleEventHandler(); public static final ParameterizedEventHandler RawChunkLoaded = new ParameterizedEventHandler<>(); @@ -59,7 +57,6 @@ public class Events { public static final ParameterizedEventHandler BlockUpdated = new ParameterizedEventHandler<>(); - public static final CancelableEventHandler PreRenderGuiOverlay = new CancelableEventHandler<>(); public static final CancelableEventHandler MouseScroll = new CancelableEventHandler<>(); @@ -86,4 +83,21 @@ public class Events { public static final CancelableEventHandler PlayerReleaseUsingItem = new CancelableEventHandler<>(); public static final CancelableEventHandler PlayerTurnByMouse = new CancelableEventHandler<>(); public static final ParameterizedEventHandler PlayerInfoUpdated = new ParameterizedEventHandler<>(); + + /** + * binds 2 functions to the beforeAttack and afterAttack event respectively. + * Tries to ensure that the order of module execution is preserved
+ * Example:
+ * if there are 2 actions bound: + *

+ * breachSwap and criticals, it should function like this: + *

+ * {@code BreachSwapBefore -> CriticalsBefore -> Vanilla code -> CriticalsAfter -> BreachSwapAfter}
+ * This ensures that the cleanup for each module always gets the same state as its initial condition + */ + + public static void AttackEventHandler(Consumer beforeAttackFunction, Runnable afterAttackFunction, int priority) { + BeforeAttack.add(beforeAttackFunction, priority); + AfterAttack.add(afterAttackFunction, -priority); + } } \ No newline at end of file diff --git a/common/java/com/zergatul/cheatutils/common/events/CancelableEventHandler.java b/common/java/com/zergatul/cheatutils/common/events/CancelableEventHandler.java index 53dd8f15..aa159e21 100644 --- a/common/java/com/zergatul/cheatutils/common/events/CancelableEventHandler.java +++ b/common/java/com/zergatul/cheatutils/common/events/CancelableEventHandler.java @@ -1,19 +1,42 @@ package com.zergatul.cheatutils.common.events; +import org.jetbrains.annotations.NotNull; + import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.function.Consumer; public class CancelableEventHandler { + private final List> entries = new ArrayList<>(); private final List> handlers = new ArrayList<>(); + private int counter; public void add(Consumer handler) { - handlers.add(handler); + add(handler, 0); + } + + /** + * + * @param handler Passed function that is added to the Event list + * @param priority Defaults to 0 when not passed. + * Events are executed in ascending order of their priority. + * If multiple functions have the same priority, it follows the order it was added
+ *
+ * Example execution order: + * {@code Priority 1 -> Priority 2} + */ + public void add(Consumer handler, int priority) { + entries.add(new Entry<>(handler, priority, counter++)); + Collections.sort(entries); + + handlers.clear(); + entries.stream().map(entry -> entry.handler).forEach(handlers::add); } public boolean trigger(T parameter) { - for (Consumer handler: handlers) { + for (Consumer handler : handlers) { handler.accept(parameter); if (parameter.isCanceled()) { return true; @@ -21,4 +44,16 @@ public boolean trigger(T parameter) { } return false; } + + private record Entry(Consumer handler, int priority1, int priority2) implements Comparable> { + @Override + public int compareTo(@NotNull Entry other) { + int result = Integer.compare(priority1, other.priority1); + if (result != 0) { + return result; + } else { + return Integer.compare(priority2, other.priority2); + } + } + } } \ No newline at end of file diff --git a/common/java/com/zergatul/cheatutils/common/events/ParameterizedEventHandler.java b/common/java/com/zergatul/cheatutils/common/events/ParameterizedEventHandler.java index 2a50de91..18c315af 100644 --- a/common/java/com/zergatul/cheatutils/common/events/ParameterizedEventHandler.java +++ b/common/java/com/zergatul/cheatutils/common/events/ParameterizedEventHandler.java @@ -1,20 +1,56 @@ package com.zergatul.cheatutils.common.events; +import org.jetbrains.annotations.NotNull; + import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.function.Consumer; public class ParameterizedEventHandler { + private final List> entries = new ArrayList<>(); private final List> handlers = new ArrayList<>(); + private int counter; public void add(Consumer handler) { - handlers.add(handler); + add(handler, 0); + } + + /** + * + * @param handler Passed function that is added to the Event list + * @param priority Defaults to 0 when not passed. + * Events are executed in ascending order of their priority. + * If multiple functions have the same priority, it follows the order it was added
+ *
+ * Example execution order: + * {@code Priority 1 -> Priority 2} + */ + public void add(Consumer handler, int priority) { + entries.add(new Entry<>(handler, priority, counter++)); + Collections.sort(entries); + + handlers.clear(); + entries.stream().map(entry -> entry.handler).forEach(handlers::add); } + public void trigger(T parameter) { - for (Consumer handler: handlers) { + for (Consumer handler : handlers) { handler.accept(parameter); } } + + private record Entry(Consumer handler, int priority1, int priority2) implements Comparable> { + @Override + public int compareTo(@NotNull Entry other) { + int result = Integer.compare(priority1, other.priority1); + if (result != 0) { + return result; + } else { + return Integer.compare(priority2, other.priority2); + } + } + } } \ No newline at end of file diff --git a/common/java/com/zergatul/cheatutils/common/events/SimpleEventHandler.java b/common/java/com/zergatul/cheatutils/common/events/SimpleEventHandler.java index 3c7d34c5..eff90ed4 100644 --- a/common/java/com/zergatul/cheatutils/common/events/SimpleEventHandler.java +++ b/common/java/com/zergatul/cheatutils/common/events/SimpleEventHandler.java @@ -16,6 +16,16 @@ public void add(Runnable handler) { add(handler, 0); } + /** + * + * @param handler Passed function that is added to the Event list + * @param priority Defaults to 0 when not passed. + * Events are executed in ascending order of their priority. + * If multiple functions have the same priority, it follows the order it was added
+ *
+ * Example execution order: + * {@code Priority 1 -> Priority 2} + */ public void add(Runnable handler, int priority) { entries.add(new Entry(handler, priority, counter++)); Collections.sort(entries); @@ -25,14 +35,14 @@ public void add(Runnable handler, int priority) { } public void trigger() { - for (Runnable handler: handlers) { + for (Runnable handler : handlers) { handler.run(); } } private record Entry(Runnable handler, int priority1, int priority2) implements Comparable { @Override - public int compareTo(@NotNull SimpleEventHandler.Entry other) { + public int compareTo(@NotNull Entry other) { int result = Integer.compare(priority1, other.priority1); if (result != 0) { return result; diff --git a/common/java/com/zergatul/cheatutils/extensions/MultiPlayerGameModeExtension.java b/common/java/com/zergatul/cheatutils/extensions/MultiPlayerGameModeExtension.java new file mode 100644 index 00000000..e6dd4db9 --- /dev/null +++ b/common/java/com/zergatul/cheatutils/extensions/MultiPlayerGameModeExtension.java @@ -0,0 +1,17 @@ +package com.zergatul.cheatutils.extensions; + +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.player.Player; + +public interface MultiPlayerGameModeExtension { + /** + * A vanilla implementation of the + * {@code void attack(Player player, Entity entity)} + * method.
+ * This method will NOT trigger automations / events from the regular method.
+ * intended to only be used internally to make modules that trigger on beforeAttackMethod + * Should be used in this format:
+ * {@code ((MultiPlayerGameModeExtension) mc.gameMode).attackClone(mc.player, entity);} + **/ + void attackClone_CU(Player player, Entity entity); +} diff --git a/common/java/com/zergatul/cheatutils/mixins/common/MixinMultiPlayerGameMode.java b/common/java/com/zergatul/cheatutils/mixins/common/MixinMultiPlayerGameMode.java index 687648de..db4f6850 100644 --- a/common/java/com/zergatul/cheatutils/mixins/common/MixinMultiPlayerGameMode.java +++ b/common/java/com/zergatul/cheatutils/mixins/common/MixinMultiPlayerGameMode.java @@ -5,32 +5,69 @@ import com.zergatul.cheatutils.common.events.PlayerReleaseUsingItemEvent; import com.zergatul.cheatutils.configs.ConfigStore; import com.zergatul.cheatutils.configs.FastBreakConfig; +import com.zergatul.cheatutils.extensions.MultiPlayerGameModeExtension; +import net.minecraft.client.multiplayer.ClientPacketListener; import net.minecraft.client.multiplayer.MultiPlayerGameMode; import net.minecraft.client.player.LocalPlayer; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.network.protocol.game.ServerboundInteractPacket; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.GameType; import net.minecraft.world.level.block.BedBlock; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.EntityHitResult; +import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(MultiPlayerGameMode.class) -public abstract class MixinMultiPlayerGameMode { +public abstract class MixinMultiPlayerGameMode implements MultiPlayerGameModeExtension { @Shadow private int destroyDelay; + + @Shadow + private GameType localPlayerMode; + + @Shadow + protected abstract void ensureHasSentCarriedItem(); + + @Shadow + @Final + private ClientPacketListener connection; + + /** + * A vanilla implementation of the + * {@code void attack(Player player, Entity entity)} + * method.
+ * This method will NOT trigger automations / events from the regular method.
+ * intended to only be used internally to make modules that trigger on beforeAttackMethod + * Should be used in this format:
+ * {@code ((MultiPlayerGameModeExtension) mc.gameMode).attackClone(mc.player, entity);} + *

+ * If you see this comment, you are not using the correct syntax. Make sure to cast the call first! + **/ + public void attackClone_CU(Player player, Entity entity) { + this.ensureHasSentCarriedItem(); + this.connection.send(ServerboundInteractPacket.createAttackPacket(entity, player.isShiftKeyDown())); + if (this.localPlayerMode != GameType.SPECTATOR) { + player.attack(entity); + player.resetAttackStrengthTicker(); + } + } + @Inject(at = @At("HEAD"), method = "releaseUsingItem(Lnet/minecraft/world/entity/player/Player;)V", cancellable = true) private void onReleaseUsingItem(Player player, CallbackInfo info) { if (Events.PlayerReleaseUsingItem.trigger(new PlayerReleaseUsingItemEvent())) { @@ -76,8 +113,9 @@ private void onAttack(Player player, Entity entity, CallbackInfo ci) { ci.cancel(); } } + @Inject(at = @At("TAIL"), method = "attack", cancellable = false) - private void afterAttack(Player player, Entity entity, CallbackInfo ci){ + private void afterAttack(Player player, Entity entity, CallbackInfo ci) { Events.AfterAttack.trigger(); } } diff --git a/common/java/com/zergatul/cheatutils/modules/automation/AutoStunner.java b/common/java/com/zergatul/cheatutils/modules/automation/AutoStunner.java index d2c0e7f0..d4411be1 100644 --- a/common/java/com/zergatul/cheatutils/modules/automation/AutoStunner.java +++ b/common/java/com/zergatul/cheatutils/modules/automation/AutoStunner.java @@ -3,7 +3,9 @@ import com.zergatul.cheatutils.common.Events; import com.zergatul.cheatutils.common.events.BeforeAttackEvent; import com.zergatul.cheatutils.configs.ConfigStore; +import com.zergatul.cheatutils.extensions.MultiPlayerGameModeExtension; import com.zergatul.cheatutils.modules.Module; +import com.zergatul.cheatutils.scripting.Root; import net.minecraft.client.Minecraft; import net.minecraft.tags.ItemTags; import net.minecraft.world.entity.Entity; @@ -22,8 +24,7 @@ public class AutoStunner implements Module { int axe = -1; AutoStunner() { - Events.BeforeAttack.add(this::onBeforeAttack); - Events.AfterAttack.add(this::onAfterAttack); + Events.AttackEventHandler(this::onBeforeAttack, this::onAfterAttack, 1); } private boolean isUsingShield(Entity entity) { @@ -48,6 +49,7 @@ private void onBeforeAttack(BeforeAttackEvent event) { if (mc.hitResult.getType() != HitResult.Type.ENTITY) { return; } + Entity entity = ((EntityHitResult) mc.hitResult).getEntity(); double reach = mc.player.entityInteractionRange(); @@ -60,7 +62,6 @@ private void onBeforeAttack(BeforeAttackEvent event) { } inventory = mc.player.getInventory(); - prevSelectedSlot = inventory.getSelectedSlot(); for (int i = 0; i < 9; i++) { ItemStack item = inventory.getItem(i); @@ -69,7 +70,13 @@ private void onBeforeAttack(BeforeAttackEvent event) { break; } } + if (axe == -1) return; + + prevSelectedSlot = inventory.getSelectedSlot(); + inventory.setSelectedSlot(axe); + ((MultiPlayerGameModeExtension) mc.gameMode).attackClone_CU(mc.player, entity); + } private void onAfterAttack() { @@ -77,5 +84,11 @@ private void onAfterAttack() { if (prevSelectedSlot == -1) return; inventory.setSelectedSlot(prevSelectedSlot); } + private void func1(BeforeAttackEvent event){ + Root.debug.write("Func 1 run"); + } + private void func2(BeforeAttackEvent event){ + Root.debug.write("Func 2 run"); + } } diff --git a/common/resources/web/components/automation/AutoStunner.html b/common/resources/web/components/automation/AutoStunner.html index 40e7ab55..c81c768b 100644 --- a/common/resources/web/components/automation/AutoStunner.html +++ b/common/resources/web/components/automation/AutoStunner.html @@ -1,6 +1,6 @@

- Automatically disables shield if you have an axe available and the target is holding a shield that would block your attack + Automatically disables shield if you have an axe available and the target is holding a shield that would block your attack
Module accounts for target look direction
diff --git a/common/resources/web/components/automation/AutoStunner.js b/common/resources/web/components/automation/AutoStunner.js index 5c3e8609..d70b5490 100644 --- a/common/resources/web/components/automation/AutoStunner.js +++ b/common/resources/web/components/automation/AutoStunner.js @@ -1,5 +1,5 @@ import { createSimpleComponent } from '/components/SimpleModule.js'; export function createComponent(template) { - return createSimpleComponent('/api/auto-hotbar', template); + return createSimpleComponent('/api/auto-stunner', template); } \ No newline at end of file From cb8597ae129bcf5a0b8c111e97a700197facec04 Mon Sep 17 00:00:00 2001 From: someRandomDude-a Date: Tue, 13 Jan 2026 07:50:38 +0530 Subject: [PATCH 07/17] updated methods to use priority --- .../common/MixinMultiPlayerGameMode.java | 1 + .../zergatul/cheatutils/modules/Modules.java | 13 ++++++----- .../modules/automation/AutoStunner.java | 22 +++---------------- .../modules/automation/BreachSwap.java | 4 +--- .../modules/automation/SpearRange.java | 3 +-- .../modules/hacks/AutoCriticals.java | 2 +- .../cheatutils/modules/hacks/KillAura.java | 13 ++++++----- 7 files changed, 22 insertions(+), 36 deletions(-) diff --git a/common/java/com/zergatul/cheatutils/mixins/common/MixinMultiPlayerGameMode.java b/common/java/com/zergatul/cheatutils/mixins/common/MixinMultiPlayerGameMode.java index db4f6850..828c8f3c 100644 --- a/common/java/com/zergatul/cheatutils/mixins/common/MixinMultiPlayerGameMode.java +++ b/common/java/com/zergatul/cheatutils/mixins/common/MixinMultiPlayerGameMode.java @@ -61,6 +61,7 @@ public abstract class MixinMultiPlayerGameMode implements MultiPlayerGameModeExt **/ public void attackClone_CU(Player player, Entity entity) { this.ensureHasSentCarriedItem(); + this.connection.send(ServerboundInteractPacket.createAttackPacket(entity, player.isShiftKeyDown())); if (this.localPlayerMode != GameType.SPECTATOR) { player.attack(entity); diff --git a/common/java/com/zergatul/cheatutils/modules/Modules.java b/common/java/com/zergatul/cheatutils/modules/Modules.java index 3b312492..fa14c4c6 100644 --- a/common/java/com/zergatul/cheatutils/modules/Modules.java +++ b/common/java/com/zergatul/cheatutils/modules/Modules.java @@ -25,11 +25,9 @@ public class Modules { public static void register() { - //Order dependent modules + //Order dependent modules -> legacy method, use Event.event.add(function, priority) for new modules, use the priority value instead //========================== - register(SpearRange.instance); - register(AutoStunner.instance); - register(BreachSwap.instance); + //=========================== register(FakeRotation.instance); @@ -91,8 +89,6 @@ public static void register() { register(AutoTool.instance); register(AirPlace.instance); - // should be after everything so "Don't Attack on Item Use" can work better - register(KillAura.instance); register(TickEndExecutor.instance); @@ -100,10 +96,15 @@ public static void register() { //========================================== register(AfterPlayerAiStepExecutor.instance); register(AfterSendPlayerPosExecutor.instance); + register(KillAura.instance); FontBackendHolders.add(StatusOverlay.instance); FontBackendHolders.add(EntityTitle.instance); FontBackendHolders.add(WorldMarkers.instance); + + register(SpearRange.instance); + register(AutoStunner.instance); + register(BreachSwap.instance); //=========================================== } diff --git a/common/java/com/zergatul/cheatutils/modules/automation/AutoStunner.java b/common/java/com/zergatul/cheatutils/modules/automation/AutoStunner.java index d4411be1..be75bc73 100644 --- a/common/java/com/zergatul/cheatutils/modules/automation/AutoStunner.java +++ b/common/java/com/zergatul/cheatutils/modules/automation/AutoStunner.java @@ -5,7 +5,6 @@ import com.zergatul.cheatutils.configs.ConfigStore; import com.zergatul.cheatutils.extensions.MultiPlayerGameModeExtension; import com.zergatul.cheatutils.modules.Module; -import com.zergatul.cheatutils.scripting.Root; import net.minecraft.client.Minecraft; import net.minecraft.tags.ItemTags; import net.minecraft.world.entity.Entity; @@ -19,12 +18,10 @@ public class AutoStunner implements Module { public static final AutoStunner instance = new AutoStunner(); private final Minecraft mc = Minecraft.getInstance(); - private Inventory inventory; - private static int prevSelectedSlot = -1; int axe = -1; AutoStunner() { - Events.AttackEventHandler(this::onBeforeAttack, this::onAfterAttack, 1); + Events.BeforeAttack.add(this::onBeforeAttack, 1); } private boolean isUsingShield(Entity entity) { @@ -44,7 +41,7 @@ private boolean isUsingShield(Entity entity) { private void onBeforeAttack(BeforeAttackEvent event) { if (!ConfigStore.instance.getConfig().autoStunnerConfig.enabled) return; - prevSelectedSlot = -1; + int prevSelectedSlot = -1; if (mc.hitResult.getType() != HitResult.Type.ENTITY) { return; @@ -61,7 +58,7 @@ private void onBeforeAttack(BeforeAttackEvent event) { return; } - inventory = mc.player.getInventory(); + Inventory inventory = mc.player.getInventory(); for (int i = 0; i < 9; i++) { ItemStack item = inventory.getItem(i); @@ -76,19 +73,6 @@ private void onBeforeAttack(BeforeAttackEvent event) { inventory.setSelectedSlot(axe); ((MultiPlayerGameModeExtension) mc.gameMode).attackClone_CU(mc.player, entity); - - } - - private void onAfterAttack() { - if (!ConfigStore.instance.getConfig().autoStunnerConfig.enabled) return; - if (prevSelectedSlot == -1) return; inventory.setSelectedSlot(prevSelectedSlot); } - private void func1(BeforeAttackEvent event){ - Root.debug.write("Func 1 run"); - } - private void func2(BeforeAttackEvent event){ - Root.debug.write("Func 2 run"); - } - } diff --git a/common/java/com/zergatul/cheatutils/modules/automation/BreachSwap.java b/common/java/com/zergatul/cheatutils/modules/automation/BreachSwap.java index 4e625a1f..dcfa4523 100644 --- a/common/java/com/zergatul/cheatutils/modules/automation/BreachSwap.java +++ b/common/java/com/zergatul/cheatutils/modules/automation/BreachSwap.java @@ -18,9 +18,7 @@ public class BreachSwap implements Module { private static int prevSelectedSlot = -1; private BreachSwap() { - - Events.BeforeAttack.add(this::onBeforeAttack); - Events.AfterAttack.add(this::onAfterAttack); + Events.AttackEventHandler(this::onBeforeAttack, this::onAfterAttack, 2); } private void onBeforeAttack(BeforeAttackEvent event) { diff --git a/common/java/com/zergatul/cheatutils/modules/automation/SpearRange.java b/common/java/com/zergatul/cheatutils/modules/automation/SpearRange.java index 7f45f2f0..dde4ba3e 100644 --- a/common/java/com/zergatul/cheatutils/modules/automation/SpearRange.java +++ b/common/java/com/zergatul/cheatutils/modules/automation/SpearRange.java @@ -17,8 +17,7 @@ public class SpearRange implements Module { int prevSelectedSlot = -1; private SpearRange() { - Events.BeforeAttack.add(this::onBeforeAttack); - Events.AfterAttack.add(this::onAfterAttack); + Events.AttackEventHandler(this::onBeforeAttack, this::onAfterAttack, 0); } public void onBeforeAttack(BeforeAttackEvent event) { diff --git a/common/java/com/zergatul/cheatutils/modules/hacks/AutoCriticals.java b/common/java/com/zergatul/cheatutils/modules/hacks/AutoCriticals.java index ff331fac..76964c22 100644 --- a/common/java/com/zergatul/cheatutils/modules/hacks/AutoCriticals.java +++ b/common/java/com/zergatul/cheatutils/modules/hacks/AutoCriticals.java @@ -17,7 +17,7 @@ public class AutoCriticals { private final Minecraft mc = Minecraft.getInstance(); private AutoCriticals() { - Events.BeforeAttack.add(this::onBeforeAttack); + Events.BeforeAttack.add(this::onBeforeAttack, -1); } private void onBeforeAttack(BeforeAttackEvent event) { diff --git a/common/java/com/zergatul/cheatutils/modules/hacks/KillAura.java b/common/java/com/zergatul/cheatutils/modules/hacks/KillAura.java index ed04bece..1d47afe3 100644 --- a/common/java/com/zergatul/cheatutils/modules/hacks/KillAura.java +++ b/common/java/com/zergatul/cheatutils/modules/hacks/KillAura.java @@ -35,11 +35,14 @@ public class KillAura implements Module { private KillAuraFunction script; private KillAura() { - Events.AfterPlayerAiStep.add(this::onAfterPlayerAiStep); - Events.AfterSendPlayerPos.add(this::onAfterSendPlayerPos); - Events.ClientTickStart.add(this::onClientTickStart); - Events.ClientPlayerLoggingIn.add(this::onPlayerLoggingIn); - Events.DimensionChange.add(this::onDimensionChange); + + // should be after everything so "Don't Attack on Item Use" can work better + int priority = Integer.MAX_VALUE; + Events.AfterPlayerAiStep.add(this::onAfterPlayerAiStep, priority); + Events.AfterSendPlayerPos.add(this::onAfterSendPlayerPos, priority); + Events.ClientTickStart.add(this::onClientTickStart, priority); + Events.ClientPlayerLoggingIn.add(this::onPlayerLoggingIn, priority); + Events.DimensionChange.add(this::onDimensionChange, priority); } public void onEnabled() { From 89679752e2888ff31285524c1d454c15c1458f72 Mon Sep 17 00:00:00 2001 From: someRandomDude-a Date: Sat, 17 Jan 2026 09:58:23 +0530 Subject: [PATCH 08/17] updating spearRange --- .../mixins/common/MixinLocalPlayer.java | 13 +++-- .../common/MixinMultiPlayerGameMode.java | 2 +- .../modules/automation/AutoStunner.java | 27 +++++----- .../modules/automation/BreachSwap.java | 2 +- .../modules/automation/SpearRange.java | 51 +++++++++++++------ .../scripting/modules/PlayerApi.java | 14 ++--- .../zergatul/cheatutils/utils/RayCast.java | 2 +- .../web/components/automation/BreachSwap.html | 2 + 8 files changed, 67 insertions(+), 46 deletions(-) diff --git a/common/java/com/zergatul/cheatutils/mixins/common/MixinLocalPlayer.java b/common/java/com/zergatul/cheatutils/mixins/common/MixinLocalPlayer.java index 624674fa..d8b0f418 100644 --- a/common/java/com/zergatul/cheatutils/mixins/common/MixinLocalPlayer.java +++ b/common/java/com/zergatul/cheatutils/mixins/common/MixinLocalPlayer.java @@ -2,7 +2,10 @@ import com.mojang.authlib.GameProfile; import com.zergatul.cheatutils.common.Events; -import com.zergatul.cheatutils.configs.*; +import com.zergatul.cheatutils.configs.ConfigStore; +import com.zergatul.cheatutils.configs.MovementHackConfig; +import com.zergatul.cheatutils.configs.ReachConfig; +import com.zergatul.cheatutils.configs.StepUpConfig; import com.zergatul.cheatutils.modules.hacks.ElytraFly; import com.zergatul.mixin.ExecuteAfterIfElseCondition; import com.zergatul.mixin.ModifyMethodReturnValue; @@ -147,9 +150,13 @@ public double entityInteractionRange() { ReachConfig config = ConfigStore.instance.getConfig().reachConfig; if (config.overrideAttackRange) { return config.attackRange; - } else { - return super.entityInteractionRange(); } + + if (ConfigStore.instance.getConfig().spearRangeConfig.isEnabled()) { + return 4.5; + } + + return super.entityInteractionRange(); } @Override diff --git a/common/java/com/zergatul/cheatutils/mixins/common/MixinMultiPlayerGameMode.java b/common/java/com/zergatul/cheatutils/mixins/common/MixinMultiPlayerGameMode.java index 828c8f3c..f883b8d1 100644 --- a/common/java/com/zergatul/cheatutils/mixins/common/MixinMultiPlayerGameMode.java +++ b/common/java/com/zergatul/cheatutils/mixins/common/MixinMultiPlayerGameMode.java @@ -53,7 +53,7 @@ public abstract class MixinMultiPlayerGameMode implements MultiPlayerGameModeExt * {@code void attack(Player player, Entity entity)} * method.
* This method will NOT trigger automations / events from the regular method.
- * intended to only be used internally to make modules that trigger on beforeAttackMethod + * intended to only be used internally to make modules that trigger on beforeAttackMethod.
* Should be used in this format:
* {@code ((MultiPlayerGameModeExtension) mc.gameMode).attackClone(mc.player, entity);} *

diff --git a/common/java/com/zergatul/cheatutils/modules/automation/AutoStunner.java b/common/java/com/zergatul/cheatutils/modules/automation/AutoStunner.java index be75bc73..b6adad8a 100644 --- a/common/java/com/zergatul/cheatutils/modules/automation/AutoStunner.java +++ b/common/java/com/zergatul/cheatutils/modules/automation/AutoStunner.java @@ -30,6 +30,7 @@ private boolean isUsingShield(Entity entity) { // Calculate if target is looking at us // Shields only block a 180 degree slice of a cylinder Vec3 shield = living.calculateViewVector(0.0F, living.getYHeadRot()); + assert mc.player != null; Vec3 player = mc.player.position().subtract(living.position()); player = (new Vec3(player.x, 0D, player.z)).normalize(); double dotProduct = player.dot(shield); @@ -41,22 +42,18 @@ private boolean isUsingShield(Entity entity) { private void onBeforeAttack(BeforeAttackEvent event) { if (!ConfigStore.instance.getConfig().autoStunnerConfig.enabled) return; - int prevSelectedSlot = -1; - if (mc.hitResult.getType() != HitResult.Type.ENTITY) { - return; - } + if (mc.hitResult == null) return; - Entity entity = ((EntityHitResult) mc.hitResult).getEntity(); - double reach = mc.player.entityInteractionRange(); + if (mc.hitResult.getType() != HitResult.Type.ENTITY) return; - if (reach * reach < mc.player.getEyePosition().distanceToSqr(mc.hitResult.getLocation())) { - return; - } + assert mc.player != null; + final double reach = 3; + if (reach * reach < mc.player.getEyePosition().distanceToSqr(mc.hitResult.getLocation())) return; - if (!isUsingShield(entity)) { - return; - } + + Entity entity = ((EntityHitResult) mc.hitResult).getEntity(); + if (!isUsingShield(entity)) return; Inventory inventory = mc.player.getInventory(); @@ -69,10 +66,12 @@ private void onBeforeAttack(BeforeAttackEvent event) { } if (axe == -1) return; - prevSelectedSlot = inventory.getSelectedSlot(); - + int prevSelectedSlot = inventory.getSelectedSlot(); inventory.setSelectedSlot(axe); + + assert mc.gameMode != null; ((MultiPlayerGameModeExtension) mc.gameMode).attackClone_CU(mc.player, entity); + inventory.setSelectedSlot(prevSelectedSlot); } } diff --git a/common/java/com/zergatul/cheatutils/modules/automation/BreachSwap.java b/common/java/com/zergatul/cheatutils/modules/automation/BreachSwap.java index dcfa4523..375aaa2c 100644 --- a/common/java/com/zergatul/cheatutils/modules/automation/BreachSwap.java +++ b/common/java/com/zergatul/cheatutils/modules/automation/BreachSwap.java @@ -39,7 +39,7 @@ private void onBeforeAttack(BeforeAttackEvent event) { return; } - double reach = mc.player.entityInteractionRange(); + final double reach = 3; if (reach * reach < mc.player.getEyePosition().distanceToSqr(mc.hitResult.getLocation())) { return; diff --git a/common/java/com/zergatul/cheatutils/modules/automation/SpearRange.java b/common/java/com/zergatul/cheatutils/modules/automation/SpearRange.java index dde4ba3e..cb2d4b18 100644 --- a/common/java/com/zergatul/cheatutils/modules/automation/SpearRange.java +++ b/common/java/com/zergatul/cheatutils/modules/automation/SpearRange.java @@ -3,21 +3,40 @@ import com.zergatul.cheatutils.common.Events; import com.zergatul.cheatutils.common.events.BeforeAttackEvent; import com.zergatul.cheatutils.configs.ConfigStore; +import com.zergatul.cheatutils.extensions.MultiPlayerGameModeExtension; import com.zergatul.cheatutils.modules.Module; import net.minecraft.client.Minecraft; +import net.minecraft.world.InteractionHand; import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.item.ItemStack; +import net.minecraft.world.phys.EntityHitResult; import static net.minecraft.core.component.DataComponents.ATTACK_RANGE; public class SpearRange implements Module { public static final SpearRange instance = new SpearRange(); private final Minecraft mc = Minecraft.getInstance(); - private Inventory inventory; int prevSelectedSlot = -1; + /** + * + * @param inventory player inventory + * @return returns position of spear in the hotbar. If no spear is present, returns -1 + */ + public final int spearPos(Inventory inventory) { + int spear = -1; + for (int i = 0; i < 9; i++) { + ItemStack item = inventory.getItem(i); + if (item.getComponents().stream().anyMatch(component -> component.type() == ATTACK_RANGE)) { + spear = i; + break; + } + } + return spear; + } + private SpearRange() { - Events.AttackEventHandler(this::onBeforeAttack, this::onAfterAttack, 0); + Events.BeforeAttack.add(this::onBeforeAttack, 0); } public void onBeforeAttack(BeforeAttackEvent event) { @@ -25,26 +44,28 @@ public void onBeforeAttack(BeforeAttackEvent event) { prevSelectedSlot = -1; if (mc.player == null) return; if (mc.player.isSpectator()) return; - inventory = mc.player.getInventory(); + Inventory inventory = mc.player.getInventory(); + + + //If already in range normally, do nothing + assert mc.hitResult != null; + final double reach = 3; + if (reach * reach > mc.player.getEyePosition().distanceToSqr(mc.hitResult.getLocation())) return; + + int spear = spearPos(inventory); - int spear = -1; - for (int i = 0; i < 9; i++) { - ItemStack item = inventory.getItem(i); - if (item.getComponents().stream().anyMatch(component -> component.type() == ATTACK_RANGE)) { - spear = i; - break; - } - } if (spear == -1) return; if (spear == prevSelectedSlot) return; prevSelectedSlot = inventory.getSelectedSlot(); inventory.setSelectedSlot(spear); - } - private void onAfterAttack() { - if (!ConfigStore.instance.getConfig().spearRangeConfig.enabled) return; - if (prevSelectedSlot == -1) return; + assert mc.gameMode != null; + ((MultiPlayerGameModeExtension) mc.gameMode).attackClone_CU(mc.player, ((EntityHitResult) mc.hitResult).getEntity()); + mc.player.swing(InteractionHand.MAIN_HAND); + inventory.setSelectedSlot(prevSelectedSlot); + + event.cancel(); } } diff --git a/common/java/com/zergatul/cheatutils/scripting/modules/PlayerApi.java b/common/java/com/zergatul/cheatutils/scripting/modules/PlayerApi.java index f3c12284..b47f2523 100644 --- a/common/java/com/zergatul/cheatutils/scripting/modules/PlayerApi.java +++ b/common/java/com/zergatul/cheatutils/scripting/modules/PlayerApi.java @@ -4,17 +4,12 @@ import com.zergatul.cheatutils.controllers.SpeedCounterController; import com.zergatul.cheatutils.mixins.common.accessors.LocalPlayerAccessor; import com.zergatul.cheatutils.mixins.common.accessors.MultiPlayerGameModeAccessor; -import com.zergatul.cheatutils.scripting.ApiVisibility; import com.zergatul.cheatutils.scripting.ApiType; +import com.zergatul.cheatutils.scripting.ApiVisibility; +import com.zergatul.cheatutils.scripting.types.BlockPosWrapper; import com.zergatul.cheatutils.scripting.types.HitResultWrapper; import com.zergatul.cheatutils.scripting.types.Position3d; -import com.zergatul.cheatutils.scripting.types.BlockPosWrapper; -import com.zergatul.cheatutils.utils.InputBuilder; -import com.zergatul.cheatutils.utils.NearbyBlockEnumerator; -import com.zergatul.cheatutils.utils.RayCast; -import com.zergatul.cheatutils.utils.Rotation; -import com.zergatul.cheatutils.utils.RotationUtils; -import com.zergatul.cheatutils.scripting.modules.GameApi; +import com.zergatul.cheatutils.utils.*; import com.zergatul.scripting.MethodDescription; import net.minecraft.client.Minecraft; import net.minecraft.client.player.LocalPlayer; @@ -36,15 +31,12 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.levelgen.structure.BoundingBox; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.EntityHitResult; import net.minecraft.world.phys.HitResult; import net.minecraft.world.phys.Vec3; -import net.minecraft.world.phys.AABB; import java.util.Comparator; -import java.util.List; import java.util.Locale; import java.util.stream.Stream; import java.util.stream.StreamSupport; diff --git a/common/java/com/zergatul/cheatutils/utils/RayCast.java b/common/java/com/zergatul/cheatutils/utils/RayCast.java index 10471b2b..3cec72e9 100644 --- a/common/java/com/zergatul/cheatutils/utils/RayCast.java +++ b/common/java/com/zergatul/cheatutils/utils/RayCast.java @@ -138,7 +138,7 @@ private static boolean isValidPosition(Entity target, double range, Vec3 origin, } if (entityHit.getEntity() == target) { - //Only accept point if block collision is further then entity collision + //Only accept point if block collision is further than entity collision if (entityHit.getLocation().distanceToSqr(origin) <= maxDistSqr) { return true; } diff --git a/common/resources/web/components/automation/BreachSwap.html b/common/resources/web/components/automation/BreachSwap.html index 83699165..5d7496ba 100644 --- a/common/resources/web/components/automation/BreachSwap.html +++ b/common/resources/web/components/automation/BreachSwap.html @@ -5,4 +5,6 @@
Enabled +
+
\ No newline at end of file From 3489f12652531879e9c76f0b02196671c56f9d33 Mon Sep 17 00:00:00 2001 From: someRandomDude-a Date: Sun, 18 Jan 2026 23:08:37 +0530 Subject: [PATCH 09/17] implemented spear range and updated modules for better anti-cheat compatibility --- .../zergatul/cheatutils/common/Events.java | 4 +++ .../mixins/common/MixinLocalPlayer.java | 8 ++--- .../mixins/common/MixinMinecraft.java | 12 +++++++ .../modules/automation/AutoAttack.java | 2 ++ .../modules/automation/AutoStunner.java | 7 +--- .../modules/automation/BreachSwap.java | 7 ---- .../modules/automation/SpearRange.java | 36 ++++++++----------- 7 files changed, 35 insertions(+), 41 deletions(-) diff --git a/common/java/com/zergatul/cheatutils/common/Events.java b/common/java/com/zergatul/cheatutils/common/Events.java index 40ff850e..14f65ad1 100644 --- a/common/java/com/zergatul/cheatutils/common/Events.java +++ b/common/java/com/zergatul/cheatutils/common/Events.java @@ -2,6 +2,7 @@ import com.zergatul.cheatutils.common.events.*; import com.zergatul.cheatutils.controllers.SnapshotChunk; +import net.minecraft.WorldVersion; import net.minecraft.client.DeltaTracker; import net.minecraft.core.BlockPos; import net.minecraft.network.Connection; @@ -73,6 +74,9 @@ public class Events { public static final CancelableEventHandler SendChat = new CancelableEventHandler<>(); public static final CancelableEventHandler BeforeAttack = new CancelableEventHandler<>(); public static final SimpleEventHandler AfterAttack = new SimpleEventHandler(); + public static final SimpleEventHandler BeforeStartAttack = new SimpleEventHandler(); + public static final SimpleEventHandler AfterStartAttack = new SimpleEventHandler(); + public static final ParameterizedEventHandler EntityInteract = new ParameterizedEventHandler<>(); public static final ParameterizedEventHandler BeforeInstaMine = new ParameterizedEventHandler<>(); public static final SimpleEventHandler WindowResize = new SimpleEventHandler(); diff --git a/common/java/com/zergatul/cheatutils/mixins/common/MixinLocalPlayer.java b/common/java/com/zergatul/cheatutils/mixins/common/MixinLocalPlayer.java index d8b0f418..18aa4aca 100644 --- a/common/java/com/zergatul/cheatutils/mixins/common/MixinLocalPlayer.java +++ b/common/java/com/zergatul/cheatutils/mixins/common/MixinLocalPlayer.java @@ -150,13 +150,9 @@ public double entityInteractionRange() { ReachConfig config = ConfigStore.instance.getConfig().reachConfig; if (config.overrideAttackRange) { return config.attackRange; + } else { + return super.entityInteractionRange(); } - - if (ConfigStore.instance.getConfig().spearRangeConfig.isEnabled()) { - return 4.5; - } - - return super.entityInteractionRange(); } @Override diff --git a/common/java/com/zergatul/cheatutils/mixins/common/MixinMinecraft.java b/common/java/com/zergatul/cheatutils/mixins/common/MixinMinecraft.java index 171b5ad6..72292267 100644 --- a/common/java/com/zergatul/cheatutils/mixins/common/MixinMinecraft.java +++ b/common/java/com/zergatul/cheatutils/mixins/common/MixinMinecraft.java @@ -37,6 +37,16 @@ public abstract class MixinMinecraft { @Shadow public abstract boolean isGameLoadFinished(); + @Inject(at = @At("HEAD"), method = "startAttack") + private void onBeforeStartAttack(CallbackInfoReturnable cir) { + Events.BeforeStartAttack.trigger(); + } + @Inject(at = @At("RETURN"), method = "startAttack") + private void onAfterStartAttack(CallbackInfoReturnable cir) { + Events.AfterStartAttack.trigger(); + } + + @Inject(at = @At("HEAD"), method = "shouldEntityAppearGlowing(Lnet/minecraft/world/entity/Entity;)Z", cancellable = true) public void onShouldEntityAppearGlowing(Entity entity, CallbackInfoReturnable info) { if (EntityEsp.instance.shouldEntityGlow(entity)) { @@ -67,6 +77,8 @@ private void onCreateTitle(CallbackInfoReturnable info) { } } + + @Inject(at = @At("HEAD"), method = "tick()V") private void onBeforeTick(CallbackInfo info) { if (this.isGameLoadFinished()) { diff --git a/common/java/com/zergatul/cheatutils/modules/automation/AutoAttack.java b/common/java/com/zergatul/cheatutils/modules/automation/AutoAttack.java index 31355287..554a56e3 100644 --- a/common/java/com/zergatul/cheatutils/modules/automation/AutoAttack.java +++ b/common/java/com/zergatul/cheatutils/modules/automation/AutoAttack.java @@ -55,6 +55,8 @@ private void onClientTickEnd() { nextExtraTicks = Integer.MIN_VALUE; + + Entity entity = ((EntityHitResult) mc.hitResult).getEntity(); mc.gameMode.attack(mc.player, entity); mc.player.swing(InteractionHand.MAIN_HAND); diff --git a/common/java/com/zergatul/cheatutils/modules/automation/AutoStunner.java b/common/java/com/zergatul/cheatutils/modules/automation/AutoStunner.java index b6adad8a..72fc239b 100644 --- a/common/java/com/zergatul/cheatutils/modules/automation/AutoStunner.java +++ b/common/java/com/zergatul/cheatutils/modules/automation/AutoStunner.java @@ -32,7 +32,7 @@ private boolean isUsingShield(Entity entity) { Vec3 shield = living.calculateViewVector(0.0F, living.getYHeadRot()); assert mc.player != null; Vec3 player = mc.player.position().subtract(living.position()); - player = (new Vec3(player.x, 0D, player.z)).normalize(); + player = (new Vec3(player.x, 0D, player.z)); double dotProduct = player.dot(shield); return dotProduct >= 0; } @@ -47,11 +47,6 @@ private void onBeforeAttack(BeforeAttackEvent event) { if (mc.hitResult.getType() != HitResult.Type.ENTITY) return; - assert mc.player != null; - final double reach = 3; - if (reach * reach < mc.player.getEyePosition().distanceToSqr(mc.hitResult.getLocation())) return; - - Entity entity = ((EntityHitResult) mc.hitResult).getEntity(); if (!isUsingShield(entity)) return; diff --git a/common/java/com/zergatul/cheatutils/modules/automation/BreachSwap.java b/common/java/com/zergatul/cheatutils/modules/automation/BreachSwap.java index 375aaa2c..576b40c5 100644 --- a/common/java/com/zergatul/cheatutils/modules/automation/BreachSwap.java +++ b/common/java/com/zergatul/cheatutils/modules/automation/BreachSwap.java @@ -39,13 +39,6 @@ private void onBeforeAttack(BeforeAttackEvent event) { return; } - final double reach = 3; - - if (reach * reach < mc.player.getEyePosition().distanceToSqr(mc.hitResult.getLocation())) { - return; - } - - int mace = -1; inventory = mc.player.getInventory(); diff --git a/common/java/com/zergatul/cheatutils/modules/automation/SpearRange.java b/common/java/com/zergatul/cheatutils/modules/automation/SpearRange.java index cb2d4b18..3f484acb 100644 --- a/common/java/com/zergatul/cheatutils/modules/automation/SpearRange.java +++ b/common/java/com/zergatul/cheatutils/modules/automation/SpearRange.java @@ -1,15 +1,12 @@ package com.zergatul.cheatutils.modules.automation; import com.zergatul.cheatutils.common.Events; -import com.zergatul.cheatutils.common.events.BeforeAttackEvent; import com.zergatul.cheatutils.configs.ConfigStore; -import com.zergatul.cheatutils.extensions.MultiPlayerGameModeExtension; import com.zergatul.cheatutils.modules.Module; import net.minecraft.client.Minecraft; -import net.minecraft.world.InteractionHand; import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.item.ItemStack; -import net.minecraft.world.phys.EntityHitResult; +import net.minecraft.world.phys.HitResult; import static net.minecraft.core.component.DataComponents.ATTACK_RANGE; @@ -36,36 +33,31 @@ public final int spearPos(Inventory inventory) { } private SpearRange() { - Events.BeforeAttack.add(this::onBeforeAttack, 0); + Events.BeforeStartAttack.add(this::onBeforeStartAttack, 0); + Events.AfterStartAttack.add(this::onAfterStartAttack, 0); } - public void onBeforeAttack(BeforeAttackEvent event) { + public void onBeforeStartAttack() { if (!ConfigStore.instance.getConfig().spearRangeConfig.enabled) return; prevSelectedSlot = -1; if (mc.player == null) return; if (mc.player.isSpectator()) return; - Inventory inventory = mc.player.getInventory(); - - - //If already in range normally, do nothing - assert mc.hitResult != null; - final double reach = 3; - if (reach * reach > mc.player.getEyePosition().distanceToSqr(mc.hitResult.getLocation())) return; + if (mc.hitResult.getType() == HitResult.Type.ENTITY) return; + Inventory inventory = mc.player.getInventory(); int spear = spearPos(inventory); - if (spear == -1) return; - if (spear == prevSelectedSlot) return; + if (spear == inventory.getSelectedSlot()) return; prevSelectedSlot = inventory.getSelectedSlot(); inventory.setSelectedSlot(spear); + } - assert mc.gameMode != null; - ((MultiPlayerGameModeExtension) mc.gameMode).attackClone_CU(mc.player, ((EntityHitResult) mc.hitResult).getEntity()); - mc.player.swing(InteractionHand.MAIN_HAND); - - inventory.setSelectedSlot(prevSelectedSlot); - - event.cancel(); + public void onAfterStartAttack() { + if (mc.player == null) return; + if (!ConfigStore.instance.getConfig().spearRangeConfig.enabled) return; + if (prevSelectedSlot == -1) return; + mc.player.getInventory().setSelectedSlot(prevSelectedSlot); + prevSelectedSlot = -1; } } From f50710f2f8376e3799ff0342249c960a4dba19eb Mon Sep 17 00:00:00 2001 From: someRandomDude-a Date: Mon, 19 Jan 2026 13:09:28 +0530 Subject: [PATCH 10/17] updated autoAttack implementation to use "boolean startAttack()" method which is more in-line with user intention --- .../zergatul/cheatutils/common/Events.java | 10 +++++--- .../extensions/MinecraftExtension.java | 5 ++++ .../mixins/common/MixinMinecraft.java | 25 +++++++++++++++---- .../modules/automation/AutoAttack.java | 8 +++--- .../scripting/modules/SpearRangeApi.java | 14 +++++++++++ 5 files changed, 48 insertions(+), 14 deletions(-) create mode 100644 common/java/com/zergatul/cheatutils/extensions/MinecraftExtension.java diff --git a/common/java/com/zergatul/cheatutils/common/Events.java b/common/java/com/zergatul/cheatutils/common/Events.java index 14f65ad1..774987a0 100644 --- a/common/java/com/zergatul/cheatutils/common/Events.java +++ b/common/java/com/zergatul/cheatutils/common/Events.java @@ -72,10 +72,6 @@ public class Events { public static final SimpleEventHandler PostRenderTooltip = new SimpleEventHandler(); public static final ParameterizedEventHandler AfterScreenRendered = new ParameterizedEventHandler<>(); public static final CancelableEventHandler SendChat = new CancelableEventHandler<>(); - public static final CancelableEventHandler BeforeAttack = new CancelableEventHandler<>(); - public static final SimpleEventHandler AfterAttack = new SimpleEventHandler(); - public static final SimpleEventHandler BeforeStartAttack = new SimpleEventHandler(); - public static final SimpleEventHandler AfterStartAttack = new SimpleEventHandler(); public static final ParameterizedEventHandler EntityInteract = new ParameterizedEventHandler<>(); public static final ParameterizedEventHandler BeforeInstaMine = new ParameterizedEventHandler<>(); @@ -88,6 +84,12 @@ public class Events { public static final CancelableEventHandler PlayerTurnByMouse = new CancelableEventHandler<>(); public static final ParameterizedEventHandler PlayerInfoUpdated = new ParameterizedEventHandler<>(); + //Attack Events ====================== + public static final CancelableEventHandler BeforeAttack = new CancelableEventHandler<>(); + public static final SimpleEventHandler AfterAttack = new SimpleEventHandler(); + public static final SimpleEventHandler BeforeStartAttack = new SimpleEventHandler(); + public static final SimpleEventHandler AfterStartAttack = new SimpleEventHandler(); + //===================================== /** * binds 2 functions to the beforeAttack and afterAttack event respectively. * Tries to ensure that the order of module execution is preserved
diff --git a/common/java/com/zergatul/cheatutils/extensions/MinecraftExtension.java b/common/java/com/zergatul/cheatutils/extensions/MinecraftExtension.java new file mode 100644 index 00000000..8cf6be5d --- /dev/null +++ b/common/java/com/zergatul/cheatutils/extensions/MinecraftExtension.java @@ -0,0 +1,5 @@ +package com.zergatul.cheatutils.extensions; + +public interface MinecraftExtension { + void runStartAttack_CU(); +} diff --git a/common/java/com/zergatul/cheatutils/mixins/common/MixinMinecraft.java b/common/java/com/zergatul/cheatutils/mixins/common/MixinMinecraft.java index 72292267..e95946c5 100644 --- a/common/java/com/zergatul/cheatutils/mixins/common/MixinMinecraft.java +++ b/common/java/com/zergatul/cheatutils/mixins/common/MixinMinecraft.java @@ -2,11 +2,12 @@ import com.zergatul.cheatutils.common.Events; import com.zergatul.cheatutils.configs.ConfigStore; -import com.zergatul.cheatutils.modules.hacks.AirPlace; -import com.zergatul.cheatutils.modules.scripting.BlockAutomation; +import com.zergatul.cheatutils.extensions.MinecraftExtension; import com.zergatul.cheatutils.modules.automation.VillagerRoller; import com.zergatul.cheatutils.modules.esp.EntityEsp; +import com.zergatul.cheatutils.modules.hacks.AirPlace; import com.zergatul.cheatutils.modules.hacks.InvMove; +import com.zergatul.cheatutils.modules.scripting.BlockAutomation; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.multiplayer.ClientLevel; @@ -23,7 +24,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(Minecraft.class) -public abstract class MixinMinecraft { +public abstract class MixinMinecraft implements MinecraftExtension { @Shadow public LocalPlayer player; @@ -37,15 +38,30 @@ public abstract class MixinMinecraft { @Shadow public abstract boolean isGameLoadFinished(); + @Shadow + protected abstract boolean startAttack(); + + /** + * This method will trigger automations / events from the regular method.
+ * intended to only be used internally to make modules that trigger on beforeAttackStartMethod.
+ * Should be used in this format:
+ * {@code ((MinecraftExtension) mc).runStartAttack_CU();} + **/ + public void runStartAttack_CU() { + this.startAttack(); + } + + //Start Attack method, event triggers ================================== @Inject(at = @At("HEAD"), method = "startAttack") private void onBeforeStartAttack(CallbackInfoReturnable cir) { Events.BeforeStartAttack.trigger(); } + @Inject(at = @At("RETURN"), method = "startAttack") private void onAfterStartAttack(CallbackInfoReturnable cir) { Events.AfterStartAttack.trigger(); } - + //======================================================================== @Inject(at = @At("HEAD"), method = "shouldEntityAppearGlowing(Lnet/minecraft/world/entity/Entity;)Z", cancellable = true) public void onShouldEntityAppearGlowing(Entity entity, CallbackInfoReturnable info) { @@ -78,7 +94,6 @@ private void onCreateTitle(CallbackInfoReturnable info) { } - @Inject(at = @At("HEAD"), method = "tick()V") private void onBeforeTick(CallbackInfo info) { if (this.isGameLoadFinished()) { diff --git a/common/java/com/zergatul/cheatutils/modules/automation/AutoAttack.java b/common/java/com/zergatul/cheatutils/modules/automation/AutoAttack.java index 554a56e3..53dfdaac 100644 --- a/common/java/com/zergatul/cheatutils/modules/automation/AutoAttack.java +++ b/common/java/com/zergatul/cheatutils/modules/automation/AutoAttack.java @@ -3,6 +3,8 @@ import com.zergatul.cheatutils.common.Events; import com.zergatul.cheatutils.configs.AutoAttackConfig; import com.zergatul.cheatutils.configs.ConfigStore; +import com.zergatul.cheatutils.extensions.MinecraftExtension; +import com.zergatul.cheatutils.mixins.common.MixinMinecraft; import com.zergatul.cheatutils.modules.Module; import net.minecraft.client.Minecraft; import net.minecraft.world.InteractionHand; @@ -55,11 +57,7 @@ private void onClientTickEnd() { nextExtraTicks = Integer.MIN_VALUE; - - - Entity entity = ((EntityHitResult) mc.hitResult).getEntity(); - mc.gameMode.attack(mc.player, entity); - mc.player.swing(InteractionHand.MAIN_HAND); + ((MinecraftExtension) mc).runStartAttack_CU(); } private void calculateNextExtraTicksIfRequired(AutoAttackConfig config) { diff --git a/common/java/com/zergatul/cheatutils/scripting/modules/SpearRangeApi.java b/common/java/com/zergatul/cheatutils/scripting/modules/SpearRangeApi.java index f6aa19be..858bbc88 100644 --- a/common/java/com/zergatul/cheatutils/scripting/modules/SpearRangeApi.java +++ b/common/java/com/zergatul/cheatutils/scripting/modules/SpearRangeApi.java @@ -2,6 +2,11 @@ import com.zergatul.cheatutils.configs.SpearRangeConfig; import com.zergatul.cheatutils.configs.ConfigStore; +import com.zergatul.cheatutils.modules.automation.SpearRange; +import com.zergatul.cheatutils.scripting.ApiType; +import com.zergatul.cheatutils.scripting.ApiVisibility; +import com.zergatul.scripting.MethodDescription; +import net.minecraft.client.Minecraft; public class SpearRangeApi extends ModuleApi { @@ -10,4 +15,13 @@ public class SpearRangeApi extends ModuleApi { protected SpearRangeConfig getConfig() { return ConfigStore.instance.getConfig().spearRangeConfig; } + + @MethodDescription(""" + Returns the position of FIRST spear in the hotbar. + If no spear is present, returns -1 + """) + @ApiVisibility(ApiType.ACTION) + public int getSpearPosition(){ + return SpearRange.instance.spearPos(Minecraft.getInstance().player.getInventory()); + } } \ No newline at end of file From 315ec301ab62784df6e412986c4fa14485decc0e Mon Sep 17 00:00:00 2001 From: someRandomDude-a Date: Mon, 19 Jan 2026 19:25:24 +0530 Subject: [PATCH 11/17] resolving review comments --- README.md | 12 +++---- .../modules/automation/AutoStunner.java | 35 ++++++++++--------- .../modules/automation/SpearRange.java | 5 +-- .../modules/hacks/AutoCriticals.java | 2 ++ .../scripting/modules/SpearRangeApi.java | 16 +-------- common/resources/web/Web Examples.md | 10 +++--- 6 files changed, 36 insertions(+), 44 deletions(-) diff --git a/README.md b/README.md index f2878964..e397db7e 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Zergatul Cheat Utils +# Cheat Utils ## Warning @@ -89,10 +89,10 @@ public class ClassNameConfig extends ModuleConfig implements ValidatableConfig { add your config validation inside the `validate()` function, this is where you will add limits to your variables, for example clampign the range of a value. If your API will be accessible from the scripting, it is highly recomended to include validation for any variables. -##### Note:- - -* in case if your module does not require validation, you can skip `implements ValidatableConfig` and the overriden `public void validate()` function. When doing this, also skip adding validation to [`Root.java`](#adding-a-module-to-the-mod--) -* If your module does not require enable / disable, you can skip `extends ModuleConfig` as well. This also means you cannot use the `enabled` boolean or the `isEnabled()` inherited functions. Keep this in mind when creating the website / code for it. +>[!NOTE] +> In case if your module does not require validation, you can skip `implements ValidatableConfig` and the overriden `public void validate()` function. When doing this, also skip adding validation to [`Root.java`](#adding-a-module-to-the-mod--) +> +> If your module does not require enable / disable, you can skip `extends ModuleConfig` as well. This also means you cannot use the `enabled` boolean or the `isEnabled()` inherited functions. Keep this in mind when creating the website / code for it. you can also add any more functions or values to change here. for example: @@ -119,7 +119,7 @@ Add your config to the class public ClassNameConfig classNameConfig = new ClassNameConfig(); ``` -##### Now, navigate to `configStore.java`, located in the same directory and add this line +Now, navigate to `configStore.java`, located in the same directory and add these lines ```java private void onConfigLoaded() { diff --git a/common/java/com/zergatul/cheatutils/modules/automation/AutoStunner.java b/common/java/com/zergatul/cheatutils/modules/automation/AutoStunner.java index 72fc239b..efea3560 100644 --- a/common/java/com/zergatul/cheatutils/modules/automation/AutoStunner.java +++ b/common/java/com/zergatul/cheatutils/modules/automation/AutoStunner.java @@ -18,28 +18,12 @@ public class AutoStunner implements Module { public static final AutoStunner instance = new AutoStunner(); private final Minecraft mc = Minecraft.getInstance(); - int axe = -1; + private int axe = -1; AutoStunner() { Events.BeforeAttack.add(this::onBeforeAttack, 1); } - private boolean isUsingShield(Entity entity) { - if (entity instanceof LivingEntity living) { - if (living.isBlocking()) { - // Calculate if target is looking at us - // Shields only block a 180 degree slice of a cylinder - Vec3 shield = living.calculateViewVector(0.0F, living.getYHeadRot()); - assert mc.player != null; - Vec3 player = mc.player.position().subtract(living.position()); - player = (new Vec3(player.x, 0D, player.z)); - double dotProduct = player.dot(shield); - return dotProduct >= 0; - } - } - return false; - } - private void onBeforeAttack(BeforeAttackEvent event) { if (!ConfigStore.instance.getConfig().autoStunnerConfig.enabled) return; @@ -69,4 +53,21 @@ private void onBeforeAttack(BeforeAttackEvent event) { inventory.setSelectedSlot(prevSelectedSlot); } + + + private boolean isUsingShield(Entity entity) { + if (entity instanceof LivingEntity living) { + if (living.isBlocking()) { + // Calculate if target is looking at us + // Shields only block a 180 degree slice of a cylinder + Vec3 shield = living.calculateViewVector(0.0F, living.getYHeadRot()); + assert mc.player != null; + Vec3 player = mc.player.position().subtract(living.position()); + player = (new Vec3(player.x, 0D, player.z)); + double dotProduct = player.dot(shield); + return dotProduct >= 0; + } + } + return false; + } } diff --git a/common/java/com/zergatul/cheatutils/modules/automation/SpearRange.java b/common/java/com/zergatul/cheatutils/modules/automation/SpearRange.java index 3f484acb..3aa9ba6d 100644 --- a/common/java/com/zergatul/cheatutils/modules/automation/SpearRange.java +++ b/common/java/com/zergatul/cheatutils/modules/automation/SpearRange.java @@ -13,14 +13,14 @@ public class SpearRange implements Module { public static final SpearRange instance = new SpearRange(); private final Minecraft mc = Minecraft.getInstance(); - int prevSelectedSlot = -1; + private int prevSelectedSlot = -1; /** * * @param inventory player inventory * @return returns position of spear in the hotbar. If no spear is present, returns -1 */ - public final int spearPos(Inventory inventory) { + private int spearPos(Inventory inventory) { int spear = -1; for (int i = 0; i < 9; i++) { ItemStack item = inventory.getItem(i); @@ -32,6 +32,7 @@ public final int spearPos(Inventory inventory) { return spear; } + private SpearRange() { Events.BeforeStartAttack.add(this::onBeforeStartAttack, 0); Events.AfterStartAttack.add(this::onAfterStartAttack, 0); diff --git a/common/java/com/zergatul/cheatutils/modules/hacks/AutoCriticals.java b/common/java/com/zergatul/cheatutils/modules/hacks/AutoCriticals.java index 76964c22..53958a27 100644 --- a/common/java/com/zergatul/cheatutils/modules/hacks/AutoCriticals.java +++ b/common/java/com/zergatul/cheatutils/modules/hacks/AutoCriticals.java @@ -35,6 +35,8 @@ private void onBeforeAttack(BeforeAttackEvent event) { return; } // Hard Conditions not met, cannot do anything about it + // Refer to `Player.class` -> boolean canCriticalAttack(Entity entity) + // Refer to `Player.class` -> void attack(Entity entity) if (!((mc.player.getAttackStrengthScale(0.5F) > 0.9F) && (!mc.player.onClimbable() && !mc.player.isInWater() && !mc.player.isMobilityRestricted() && !mc.player.isPassenger() diff --git a/common/java/com/zergatul/cheatutils/scripting/modules/SpearRangeApi.java b/common/java/com/zergatul/cheatutils/scripting/modules/SpearRangeApi.java index 858bbc88..34bdffbf 100644 --- a/common/java/com/zergatul/cheatutils/scripting/modules/SpearRangeApi.java +++ b/common/java/com/zergatul/cheatutils/scripting/modules/SpearRangeApi.java @@ -1,12 +1,7 @@ package com.zergatul.cheatutils.scripting.modules; -import com.zergatul.cheatutils.configs.SpearRangeConfig; import com.zergatul.cheatutils.configs.ConfigStore; -import com.zergatul.cheatutils.modules.automation.SpearRange; -import com.zergatul.cheatutils.scripting.ApiType; -import com.zergatul.cheatutils.scripting.ApiVisibility; -import com.zergatul.scripting.MethodDescription; -import net.minecraft.client.Minecraft; +import com.zergatul.cheatutils.configs.SpearRangeConfig; public class SpearRangeApi extends ModuleApi { @@ -15,13 +10,4 @@ public class SpearRangeApi extends ModuleApi { protected SpearRangeConfig getConfig() { return ConfigStore.instance.getConfig().spearRangeConfig; } - - @MethodDescription(""" - Returns the position of FIRST spear in the hotbar. - If no spear is present, returns -1 - """) - @ApiVisibility(ApiType.ACTION) - public int getSpearPosition(){ - return SpearRange.instance.spearPos(Minecraft.getInstance().player.getInventory()); - } } \ No newline at end of file diff --git a/common/resources/web/Web Examples.md b/common/resources/web/Web Examples.md index 5978398a..b79f4014 100644 --- a/common/resources/web/Web Examples.md +++ b/common/resources/web/Web Examples.md @@ -2,9 +2,9 @@ ## Explanation:- -### `v-model="config.VariableName"` This defines the variable to be modified. +- `v-model="config.VariableName"` This defines the variable to be modified. -### `@change="update()"` This defines the function to be run on value change +- `@change="update()"` This defines the function to be run on value change ### [Website uses Vue components](https://vuejs.org/guide/introduction.html) @@ -15,11 +15,13 @@ ```html Enabled ``` -boolean output + +#### boolean output ### Text Box ```html ``` -typecast output to the variable type \ No newline at end of file + +#### typecast output to the variable type From 25729b7fa790a7e68a16e62d7ce59dc994fc5d5b Mon Sep 17 00:00:00 2001 From: someRandomDude-a Date: Tue, 20 Jan 2026 19:42:15 +0530 Subject: [PATCH 12/17] updated runStartAttack_CU to use @Invoker --- .../cheatutils/extensions/MinecraftExtension.java | 5 ----- .../cheatutils/mixins/common/MixinMinecraft.java | 15 +-------------- .../common/accessors/MinecraftAccessor.java | 9 +++++++++ .../cheatutils/modules/automation/AutoAttack.java | 8 ++------ .../cheatutils/modules/hacks/KillAura.java | 2 +- common/resources/web/Web Examples.md | 2 +- 6 files changed, 14 insertions(+), 27 deletions(-) delete mode 100644 common/java/com/zergatul/cheatutils/extensions/MinecraftExtension.java diff --git a/common/java/com/zergatul/cheatutils/extensions/MinecraftExtension.java b/common/java/com/zergatul/cheatutils/extensions/MinecraftExtension.java deleted file mode 100644 index 8cf6be5d..00000000 --- a/common/java/com/zergatul/cheatutils/extensions/MinecraftExtension.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.zergatul.cheatutils.extensions; - -public interface MinecraftExtension { - void runStartAttack_CU(); -} diff --git a/common/java/com/zergatul/cheatutils/mixins/common/MixinMinecraft.java b/common/java/com/zergatul/cheatutils/mixins/common/MixinMinecraft.java index e95946c5..0698bdf5 100644 --- a/common/java/com/zergatul/cheatutils/mixins/common/MixinMinecraft.java +++ b/common/java/com/zergatul/cheatutils/mixins/common/MixinMinecraft.java @@ -2,7 +2,6 @@ import com.zergatul.cheatutils.common.Events; import com.zergatul.cheatutils.configs.ConfigStore; -import com.zergatul.cheatutils.extensions.MinecraftExtension; import com.zergatul.cheatutils.modules.automation.VillagerRoller; import com.zergatul.cheatutils.modules.esp.EntityEsp; import com.zergatul.cheatutils.modules.hacks.AirPlace; @@ -24,7 +23,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(Minecraft.class) -public abstract class MixinMinecraft implements MinecraftExtension { +public abstract class MixinMinecraft { @Shadow public LocalPlayer player; @@ -38,18 +37,6 @@ public abstract class MixinMinecraft implements MinecraftExtension { @Shadow public abstract boolean isGameLoadFinished(); - @Shadow - protected abstract boolean startAttack(); - - /** - * This method will trigger automations / events from the regular method.
- * intended to only be used internally to make modules that trigger on beforeAttackStartMethod.
- * Should be used in this format:
- * {@code ((MinecraftExtension) mc).runStartAttack_CU();} - **/ - public void runStartAttack_CU() { - this.startAttack(); - } //Start Attack method, event triggers ================================== @Inject(at = @At("HEAD"), method = "startAttack") diff --git a/common/java/com/zergatul/cheatutils/mixins/common/accessors/MinecraftAccessor.java b/common/java/com/zergatul/cheatutils/mixins/common/accessors/MinecraftAccessor.java index 85d6882a..8fa69a31 100644 --- a/common/java/com/zergatul/cheatutils/mixins/common/accessors/MinecraftAccessor.java +++ b/common/java/com/zergatul/cheatutils/mixins/common/accessors/MinecraftAccessor.java @@ -11,6 +11,15 @@ public interface MinecraftAccessor { @Invoker("startUseItem") void startUseItem_CU(); + /** + * This method will trigger automations / events from the regular method.
+ * intended to only be used internally to make modules that trigger on beforeAttackStartMethod.
+ * Should be used in this format:
+ * {@code ((MinecraftExtension) mc).runStartAttack_CU();} + **/ + @Invoker("startAttack") + boolean runStartAttack_CU(); + @Accessor("clientTickCount") long getClientTickCount_CU(); } \ No newline at end of file diff --git a/common/java/com/zergatul/cheatutils/modules/automation/AutoAttack.java b/common/java/com/zergatul/cheatutils/modules/automation/AutoAttack.java index 53dfdaac..f6fac566 100644 --- a/common/java/com/zergatul/cheatutils/modules/automation/AutoAttack.java +++ b/common/java/com/zergatul/cheatutils/modules/automation/AutoAttack.java @@ -3,13 +3,9 @@ import com.zergatul.cheatutils.common.Events; import com.zergatul.cheatutils.configs.AutoAttackConfig; import com.zergatul.cheatutils.configs.ConfigStore; -import com.zergatul.cheatutils.extensions.MinecraftExtension; -import com.zergatul.cheatutils.mixins.common.MixinMinecraft; +import com.zergatul.cheatutils.mixins.common.accessors.MinecraftAccessor; import com.zergatul.cheatutils.modules.Module; import net.minecraft.client.Minecraft; -import net.minecraft.world.InteractionHand; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.phys.EntityHitResult; import net.minecraft.world.phys.HitResult; public class AutoAttack implements Module { @@ -57,7 +53,7 @@ private void onClientTickEnd() { nextExtraTicks = Integer.MIN_VALUE; - ((MinecraftExtension) mc).runStartAttack_CU(); + ((MinecraftAccessor) mc).runStartAttack_CU(); } private void calculateNextExtraTicksIfRequired(AutoAttackConfig config) { diff --git a/common/java/com/zergatul/cheatutils/modules/hacks/KillAura.java b/common/java/com/zergatul/cheatutils/modules/hacks/KillAura.java index 1d47afe3..6e286bec 100644 --- a/common/java/com/zergatul/cheatutils/modules/hacks/KillAura.java +++ b/common/java/com/zergatul/cheatutils/modules/hacks/KillAura.java @@ -37,7 +37,7 @@ public class KillAura implements Module { private KillAura() { // should be after everything so "Don't Attack on Item Use" can work better - int priority = Integer.MAX_VALUE; + int priority = 1000; Events.AfterPlayerAiStep.add(this::onAfterPlayerAiStep, priority); Events.AfterSendPlayerPos.add(this::onAfterSendPlayerPos, priority); Events.ClientTickStart.add(this::onClientTickStart, priority); diff --git a/common/resources/web/Web Examples.md b/common/resources/web/Web Examples.md index b79f4014..cdfb42d8 100644 --- a/common/resources/web/Web Examples.md +++ b/common/resources/web/Web Examples.md @@ -24,4 +24,4 @@ ``` -#### typecast output to the variable type +#### Parses output to the variable type From 98e39dcb75fed0b600d05afb0c6fb23dd6cd0835 Mon Sep 17 00:00:00 2001 From: someRandomDude-a Date: Tue, 20 Jan 2026 19:53:24 +0530 Subject: [PATCH 13/17] Update README.md --- README.md | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index e397db7e..6c3979b9 100644 --- a/README.md +++ b/README.md @@ -33,15 +33,18 @@ This is where most of your modules code will be written. First, navigate to the modules folder located in `common/java/com/zergatul/cheatutils/modules`. Select the folder that best fits your module type. -Create a new file : `"ClassName.java"`. +from here on, we will refer to a theoretical module named "AutoPearl", however you should follow the same naming conventions + +Create a new file : `"AutoPearl.java"`. + the class should be in this format: ```java import com.zergatul.cheatutils.modules.Module; -public class ClassName implements Module { - public static final ClassName instance = new ClassName(); - ClassName(){ +public class AutoPearl implements Module { + public static final AutoPearl instance = new AutoPearl(); + AutoPearl(){ } } @@ -49,14 +52,14 @@ public class ClassName implements Module { #### Step 2 -For the purposes of this explaination, it is assumed your mod is named as "ClassName" +For the purposes of this explaination, it is assumed your module is named as "AutoPearl" Register your module in the mod. Navigate to `Modules.java` in the same directory. Add your module to the following function ```java public static void register() { - register(ClassName.instance); + register(AutoPearl.instance); } ``` @@ -68,14 +71,14 @@ Add your configuration class Navigate to `common/java/com/zergatul/cheatutils/configs` -create a new file `ClassNameConfig.java` +create a new file `AutoPearlConfig.java` ```java package com.zergatul.cheatutils.configs; -public class ClassNameConfig extends ModuleConfig implements ValidatableConfig { +public class AutoPearlConfig extends ModuleConfig implements ValidatableConfig { - ClassNameConfig() { + AutoPearlConfig() { } @@ -108,7 +111,7 @@ The API directly changes variables. an example of a minimal config which does not need validation or enable variable: ```java - public class ClassNameConfig {} + public class AutoPearlConfig {} ``` Next, navigate to `Config.java`, located in the same directory. @@ -116,7 +119,7 @@ Next, navigate to `Config.java`, located in the same directory. Add your config to the class ```java - public ClassNameConfig classNameConfig = new ClassNameConfig(); + public AutoPearlConfig classNameConfig = new AutoPearlConfig(); ``` Now, navigate to `configStore.java`, located in the same directory and add these lines @@ -130,21 +133,21 @@ Now, navigate to `configStore.java`, located in the same directory and add these Adding the module API for the website to work with. Navigate to `common/java/com/zergatul/cheatutils/scripting/modules/` -make a new file `ClassNameConfig.java` +make a new file `AutoPearlConfig.java` add these lines ```java package com.zergatul.cheatutils.scripting.modules; -import com.zergatul.cheatutils.configs.ClassNameConfig; +import com.zergatul.cheatutils.configs.AutoPearlConfig; import com.zergatul.cheatutils.configs.ConfigStore; -public class ClassNameApi extends ModuleApi { +public class AutoPearlApi extends ModuleApi { @Override - protected ClassNameConfig getConfig() { + protected AutoPearlConfig getConfig() { return ConfigStore.instance.getConfig().classNameconfig; } } @@ -159,7 +162,7 @@ Navigate to `common/java/com/zergatul/cheatutils/scripting/Root.java` Add the following lines inside the Root class. ```java -public static ClassNameApi className = new ClassNameApi(); +public static AutoPearlApi className = new AutoPearlApi(); ``` This step is OPTIONAL and not required for module to function. @@ -178,7 +181,7 @@ Add your module under line 21 with the following format: module({ group: 'automation', name: 'Display Name', - component: 'ClassName', + component: 'AutoPearl', path: 'class-name', tags: ['search', 'terms', 'identifers'] }); @@ -203,8 +206,8 @@ next, navigate to the relevant folder for your module from the available folders Create 2 new files: -* ClassName.js -* ClassName.html +* AutoPearl.js +* AutoPearl.html inside the javascript file, add the following: From 3dc15847e01c9310cb3306a8b4798c1704122e06 Mon Sep 17 00:00:00 2001 From: someRandomDude-a Date: Wed, 21 Jan 2026 20:04:38 +0530 Subject: [PATCH 14/17] fixing potential bugs --- .../cheatutils/mixins/common/MixinMultiPlayerGameMode.java | 7 +++---- .../cheatutils/modules/automation/AutoStunner.java | 4 ++++ .../zergatul/cheatutils/modules/automation/BreachSwap.java | 2 +- .../zergatul/cheatutils/modules/automation/SpearRange.java | 3 ++- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/common/java/com/zergatul/cheatutils/mixins/common/MixinMultiPlayerGameMode.java b/common/java/com/zergatul/cheatutils/mixins/common/MixinMultiPlayerGameMode.java index f883b8d1..c7cf703f 100644 --- a/common/java/com/zergatul/cheatutils/mixins/common/MixinMultiPlayerGameMode.java +++ b/common/java/com/zergatul/cheatutils/mixins/common/MixinMultiPlayerGameMode.java @@ -25,7 +25,6 @@ import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @@ -55,9 +54,9 @@ public abstract class MixinMultiPlayerGameMode implements MultiPlayerGameModeExt * This method will NOT trigger automations / events from the regular method.
* intended to only be used internally to make modules that trigger on beforeAttackMethod.
* Should be used in this format:
- * {@code ((MultiPlayerGameModeExtension) mc.gameMode).attackClone(mc.player, entity);} - *

- * If you see this comment, you are not using the correct syntax. Make sure to cast the call first! + * {@code ((MultiPlayerGameModeExtension) mc.gameMode).attackClone(mc.player, entity);} + *

+ * If you see this comment, you are not using the correct syntax. Make sure to cast the call first! **/ public void attackClone_CU(Player player, Entity entity) { this.ensureHasSentCarriedItem(); diff --git a/common/java/com/zergatul/cheatutils/modules/automation/AutoStunner.java b/common/java/com/zergatul/cheatutils/modules/automation/AutoStunner.java index efea3560..82962509 100644 --- a/common/java/com/zergatul/cheatutils/modules/automation/AutoStunner.java +++ b/common/java/com/zergatul/cheatutils/modules/automation/AutoStunner.java @@ -27,6 +27,8 @@ public class AutoStunner implements Module { private void onBeforeAttack(BeforeAttackEvent event) { if (!ConfigStore.instance.getConfig().autoStunnerConfig.enabled) return; + if (mc.player == null) return; + if (mc.hitResult == null) return; if (mc.hitResult.getType() != HitResult.Type.ENTITY) return; @@ -36,6 +38,7 @@ private void onBeforeAttack(BeforeAttackEvent event) { Inventory inventory = mc.player.getInventory(); + for (int i = 0; i < 9; i++) { ItemStack item = inventory.getItem(i); if (item.getTags().anyMatch(tag -> tag == ItemTags.AXES)) { @@ -52,6 +55,7 @@ private void onBeforeAttack(BeforeAttackEvent event) { ((MultiPlayerGameModeExtension) mc.gameMode).attackClone_CU(mc.player, entity); inventory.setSelectedSlot(prevSelectedSlot); + axe = -1; } diff --git a/common/java/com/zergatul/cheatutils/modules/automation/BreachSwap.java b/common/java/com/zergatul/cheatutils/modules/automation/BreachSwap.java index 576b40c5..98c401ed 100644 --- a/common/java/com/zergatul/cheatutils/modules/automation/BreachSwap.java +++ b/common/java/com/zergatul/cheatutils/modules/automation/BreachSwap.java @@ -15,7 +15,7 @@ public class BreachSwap implements Module { private final Minecraft mc = Minecraft.getInstance(); private Inventory inventory; - private static int prevSelectedSlot = -1; + private int prevSelectedSlot = -1; private BreachSwap() { Events.AttackEventHandler(this::onBeforeAttack, this::onAfterAttack, 2); diff --git a/common/java/com/zergatul/cheatutils/modules/automation/SpearRange.java b/common/java/com/zergatul/cheatutils/modules/automation/SpearRange.java index 3aa9ba6d..f9c27f61 100644 --- a/common/java/com/zergatul/cheatutils/modules/automation/SpearRange.java +++ b/common/java/com/zergatul/cheatutils/modules/automation/SpearRange.java @@ -43,6 +43,7 @@ public void onBeforeStartAttack() { prevSelectedSlot = -1; if (mc.player == null) return; if (mc.player.isSpectator()) return; + if (mc.hitResult == null) return; if (mc.hitResult.getType() == HitResult.Type.ENTITY) return; Inventory inventory = mc.player.getInventory(); @@ -55,8 +56,8 @@ public void onBeforeStartAttack() { } public void onAfterStartAttack() { - if (mc.player == null) return; if (!ConfigStore.instance.getConfig().spearRangeConfig.enabled) return; + if (mc.player == null) return; if (prevSelectedSlot == -1) return; mc.player.getInventory().setSelectedSlot(prevSelectedSlot); prevSelectedSlot = -1; From 8a1c2f1ce7c479aa9a0f8088baafb1c9debf15f9 Mon Sep 17 00:00:00 2001 From: someRandomDude-a Date: Thu, 22 Jan 2026 17:09:45 +0530 Subject: [PATCH 15/17] fixed bug in rayCast code, updated spearRange module with new option --- .../cheatutils/configs/SpearRangeConfig.java | 1 + .../common/accessors/MinecraftAccessor.java | 2 +- .../modules/automation/AutoAttack.java | 2 +- .../modules/automation/AutoStunner.java | 4 +- .../modules/automation/SpearRange.java | 93 +++++++++++++++---- .../zergatul/cheatutils/utils/RayCast.java | 13 +-- .../web/components/automation/SpearRange.html | 3 +- common/resources/web/modules.js | 30 +++--- 8 files changed, 100 insertions(+), 48 deletions(-) diff --git a/common/java/com/zergatul/cheatutils/configs/SpearRangeConfig.java b/common/java/com/zergatul/cheatutils/configs/SpearRangeConfig.java index 9f8063b4..13c2f997 100644 --- a/common/java/com/zergatul/cheatutils/configs/SpearRangeConfig.java +++ b/common/java/com/zergatul/cheatutils/configs/SpearRangeConfig.java @@ -1,4 +1,5 @@ package com.zergatul.cheatutils.configs; public class SpearRangeConfig extends ModuleConfig { + public boolean lungeWithoutTarget; } \ No newline at end of file diff --git a/common/java/com/zergatul/cheatutils/mixins/common/accessors/MinecraftAccessor.java b/common/java/com/zergatul/cheatutils/mixins/common/accessors/MinecraftAccessor.java index 8fa69a31..601252b3 100644 --- a/common/java/com/zergatul/cheatutils/mixins/common/accessors/MinecraftAccessor.java +++ b/common/java/com/zergatul/cheatutils/mixins/common/accessors/MinecraftAccessor.java @@ -18,7 +18,7 @@ public interface MinecraftAccessor { * {@code ((MinecraftExtension) mc).runStartAttack_CU();} **/ @Invoker("startAttack") - boolean runStartAttack_CU(); + boolean startAttack_CU(); @Accessor("clientTickCount") long getClientTickCount_CU(); diff --git a/common/java/com/zergatul/cheatutils/modules/automation/AutoAttack.java b/common/java/com/zergatul/cheatutils/modules/automation/AutoAttack.java index f6fac566..ad485e1a 100644 --- a/common/java/com/zergatul/cheatutils/modules/automation/AutoAttack.java +++ b/common/java/com/zergatul/cheatutils/modules/automation/AutoAttack.java @@ -53,7 +53,7 @@ private void onClientTickEnd() { nextExtraTicks = Integer.MIN_VALUE; - ((MinecraftAccessor) mc).runStartAttack_CU(); + ((MinecraftAccessor) mc).startAttack_CU(); } private void calculateNextExtraTicksIfRequired(AutoAttackConfig config) { diff --git a/common/java/com/zergatul/cheatutils/modules/automation/AutoStunner.java b/common/java/com/zergatul/cheatutils/modules/automation/AutoStunner.java index 82962509..b3b6d99e 100644 --- a/common/java/com/zergatul/cheatutils/modules/automation/AutoStunner.java +++ b/common/java/com/zergatul/cheatutils/modules/automation/AutoStunner.java @@ -18,7 +18,6 @@ public class AutoStunner implements Module { public static final AutoStunner instance = new AutoStunner(); private final Minecraft mc = Minecraft.getInstance(); - private int axe = -1; AutoStunner() { Events.BeforeAttack.add(this::onBeforeAttack, 1); @@ -38,7 +37,7 @@ private void onBeforeAttack(BeforeAttackEvent event) { Inventory inventory = mc.player.getInventory(); - + int axe = -1; for (int i = 0; i < 9; i++) { ItemStack item = inventory.getItem(i); if (item.getTags().anyMatch(tag -> tag == ItemTags.AXES)) { @@ -55,7 +54,6 @@ private void onBeforeAttack(BeforeAttackEvent event) { ((MultiPlayerGameModeExtension) mc.gameMode).attackClone_CU(mc.player, entity); inventory.setSelectedSlot(prevSelectedSlot); - axe = -1; } diff --git a/common/java/com/zergatul/cheatutils/modules/automation/SpearRange.java b/common/java/com/zergatul/cheatutils/modules/automation/SpearRange.java index f9c27f61..4d4c71dc 100644 --- a/common/java/com/zergatul/cheatutils/modules/automation/SpearRange.java +++ b/common/java/com/zergatul/cheatutils/modules/automation/SpearRange.java @@ -5,8 +5,10 @@ import com.zergatul.cheatutils.modules.Module; import net.minecraft.client.Minecraft; import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.entity.projectile.ProjectileUtil; import net.minecraft.world.item.ItemStack; -import net.minecraft.world.phys.HitResult; +import net.minecraft.world.level.ClipContext; +import net.minecraft.world.phys.*; import static net.minecraft.core.component.DataComponents.ATTACK_RANGE; @@ -15,23 +17,6 @@ public class SpearRange implements Module { private final Minecraft mc = Minecraft.getInstance(); private int prevSelectedSlot = -1; - /** - * - * @param inventory player inventory - * @return returns position of spear in the hotbar. If no spear is present, returns -1 - */ - private int spearPos(Inventory inventory) { - int spear = -1; - for (int i = 0; i < 9; i++) { - ItemStack item = inventory.getItem(i); - if (item.getComponents().stream().anyMatch(component -> component.type() == ATTACK_RANGE)) { - spear = i; - break; - } - } - return spear; - } - private SpearRange() { Events.BeforeStartAttack.add(this::onBeforeStartAttack, 0); @@ -44,13 +29,20 @@ public void onBeforeStartAttack() { if (mc.player == null) return; if (mc.player.isSpectator()) return; if (mc.hitResult == null) return; - if (mc.hitResult.getType() == HitResult.Type.ENTITY) return; + if (mc.hitResult.getType() != HitResult.Type.MISS) return; Inventory inventory = mc.player.getInventory(); int spear = spearPos(inventory); if (spear == -1) return; if (spear == inventory.getSelectedSlot()) return; + //Check for valid target before executing + if (!ConfigStore.instance.getConfig().spearRangeConfig.lungeWithoutTarget) { + if (!hasValidTarget(inventory.getItem(spear))) { + return; + } + } + prevSelectedSlot = inventory.getSelectedSlot(); inventory.setSelectedSlot(spear); } @@ -62,4 +54,67 @@ public void onAfterStartAttack() { mc.player.getInventory().setSelectedSlot(prevSelectedSlot); prevSelectedSlot = -1; } + + /** + * + * @param inventory player inventory + * @return returns position of spear in the hotbar. If no spear is present, returns -1 + */ + private int spearPos(Inventory inventory) { + int spear = -1; + for (int i = 0; i < 9; i++) { + ItemStack item = inventory.getItem(i); + if (item.getComponents().stream().anyMatch(component -> component.type() == ATTACK_RANGE)) { + spear = i; + break; + } + } + return spear; + } + + private boolean hasValidTarget(ItemStack spear) { + assert mc.level != null; + assert mc.player != null; + double maxDist = spear.getComponents().get(ATTACK_RANGE).effectiveMaxRange(mc.player); + double maxDistSqr = maxDist * maxDist; + + Vec3 origin = mc.player.getEyePosition(); + Vec3 point = mc.player.getLookAngle().scale(maxDist).add(origin); + + ClipContext levelClip = new ClipContext( + origin, + point, + ClipContext.Block.COLLIDER, + ClipContext.Fluid.NONE, + mc.player + ); + + BlockHitResult blockHit = mc.level.clip(levelClip); + + if (blockHit.getType() != HitResult.Type.MISS) { + maxDistSqr = blockHit.getLocation().distanceToSqr(origin);//Limit max range after + } //to compare with entity hit test + + AABB searchBox = mc.player.getBoundingBox().expandTowards(point.subtract(origin)).inflate(1); + + EntityHitResult entityHit = ProjectileUtil.getEntityHitResult( + mc.player, + origin, + point, + searchBox, + e -> e != mc.player && e != mc.player.getVehicle(), + maxDistSqr + ); + + if (entityHit == null) { + return false; + } + + if (entityHit.getType() != EntityHitResult.Type.MISS) { + //Only accept point if block collision is further than entity collision + return true; + } + return false; + } + } diff --git a/common/java/com/zergatul/cheatutils/utils/RayCast.java b/common/java/com/zergatul/cheatutils/utils/RayCast.java index 3cec72e9..cfb02ac2 100644 --- a/common/java/com/zergatul/cheatutils/utils/RayCast.java +++ b/common/java/com/zergatul/cheatutils/utils/RayCast.java @@ -119,18 +119,18 @@ private static boolean isValidPosition(Entity target, double range, Vec3 origin, maxDistSqr = blockHit.getLocation().distanceToSqr(origin);//Limit max range after } //to compare with entity hit test - Vec3 end = point.subtract(origin).normalize().scale(range).add(origin);//Calculate a ray in that direction, with length range + Vec3 end = point.subtract(origin).normalize().scale(range);//Calculate a ray in that direction, with length range //This is required, otherwise point remains on entity surface and never contains the target entity in searchBox - AABB searchBox = new AABB(origin, end); + AABB searchBox = mc.player.getBoundingBox().expandTowards(end).inflate(1); EntityHitResult entityHit = ProjectileUtil.getEntityHitResult( mc.player, origin, - end, + end.add(origin), searchBox, e -> e != mc.player && e != mc.player.getVehicle(), - range + maxDistSqr ); if (entityHit == null) { @@ -138,10 +138,7 @@ private static boolean isValidPosition(Entity target, double range, Vec3 origin, } if (entityHit.getEntity() == target) { - //Only accept point if block collision is further than entity collision - if (entityHit.getLocation().distanceToSqr(origin) <= maxDistSqr) { - return true; - } + return true; } return false; } diff --git a/common/resources/web/components/automation/SpearRange.html b/common/resources/web/components/automation/SpearRange.html index 9d25644d..6b044057 100644 --- a/common/resources/web/components/automation/SpearRange.html +++ b/common/resources/web/components/automation/SpearRange.html @@ -4,7 +4,8 @@
- Enabled + Enabled
+ Lunge Without Target?
\ No newline at end of file diff --git a/common/resources/web/modules.js b/common/resources/web/modules.js index 376215ad..a1e982bc 100644 --- a/common/resources/web/modules.js +++ b/common/resources/web/modules.js @@ -18,21 +18,6 @@ const module = (params) => { modules[params.group][params.component] = params; }; //Automation Modules ================= -module({ - group: 'automation', - name: 'Spear Range', - component: 'SpearRange', - path: 'spear-range', - tags: ['spear', 'reach', 'range'] -}); - -module({ - group: 'automation', - name: 'Shield breaker', - component: 'AutoStunner', - path: 'auto-stunner', - tags: ['stun', 'shield', 'break', 'auto'] -}); module({ group: 'automation', name: 'Auto Disconnect', @@ -131,6 +116,21 @@ module({ path: 'auto-tool', tags: ['auto', 'tool'] }); +module({ + group: 'automation', + name: 'Spear Range', + component: 'SpearRange', + path: 'spear-range', + tags: ['spear', 'reach', 'range'] +}); + +module({ + group: 'automation', + name: 'Shield breaker', + component: 'AutoStunner', + path: 'auto-stunner', + tags: ['stun', 'shield', 'break', 'auto'] +}); //ESP modules ====================== From ca37603ae1b8ba230458755b9559acd26b0be6cd Mon Sep 17 00:00:00 2001 From: someRandomDude-a Date: Fri, 23 Jan 2026 05:35:10 +0530 Subject: [PATCH 16/17] added description to spearRange html, added check for already held spear in the game --- .../cheatutils/modules/automation/SpearRange.java | 6 ++++-- .../resources/web/components/automation/SpearRange.html | 9 ++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/common/java/com/zergatul/cheatutils/modules/automation/SpearRange.java b/common/java/com/zergatul/cheatutils/modules/automation/SpearRange.java index 4d4c71dc..a8819240 100644 --- a/common/java/com/zergatul/cheatutils/modules/automation/SpearRange.java +++ b/common/java/com/zergatul/cheatutils/modules/automation/SpearRange.java @@ -34,7 +34,6 @@ public void onBeforeStartAttack() { Inventory inventory = mc.player.getInventory(); int spear = spearPos(inventory); if (spear == -1) return; - if (spear == inventory.getSelectedSlot()) return; //Check for valid target before executing if (!ConfigStore.instance.getConfig().spearRangeConfig.lungeWithoutTarget) { @@ -61,10 +60,13 @@ public void onAfterStartAttack() { * @return returns position of spear in the hotbar. If no spear is present, returns -1 */ private int spearPos(Inventory inventory) { + if (inventory.getSelectedItem().getComponents().has(ATTACK_RANGE)) { + return -1; + } int spear = -1; for (int i = 0; i < 9; i++) { ItemStack item = inventory.getItem(i); - if (item.getComponents().stream().anyMatch(component -> component.type() == ATTACK_RANGE)) { + if (item.getComponents().has(ATTACK_RANGE)) { spear = i; break; } diff --git a/common/resources/web/components/automation/SpearRange.html b/common/resources/web/components/automation/SpearRange.html index 6b044057..44bcf7a1 100644 --- a/common/resources/web/components/automation/SpearRange.html +++ b/common/resources/web/components/automation/SpearRange.html @@ -5,7 +5,14 @@
Enabled
- Lunge Without Target?
+
+ + Lunge Without Target + +
+ When Enabled, allows you to use the spear to lunge without having a target. This allows bypassing the cooldown of the spear. +
+
\ No newline at end of file From f8584350f869ef1d5f85cdf435337b384231c216 Mon Sep 17 00:00:00 2001 From: someRandomDude-a Date: Fri, 23 Jan 2026 21:08:17 +0530 Subject: [PATCH 17/17] updated breachSwap code with minor logic improvement, clarified RADME file --- README.md | 2 +- .../com/zergatul/cheatutils/modules/automation/BreachSwap.java | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 6c3979b9..e1a55ce7 100644 --- a/README.md +++ b/README.md @@ -238,7 +238,7 @@ export function createComponent(template) { This guide will focus on the working, for style and other formatting / component usage, look at the html of other modules already implemented -your html file should look like this: +your barebones html file should look like this: ```html
diff --git a/common/java/com/zergatul/cheatutils/modules/automation/BreachSwap.java b/common/java/com/zergatul/cheatutils/modules/automation/BreachSwap.java index 98c401ed..77c86b53 100644 --- a/common/java/com/zergatul/cheatutils/modules/automation/BreachSwap.java +++ b/common/java/com/zergatul/cheatutils/modules/automation/BreachSwap.java @@ -26,7 +26,6 @@ private void onBeforeAttack(BeforeAttackEvent event) { if (!ConfigStore.instance.getConfig().breachSwapConfig.enabled) { return; } - prevSelectedSlot = -1; if (mc.player == null) { return; } @@ -63,7 +62,7 @@ private void onAfterAttack() { if (!ConfigStore.instance.getConfig().breachSwapConfig.enabled) return; if (prevSelectedSlot == -1) return; inventory.setSelectedSlot(prevSelectedSlot); + prevSelectedSlot = -1; } - } \ No newline at end of file