Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.lambda.mixin.render;

import com.lambda.module.modules.render.WorldColors;
import net.minecraft.client.render.BackgroundRenderer;
import net.minecraft.util.math.Vec3d;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

@Mixin(BackgroundRenderer.class)
public class BackgroundRendererMixin {
@Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/Vec3d;getX()D"))
private static double redirectRed(Vec3d baseColor) {
return WorldColors.backgroundColor(baseColor).getX();
}

@Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/Vec3d;getY()D"))
private static double redirectGreen(Vec3d baseColor) {
return WorldColors.backgroundColor(baseColor).getY();
}

@Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/Vec3d;getZ()D"))
private static double redirectBlue(Vec3d baseColor) {
return WorldColors.backgroundColor(baseColor).getZ();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.lambda.mixin.render;

import com.lambda.module.modules.render.WorldColors;
import com.mojang.blaze3d.systems.RenderSystem;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(RenderSystem.class)
public class RenderSystemMixin {
@Shadow @Final private static float[] shaderFogColor;

@Inject(method = "_setShaderFogColor", at = @At(value ="HEAD"), cancellable = true)
private static void onSetShaderFogColor(float red, float green, float blue, float alpha, CallbackInfo ci){
if (WorldColors.INSTANCE.isEnabled() && WorldColors.getCustomFog()){
ci.cancel();
shaderFogColor[0] = WorldColors.getFogColor().getRed() / 255f;
shaderFogColor[1] = WorldColors.getFogColor().getGreen() / 255f;
shaderFogColor[2] = WorldColors.getFogColor().getBlue() / 255f;
shaderFogColor[3] = WorldColors.getFogColor().getAlpha() / 255f;
}
}
}
18 changes: 18 additions & 0 deletions common/src/main/java/com/lambda/mixin/world/ClientWorldMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@

import com.lambda.event.EventFlow;
import com.lambda.event.events.WorldEvent;
import com.lambda.module.modules.render.WorldColors;
import com.lambda.util.math.ColorUtils;
import net.minecraft.block.BlockState;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.entity.Entity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
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 org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(ClientWorld.class)
public class ClientWorldMixin {
Expand All @@ -24,4 +28,18 @@ private void handleBlockUpdateInject(BlockPos pos, BlockState state, int flags,
private void addEntity(Entity entity, CallbackInfo ci) {
if (EventFlow.post(new WorldEvent.EntitySpawn(entity)).isCanceled()) ci.cancel();
}

@Inject(method = "getCloudsColor", at = @At("HEAD"), cancellable = true)
private void getCloudsColorInject(float tickDelta, CallbackInfoReturnable<Vec3d> cir) {
if (WorldColors.INSTANCE.isEnabled() && WorldColors.getCustomClouds()) {
cir.setReturnValue(ColorUtils.getVec3d(WorldColors.getCloudColor()));
}
}

@Inject(method = "getSkyColor", at = @At("HEAD"), cancellable = true)
private void getSkyColorInject(Vec3d cameraPos, float tickDelta, CallbackInfoReturnable<Vec3d> cir) {
if (WorldColors.INSTANCE.isEnabled() && WorldColors.getCustomSky()) {
cir.setReturnValue(ColorUtils.getVec3d(WorldColors.getSkyColor()));
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.lambda.module.modules.render

import com.lambda.module.Module
import com.lambda.module.tag.ModuleTag
import com.lambda.util.math.ColorUtils.vec3d
import net.minecraft.util.math.Vec3d
import java.awt.Color

object WorldColors : Module(
name = "World Colors",
description = "Changes the color of the sky",
defaultTags = setOf(ModuleTag.RENDER)
){
@JvmStatic
val customSky by setting("Custom Sky", true)
@JvmStatic
val skyColor by setting("Sky Color", Color(255, 24, 75), "The color of your sky") { customSky }
@JvmStatic
val customFog by setting("Custom Fog",false)
@JvmStatic
val fogColor by setting("Fog Color", Color(255, 24, 75, 255), "The color of your fog") { customFog }
@JvmStatic
val customClouds by setting("Custom Clouds", false)
@JvmStatic
val cloudColor by setting("Cloud Color", Color(255, 24, 75)) { customClouds }

@JvmStatic
fun backgroundColor(base: Vec3d) =
if (customFog && isEnabled) fogColor.vec3d else base
}
4 changes: 4 additions & 0 deletions common/src/main/kotlin/com/lambda/util/math/ColorUtils.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.lambda.util.math

import net.minecraft.util.math.Vec3d
import java.awt.Color

object ColorUtils {
Expand All @@ -13,4 +14,7 @@ object ColorUtils {
val Color.g get() = green.toDouble() / 255.0
val Color.b get() = blue.toDouble() / 255.0
val Color.a get() = alpha.toDouble() / 255.0

@JvmStatic
val Color.vec3d get() = Vec3d(r, g, b)
}
2 changes: 2 additions & 0 deletions common/src/main/resources/lambda.mixins.common.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"network.HandshakeC2SPacketMixin",
"network.LoginHelloC2SPacketMixin",
"network.LoginKeyC2SPacketMixin",
"render.BackgroundRendererMixin",
"render.BlockRenderManagerMixin",
"render.CameraMixin",
"render.ChatInputSuggestorMixin",
Expand All @@ -34,6 +35,7 @@
"render.LightmapTextureManagerMixin",
"render.LivingEntityRendererMixin",
"render.RenderLayersMixin",
"render.RenderSystemMixin",
"render.RenderTickCounterMixin",
"render.ScreenHandlerMixin",
"render.VertexBufferMixin",
Expand Down