Files
src
build.gradle
gradle.properties
settings.gradle
Code
5 201
src/client/java/com/kodari/crimsonarmor/CrimsonArmorClient.java
package com.kodari.crimsonarmor;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.item.ItemStack;
import net.minecraft.particle.DustParticleEffect;
import net.minecraft.registry.tag.ItemTags;
public final class CrimsonArmorClient implements ClientModInitializer {
private static final DustParticleEffect EYE_GLOW = new DustParticleEffect(0xFF1830, 0.45f);
private static final DustParticleEffect CHEST_GLOW = new DustParticleEffect(0xFF1028, 0.55f);
private static final DustParticleEffect CHEST_PIXEL = new DustParticleEffect(0xFF1028, 0.12f);
private static final DustParticleEffect VEIN_GLOW = new DustParticleEffect(0xC90020, 0.35f);
private static final DustParticleEffect AURA_GLOW = new DustParticleEffect(0xE00025, 0.6f);
@Override
public void onInitializeClient() {
ClientTickEvents.END_CLIENT_TICK.register(CrimsonArmorClient::onClientTick);
}
private static void onClientTick(MinecraftClient client) {
ClientPlayerEntity player = client.player;
ClientWorld world = client.world;
if (player == null || world == null || !hasFullArmor(player)) {
return;
}
spawnCrimsonEffect(player, world);
}
private static boolean hasFullArmor(ClientPlayerEntity player) {
return !player.getEquippedStack(EquipmentSlot.HEAD).isEmpty()
&& !player.getEquippedStack(EquipmentSlot.CHEST).isEmpty()
&& !player.getEquippedStack(EquipmentSlot.LEGS).isEmpty()
&& !player.getEquippedStack(EquipmentSlot.FEET).isEmpty();
}
private static void spawnCrimsonEffect(ClientPlayerEntity player, ClientWorld world) {
double x = player.getX();
double y = player.getY();
double z = player.getZ();
double yaw = Math.toRadians(player.getYaw());
double forwardX = -Math.sin(yaw);
double forwardZ = Math.cos(yaw);
double rightX = Math.cos(yaw);
double rightZ = Math.sin(yaw);
double faceX = x + forwardX * 0.16;
double faceZ = z + forwardZ * 0.16;
double eyeY = player.getEyeY() - 0.07;
spawn(world, EYE_GLOW, faceX - rightX * 0.065, eyeY, faceZ - rightZ * 0.065);
spawn(world, EYE_GLOW, faceX + rightX * 0.065, eyeY, faceZ + rightZ * 0.065);
double chestX = x + forwardX * 0.17;
double chestZ = z + forwardZ * 0.17;
double chestY = y + 1.28;
for (double side : new double[]{-1.0, 1.0}) {
for (double vertical : new double[]{-1.0, 1.0}) {
spawn(world, CHEST_PIXEL,
chestX + rightX * side * 0.022,
chestY + vertical * 0.022,
chestZ + rightZ * side * 0.022);
}
}
for (int i = 0; i < 6; i++) {
double veinY = y + 1.18 - i * 0.13;
spawn(world, VEIN_GLOW, x + forwardX * 0.16, veinY, z + forwardZ * 0.16);
}
for (double side : new double[]{-1.0, 1.0}) {
for (int i = 0; i < 4; i++) {
double lateral = side * (0.09 + i * 0.075);
spawn(world, VEIN_GLOW,
x + forwardX * 0.15 + rightX * lateral,
y + 1.34 - i * 0.045,
z + forwardZ * 0.15 + rightZ * lateral);
}
for (int i = 0; i < 4; i++) {
spawn(world, VEIN_GLOW,
x + forwardX * 0.14 + rightX * side * (0.08 + i * 0.025),
y + 0.62 - i * 0.14,
z + forwardZ * 0.14 + rightZ * side * (0.08 + i * 0.025));
}
}
for (int i = 0; i < 6; i++) {
double angle = player.age * 0.08 + i * Math.PI / 3.0;
double auraX = x + Math.cos(angle) * 0.52;
double auraZ = z + Math.sin(angle) * 0.52;
double auraY = y + 0.35 + (i % 3) * 0.48 + Math.sin(angle * 1.7) * 0.08;
spawn(world, AURA_GLOW, auraX, auraY, auraZ, 0.0, 0.012, 0.0);
}
ItemStack heldItem = player.getMainHandStack();
if (heldItem.isIn(ItemTags.SWORDS)) {
double swordX = x + rightX * 0.38 + forwardX * 0.28;
double swordZ = z + rightZ * 0.38 + forwardZ * 0.28;
spawn(world, CHEST_GLOW, swordX, y + 0.88, swordZ);
spawn(world, AURA_GLOW, swordX, y + 1.08, swordZ, 0.0, 0.015, 0.0);
}
}
private static void spawn(ClientWorld world, DustParticleEffect effect, double x, double y, double z) {
spawn(world, effect, x, y, z, 0.0, 0.0, 0.0);
}
private static void spawn(ClientWorld world, DustParticleEffect effect, double x, double y, double z,
double velocityX, double velocityY, double velocityZ) {
world.addParticleClient(effect, x, y, z, velocityX, velocityY, velocityZ);
}
}