Skip to content

Commit

Permalink
Better AimAssist. Also new ListSettings. A bit of refactoring. More e…
Browse files Browse the repository at this point in the history
…asing type. 1.8 sword animations. Also speed mine
  • Loading branch information
tanishisherewithhh committed Jun 23, 2024
1 parent 8c07825 commit 80cd3ec
Show file tree
Hide file tree
Showing 42 changed files with 1,484 additions and 199 deletions.
78 changes: 57 additions & 21 deletions src/main/java/dev/heliosclient/hud/HudElement.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,28 @@ public class HudElement implements ISettingChange, ISaveAndLoad, Listener {
public SettingGroup sgUI = new SettingGroup("UI");
public boolean isInHudEditor = false;
public UniqueID id;
int startX, startY, snapSize = 120;


// Default settings
// This is a lot of complete customisation.
// Todo: Add radius setting for rounded background

public BooleanSetting renderBg = sgUI.add(new BooleanSetting.Builder()
.name("Render background")
.description("Render the background for the element")
.value(false)
.defaultValue(false)
.onSettingChange(this)
.build());
public BooleanSetting rounded = sgUI.add(new BooleanSetting.Builder()
.name("Rounded background")
.description("Rounds the background of the element for better visuals")
.value(false)
.defaultValue(false)
.onSettingChange(this)
.shouldRender(() -> renderBg.value)
.build());
public BooleanSetting clientColorCycle = sgUI.add(new BooleanSetting.Builder()
.name("Client Color Cycle")
.description("Use the client default color cycle for the background of the element")
Expand All @@ -93,14 +107,6 @@ public class HudElement implements ISettingChange, ISaveAndLoad, Listener {
.shouldRender(() -> renderBg.value)
.onSettingChange(this)
.build());
public BooleanSetting rounded = sgUI.add(new BooleanSetting.Builder()
.name("Rounded background")
.description("Rounds the background of the element for better visuals")
.value(false)
.defaultValue(false)
.onSettingChange(this)
.shouldRender(() -> renderBg.value)
.build());
public BooleanSetting shadow = sgUI.add(new BooleanSetting.Builder()
.name("Shadow")
.description("Shadow for the background of the element")
Expand All @@ -109,10 +115,34 @@ public class HudElement implements ISettingChange, ISaveAndLoad, Listener {
.onSettingChange(this)
.shouldRender(() -> renderBg.value)
.build());
int startX, startY, snapSize = 120;
public DoubleSetting shadowRadius = sgUI.add(new DoubleSetting.Builder()
.name("Shadow Radius")
.description("Radius of the shadow")
.min(0)
.max(50)
.defaultValue(5D)
.shouldRender(() -> shadow.value && renderBg.value)
.onSettingChange(this)
.build());

public BooleanSetting syncShadowColorAsBackground = sgUI.add(new BooleanSetting.Builder()
.name("Sync Background color to shadow")
.description("Syncs shadow color with background color")
.defaultValue(true)
.onSettingChange(this)
.shouldRender(() -> shadow.value && renderBg.value)
.build());
public RGBASetting shadowColor = sgUI.add(new RGBASetting.Builder()
.name("Shadow Color")
.description("Render the shadow for the element")
.value(new Color(4, 3, 3, 157))
.defaultValue(new Color(4, 3, 3, 157))
.shouldRender(() -> shadow.value && !syncShadowColorAsBackground.value && renderBg.value)
.onSettingChange(this)
.build());


public HudElement(HudElementData hudElementInfo) {
public HudElement(HudElementData<?> hudElementInfo) {
this.name = hudElementInfo.name();
this.description = hudElementInfo.description();
this.id = UniqueID.generate();
Expand Down Expand Up @@ -286,21 +316,27 @@ public void renderElement(DrawContext drawContext, TextRenderer textRenderer) {
bgEnd = bgStart;
}
Color blended = ColorUtils.blend(bgStart, bgEnd, 1 / 2f);
Color finalShadowColor = syncShadowColorAsBackground.value ? blended : shadowColor.value;

if (rounded.value && !shadow.value) {
Renderer2D.drawRoundedGradientRectangle(drawContext.getMatrices().peek().getPositionMatrix(), bgStart, bgEnd, bgEnd, bgStart, hudBox.getX(), hudBox.getY(), hudBox.getWidth() - 1.9f, hudBox.getHeight(), 2);
} else if (!shadow.value) {
Renderer2D.drawGradient(drawContext.getMatrices().peek().getPositionMatrix(), hudBox.getX(), hudBox.getY(), hudBox.getWidth() - 1.9f, hudBox.getHeight(), bgStart.getRGB(), bgEnd.getRGB(), Renderer2D.Direction.LEFT_RIGHT);
}
drawBackground(drawContext, bgStart, bgEnd, finalShadowColor);

if (rounded.value && shadow.value) {
Renderer2D.drawRoundedGradientRectangleWithShadow(drawContext.getMatrices(), hudBox.getX(), hudBox.getY(), hudBox.getWidth() - 1.9f, hudBox.getHeight(), bgStart, bgEnd, bgEnd, bgStart, 2, 4, blended);
drawContext.getMatrices().pop();
}
}

private void drawBackground(DrawContext drawContext, Color bgStart, Color bgEnd, Color finalShadowColor) {
if (rounded.value) {
if (shadow.value) {
Renderer2D.drawRoundedGradientRectangleWithShadow(drawContext.getMatrices(), hudBox.getX(), hudBox.getY(), hudBox.getWidth() - 1.9f, hudBox.getHeight(), bgStart, bgEnd, bgEnd, bgStart, 2, (int)shadowRadius.value, finalShadowColor);
} else {
Renderer2D.drawRoundedGradientRectangle(drawContext.getMatrices().peek().getPositionMatrix(), bgStart, bgEnd, bgEnd, bgStart, hudBox.getX(), hudBox.getY(), hudBox.getWidth() - 1.9f, hudBox.getHeight(), 2);
}
if (!rounded.value && shadow.value) {
Renderer2D.drawGradientWithShadow(drawContext.getMatrices(), hudBox.getX(), hudBox.getY(), hudBox.getWidth() - 1.9f, hudBox.getHeight(), 4, bgStart.getRGB(), bgEnd.getRGB(), Renderer2D.Direction.LEFT_RIGHT);
} else {
if (shadow.value) {
Renderer2D.drawGradientWithShadow(drawContext.getMatrices(), hudBox.getX(), hudBox.getY(), hudBox.getWidth() - 1.9f, hudBox.getHeight(), (int)shadowRadius.value, bgStart.getRGB(), bgEnd.getRGB(), finalShadowColor, Renderer2D.Direction.LEFT_RIGHT);
} else {
Renderer2D.drawGradient(drawContext.getMatrices().peek().getPositionMatrix(), hudBox.getX(), hudBox.getY(), hudBox.getWidth() - 1.9f, hudBox.getHeight(), bgStart.getRGB(), bgEnd.getRGB(), Renderer2D.Direction.LEFT_RIGHT);
}

drawContext.getMatrices().pop();
}
}

Expand Down
19 changes: 6 additions & 13 deletions src/main/java/dev/heliosclient/managers/EventManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@
import org.luaj.vm2.lib.jse.CoerceJavaToLua;

import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.concurrent.*;

public class EventManager {
Expand All @@ -34,12 +31,10 @@ public static void register(Listener listener) {
if (method.isAnnotationPresent(SubscribeEvent.class) && method.getParameterCount() == 1) {
Class<?> eventType = method.getParameterTypes()[0];
EventListener eventListener = new EventListener(listener, method);
List<EventListener> eventListeners = getListeners(eventType);
synchronized (eventListeners) {
eventListeners.add(eventListener);
if (eventListeners.size() > 1) {
eventListeners.sort(METHOD_COMPARATOR);
}
List<EventListener> eventListeners = getListeners(eventType);
eventListeners.add(eventListener);
if (eventListeners.size() > 1) {
eventListeners.sort(METHOD_COMPARATOR);
}
}
}
Expand All @@ -51,10 +46,8 @@ private static List<EventListener> getListeners(Class<?> eventClass) {


public static void unregister(Listener listener) {
for (List<EventListener> eventListeners : listeners.values()) {
synchronized (eventListeners) {
for (List<EventListener> eventListeners : new CopyOnWriteArraySet<>(listeners.values())) {
eventListeners.removeIf(el -> el.listener.getClass() == listener.getClass());
}
}
}

Expand Down
6 changes: 4 additions & 2 deletions src/main/java/dev/heliosclient/managers/ModuleManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public static void init() {
// World
registerModules(
new AntiBookBan(),
new SpeedMine(),
new PacketMine(),
new PacketPlace(),
new Timer(),
Expand All @@ -47,6 +48,7 @@ public static void init() {
new AutoSign(),
new Collisions(),
new AbortBreaking(),
new AntiGhostBlocks(),
new ChatHighlight()
);
// Misc
Expand Down Expand Up @@ -200,8 +202,8 @@ public static ArrayList<Module_> getModuleByNameSearch(String moduleName, int am
}

moduleS.sort((m1, m2) -> {
int m1Score = StringUtils.getLevenshteinDistance(m1.name, moduleName);
int m2Score = StringUtils.getLevenshteinDistance(m2.name, moduleName);
int m1Score = StringUtils.getLevenshteinDistance(m1.name.trim().toLowerCase(), moduleName.trim().toLowerCase());
int m2Score = StringUtils.getLevenshteinDistance(m2.name.trim().toLowerCase(), moduleName.trim().toLowerCase());
return Integer.compare(m2Score, m1Score);
});

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/dev/heliosclient/managers/NavBarManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import dev.heliosclient.HeliosClient;
import dev.heliosclient.ui.clickgui.ClickGUIScreen;
import dev.heliosclient.ui.clickgui.ClientSettingsScreen;
import dev.heliosclient.ui.clickgui.settings.ClientSettingsScreen;
import dev.heliosclient.ui.clickgui.ScriptManagerScreen;
import dev.heliosclient.ui.clickgui.hudeditor.HudEditorScreen;
import dev.heliosclient.ui.clickgui.navbar.NavBarItem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,8 @@ public interface AccessorClientPlayerInteractionManager {

@Accessor("currentBreakingPos")
BlockPos getCurrentBreakingBlockPos();

@Accessor("currentBreakingProgress")
void setCurrentBreakingProgress(float currentBlockBreakingProgress);

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package dev.heliosclient.mixin;

import dev.heliosclient.event.events.block.BeginBreakingBlockEvent;
import dev.heliosclient.event.events.block.BlockBreakEvent;
import dev.heliosclient.event.events.block.BlockInteractEvent;
import dev.heliosclient.event.events.block.CancelBlockBreakingEvent;
import dev.heliosclient.event.events.player.PlayerAttackEntityEvent;
Expand All @@ -10,6 +11,7 @@
import dev.heliosclient.module.modules.player.NoBreakDelay;
import dev.heliosclient.module.modules.render.Freecam;
import dev.heliosclient.util.player.FreeCamEntity;
import net.minecraft.block.BlockState;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.client.network.ClientPlayerInteractionManager;
Expand Down Expand Up @@ -89,6 +91,15 @@ private void onInteractBlock(ClientPlayerEntity player, Hand hand, BlockHitResul
cir.cancel();
}
}
@Inject(method = "breakBlock", at = @At(value = "HEAD"), cancellable = true)
private void onBreakBlock(BlockPos pos, CallbackInfoReturnable<Boolean> cir) {
BlockState state = client.player.getWorld().getBlockState(pos);
BlockBreakEvent event = new BlockBreakEvent(pos, state);
EventManager.postEvent(event);
if (event.isCanceled()) {
cir.setReturnValue(event.isCanceled());
}
}

@ModifyConstant(method = "updateBlockBreakingProgress", constant = @Constant(intValue = 5))
private int updateBlockBreakingProgress(int value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public abstract class MixinItemRenderer {
)
)
private void modifyEnchant(Args args, ItemStack stack, ModelTransformationMode renderMode, boolean leftHanded, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay, BakedModel model) {
if (!NoRender.get().isActive() && !NoRender.get().noEnchantGlint.value) return;
if (NoRender.get().isActive() && !NoRender.get().noEnchantGlint.value) return;
boolean bl = (renderMode == ModelTransformationMode.GUI || renderMode.isFirstPerson() || !(stack.getItem() instanceof BlockItem blockItem) || !(blockItem.getBlock() instanceof TransparentBlock) && !(blockItem.getBlock() instanceof StainedGlassPaneBlock));
args.set(5, vertexConsumers.getBuffer(RenderLayers.getItemLayer(stack, bl)));
}
Expand Down
30 changes: 30 additions & 0 deletions src/main/java/dev/heliosclient/mixin/MixinPlayerEntity.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
package dev.heliosclient.mixin;

import com.llamalad7.mixinextras.injector.ModifyReturnValue;
import dev.heliosclient.HeliosClient;
import dev.heliosclient.event.events.player.*;
import dev.heliosclient.managers.EventManager;
import dev.heliosclient.managers.ModuleManager;
import dev.heliosclient.module.modules.world.SpeedMine;
import dev.heliosclient.util.BlockUtils;
import dev.heliosclient.util.player.FreeCamEntity;
import net.minecraft.block.AbstractBlock;
import net.minecraft.block.BlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.ItemEntity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
Expand All @@ -34,6 +42,7 @@ private void dropItem(ItemStack stack, boolean throwRandomly, boolean retainOwne
}
}


@Inject(method = "onDeath", at = @At("HEAD"), cancellable = true)
private void onDeath(DamageSource damageSource, CallbackInfo ci) {
PlayerDeathEvent event = new PlayerDeathEvent(HeliosClient.MC.player);
Expand All @@ -43,6 +52,27 @@ private void onDeath(DamageSource damageSource, CallbackInfo ci) {
}
}

@ModifyReturnValue(method = "getBlockBreakingSpeed", at = @At(value = "RETURN"))
public float ongetBlockBreakingSpeed(float ogBreakSpeed, BlockState block) {
if (!getWorld().isClient) return ogBreakSpeed;

SpeedMine speedMine = ModuleManager.get(SpeedMine.class);
if (!speedMine.isActive() || speedMine.mode.getOption() != SpeedMine.Mode.Modifier) return ogBreakSpeed;

float breakSpeedMod = (float) (ogBreakSpeed * speedMine.modifier.value);

if (HeliosClient.MC.crosshairTarget instanceof BlockHitResult bhr) {
BlockPos pos = bhr.getBlockPos();
if (speedMine.modifier.value < 1 || (BlockUtils.canBreakInstantly(block,breakSpeedMod) == BlockUtils.canBreakInstantly(block,ogBreakSpeed) )) {
return breakSpeedMod;
} else {
return (float) (0.9f / BlockUtils.calcBlockBreakingDelta2(HeliosClient.MC.world.getBlockState(pos),1f));
}
}

return ogBreakSpeed;
}

@Inject(method = "damage", at = @At("HEAD"), cancellable = true)
private void onPlayerDamage(DamageSource source, float amount, CallbackInfoReturnable<Boolean> cir) {
if (EventManager.postEvent(new PlayerDamageEvent((PlayerEntity) (Object) this, source)).isCanceled()) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ public void onChatMessageEvent(ChatMessageEvent event) {

String originalMessage = event.getMessage().getString();

//Remove formatting from the message (some servers send formatted message for each character which makes it difficult to find words in it).
StringBuilder builder = new StringBuilder(originalMessage);


Expand Down
Loading

0 comments on commit 80cd3ec

Please sign in to comment.