Files
src
build.gradle
gradle.properties
manifest.kod
settings.gradle
Code
37 1,108
src/client/java/ru/moodyvisuals/MoodyVisualsClient.java
package ru.moodyvisuals;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
import net.fabricmc.fabric.api.client.rendering.v1.hud.HudElementRegistry;
import net.fabricmc.fabric.api.client.particle.v1.ParticleFactoryRegistry;
import net.fabricmc.fabric.api.particle.v1.FabricParticleTypes;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.client.util.InputUtil;
import net.minecraft.entity.Entity;
import net.minecraft.particle.SimpleParticleType;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.util.Identifier;
import net.minecraft.client.gui.screen.ChatScreen;
import io.wispforest.owo.ui.container.FlowLayout;
import io.wispforest.owo.ui.container.UIContainers;
import io.wispforest.owo.ui.core.Positioning;
import io.wispforest.owo.ui.core.Sizing;
import io.wispforest.owo.ui.core.Surface;
import io.wispforest.owo.ui.layers.Layers;
import org.lwjgl.glfw.GLFW;
public final class MoodyVisualsClient implements ClientModInitializer {
private static final SimpleParticleType STAR = Registry.register(Registries.PARTICLE_TYPE, Identifier.of("moodyvisuals", "star"), FabricParticleTypes.simple(true));
private static final SimpleParticleType HEART = Registry.register(Registries.PARTICLE_TYPE, Identifier.of("moodyvisuals", "heart"), FabricParticleTypes.simple(true));
private static final SimpleParticleType ORB = Registry.register(Registries.PARTICLE_TYPE, Identifier.of("moodyvisuals", "orb"), FabricParticleTypes.simple(true));
private static final SimpleParticleType DOLLAR = Registry.register(Registries.PARTICLE_TYPE, Identifier.of("moodyvisuals", "dollar"), FabricParticleTypes.simple(true));
private static final SimpleParticleType SNOWFLAKE = Registry.register(Registries.PARTICLE_TYPE, Identifier.of("moodyvisuals", "snowflake"), FabricParticleTypes.simple(true));
private static boolean wasGrounded;
private static boolean wasDead;
private static double lastY;
private static Object lastPlayer;
private static long lastTimePacket;
private static long lastWorldTime;
private static Double originalGamma;
public static double tps = -1;
@Override
public void onInitializeClient() {
Settings.load();
WaypointMarkers.load();
ParticleFactoryRegistry.getInstance().register(STAR, sprites -> (parameters, world, x, y, z, vx, vy, vz, random) -> new StarParticle(world, x, y, z, vx, vy, vz, sprites));
for (SimpleParticleType type : new SimpleParticleType[]{HEART, ORB, DOLLAR, SNOWFLAKE})
ParticleFactoryRegistry.getInstance().register(type, sprites -> (parameters, world, x, y, z, vx, vy, vz, random) -> new StarParticle(world, x, y, z, vx, vy, vz, sprites));
KeyBinding key = KeyBindingHelper.registerKeyBinding(new KeyBinding("key.moodyvisuals.menu", InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_RIGHT_SHIFT, KeyBinding.Category.create(Identifier.of("moodyvisuals", "main"))));
KeyBinding waypointKey = KeyBindingHelper.registerKeyBinding(new KeyBinding("key.moodyvisuals.waypoint", InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_B, KeyBinding.Category.create(Identifier.of("moodyvisuals", "main"))));
HudElementRegistry.addLast(Identifier.of("moodyvisuals", "info"), MoodyHud::render);
Layers.add(UIContainers::verticalFlow, instance -> {
int width = instance.screen.width;
String brand = MoodyHud.brandText();
int brandWidth = MinecraftClient.getInstance().textRenderer.getWidth(brand) + 36;
if (Settings.get("hud_brand", true)) addHandle(instance.adapter.rootComponent, "brand", brandWidth, 24, Math.max(0, (width - brandWidth) / 2), 6);
if (Settings.get("hud_info", true)) addHandle(instance.adapter.rootComponent, "info", 160, 48, Math.max(0, width - 170), 8);
if (Settings.get("hud_target", true)) addHandle(instance.adapter.rootComponent, "target", 150, 38, 10, 90);
int x = Math.max(0, width - 170);
if (Settings.get("hud_health", true)) addHandle(instance.adapter.rootComponent, "health", 120, 12, x, 60);
if (Settings.get("hud_fps", true)) addHandle(instance.adapter.rootComponent, "fps", 90, 12, x, 76);
if (Settings.get("hud_tps", false)) addHandle(instance.adapter.rootComponent, "tps", 90, 12, x, 92);
if (Settings.get("hud_coords", false)) addHandle(instance.adapter.rootComponent, "coords", 140, 12, x, 108);
if (Settings.get("hud_armor", false)) addHandle(instance.adapter.rootComponent, "armor", 90, 80, x, 126);
if (Settings.get("hud_effects", false)) addHandle(instance.adapter.rootComponent, "effects", 140, 70, x, 220);
if (Settings.get("hud_cooldowns", true)) addHandle(instance.adapter.rootComponent, "cooldowns", 140, 70, x, 300);
if (Settings.get("hud_waypoints", true)) addHandle(instance.adapter.rootComponent, "waypoints", 160, 60, 10, 150);
}, ChatScreen.class);
ClientTickEvents.END_CLIENT_TICK.register(client -> {
if (Settings.get("bright", false)) {
if (originalGamma == null) originalGamma = client.options.getGamma().getValue();
if (client.options.getGamma().getValue() != 1.0) client.options.getGamma().setValue(1.0);
} else if (originalGamma != null) {
client.options.getGamma().setValue(originalGamma);
originalGamma = null;
}
while (key.wasPressed()) {
if (client.currentScreen == null) client.setScreen(new MoodyScreen());
}
if (client.player == null || client.world == null) {
lastPlayer = null;
lastTimePacket = 0;
tps = -1;
return;
}
var player = client.player;
while (waypointKey.wasPressed()) {
if (client.currentScreen == null && Settings.get("waypoints", true)) WaypointMarkers.add(client, false);
}
if (lastPlayer != player) {
lastPlayer = player;
wasGrounded = player.isOnGround();
wasDead = player.isDead();
lastY = player.getY();
} else {
if (Settings.get("jump", false) && wasGrounded && !player.isOnGround() && player.getVelocity().y > 0) particles(player, false, "jump");
if (Settings.get("death", false) && !wasDead && player.isDead()) particles(player, true, "death");
if (Settings.get("death_markers", true) && !wasDead && player.isDead()) WaypointMarkers.add(client, true);
wasGrounded = player.isOnGround();
wasDead = player.isDead();
lastY = player.getY();
}
if (player.age % 20 == 0) WaypointMarkers.removeNearbyDeaths(client);
if (Settings.get("ambient", false) && player.age % 5 == 0) particles(player, false, "ambient");
if (Settings.get("trail", false) && player.age % 5 == 0 && player.getVelocity().lengthSquared() > 0.01) particles(player, false, "trail");
});
}
private static void addHandle(FlowLayout root, String key, int width, int height, int defaultX, int defaultY) {
var content = UIContainers.verticalFlow(Sizing.fill(100), Sizing.fill(100));
var handle = UIContainers.draggable(Sizing.fixed(width), Sizing.fixed(height), content);
handle.foreheadSize(height);
handle.positioning(Positioning.absolute(Settings.number(key + "_x", defaultX, 0, 10000), Settings.number(key + "_y", defaultY, 0, 10000)));
handle.surface(Surface.flat(0x22808080).and(Surface.outline(0xAAFFFFFF)));
handle.mouseUp().subscribe(click -> {
Settings.setNumber(key + "_x", Math.max(0, handle.x()));
Settings.setNumber(key + "_y", Math.max(0, handle.y()));
return false;
});
root.child(handle);
}
public static void particles(Entity entity, boolean death) {
particles(entity, death, "other");
}
public static void particles(Entity entity, boolean death, String effect) {
var world = MinecraftClient.getInstance().world;
if (world == null) return;
int count = Settings.number("particle_count", death ? 30 : 20, 1, 100);
double radius = Settings.number("particle_radius", 100, 20, 300) / 100.0;
double speed = Settings.number("particle_speed", 100, 10, 300) / 100.0;
for (int i = 0; i < count; i++) {
double angle = Math.PI * 2 * i / count;
double height = death ? entity.getHeight() * 0.5 : entity.getHeight() * 0.55;
SimpleParticleType type = switch (Settings.number(effect + "_shape", 0, 0, 4)) {
case 1 -> HEART;
case 2 -> ORB;
case 3 -> DOLLAR;
case 4 -> SNOWFLAKE;
default -> STAR;
};
world.addImportantParticleClient(type,
entity.getX() + Math.cos(angle) * 0.35 * radius, entity.getY() + height, entity.getZ() + Math.sin(angle) * 0.35 * radius,
Math.cos(angle) * 0.12 * speed, (0.08 + (i % 5) * 0.025) * speed, Math.sin(angle) * 0.12 * speed);
}
}
public static void timeUpdate(long time) {
long now = System.nanoTime();
if (lastTimePacket != 0 && time > lastWorldTime) {
double seconds = (now - lastTimePacket) / 1_000_000_000.0;
if (seconds > 0) tps = Math.min(20, (time - lastWorldTime) / seconds);
}
lastTimePacket = now;
lastWorldTime = time;
}
}
















