Skip to content

Commit

Permalink
New MultiLineInputBox (WIP), Better rotations, fixed a few issues wit…
Browse files Browse the repository at this point in the history
…h scaffold and auto-totem. And fixed compatibility with meteor. New ScaffoldCount, and basically a whole lot of changes.
  • Loading branch information
tanishisherewithhh committed Oct 2, 2024
1 parent ee2f3e9 commit dcb61ec
Show file tree
Hide file tree
Showing 49 changed files with 2,083 additions and 697 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package dev.heliosclient.event.events.player;

import dev.heliosclient.event.Event;

public class SendMovementPacketEvent extends Event {
public static class PRE extends SendMovementPacketEvent{}
public static class POST extends SendMovementPacketEvent{}
}
5 changes: 5 additions & 0 deletions src/main/java/dev/heliosclient/hud/HudElement.java
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,11 @@ public void setWidth(int width) {
this.width = width;
}

public void setSize(int width, int height){
this.height = height;
this.width = width;
}

/**
* Called when setting gets changed.
*/
Expand Down
1 change: 1 addition & 0 deletions src/main/java/dev/heliosclient/hud/HudElementList.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public HudElementList() {
registerElement(SpeedHud.DATA);
registerElement(Ping.DATA);
registerElement(Tps.DATA);
registerElement(ScaffoldCount.DATA);

AddonManager.HELIOS_ADDONS.forEach(HeliosAddon::registerHudElementData);
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/dev/heliosclient/hud/hudelements/ClientTag.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import java.util.List;

public class ClientTag extends HudElement {
public static HudElementData<ClientTag> DATA = new HudElementData<>("Client Tag", "Shows client watermark", ClientTag::new);

public SettingGroup sgSettings = new SettingGroup("General");

static Texture LOGO = new Texture("icon.png");
Expand Down Expand Up @@ -48,8 +50,6 @@ public ClientTag() {
addSettingGroup(sgSettings);
}

public static HudElementData<ClientTag> DATA = new HudElementData<>("Client Tag", "Shows client watermark", ClientTag::new);

@Override
public void renderElement(DrawContext drawContext, TextRenderer textRenderer) {
super.renderElement(drawContext, textRenderer);
Expand Down
83 changes: 71 additions & 12 deletions src/main/java/dev/heliosclient/hud/hudelements/Radar.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,24 @@
import dev.heliosclient.util.render.Renderer2D;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.render.entity.EntityRenderer;
import net.minecraft.entity.Entity;
import net.minecraft.entity.ItemEntity;
import net.minecraft.entity.mob.HostileEntity;
import net.minecraft.entity.passive.PassiveEntity;
import net.minecraft.entity.passive.TameableEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.Vec3d;

import java.awt.*;
import java.util.List;

public class Radar extends HudElement {
private static int RADAR_SIZE = 100; // Size of the radar in pixels
private static int MAX_DISTANCE = 25; // Maximum entity distance
public static HudElementData<Radar> DATA = new HudElementData<>("Radar", "Shows entities radar", Radar::new);

public SettingGroup sgRadarSettings = new SettingGroup("General");
public SettingGroup sgRadarColors = new SettingGroup("Colors");
public DoubleSetting distance = sgRadarSettings.add(new DoubleSetting.Builder()
Expand All @@ -32,7 +37,26 @@ public class Radar extends HudElement {
.value(25.0D)
.onSettingChange(this)
.build()
); public static HudElementData<Radar> DATA = new HudElementData<>("Radar", "Shows entities radar", Radar::new);
);
public DropDownSetting drawingMode = sgRadarSettings.add(new DropDownSetting.Builder()
.name("Drawing Mode")
.description("Mode of drawing entities on the radar")
.defaultValue(List.of(DrawingMode.values()))
.defaultListOption(DrawingMode.DOT)
.onSettingChange(this)
.build()
);
public DoubleSetting drawingScale = sgRadarSettings.add(new DoubleSetting.Builder()
.name("Scale of the drawn entities")
.description("Scale of the drawn entities, specifically for text or Face mode")
.min(0.1)
.max(2f)
.roundingPlace(1)
.defaultValue(0.5f)
.value(0.5f)
.onSettingChange(this)
.build()
);
public DoubleSetting size = sgRadarSettings.add(new DoubleSetting.Builder()
.name("Size")
.description("Radar size")
Expand Down Expand Up @@ -92,6 +116,14 @@ public class Radar extends HudElement {
.onSettingChange(this)
.build()
);
public RGBASetting yourColor = sgRadarColors.add(new RGBASetting.Builder()
.name("Your Color")
.description("Color of you in the radar")
.defaultValue(Color.CYAN)
.value(Color.CYAN)
.onSettingChange(this)
.build()
);
public RGBASetting playerColor = sgRadarColors.add(new RGBASetting.Builder()
.name("Player")
.description("Color of players in radar")
Expand Down Expand Up @@ -147,6 +179,7 @@ public Radar() {

this.width = (int) size.value;
this.height = (int) size.value;
renderBg.setValue(true);
}

@Override
Expand All @@ -156,17 +189,13 @@ public void renderElement(DrawContext drawContext, TextRenderer textRenderer) {
RADAR_SIZE = this.width;

super.renderElement(drawContext, textRenderer);

if (mc.player == null || mc.world == null) {
return;
}

int centerX = x + RADAR_SIZE / 2;
int centerY = y + RADAR_SIZE / 2;

renderBg.value = true;
rounded.value = true;

Vec3d playerPos = mc.player.getPos();

for (Entity entity : mc.world.getEntities()) {
Expand All @@ -175,7 +204,9 @@ public void renderElement(DrawContext drawContext, TextRenderer textRenderer) {
}
Vec3d entityPos = entity.getPos();
// Ignore the Y-level difference
double distance = playerPos.distanceTo(new Vec3d(entityPos.x, playerPos.y, entityPos.z));
double dx = playerPos.x - entityPos.x;
double dz = playerPos.z - entityPos.z;
double distance = Math.sqrt(dx*dx + dz*dz);

if (distance <= MAX_DISTANCE) {
// Calculate the entity's position on the radar
Expand All @@ -190,10 +221,35 @@ public void renderElement(DrawContext drawContext, TextRenderer textRenderer) {
radius = 1.5f;
}
if (entity == mc.player) {
FontRenderers.Small_iconRenderer.drawString(drawContext.getMatrices(), "\uF123", x2 - 1.5f, y2 - 1.2f, color);
} else {
// Draw a dot for the entity
Renderer2D.drawFilledCircle(drawContext.getMatrices().peek().getPositionMatrix(), x2, y2, radius, color);
FontRenderers.Small_iconRenderer.drawString(drawContext.getMatrices(), "\uF18B", x2 - 1.5f, y2 - 1.2f, yourColor.value.getRGB());
}else {
switch ((DrawingMode) drawingMode.getOption()) {
case DOT -> Renderer2D.drawFilledCircle(drawContext.getMatrices().peek().getPositionMatrix(), x2, y2, radius, color);
case FIRST_LETTER -> {
float scaledX = x2/drawingScale.getFloat();
float scaledY = y2/drawingScale.getFloat();
drawContext.getMatrices().push();
drawContext.getMatrices().scale(drawingScale.getFloat(),drawingScale.getFloat(),1f);

String text = entity.getType().getUntranslatedName().substring(0,1);

drawContext.drawText(mc.textRenderer,text, (int) scaledX, (int) scaledY,color,false);
drawContext.getMatrices().pop();
}
case FACE -> {
EntityRenderer<? super Entity> e = mc.getEntityRenderDispatcher().getRenderer(entity);
if(e != null) {
Identifier texture = e.getTexture(entity);

if (texture != null) {
drawContext.getMatrices().push();
drawContext.getMatrices().scale(drawingScale.getFloat(), drawingScale.getFloat(), 1f);
drawContext.drawTexture(texture, (int) (x2 / drawingScale.getFloat() - 8), (int) (y2 / drawingScale.getFloat() - 8), 8, 8, 8, 8, 64, 64);
drawContext.getMatrices().pop();
}
}
}
}
}
}
}
Expand Down Expand Up @@ -235,6 +291,9 @@ private int getColor(Entity entity) {
}
return color;
}


public enum DrawingMode {
DOT,
FIRST_LETTER,
FACE
}
}
92 changes: 92 additions & 0 deletions src/main/java/dev/heliosclient/hud/hudelements/ScaffoldCount.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
package dev.heliosclient.hud.hudelements;

import dev.heliosclient.hud.HudElement;
import dev.heliosclient.hud.HudElementData;
import dev.heliosclient.managers.ColorManager;
import dev.heliosclient.module.settings.DoubleSetting;
import dev.heliosclient.module.settings.SettingGroup;
import dev.heliosclient.util.render.Renderer2D;
import dev.heliosclient.util.timer.TimerUtils;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.MathHelper;

public class ScaffoldCount extends HudElement {
public static HudElementData<ScaffoldCount> DATA = new HudElementData<>("ScaffoldCount", "Shows block counts in your main hand/scaffold hand", ScaffoldCount::new);
private static ItemStack SCAFFOLD_STACK = ItemStack.EMPTY;
private static final TimerUtils timer = new TimerUtils();
private static boolean isVisible = false;
private static float animationProgress = 0.0f;
private static final float ANIMATION_DURATION = 0.5f; // Duration of the pop-in/out animation in seconds
private static final float DISPLAY_DURATION = 2f; // Duration to display the item before popping out. Currently it is 2s
private final SettingGroup sgSettings = new SettingGroup("Settings");
private final DoubleSetting scale = sgSettings.add(new DoubleSetting.Builder()
.name("Scale")
.description("Change the scale")
.min(0.3d)
.max(5d)
.value(1D)
.defaultValue(1D)
.onSettingChange(this)
.roundingPlace(2)
.build()
);
public ScaffoldCount() {
super(DATA);
addSettingGroup(sgSettings);
setSize(40, 20);
}

@Override
public void renderElement(DrawContext drawContext, TextRenderer textRenderer) {
if (!SCAFFOLD_STACK.isEmpty()) {
if (!isVisible) {
isVisible = true;
timer.startTimer();
}

// Update animation progress
if(timer.getElapsedTime() < DISPLAY_DURATION) {
updateProgress(false);
}

// Render the element with animation
if (isVisible) {
float scale = Math.min(animationProgress, 1.0f);
Renderer2D.scaleAndPosition(drawContext.getMatrices(), x, y, width, height, scale);
super.renderElement(drawContext, textRenderer);
drawContext.drawItem(SCAFFOLD_STACK, x + 2, y + 2);
Renderer2D.drawString(drawContext.getMatrices(), String.valueOf(SCAFFOLD_STACK.getCount()), x + 20, y + 10 - Renderer2D.getStringHeight() / 2.0f, ColorManager.INSTANCE.hudColor);
Renderer2D.stopScaling(drawContext.getMatrices());
}

this.width = (int) (24 + Renderer2D.getStringWidth(String.valueOf(SCAFFOLD_STACK.getCount())));
}

if (isVisible && timer.getElapsedTime() > DISPLAY_DURATION) {
updateProgress(true);
if (animationProgress <= 0.0f) {
SCAFFOLD_STACK = ItemStack.EMPTY;
isVisible = false;
}
}
}

public void updateProgress(boolean out) {
if (out) {
animationProgress -= 1.0f / (ANIMATION_DURATION * 20);
} else {
animationProgress += 1.0f / (ANIMATION_DURATION * 20);
}

animationProgress = MathHelper.clamp(animationProgress, 0, scale.getFloat());
}

public static void setScaffoldStack(ItemStack stack) {
SCAFFOLD_STACK = stack;
timer.restartTimer();
isVisible = true;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import java.util.concurrent.CompletableFuture;

@Mixin(ChatInputSuggestor.class)
@Mixin(value = ChatInputSuggestor.class, priority = 2000)
public abstract class ChatInputSuggestorMixin {

@Shadow
Expand Down
36 changes: 28 additions & 8 deletions src/main/java/dev/heliosclient/mixin/ClientPlayerEntityMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import dev.heliosclient.event.events.TickEvent;
import dev.heliosclient.event.events.player.PlayerMotionEvent;
import dev.heliosclient.event.events.player.PostMovementUpdatePlayerEvent;
import dev.heliosclient.event.events.player.SendMovementPacketEvent;
import dev.heliosclient.managers.EventManager;
import dev.heliosclient.managers.ModuleManager;
import dev.heliosclient.module.Module_;
Expand All @@ -21,6 +22,7 @@
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.ModifyArg;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
Expand All @@ -37,8 +39,6 @@ public abstract class ClientPlayerEntityMixin {
@Shadow
protected abstract void sendMovementPackets();

@Shadow public abstract boolean isSneaking();

@Inject(method = "move", at = @At(value = "HEAD"), cancellable = true)
public void onMove(MovementType type, Vec3d movement, CallbackInfo ci) {
PlayerMotionEvent event = new PlayerMotionEvent(type, movement);
Expand All @@ -62,6 +62,16 @@ private void onIsSneaking(CallbackInfoReturnable<Boolean> info) {
if (ModuleManager.get(AutoSneak.class).isActive() && ModuleManager.get(AutoSneak.class).packet.value) info.setReturnValue(true);
}

@Inject(method = "sendMovementPackets", at = @At(value = "HEAD"))
private void onSendMovementPacketsPRE(CallbackInfo ci) {
EventManager.postEvent(new SendMovementPacketEvent.PRE());
}

@Inject(method = "sendMovementPackets", at = @At(value = "TAIL"))
private void onSendMovementPacketsPOST(CallbackInfo ci) {
EventManager.postEvent(new SendMovementPacketEvent.POST());
}

@ModifyExpressionValue(method = "sendMovementPackets", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isSneaking()Z"))
private boolean isSneaking(boolean sneaking) {
return (ModuleManager.get(SafeWalk.class).isActive() && ModuleManager.get(SafeWalk.class).packet.value) || sneaking;
Expand Down Expand Up @@ -110,8 +120,8 @@ private void noPush(CallbackInfo callbackInfo) {
}
}

@Inject(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;sendMovementPackets()V", shift = At.Shift.BEFORE), cancellable = true)
private void PostUpdateHook(CallbackInfo info) {
@Inject(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;sendMovementPackets()V", shift = At.Shift.AFTER,opcode = 1), cancellable = true)
private void postUpdateHook(CallbackInfo info) {
if (doNotTickSelf) {
return;
}
Expand All @@ -131,9 +141,19 @@ private void PostUpdateHook(CallbackInfo info) {
}
}

@Redirect(method = "updateNausea", at = @At(value = "FIELD", target = "Lnet/minecraft/client/MinecraftClient;currentScreen:Lnet/minecraft/client/gui/screen/Screen;"))
private Screen updateNausea$setcurrentScreen(MinecraftClient client) {
if (ModuleManager.get(BetterPortals.class).isActive()) return null;
return client.currentScreen;
@ModifyArg(
method = "updateNausea",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/MinecraftClient;setScreen(Lnet/minecraft/client/gui/screen/Screen;)V"
),
index = 0
)
private Screen modifySetScreenArg(Screen screen) {
if (ModuleManager.get(BetterPortals.class).isActive()) {
return MinecraftClient.getInstance().currentScreen;
}
return screen;
}

}
Loading

0 comments on commit dcb61ec

Please sign in to comment.