Files
src
build.gradle
gradle.properties
settings.gradle
Code
5 997
src/main/java/com/simba/visuals/SimbaVisualsClient.java
package com.simba.visuals;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback;
import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext;
import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.option.SimpleOption;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.VertexRendering;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.ItemEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.text.Text;
import net.minecraft.util.math.Box;
import net.minecraft.util.math.Vec3d;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Properties;
public class SimbaVisualsClient implements ClientModInitializer {
private static final SimbaSettings SETTINGS = new SimbaSettings();
private static double savedGamma = Double.NaN;
@Override
public void onInitializeClient() {
SETTINGS.load();
ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) ->
dispatcher.register(ClientCommandManager.literal("simba").executes(context -> {
MinecraftClient.getInstance().setScreen(new SimbaScreen());
return 1;
})));
ClientTickEvents.END_CLIENT_TICK.register(SimbaVisualsClient::updateGamma);
HudRenderCallback.EVENT.register(SimbaVisualsClient::renderHud);
WorldRenderEvents.AFTER_ENTITIES.register(SimbaVisualsClient::renderWorldOverlays);
}
private static void updateGamma(MinecraftClient client) {
boolean fullbright = SETTINGS.enabled("fullbright");
boolean gammaControl = SETTINGS.enabled("gamma_control");
SimpleOption<Double> gammaOption = client.options.getGamma();
if (fullbright || gammaControl) {
if (Double.isNaN(savedGamma)) {
savedGamma = gammaOption.getValue();
}
double target = fullbright ? 1.0 : SETTINGS.value("gamma_control") / 100.0;
gammaOption.setValue(Math.max(0.0, Math.min(1.0, target)));
} else if (!Double.isNaN(savedGamma)) {
gammaOption.setValue(savedGamma);
savedGamma = Double.NaN;
}
}
private static void renderHud(DrawContext context, Object tickCounter) {
MinecraftClient client = MinecraftClient.getInstance();
if (client.player == null || client.currentScreen instanceof SimbaScreen) {
return;
}
int x = 8;
int y = 8;
if (SETTINGS.enabled("fps_counter")) {
drawHudText(context, client, "FPS " + client.getCurrentFps(), x, y);
y += 12;
}
if (SETTINGS.enabled("coordinates")) {
Vec3d pos = client.player.getPos();
drawHudText(context, client, String.format(Locale.ROOT, "XYZ %.1f %.1f %.1f", pos.x, pos.y, pos.z), x, y);
y += 12;
}
if (SETTINGS.enabled("speed_display")) {
double speed = client.player.getVelocity().horizontalLength() * 20.0;
drawHudText(context, client, String.format(Locale.ROOT, "SPEED %.2f m/s", speed), x, y);
y += 12;
}
if (SETTINGS.enabled("clock")) {
drawHudText(context, client, LocalTime.now().format(DateTimeFormatter.ofPattern("HH:mm:ss")), x, y);
}
if (SETTINGS.enabled("custom_crosshair")) {
renderCrosshair(context, client);
}
}
private static void drawHudText(DrawContext context, MinecraftClient client, String text, int x, int y) {
context.fill(x - 4, y - 2, x + client.textRenderer.getWidth(text) + 4, y + 10, 0x990C1015);
context.drawText(client.textRenderer, text, x, y, 0xFFE8F0F2, true);
}
private static void renderCrosshair(DrawContext context, MinecraftClient client) {
int centerX = client.getWindow().getScaledWidth() / 2;
int centerY = client.getWindow().getScaledHeight() / 2;
int size = Math.max(2, Math.round(SETTINGS.value("crosshair_size") / 10.0f));
int thickness = Math.max(1, Math.round(SETTINGS.value("crosshair_thickness") / 20.0f));
int gap = Math.max(1, Math.round(SETTINGS.value("crosshair_gap") / 10.0f));
int color = SETTINGS.color("crosshair_color");
int rgb = 0xFF000000 | color;
if (SETTINGS.enabled("crosshair_outline")) {
int outline = 0xFF101014;
context.fill(centerX - thickness - 1, centerY - size - gap - 1, centerX + thickness + 1, centerY - gap + 1, outline);
context.fill(centerX - thickness - 1, centerY + gap - 1, centerX + thickness + 1, centerY + size + gap + 1, outline);
context.fill(centerX - size - gap - 1, centerY - thickness - 1, centerX - gap + 1, centerY + thickness + 1, outline);
context.fill(centerX + gap - 1, centerY - thickness - 1, centerX + size + gap + 1, centerY + thickness + 1, outline);
}
context.fill(centerX - thickness, centerY - size - gap, centerX + thickness, centerY - gap, rgb);
context.fill(centerX - thickness, centerY + gap, centerX + thickness, centerY + size + gap, rgb);
context.fill(centerX - size - gap, centerY - thickness, centerX - gap, centerY + thickness, rgb);
context.fill(centerX + gap, centerY - thickness, centerX + size + gap, centerY + thickness, rgb);
if (SETTINGS.enabled("crosshair_dot")) {
context.fill(centerX - 1, centerY - 1, centerX + 2, centerY + 2, rgb);
}
}
private static void renderWorldOverlays(WorldRenderContext context) {
MinecraftClient client = MinecraftClient.getInstance();
if (client.player == null || context.world() == null || context.matrixStack() == null || context.consumers() == null) {
return;
}
boolean playerBoxes = SETTINGS.enabled("player_esp") || SETTINGS.enabled("box_esp")
|| SETTINGS.enabled("box_2d") || SETTINGS.enabled("box_3d")
|| SETTINGS.enabled("glow_esp") || SETTINGS.enabled("enemy_highlight");
boolean itemBoxes = SETTINGS.enabled("item_esp") || SETTINGS.enabled("dropped_item_highlight");
if (!playerBoxes && !itemBoxes) {
return;
}
MatrixStack matrices = context.matrixStack();
VertexConsumerProvider consumers = context.consumers();
Vec3d camera = context.camera().getPos();
VertexConsumer lines = consumers.getBuffer(RenderLayer.getLines());
if (playerBoxes) {
int color = SETTINGS.color("custom_player_colors");
for (PlayerEntity target : context.world().getPlayers()) {
if (target == client.player) {
continue;
}
drawOutline(matrices, lines, target.getBoundingBox(), camera, color);
}
}
if (itemBoxes) {
int color = SETTINGS.color("custom_item_color");
for (var entity : context.world().getEntities()) {
if (entity instanceof ItemEntity item) {
drawOutline(matrices, lines, item.getBoundingBox(), camera, color);
}
}
}
}
private static void drawOutline(MatrixStack matrices, VertexConsumer lines, Box worldBox, Vec3d camera, int color) {
Box cameraRelative = worldBox.offset(-camera.x, -camera.y, -camera.z);
float red = ((color >> 16) & 0xFF) / 255.0F;
float green = ((color >> 8) & 0xFF) / 255.0F;
float blue = (color & 0xFF) / 255.0F;
VertexRendering.drawBox(matrices, lines, cameraRelative, red, green, blue, 1.0F);
}
private static final class SimbaSettings {
private static final Path FILE = Path.of("config", "simba-visuals.properties");
private final List<Feature> features = new ArrayList<>();
private String activeProfile = "Normal";
private int accentColor = 0x9DFF5A;
private SimbaSettings() {
add("Player Visuals", "player_esp", "Player ESP", "Draw a colored outline around other players.");
add("Player Visuals", "box_esp", "Box ESP", "Outline player hitboxes in the world.");
add("Player Visuals", "box_2d", "2D Box", "Enable the player box overlay.");
add("Player Visuals", "box_3d", "3D Box", "Enable three-dimensional player boxes.");
add("Player Visuals", "glow_esp", "Glow ESP", "Highlight players with the configured player color.");
add("Player Visuals", "nickname_esp", "Nickname ESP", "Show player names above outlined players.");
add("Player Visuals", "health_bar", "Health Bar", "Display health beside player outlines.");
add("Player Visuals", "health_text", "Health Text", "Display numeric health values.");
add("Player Visuals", "distance_esp", "Distance ESP", "Display distance to other players.");
add("Player Visuals", "armor_esp", "Armor ESP", "Display players' armor status.");
add("Player Visuals", "held_item_esp", "Held Item ESP", "Display the held item beside player names.");
add("Player Visuals", "friend_highlight", "Friend Highlight", "Use a distinct highlight for friends.");