mirror of
https://github.com/XevianLight/Aphelion.git
synced 2026-05-11 01:50:56 +01:00
77 lines
3.1 KiB
Java
77 lines
3.1 KiB
Java
package net.xevianlight.aphelion.client.dimension;
|
|
|
|
import net.minecraft.client.Camera;
|
|
import net.minecraft.client.Minecraft;
|
|
import net.minecraft.client.multiplayer.ClientLevel;
|
|
import net.minecraft.client.renderer.DimensionSpecialEffects;
|
|
import net.minecraft.resources.ResourceLocation;
|
|
import net.minecraft.server.MinecraftServer;
|
|
import net.minecraft.server.level.ServerLevel;
|
|
import net.minecraft.world.phys.Vec3;
|
|
import net.xevianlight.aphelion.Aphelion;
|
|
import net.xevianlight.aphelion.client.PartitionClientState;
|
|
import net.xevianlight.aphelion.core.space.SpacePartitionSavedData;
|
|
import net.xevianlight.aphelion.util.SpacePartitionHelper;
|
|
import org.joml.Matrix4f;
|
|
|
|
public class SpaceSkyEffects extends DimensionSpecialEffects {
|
|
|
|
public SpaceSkyEffects() {
|
|
super(192, false, SkyType.NORMAL, false, false);
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
public boolean renderSky(ClientLevel level, int ticks, float partialTick, Matrix4f modelViewMatrix, Camera camera, Matrix4f projectionMatrix, boolean isFoggy, Runnable setupFog) {
|
|
ResourceLocation id = orbitForPos(net.minecraft.client.Minecraft.getInstance()
|
|
.gameRenderer.getMainCamera().getPosition());
|
|
// Aphelion.LOGGER.info("Loaded dimension_renderers: {}", DimensionRendererCache.getOrDefault(id).toString());
|
|
// Return true, meaning we are rendering the sky ourselves. Vanilla will not draw its sky.
|
|
if (DimensionRendererCache.getOrDefault(id).customSky())
|
|
return true;
|
|
return super.renderSky(level, ticks, partialTick, modelViewMatrix, camera, projectionMatrix, isFoggy, setupFog);
|
|
}
|
|
|
|
@Override
|
|
public Vec3 getBrightnessDependentFogColor(Vec3 fogColor, float brightness) {
|
|
ResourceLocation id = orbitForPos(net.minecraft.client.Minecraft.getInstance()
|
|
.gameRenderer.getMainCamera().getPosition());
|
|
if (DimensionRendererCache.getOrDefault(id).hasFog()) {
|
|
return fogColor.multiply(
|
|
brightness * 0.94 + 0.06,
|
|
brightness * 0.94 + 0.06,
|
|
brightness * 0.91 + 0.09);
|
|
}
|
|
return Vec3.ZERO;
|
|
}
|
|
|
|
@Override
|
|
public boolean isFoggyAt(int i, int i1) {
|
|
|
|
ResourceLocation id = orbitForPos(net.minecraft.client.Minecraft.getInstance()
|
|
.gameRenderer.getMainCamera().getPosition());
|
|
|
|
return DimensionRendererCache.getOrDefault(id).hasThickFog();
|
|
}
|
|
|
|
public static ResourceLocation orbitForPos(Vec3 pos) {
|
|
|
|
int x = SpacePartitionHelper.get(pos.x);
|
|
int z = SpacePartitionHelper.get(pos.z);
|
|
|
|
Minecraft mc = Minecraft.getInstance();
|
|
if (mc.level == null) return ResourceLocation.fromNamespaceAndPath(Aphelion.MOD_ID, "orbit/default");
|
|
|
|
// int px = PartitionClientState.pxOr(0);
|
|
// int py = PartitionClientState.pyOr(0);
|
|
var data = ResourceLocation.parse(PartitionClientState.idOrUnknown());
|
|
|
|
// var data = SpacePartitionSavedData.get(serverLevel).getOrbitForPartition((int) x, (int) z);
|
|
if (data != null) return data;
|
|
|
|
return ResourceLocation.fromNamespaceAndPath(Aphelion.MOD_ID, "orbit/default");
|
|
}
|
|
}
|
|
|