swstika bepary

make a realistic shadow mod plz

Kodari AI
KodariOct 28 at 8:01 am 2
RealisticShadows
A Fabric mod for Minecraft 1.26.3 that overhauls the vanilla shadow system with realistic, dynamic shadow rendering. It implements soft-edged shadows that vary in opacity and size based on light intensity, time of day, and cloud cover. Shadows stretch and rotate naturally with the sun's position, cast from all block types including transparent ones, and feature smooth transitions during sunrise and sunset. The mod adds configurable shadow quality settings, performance optimizations for large render distances, and seamless integration with existing shader pipelines. It also enhances ambient occlusion for improved depth perception and visual realism without requiring OptiFine or external shader packs.
  • Set up the Fabric 26.3 / Java 25 project scaffold.

  • Add a client-only mixin that projects entity shadows away from the sun, stretching them at low sun angles.

  • Keep vanilla shadow textures and gameplay unchanged; no extra library or custom asset is needed.

Created Realistic Shadows for Fabric 26.3. Elevated entities’ shadows shift away from the sun, with a longer projection at dawn and dusk. It’s client-side and automatic; it adds no items or survival recipes.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
settings.gradle
Code
6 135
src/client/java/com/kodari/realisticshadows/mixin/EntityRendererMixin.java
package com.kodari.realisticshadows.mixin;

import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.entity.state.EntityRenderState;
import net.minecraft.world.level.Level;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import net.minecraft.client.renderer.entity.EntityRenderer;

@Mixin(EntityRenderer.class)
public abstract class EntityRendererMixin {
	@Inject(
		method = "extractShadow(Lnet/minecraft/client/renderer/entity/state/EntityRenderState;Lnet/minecraft/client/Minecraft;Lnet/minecraft/world/level/Level;)V",
		at = @At("TAIL")
	)
	private void realisticshadows$projectShadows(EntityRenderState state, Minecraft minecraft, Level level, CallbackInfo ci) {
		long daytime = Math.floorMod(level.getDefaultClockTime(), 24000L);
		double solarPhase = daytime * (Math.PI * 2.0 / 24000.0);
		double solarAltitude = Math.sin(solarPhase);
		if (solarAltitude <= 0.0) {
			return;
		}

		double horizontalDirection = Math.cos(solarPhase);
		if (Math.abs(horizontalDirection) < 0.001) {
			return;
		}

		for (int i = 0; i < state.shadowPieces.size(); i++) {
			EntityRenderState.ShadowPiece piece = state.shadowPieces.get(i);
			double heightAboveSurface = Math.max(0.0, -piece.relativeY());
			if (heightAboveSurface == 0.0) {
				continue;
			}

			double length = Math.min(5.0, heightAboveSurface * 0.5 / Math.max(0.15, solarAltitude));
			float offsetX = (float) (-Math.signum(horizontalDirection) * length);
			state.shadowPieces.set(i, new EntityRenderState.ShadowPiece(
				piece.relativeX() + offsetX,
				piece.relativeY(),
				piece.relativeZ(),
				piece.shapeBelow(),
				piece.alpha()
			));
		}
	}
}