Skip to content

Commit

Permalink
Add config options for dynalights
Browse files Browse the repository at this point in the history
  • Loading branch information
doctor4t committed Jan 4, 2025
1 parent 0613bb2 commit 4e76734
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 8 deletions.
10 changes: 10 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
------------------------------------------------------
Effective 2.4.5 (Alpha) - 1.21.1
------------------------------------------------------
- Rewrote fireflies
- Added dynamic lighting for fireflies
- Added dynamic lighting for glow squids
- Added a new "Dynamic Lights" config category
- Added a config option to enable firefly dynamic lights
- Added a config option to enable glow squid dynamic lights

------------------------------------------------------
Effective 2.4.4 (Alpha) - 1.21.1
------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ yarn_mappings=1.21.1+build.3
loader_version=0.16.9

# Mod Properties
mod_version=2.4.4-1.21.1
mod_version=2.4.5-1.21.1
maven_group=ladysnake
archives_base_name=effective

Expand Down
14 changes: 14 additions & 0 deletions src/client/java/org/ladysnake/effective/core/EffectiveConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,20 @@ public class EffectiveConfig extends MidnightConfig {
@Entry(category = audio, min = 0, max = 100, isSlider = true)
public static int animalAmbienceVolume = 100;

/* DYNAMIC LIGHTS CATEGORY */
public static final String dynamicLights = "dynamicLights";

@Comment(category = dynamicLights)
public static Comment dynamicLightsReloadWorld;
@Comment(category = dynamicLights, centered = true)
public static Comment entitiesDynamicLights;
@Entry(category = dynamicLights)
public static boolean glowSquidDynamicLights = true;
@Comment(category = dynamicLights, centered = true)
public static Comment particlesDynamicLights;
@Entry(category = dynamicLights)
public static boolean fireflyDynamicLights = true;

/* TECHNICAL CATEGORY */
public static final String technical = "technical";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gl.GlDebug;
import net.minecraft.entity.Entity;
import net.minecraft.entity.passive.GlowSquidEntity;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import org.ladysnake.effective.core.EffectiveConfig;

import java.util.ArrayList;
import java.util.Map;
Expand All @@ -24,7 +24,7 @@ public static void initialize() {
VeilEventPlatform.INSTANCE.onVeilRenderLevelStage((stage, levelRenderer, bufferSource, matrixStack, frustumMatrix, projectionMatrix, renderTick, deltaTracker, camera, frustum) -> {
// load glow squid lights
for (Entity entity : MinecraftClient.getInstance().world.getEntities()) {
if (entity instanceof GlowSquidEntity glowSquidEntity) {
if (entity instanceof GlowSquidEntity glowSquidEntity && EffectiveConfig.glowSquidDynamicLights) {
PointLight light;

Vec3d renderPosition = glowSquidEntity.getLerpedPos(deltaTracker.getTickDelta(false));
Expand All @@ -41,7 +41,7 @@ public static void initialize() {

light = GLOW_SQUID_LIGHTS.get(glowSquidEntity.getId());
light.setPosition(renderPosition.getX(), renderPosition.getY(), renderPosition.getZ());
light.setBrightness(MathHelper.clampedLerp(0.0F, 2.0F, 1.0F - (float)glowSquidEntity.getDarkTicksRemaining() / 10.0F));
light.setBrightness(MathHelper.clampedLerp(0.0F, 2.0F, 1.0F - (float) glowSquidEntity.getDarkTicksRemaining() / 10.0F));
}
}

Expand All @@ -59,6 +59,9 @@ public static void initialize() {
}
});

ClientPlayConnectionEvents.DISCONNECT.register((handler, client) -> client.execute(GLOW_SQUID_LIGHTS::clear));
ClientPlayConnectionEvents.DISCONNECT.register((handler, client) -> {
GLOW_SQUID_LIGHTS.forEach((integer, pointLight) -> VeilRenderSystem.renderer().getLightRenderer().removeLight(pointLight));
client.execute(GLOW_SQUID_LIGHTS::clear);
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import net.minecraft.world.LightType;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import org.ladysnake.effective.core.Effective;
import org.ladysnake.effective.core.EffectiveConfig;
import org.ladysnake.effective.core.index.EffectiveLights;
import org.ladysnake.effective.core.settings.SpawnSettings;
import org.ladysnake.effective.core.settings.data.FireflySpawnSetting;
Expand Down Expand Up @@ -65,8 +65,10 @@ public FireflyParticle(ClientWorld world, double x, double y, double z, double v
this.light.setColor(color.getRGB());
this.light.setRadius(25f * this.scale);
this.light.setPosition(x, y, z);
EffectiveLights.PARTICLE_LIGHTS.add(this.light);
VeilRenderSystem.renderer().getLightRenderer().addLight(light);
if (EffectiveConfig.fireflyDynamicLights) {
EffectiveLights.PARTICLE_LIGHTS.add(this.light);
VeilRenderSystem.renderer().getLightRenderer().addLight(light);
}
}

@Override
Expand Down
7 changes: 7 additions & 0 deletions src/client/resources/assets/effective/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"effective.midnightconfig.title": "Effective Config",
"effective.midnightconfig.category.visuals": "Visuals",
"effective.midnightconfig.category.audio": "Audio",
"effective.midnightconfig.category.dynamicLights": "Dynamic Lights",
"effective.midnightconfig.category.technical": "Technical",

"effective.midnightconfig.waterEffects": "Water",
Expand Down Expand Up @@ -76,6 +77,12 @@
"effective.midnightconfig.foliageAmbienceVolume": "Foliage Volume",
"effective.midnightconfig.animalAmbienceVolume": "Animal Volume",

"effective.midnightconfig.dynamicLightsReloadWorld": "Note: Changing these parameters will only affect new particles / mobs and might need a world reload to properly apply.",
"effective.midnightconfig.entitiesDynamicLights": "Entities",
"effective.midnightconfig.glowSquidDynamicLights": "Glow Squids Emit Light",
"effective.midnightconfig.particlesDynamicLights": "Particles",
"effective.midnightconfig.fireflyDynamicLights": "Fireflies Emit Light",

"effective.midnightconfig.randomBlockDisplayTicks": "Random Block Display Ticks",
"effective.midnightconfig.randomBlockDisplayTicksTooltip": "Some Minecraft blocks have visual effects that tick randomly. These options override the Vanilla ticker values to allow these effects to play from further or more frequently, e.g. cherry leaves, rain ripples on water, sculk dust spawning, etc...",
"effective.midnightconfig.emptyComment1": "",
Expand Down

0 comments on commit 4e76734

Please sign in to comment.